/* Gfit — night-first dark theme with lamp-gold accent. Single theme by design. */
:root {
  color-scheme: dark;
  --ground: #0d0f15;
  --panel: #151823;
  --panel-2: #1c2030;
  --line: #262b3a;
  --ink: #ebe7de;
  --muted: #8d90a2;
  --faint: #5f6376;
  --lamp: #d6a756;
  --steel: #8fb0c6;
  --deep: #4f6f9c;
  --good: #86b584;
  --mid: #e3c05c;
  --low: #c9695a;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { background: var(--ground); color: var(--ink); }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--lamp); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#view { outline: none; }
.content {
  max-width: 480px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: calc(var(--safe-top) + 14px) calc(var(--safe-bottom) + 92px);
  display: grid;
  gap: 14px;
  align-content: start;
}

/* Header */
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 10px; }
.title { font-family: var(--display); font-weight: 600; font-size: 26px; letter-spacing: -.015em; line-height: 1.1; margin: 0; }
.sample { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; white-space: nowrap; background: transparent; text-decoration: none; min-height: 30px;
}
button.chip:hover, a.chip:hover { border-color: var(--faint); color: var(--ink); }
.chip i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.chip i.stale { background: var(--faint); }
.chip i.warn { background: var(--mid); }
.chip i.spin { background: none; width: 10px; height: 10px; border: 1.5px solid var(--lamp); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 20px; line-height: 1; text-decoration: none;
}
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.datenav { display: grid; grid-template-columns: 34px 1fr 34px; gap: 8px; align-items: center; }
.date-btn { border: 0; background: var(--panel); border-radius: 999px; height: 34px; font-weight: 600; font-size: 13.5px; }

