:root {
  --bg: #0e100e;
  --bg-2: #161916;
  --bg-3: #1d221c;
  --bg-4: #262c24;
  --ink: #ece6d6;
  --ink-dim: #b7b19f;
  --muted: #8a8678;
  --faint: #5c5a50;
  --line: #2a2e28;
  --gold: #c9a227;
  --gold-dim: #8a6e14;
  --teal: #3d8b7a;
  --teal-2: #2a5f54;
  --rust: #c45c3e;
  --good: #7ea36a;
  --warn: #d4a24a;
  --bad: #c45c3e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom);
  --nav-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, .serif { font-family: Fraunces, Georgia, serif; font-weight: 500; letter-spacing: -0.02em; }
a { color: var(--gold); }

#app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 18px 18px 12px;
  background: linear-gradient(180deg, rgba(14,16,14,0.96) 60%, rgba(14,16,14,0));
  backdrop-filter: blur(8px);
}
.eyebrow {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}
.topbar h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.05; }
.date-chip {
  border: 1px solid var(--line); background: var(--bg-2);
  border-radius: 999px; padding: 6px 10px; color: var(--ink-dim); font-size: 13px;
}
.sync-chip {
  border-radius: 999px; padding: 4px 9px; font-size: 11px; letter-spacing: 0.04em;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.sync-chip.ok { color: #cfe3c4; border-color: #3d5a32; background: #1a2418; }
.sync-chip.syncing { color: #f0d7a0; border-color: #4a3a18; background: #211c12; }
.sync-chip.err { color: #f3c2b6; border-color: #5a2e24; background: #241614; }
.sync-chip.local { color: var(--muted); }

.wrap { padding: 0 16px 24px; max-width: 920px; margin: 0 auto; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}
.card h3 { margin: 0 0 8px; font-size: 20px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--bg-3); border-radius: 12px; padding: 10px 10px 8px;
  border: 1px solid var(--line);
}
.stat b { display: block; font-family: Fraunces, serif; font-size: 22px; line-height: 1; }
.stat span { display: block; margin-top: 4px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border-radius: 999px; padding: 5px 10px; font-size: 12px;
  border: 1px solid var(--line); color: var(--ink-dim); background: transparent;
}
.pill.on { background: var(--gold); color: #1a1506; border-color: var(--gold); font-weight: 600; }
.pill.teal { background: var(--teal-2); color: #dff4ee; border-color: var(--teal); }
.pill.warn { background: #3a2a12; color: #f0d7a0; border-color: var(--warn); }

.btn {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink);
  border-radius: 12px; padding: 10px 14px; font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--gold); color: #1a1506; border-color: var(--gold); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: #f3c2b6; border-color: #5a2e24; }

.row { display: flex; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold-dim); border-color: var(--gold); }

.session { margin-bottom: 10px; }
.session-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  margin-bottom: 8px;
}
.session-head h3 { margin: 0; font-size: 18px; }
.cue { font-size: 13px; color: var(--muted); font-style: italic; margin: 0 0 8px; }

.item {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start;
  padding: 9px 0; border-top: 1px solid var(--line);
}
.item:first-of-type { border-top: 0; }
.check {
  width: 18px; height: 18px; margin-top: 2px; accent-color: var(--gold);
}
.item p { margin: 0; }
.item .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.item.done p { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.pct {
  display: inline-block; margin-left: 6px; color: var(--gold); font-size: 12px; font-weight: 600;
}
.log-in { width: 88px; padding: 6px 8px; font-size: 13px; }

.rings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ring { width: 84px; height: 84px; }
.ring-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.meal { margin-top: 10px; }
.food-line {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.food-line .qty { color: var(--muted); font-size: 12px; }
.balance { font-size: 12px; color: var(--muted); }
.balance.good { color: var(--good); }
.balance.off { color: var(--warn); }

.search-list { max-height: 280px; overflow: auto; margin-top: 8px; }
.search-row {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.search-row:hover { background: var(--bg-3); }
.tag { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: min(560px, 100%); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(18px + var(--safe-b));
  max-height: 88dvh; overflow: auto;
}
@media (min-width: 720px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 20px; }
}

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(14,16,14,0.94); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-b));
  backdrop-filter: blur(10px);
}
.nav button {
  background: none; border: 0; color: var(--faint); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 4px 0;
}
.nav button.on { color: var(--gold); }
.nav .ico { font-family: Fraunces, serif; font-size: 16px; line-height: 1; }

.timer {
  text-align: center; padding: 18px 8px 8px;
}
.timer .clock {
  font-family: Fraunces, serif; font-size: 72px; line-height: 0.9; letter-spacing: -0.04em;
}
.timer .phase { letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; font-size: 12px; font-weight: 600; }
.timer .move { font-size: 22px; margin: 8px 0 14px; }
.timer.work { background: linear-gradient(180deg, #1c2a22, transparent); }
.timer.rest { background: linear-gradient(180deg, #2a2216, transparent); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; }

.setup {
  max-width: 560px; margin: 0 auto; padding: 40px 18px 100px;
}
.setup h1 {
  font-size: clamp(28px, 8vw, 40px);
  margin: 8px 0 8px;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.setup p.lead { color: var(--ink-dim); font-size: 16px; }
.steps { display: flex; gap: 6px; overflow: auto; padding-bottom: 4px; }
.step {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; white-space: nowrap;
}
.step.on { background: var(--gold); color: #1a1506; border-color: var(--gold); font-weight: 600; }
.rx-list { display: grid; gap: 6px; margin: 10px 0 14px; }
.rx-line {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.rx-line b { font-family: Fraunces, serif; font-size: 22px; }
.rx-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.macro-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 10px 0 12px; }
@media (min-width: 640px) { .macro-grid { grid-template-columns: 1fr 1fr 1fr; } }
.macro-bar .bar { height: 7px; background: var(--bg-4); border-radius: 99px; overflow: hidden; margin: 4px 0; }
.macro-bar .bar > i { display: block; height: 100%; border-radius: 99px; }
.macro-bar-top { display: flex; justify-content: space-between; font-size: 13px; }
.macro-bar.full .macro-bar-top b { color: var(--good); }
.suggest { display: grid; gap: 12px; margin: 12px 0; }
@media (min-width: 640px) { .suggest { grid-template-columns: 1fr 1fr 1fr; } }
.suggest-lab { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; margin-bottom: 6px; }
.chip, .plate {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; margin-bottom: 6px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink);
  border-radius: 12px; padding: 8px 10px; font-size: 13px;
}
.chip span, .plate { font-size: 11px; color: var(--muted); }
.chip.p { border-color: #5a4a18; }
.chip.c { border-color: #2a5f54; }
.chip.f { border-color: #5a2e24; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.chip-row .chip { width: auto; flex-direction: row; align-items: center; }
.plates { display: grid; gap: 6px; margin: 0 0 10px; }
.plate { color: var(--ink-dim); }
.food-line.p { border-left: 3px solid #c9a227; padding-left: 8px; }
.food-line.c { border-left: 3px solid #3d8b7a; padding-left: 8px; }
.food-line.f { border-left: 3px solid #c45c3e; padding-left: 8px; }
.food-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.macro-dots { display: flex; gap: 6px; font-size: 11px; }
.macro-dots .p { color: #e6c96a; }
.macro-dots .c { color: #7ec9b6; }
.macro-dots .f { color: #e09a86; }
.meal.balanced { border-color: #3d5a32; }
.search-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); }

.week-bar { display: flex; gap: 6px; overflow: auto; padding-bottom: 8px; }
.week-bar button { min-width: 44px; }

.note-banner {
  background: #211c12; border: 1px solid #4a3a18; color: #e6d3a4;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}

.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.prog {
  height: 6px; background: var(--bg-4); border-radius: 99px; overflow: hidden; margin: 6px 0 2px;
}
.prog > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }

.kicker { color: var(--muted); font-size: 12px; margin: 0 0 4px; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.tiny { font-size: 12px; color: var(--muted); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.day-switch { display: flex; gap: 4px; overflow: auto; padding-bottom: 6px; }
.day-switch button { min-width: 46px; }

.list-plain { margin: 0; padding-left: 18px; color: var(--ink-dim); }
.list-plain li { margin: 3px 0; }
.list-plain.numbered { padding-left: 22px; }
.preview-line {
  margin: 0; padding: 7px 0; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--ink-dim);
}
.wu-line {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer;
}
.wu-line b { display: block; color: var(--ink); font-weight: 600; }
.bar { height: 7px; background: var(--bg-4); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--gold); }
