/* Layout: one narrow phone-first column, a sticky header, and a bottom tab bar like a team app. */
:root {
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --sunk: #E4E8EE;
  --ink: #121A2B;
  --muted: #5A6476;
  --line: #D6DCE4;
  --accent: #2448C9;
  --accent-ink: #FFFFFF;
  --good: #12805A;
  --warn: #B25E00;
  --bad: #B3261E;
  --c-blue: #2E5BE8;
  --c-plum: #9C3584;
  --c-amber: #C27A00;
  --c-green: #13855B;
  --c-red: #C2412D;
  --c-teal: #0E7C86;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Atkinson Hyperlegible", -apple-system, "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D121B; --surface: #161D29; --sunk: #1E2634; --ink: #E7EBF2; --muted: #98A2B4; --line: #2B3446;
    --accent: #7C9BFF; --accent-ink: #0D121B; --good: #3CC48D; --warn: #F0A646; --bad: #FF8A80;
    --c-blue: #7C9BFF; --c-plum: #E27ACB; --c-amber: #F2B544; --c-green: #3CC48D; --c-red: #FF8A70; --c-teal: #4CC9D3;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; padding-top: env(safe-area-inset-top, 0px); background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
.app { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 calc(var(--tabbar) + 32px + env(safe-area-inset-bottom, 0px)); }
h1, h2, h3, .num { font-family: var(--font-display); letter-spacing: 0.01em; text-wrap: balance; }
h2 { font-size: 28px; line-height: 1.1; margin: 0; font-weight: 700; }
h3 { font-size: 20px; margin: 0; font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* 16px stops iPhone zooming in on focus */
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 12px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: 0.04em; flex: none; }
.brand h1 { font-size: 24px; margin: 0; line-height: 1; font-weight: 700; text-transform: uppercase; }
.brand p { font-size: 13px; color: var(--muted); }
.who { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.who:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 5px; font-weight: 700; font-size: 15px; }
.chip[aria-pressed="true"] { border-color: var(--mc); box-shadow: inset 0 0 0 1.5px var(--mc); }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--mc); color: var(--surface); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 16px; flex: none; }
.av.lg { width: 44px; height: 44px; font-size: 24px; }

main { display: grid; gap: 16px; padding-top: 16px; }
.tab { display: grid; gap: 16px; }
.contents { display: contents; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.stats { display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; }
.stat .num { font-size: 30px; line-height: 1.05; }
.stat .num small { font-size: 16px; color: var(--muted); font-weight: 500; }

.notice { border-radius: var(--radius); padding: 12px 14px; background: var(--sunk); font-size: 14px; }
.notice.warn { border-left: 4px solid var(--warn); }
.notice.good { border-left: 4px solid var(--good); }
.notice.row { flex-wrap: wrap; }
.notice.row > span { flex: 1 1 200px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border-radius: 999px; padding: 2px 10px; background: color-mix(in srgb, var(--mc, var(--accent)) 14%, transparent); color: var(--mc, var(--accent)); }

.bar { height: 10px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--mc, var(--accent)); border-radius: 999px; transition: width .4s ease; }
.dots { display: flex; gap: 6px; }
.dots span { width: 26px; height: 26px; border-radius: 6px; background: var(--sunk); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.dots span.on { background: var(--mc); color: var(--surface); }
.dots span.today { outline: 2px solid var(--mc); outline-offset: 1px; }
.member-card { cursor: pointer; text-align: left; border: 1px solid var(--line); }

.btn { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 11px 18px; font-weight: 700; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; width: 42px; height: 42px; font-size: 20px; font-weight: 700; display: grid; place-items: center; flex: none; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.field { display: grid; gap: 4px; min-width: 0; }
.input, .field input, .field select, .field textarea, .logbar input { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; }
.field textarea { min-height: 72px; resize: vertical; }
.unit { position: relative; display: block; }
.unit input { padding-right: 46px; }
.unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 14px; pointer-events: none; }
.logbar { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; font-weight: 700; min-width: 44px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.counter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.counter .num { font-size: 32px; min-width: 2ch; text-align: center; }
.wo-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 42px; gap: 8px; align-items: center; }
.cups { display: flex; gap: 4px; flex-wrap: wrap; }
.cups i { width: 14px; height: 20px; border-radius: 3px 3px 6px 6px; border: 1.5px solid var(--c-teal); }
.cups i.on { background: var(--c-teal); }
.toggle { display: flex; gap: 10px; align-items: center; }
.toggle input { width: 22px; height: 22px; margin: 0; }

.meal { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.meal:first-child { border-top: 0; }
.photo-preview { max-height: 220px; border-radius: 10px; object-fit: cover; width: 100%; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend b { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--mc); }
.legend b.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.daylist { display: grid; }
.daylist button { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 10px 0; }
.daylist button:first-child { border-top: 0; }

.thread { display: grid; gap: 10px; }
.msg { padding: 12px 14px; border-radius: 14px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { justify-self: end; background: var(--mc); color: var(--surface); border-bottom-right-radius: 4px; }
.msg.coach { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.coach.thinking { color: var(--muted); font-style: italic; }
.msg .tag { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; min-height: 46px; max-height: 160px; resize: vertical; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; }

.glist { display: grid; }
.gitem { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 36px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.gitem:first-child { border-top: 0; }
.gitem input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--good); margin: 0; }
.gitem.got .gname b { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.gname { min-width: 0; overflow-wrap: anywhere; }
.reqs { display: flex; gap: 3px; }
.reqs .av { width: 22px; height: 22px; font-size: 13px; }
.xbtn { border: 0; background: none; color: var(--muted); font-size: 22px; width: 36px; height: 36px; border-radius: 8px; }
.gform { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; }
.gform .wide { grid-column: 1 / -1; }
.copybox { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 140px; font-size: 14px; }
.staples { display: flex; flex-wrap: wrap; gap: 6px; }
.staples button { border: 1.5px dashed var(--line); background: none; border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.sugg { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 700; font-size: 14px; }
code.box { display: block; padding: 10px 12px; background: var(--sunk); border-radius: 10px; font-size: 13px; overflow-wrap: anywhere; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }

.login-names { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.login-names button { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px; font-weight: 700; font-size: 18px; text-align: left; }
.login-names button[aria-pressed="true"] { border-color: var(--mc); box-shadow: inset 0 0 0 1.5px var(--mc); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.tabs .inner { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(6, 1fr); height: var(--tabbar); }
.tabs button { border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; padding: 0; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs button[aria-current="page"] svg { stroke: var(--accent); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700; z-index: 20; max-width: calc(100% - 32px); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