.demo { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: #1d1a14; border: 1px solid #4a3d25; font-size: 12.5px; color: var(--muted); }
.demo b { color: var(--lamp); font-weight: 600; }
.demo a, .demo button { font: 600 12.5px var(--body); color: var(--lamp); background: none; border: 0; padding: 4px 0; text-decoration: none; white-space: nowrap; }
.chip.gold { background: var(--lamp); border-color: var(--lamp); color: #17130b; font-weight: 500; }
.lead { margin: 0; color: var(--muted); font-size: 14px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border-radius: 12px; padding: 3px; }
.seg a { text-align: center; padding: 7px 4px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; }
.seg a.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* Type */
.k { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.v { font-family: var(--display); font-weight: 600; font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.v.sm { font-size: 17px; }
.v small { font-family: var(--mono); font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.d { font-family: var(--mono); font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.d.good { color: var(--good); } .d.low { color: var(--low); } .d.mid { color: var(--mid); } .d.lamp { color: var(--lamp); }
.d.full { grid-column: 1 / -1; }
.muted { color: var(--faint); }
.note { font-size: 12px; color: var(--faint); line-height: 1.45; margin: 0; }
.note.alert { color: var(--low); border: 1px solid #4d2f2b; border-radius: 12px; padding: 10px 12px; }
.h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0; }
code { font-family: var(--mono); font-size: 11.5px; color: var(--ink); word-break: break-all; }

/* Surfaces */
.panel { background: var(--panel); border-radius: 18px; padding: 12px; display: grid; gap: 10px; }
.grid-3, .grid-2 { display: grid; gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 > div, .grid-2 > div { background: var(--panel); padding: 9px 10px 8px; min-width: 0; }
.grid-2.inner > div { background: var(--panel-2); }
.block { display: grid; gap: 7px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.empty { background: var(--panel); border-radius: 18px; padding: 20px 16px; display: grid; gap: 8px; justify-items: start; }
.empty h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; }

.list { display: grid; gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; }
.li { background: var(--panel); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: center; font-size: 14px; color: var(--ink); text-decoration: none; }
a.li:active { background: var(--panel-2); }
.li .d { grid-column: 1; }
.li .right { grid-row: 1 / span 2; grid-column: 2; text-align: right; }

.btn { display: flex; justify-content: center; align-items: center; gap: 8px; font: 600 14px var(--body); color: #17130b; background: var(--lamp); border-radius: 12px; padding: 11px 14px; border: 0; text-decoration: none; min-height: 44px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: transparent; color: var(--low); border: 1px solid #4d2f2b; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.link-btn { background: none; border: 0; color: var(--faint); font-size: 12px; justify-self: center; text-decoration: underline; }

.band { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.band::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.band.good { color: var(--good); } .band.mid { color: var(--mid); } .band.low { color: var(--low); }

.scale { position: relative; height: 10px; border-radius: 999px; background: var(--panel-2); }
.scale .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, var(--steel), var(--lamp)); }
.scale .target { position: absolute; top: -4px; bottom: -4px; border: 1.5px dashed var(--lamp); border-radius: 6px; }
.ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9.5px; color: var(--faint); margin: 0; }
svg text { font-family: var(--mono); }

/* Dials */
.dials { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dial { display: grid; justify-items: center; gap: 2px; }
.dial svg { width: 100%; max-width: 96px; height: auto; }
.dial-num { font-family: var(--display); font-weight: 700; font-size: 21px; fill: var(--ink); }
.dial-unit { font-family: var(--mono); font-size: 8.5px; fill: var(--muted); }

/* Sleep */
.stages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.stage { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; background: var(--panel); padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.stage i { width: 10px; height: 10px; border-radius: 3px; }
.stage b { font-family: var(--mono); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.wake { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border-radius: 16px; padding: 12px 14px; cursor: pointer; }
.wake > span:first-child { display: grid; }
.wake input { background: transparent; border: 0; padding: 0; font-family: var(--display); font-weight: 700; font-size: 34px; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; width: 7ch; }
.wake input::-webkit-calendar-picker-indicator { filter: invert(.7); }
.opt { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); }
.opt.sel { border-color: var(--lamp); background: #1d1a14; }
.opt .name { font-weight: 600; font-size: 14px; }
.opt .time { grid-row: 1 / span 2; grid-column: 2; font-family: var(--display); font-weight: 600; font-size: 22px; font-variant-numeric: tabular-nums; }
.calc { gap: 6px; font-size: 13px; }
.calc .row { border-bottom: 1px dashed var(--line); padding-bottom: 5px; }
.calc .row b { font-family: var(--mono); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.calc .row.total { border: 0; font-weight: 600; }
.calc .row.total b { color: var(--lamp); }

/* Strain */
.hero-num { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-num .big { font-family: var(--display); font-weight: 700; font-size: 56px; letter-spacing: -.03em; line-height: .95; font-variant-numeric: tabular-nums; }
.zones { display: grid; gap: 6px; }
.zone { display: grid; grid-template-columns: 92px 1fr 52px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.zone em { font-style: normal; font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.zone .bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.zone .bar span { display: block; height: 100%; border-radius: 999px; }
.zone b { font-family: var(--mono); font-size: 11px; color: var(--ink); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* Health */
.hm { display: grid; gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; }
.hm-row { background: var(--panel); padding: 9px 12px 10px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
.hm-row .name { font-size: 13px; display: flex; align-items: center; gap: 7px; }
.hm-row .name i { width: 7px; height: 7px; border-radius: 50%; }
.hm-row .val { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.range { grid-column: 1 / -1; position: relative; height: 6px; border-radius: 999px; background: var(--panel-2); }
.range .ok { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: #2e3d33; }
.range .dot { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--panel); transform: translate(-50%, -50%); }

.ages { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 16px; overflow: hidden; }
.ages > div { background: var(--panel); padding: 12px; }
.ages .big { font-family: var(--display); font-weight: 700; font-size: 40px; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.ages .x { font-size: 22px; }
.div-list { display: grid; gap: 8px; }
.div-row, .div-axis { display: grid; grid-template-columns: minmax(96px, 38%) 1fr 44px; gap: 8px; align-items: center; }
.div-row { font-size: 12px; }
.div-row b { font-family: var(--mono); font-weight: 500; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.div-track { position: relative; height: 8px; }
.div-track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--faint); }
.div-track span { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.div-axis { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.div-axis > span:nth-child(2) { display: flex; justify-content: space-between; }

/* Journal & report */
.q { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; font-size: 14px; padding: 8px 12px; background: var(--panel); }
.yn { display: inline-grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.yn button { border: 0; background: transparent; padding: 6px 12px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); min-width: 48px; min-height: 34px; }
.yn button.on { background: var(--lamp); color: #17130b; }
.streak { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px; padding: 12px; }
.streak .num { font-family: var(--display); font-weight: 700; font-size: 30px; color: var(--lamp); line-height: 1; font-variant-numeric: tabular-nums; }
.streak-text { font-size: 13px; line-height: 1.3; }
.pips { display: flex; gap: 3px; margin-left: auto; }
.pips i { width: 7px; height: 18px; border-radius: 2px; background: var(--lamp); }
.pips i.off { background: var(--panel-2); }

/* Live (Bluetooth) */
.live-hero { display: flex; align-items: baseline; justify-content: center; gap: 12px; padding-block: 4px; }
.live-hero .big { font-family: var(--display); font-weight: 700; font-size: 92px; letter-spacing: -.04em; line-height: .9; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }
.live-hero .unit { font-family: var(--mono); color: var(--muted); font-size: 14px; }
.live-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--low); align-self: center; animation: beat 1s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(.8); opacity: .55; } 30% { transform: scale(1.15); opacity: 1; } }
.live-zone { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 28px; }
.zone-pill { font-size: 13px; font-weight: 600; color: #12141b; padding: 4px 12px; border-radius: 999px; }

/* Coach */
.chat { display: grid; gap: 8px; }
.bubble { padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; max-width: 90%; }
.bubble.me { justify-self: end; background: var(--panel-2); border-bottom-right-radius: 4px; }
.bubble.ai { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.ai .k { display: block; color: var(--lamp); margin-bottom: 2px; }
.prompts { display: flex; flex-wrap: wrap; gap: 8px; }
.prompts .chip { font-family: var(--body); font-size: 13px; color: var(--ink); }
.ask { display: grid; grid-template-columns: 1fr auto; gap: 8px; position: sticky; bottom: calc(var(--safe-bottom) + 76px); background: var(--ground); padding-block: 6px; }
.ask input { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; font-size: 16px; min-width: 0; }

/* Settings */
.field { display: grid; gap: 5px; }
.field input, .field select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; font-size: 16px; width: 100%; }
.mini-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }
.mini-steps b { color: var(--ink); }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 9px 12px; }
.copy-row .k { grid-column: 1 / -1; }
.warns summary { color: var(--mid); font-size: 13px; cursor: pointer; }
.warns ul { margin: 8px 0 0; padding-left: 18px; font-family: var(--mono); font-size: 11px; color: var(--muted); display: grid; gap: 4px; word-break: break-word; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 480px; margin: 0 auto;
  padding: 8px 4px calc(var(--safe-bottom) + 8px);
  background: rgba(13, 15, 21, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 3px; font-size: 10.5px; color: var(--faint); text-decoration: none; padding-block: 2px; }
.tab svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--lamp); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 84px); transform: translate(-50%, 12px);
  max-width: min(440px, calc(100% - 32px)); width: max-content;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 12px;
  padding: 10px 14px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: #4d2f2b; color: #f0c2b9; }

/* Breathing */
.breathe {
  position: fixed; inset: 0; z-index: 40; background: rgba(13, 15, 21, .97);
  display: grid; place-content: center; justify-items: center; gap: 18px; padding: 24px;
}
.breathe-circle {
  width: min(62vw, 260px); aspect-ratio: 1; max-width: 100%; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(214, 167, 86, .35), rgba(143, 176, 198, .12) 60%, transparent 72%);
  border: 1.5px solid var(--lamp); transform: scale(.55); transition: transform 4s ease-in-out;
}
.breathe-phase { font-family: var(--display); font-weight: 600; font-size: 28px; margin: 0; }
.breathe-left { margin: 0; }

@media (min-width: 700px) {
  .content { padding-block: 28px 104px; }
}
@media (prefers-reduced-motion: reduce) {
  .breathe-circle { transition: none !important; }
  .chip i.spin { animation: none; }
  #toast { transition: none; }
}
