/* Mobile-first, single stylesheet. Shared components are documented in CLAUDE.md-style comments below. */
:root {
  --bg: #0b1d21;
  --surface: #12292e;
  --surface-2: #19363c;
  --line: #2a4a50;
  --text: #eef6f7;
  --muted: #9fb8bc;
  --accent: #7fd4e8;        /* ice blue */
  --accent-ink: #062126;
  --warm: #f4b860;          /* pinned / highlights */
  --danger: #ff7a6e;
  --ok: #6fdc9a;
  --radius: 14px;
  --tap: 44px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
a { color: var(--accent); }
img, video { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Page shell: <header class="topbar"> + <main class="page"> + nav (added by js/nav.js) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.3rem; margin: 0; flex: 1; }
.page {
  max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
body:not(.ready) .page { opacity: .4; }
.page h2 { font-size: 1.05rem; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--muted); text-decoration: none; font-size: .72rem; cursor: pointer;
}
.bottom-nav .icon { font-size: 1.35rem; line-height: 1; position: relative; }
.bottom-nav [aria-current="page"] { color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: -6px; right: -12px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.sheet-body {
  width: 100%; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 8px 8px calc(var(--nav-h) + var(--safe-b) + 8px);
}
.sheet-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 0 16px;
  background: none; border: 0; border-radius: 12px; color: var(--text); text-decoration: none; font-size: 1.05rem; text-align: left; cursor: pointer;
}
.sheet-item:active, .sheet-item[aria-current="page"] { background: var(--surface-2); }
.sheet-item .icon { font-size: 1.4rem; width: 28px; text-align: center; }
.sheet-item.danger { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 1.15rem; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=search], textarea, select {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; /* prevents iOS zoom */
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

/* ---------- Cards, chips, lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 12px; }
.card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.meta { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: var(--tap); padding: 0 16px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.progress { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--ok); transition: width .25s; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--accent); font-size: .8rem; font-weight: 700;
}
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 10;
  min-height: 56px; padding: 0 22px; border-radius: 28px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,.4); cursor: pointer;
}

/* ---------- Dialog (use <dialog class="dialog">) ---------- */
.dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 48px); padding: 18px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px;
}
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog h2 { margin: 0 0 12px; font-size: 1.2rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 40;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

/* ---------- Countdown (login + home) ---------- */
.countdown { display: flex; justify-content: center; gap: 10px; }
.countdown div {
  min-width: 68px; padding: 10px 6px; border-radius: 12px; text-align: center;
  background: rgba(6, 22, 26, .55); border: 1px solid rgba(255,255,255,.15); backdrop-filter: blur(6px);
}
.countdown span { display: block; font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown small { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.countdown-status { text-align: center; color: var(--muted); margin: 8px 0 0; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  padding: calc(env(safe-area-inset-top, 0px) + 32px) 16px calc(var(--safe-b) + 24px);
  background: linear-gradient(180deg, rgba(6,22,26,.55) 0%, rgba(6,22,26,.15) 40%, rgba(6,22,26,.85) 100%), var(--login-img, none) center / cover no-repeat, var(--bg);
}
.login header { text-align: center; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.login h1 { font-size: 2rem; margin: 0 0 4px; }
.login .eyebrow { margin: 0 0 16px; color: var(--text); opacity: .85; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; }
.login .countdown-status { color: var(--text); text-shadow: 0 1px 6px rgba(0,0,0,.7); }
.login form {
  width: 100%; max-width: 400px; margin: 0 auto; padding: 18px;
  background: rgba(10, 28, 32, .82); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; backdrop-filter: blur(10px);
}
.login .error { color: var(--danger); min-height: 1.4em; margin: 0 0 8px; font-weight: 600; }
.setup { padding: 48px 16px; text-align: center; }

/* ---------- Home ---------- */
.hero-card { padding: 20px 12px 16px; border-radius: var(--radius); background: linear-gradient(160deg, #1b4650, #0f2a2e); margin-bottom: 16px; }
.hero-card h2 { color: var(--text); text-align: center; margin: 0 0 12px; text-transform: none; letter-spacing: 0; font-size: 1.2rem; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; min-height: 92px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 600;
}
.tile .icon { font-size: 1.6rem; }
.tile .meta { font-weight: 400; }
.mini-list { display: grid; gap: 10px; }
.mini-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: .95rem; }
.mini-row .progress { grid-column: 1 / -1; height: 6px; }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link.mini-list { display: grid; }
