:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --card: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --hint: #9a9a93;
  --border: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.16);
  --accent: #2f6fed;
  --danger: #d64545;
  --ok: #1d9e75;
  --radius: 12px;
  --radius-sm: 8px;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-hi: rgba(255, 255, 255, 0.85);
  --glass-active: rgba(255, 255, 255, 0.7);
  --glass-shadow: rgba(0, 0, 0, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #212225;
    --card: #212225;
    --text: #ececec;
    --muted: #9b9ca0;
    --hint: #6f7176;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #4f8bff;
    --glass-bg: rgba(40, 42, 48, 0.5);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-hi: rgba(255, 255, 255, 0.14);
    --glass-active: rgba(255, 255, 255, 0.12);
    --glass-shadow: rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 108px; }

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}
.appbar h1 { font-size: 19px; font-weight: 600; margin: 0; }
.appbar .sub { font-size: 12px; color: var(--hint); margin-top: 1px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: var(--surface); border: 0.5px solid var(--border); padding: 5px 10px; border-radius: 999px; }

.view { padding: 14px 16px; }
.card { background: var(--card); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }

.tonight { border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.tonight .when { font-size: 12px; opacity: .85; margin-bottom: 6px; }
.tonight .who { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; }
.tonight .who .dot { width: 13px; height: 13px; border-radius: 50%; }
.tonight .note { font-size: 13px; opacity: .85; margin-top: 8px; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .m { font-size: 16px; font-weight: 600; text-transform: capitalize; }
.nav-btn { background: var(--surface); border: 0.5px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 18px; display: grid; place-items: center; cursor: pointer; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.dow span { text-align: center; font-size: 11px; color: var(--hint); }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell { position: relative; aspect-ratio: 1 / 1; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; border: 1.5px solid transparent; overflow: hidden; }
.cell.empty { background: transparent; cursor: default; }
.cell .d { font-size: 14px; font-weight: 600; }
.cell .ini { font-size: 10px; opacity: .85; margin-top: 1px; }
.cell.today { border-color: var(--accent); }
.cell .corner { position: absolute; top: 3px; right: 4px; font-size: 9px; opacity: .9; }
.cell.missed { text-decoration: line-through; opacity: .8; }
.cell.prestart { background: repeating-linear-gradient(45deg, transparent, transparent 4px, var(--border) 4px, var(--border) 5px); color: var(--hint); cursor: default; }
.cell.prestart .d { opacity: .5; font-weight: 400; }
.cell.start { border-color: var(--ok); }
.cell .startbadge { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 8px; color: var(--ok); }
.cell.away { background: repeating-linear-gradient(45deg, transparent, transparent 5px, var(--border) 5px, var(--border) 6px); color: var(--muted); }
.cell.away .d { opacity: .6; }
.cell .awayic { font-size: 12px; margin-top: 1px; opacity: .8; }

.lookup { padding: 12px 14px; }
.lk-title { font-size: 13px; color: var(--muted); margin-bottom: 9px; }
.lk-row { display: flex; align-items: center; gap: 8px; }
.lk-row input { flex: 1; }
.lk-res { margin-top: 10px; }
.lk-day { font-size: 12px; color: var(--hint); text-transform: capitalize; margin-bottom: 4px; }
.lk-who { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 600; }
.lk-muted { font-size: 12px; color: var(--muted); margin-top: 3px; }
.lk-mine { font-size: 11px; color: var(--ok); background: rgba(29,158,117,.15); padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.visit-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px; }

.legend { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.legrow { display: flex; align-items: center; justify-content: space-between; }
.legrow .l { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.legrow .l .dot { width: 11px; height: 11px; border-radius: 50%; }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; }
.pill.info { color: #185fa5; background: rgba(47,111,237,.14); }
.pill.warn { color: #854f0b; background: rgba(186,117,23,.16); }
.pill.muted { color: var(--hint); }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--card); border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.list-item .t { font-size: 14px; }
.list-item .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .s.transfer { color: var(--accent); margin-top: 4px; }

.btn { font-family: inherit; font-size: 14px; border-radius: var(--radius-sm); border: 0.5px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 9px 14px; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; }

.fab { position: fixed; right: max(16px, calc(50% - 260px + 16px)); bottom: calc(96px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 28px; display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.28); z-index: 30; }

.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(440px, calc(100% - 24px));
  z-index: 25;
  display: flex; gap: 4px; padding: 7px;
  border-radius: 30px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  backdrop-filter: blur(26px) saturate(190%);
  border: 0.5px solid var(--glass-border);
  box-shadow: 0 10px 34px var(--glass-shadow), inset 0 1px 0 var(--glass-hi), inset 0 -1px 1px rgba(0,0,0,.04);
}
.nav::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%); }
.nav .navitem {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; color: var(--muted);
  background: none; border: none; cursor: pointer;
  padding: 8px 0 6px; border-radius: 22px;
  transition: color .25s ease, background .25s ease, transform .15s ease;
}
.nav .navitem .ic { font-size: 21px; line-height: 1; transition: transform .25s ease; }
.nav .navitem.active { color: var(--accent); background: var(--glass-active); box-shadow: inset 0 1px 0 var(--glass-hi), 0 2px 8px rgba(0,0,0,.06); }
.nav .navitem.active .ic { transform: translateY(-1px) scale(1.06); }
.nav .navitem:active { transform: scale(.92); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px max(20px, env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.sheet .handle { width: 38px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 8px auto 12px; }
.sheet h2 { font-size: 17px; font-weight: 600; margin: 4px 0 14px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; padding: 12px 12px; border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; background: var(--card); }
.sheet .opt .ic { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 17px; }
.sheet .opt .tx .t { font-size: 14px; }
.sheet .opt .tx .s { font-size: 12px; color: var(--hint); }

label.field { display: block; margin-bottom: 12px; }
label.field .lab { font-size: 13px; color: var(--muted); margin-bottom: 5px; display: block; }
input, select, textarea { font-family: inherit; font-size: 15px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 0.5px solid var(--border-strong); background: var(--card); color: var(--text); }
.hintline { font-size: 12px; color: var(--hint); margin: -6px 0 12px; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checkrow { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 0.5px solid var(--border); border-radius: var(--radius-sm); }
.checkrow input { width: auto; }

.login { padding: 40px 20px; text-align: center; }
.login h1 { font-size: 24px; margin-bottom: 6px; }
.login p { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login .btn { margin-bottom: 10px; }
.empty { text-align: center; color: var(--hint); padding: 40px 20px; font-size: 14px; }
.row-actions { display: flex; gap: 8px; }
