/* Twilight: cool graphite with a sunset accent and turquoise for "done / on pace". Geist throughout.
   Color only where it means something (turquoise = done / on pace, amber = needs attention, red = missed / past due). */

:root, [data-theme="dark"] {
    color-scheme: dark;
    --bg: #101216; --panel: #171A20; --well: #1C2027; --well-2: #242933;
    --border: #252A33; --border-2: #323946;
    --text: #F1F2F4; --text-2: #A9AFB9; --text-3: #737B88;
    --accent: #FF9A62; --accent-soft: rgba(255,154,98,.14);
    --up: #44CDB6; --amber: #E9B850; --down: #F47272;
    --land: #272C35; --land-line: #343B46; --visited: #3B6E73; --sea: #13161B;
    --card-shadow: none;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
}
[data-theme="light"] {
    color-scheme: light;
    --bg: #F4F5F7; --panel: #FFFFFF; --well: #F7F8FA; --well-2: #EDEFF3;
    --border: #E3E6EB; --border-2: #D4D9E0;
    --text: #17191E; --text-2: #5A616D; --text-3: #8C93A0;
    --accent: #E5672F; --accent-soft: rgba(229,103,47,.09);
    --up: #13917F; --amber: #A86B00; --down: #D03B3B;
    --land: #E4E7EC; --land-line: #FFFFFF; --visited: #A3D9D0; --sea: #F8F9FB;
    --card-shadow: 0 1px 2px rgba(20,20,30,.04), 0 6px 20px rgba(20,20,30,.05);
    --shadow: 0 10px 30px rgba(20,30,50,.12);
}
:root { --font-ui: "Geist Variable", system-ui, sans-serif; --r-card: 14px; --r-tile: 10px; --r-ctl: 9px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
[hidden] { display: none !important; }
html.auth-pending .tabbar, html.auth-pending main { visibility: hidden; }
body { font: 400 14px/1.45 var(--font-ui); background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { color: var(--accent); }
h2.mt { margin-top: 20px; }
code { font: 12px ui-monospace, Consolas, monospace; background: var(--well-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--text-3); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .amber { color: var(--amber); }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid var(--bg); }
main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 56px; }

/* ── Navigation: a sidebar on wide screens, a bar along the bottom on phones ───── */
body { padding-left: 220px; }
.tabbar { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 40; display: flex; flex-direction: column; gap: 4px;
    padding: 28px 14px 20px; background: var(--bg); border-right: 1px solid var(--border); }
.tabbar a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; color: var(--text-2); text-decoration: none; font-weight: 500;
    transition: background .12s, color .12s; }
.tabbar a:hover { background: var(--well-2); color: var(--text); }
.tabbar a.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(20,20,30,.08), 0 0 0 1px var(--border); }
.tabbar a.on svg { stroke: var(--accent); }
.tabbar svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save-state { margin-top: auto; padding: 0 14px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; background: none; border: 0; border-radius: var(--r-ctl); color: var(--text-2); cursor: pointer; transition: background .12s, color .12s; font-size: 16px; }
.icon-btn:hover { background: var(--well-2); color: var(--text); }

.subnav { display: flex; gap: 4px; width: fit-content; max-width: 100%; overflow-x: auto; margin: 0 0 18px; padding: 4px; background: var(--well-2); border-radius: 999px; }
.subnav a { padding: 7px 16px; border-radius: 999px; color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13px; white-space: nowrap; }
.subnav a.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(20,20,30,.12); }

.settings .setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.settings h2 + .setting { border-top: 0; padding-top: 0; }
.settings .setting-wide { flex-wrap: wrap; }
.settings .setting-wide .setup-steps { width: 100%; }
.settings a { color: var(--accent); text-decoration: none; }

/* ── Controls ──────────────────────────────────────────────────────── */
.btn { height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border-2);
    border-radius: var(--r-ctl); font-weight: 500; cursor: pointer; transition: background .12s; white-space: nowrap; }
.btn:hover { background: var(--well-2); }
.btn:disabled { opacity: .5; cursor: default; }
.app-links { display: flex; gap: 10px; }
.app-link { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; display: block; box-shadow: 0 1px 3px rgba(20,20,30,.15), 0 0 0 1px var(--border); transition: transform .12s, box-shadow .12s; }
.app-link:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20,20,30,.18), 0 0 0 1px var(--border); }
.app-link img { width: 100%; height: 100%; display: block; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 999px; padding: 0 16px; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--down); }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-ctl); overflow: hidden; }
.seg button { height: 28px; padding: 0 12px; background: var(--panel); border: 0; border-right: 1px solid var(--border-2); font-size: 12px; color: var(--text-2); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--well-2); color: var(--text); font-weight: 600; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, textarea { background: var(--well); border: 1px solid var(--border-2); border-radius: var(--r-ctl); padding: 0 10px; height: 34px; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag { display: inline-block; font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 2px 7px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { color: var(--text-3); padding: 6px 0; }

/* ── Layout ────────────────────────────────────────────────────────── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--card-shadow); }
[data-theme="light"] .panel, [data-theme="light"] .stat { border-color: transparent; }
.panel.notice { border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--panel); }
.panel.notice p { color: var(--text-2); max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 > .panel { margin-bottom: 14px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.home-grid > .panel { margin: 0; }
.span-2 { grid-column: span 2; }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .12s; }
.card-link:hover { border-color: var(--border-2); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.big { font-size: 26px; font-weight: 700; }
.big small, .stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); }
.soon { border-style: dashed; background: transparent; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px 20px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }

/* ── Training ──────────────────────────────────────────────────────── */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { background: var(--well); border: 1px solid transparent; border-radius: var(--r-tile); padding: 8px 9px; min-height: 92px; display: flex; flex-direction: column; gap: 4px; }
.day-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-2); }
.day-plan { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.day-done { font-size: 12px; overflow-wrap: anywhere; }
.day.rest .day-plan { color: var(--text-3); }
.day.done { background: color-mix(in srgb, var(--up) 12%, var(--well)); }
.day.done .day-done { color: var(--text); }
.day .tick { color: var(--up); font-weight: 700; }
.day.missed .day-done { color: var(--down); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.day.today .day-head span:first-child { color: var(--accent); }

.bars { width: 100%; height: 140px; display: block; }
.bars rect { fill: var(--well-2); }
.bars rect.now { fill: var(--accent); }
.bars rect:hover { fill: var(--text-3); }
.bars-axis { display: flex; justify-content: space-between; margin-top: 6px; }

.lifts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.lift { background: var(--well); border-radius: var(--r-tile); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.lift-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lift-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lift-value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.lift-value small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.spark { width: 100%; height: 44px; margin-top: 6px; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark circle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.spark circle.now { fill: var(--accent); }
.routine { display: grid; gap: 6px; margin-top: 10px; }
.routine label { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.routine input { height: 30px; }

.workouts { display: flex; flex-direction: column; }
.workout { display: grid; grid-template-columns: 70px 1fr minmax(180px, auto) 90px; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.workout:first-child { border-top: 0; }
.workout-date { display: flex; flex-direction: column; }
.workout-title { font-weight: 600; }
.workout-main .muted { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.workout-tops { display: flex; flex-direction: column; font-size: 12px; color: var(--text-2); }
.workout-tops b { color: var(--text); font-weight: 600; }
.workout-meta { font-size: 12px; color: var(--text-2); text-align: right; }

/* ── Goals ─────────────────────────────────────────────────────────── */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.goal-grid .panel { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.goal-line + .goal-line { margin-top: 12px; }
.goal-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.goal-title { font-weight: 600; }
.goal-top .num { color: var(--text-2); white-space: nowrap; }
.meter { height: 8px; background: var(--well-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.meter i.up { background: var(--up); } .meter i.amber { background: var(--amber); } .meter i.down { background: var(--down); }
.goal-sub { display: flex; gap: 10px; margin-top: 6px; }
.goal-notes { list-style: none; font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }

/* ── Travel ────────────────────────────────────────────────────────── */
.map { position: relative; height: 480px; border-radius: var(--r-tile); overflow: hidden; background: var(--sea); }
.map svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.map svg.dragging { cursor: grabbing; }
.map.editable svg { cursor: crosshair; }
.map.editable svg.dragging { cursor: grabbing; }
.map-sea { fill: var(--sea); }
.map-land path { fill: var(--land); stroke: var(--land-line); stroke-width: .5; vector-effect: non-scaling-stroke; transition: fill .15s; }
.map-land path.visited { fill: var(--visited); }
.map-land path:hover { fill: color-mix(in srgb, var(--land) 70%, var(--text-3)); }
.map-land path.visited:hover { fill: color-mix(in srgb, var(--visited) 80%, var(--text)); }
.map-pins circle { fill: var(--accent); stroke: var(--panel); cursor: pointer; }
.map-pins circle.future { fill: var(--panel); stroke: var(--amber); }
.map-ctrl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px; }
.map-ctrl .icon-btn { width: 28px; height: 28px; font-size: 14px; }
.map-panel { padding: 8px; }
.legend { display: flex; gap: 16px; padding: 8px 6px 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.visited { background: var(--visited); }
.lg.pin { background: var(--accent); border-radius: 50%; }
.lg.future { border: 2px solid var(--amber); border-radius: 50%; }
.place-search { position: relative; width: min(420px, 100%); }
.place-search input { width: 100%; height: 38px; }
.suggest { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; list-style: none; background: var(--panel); border: 1px solid var(--border-2);
    border-radius: var(--r-card); padding: 4px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.suggest li { padding: 8px 10px; border-radius: var(--r-ctl); cursor: pointer; font-size: 13px; }
.suggest li:hover { background: var(--well-2); }
.year { font-size: 12px; color: var(--text-3); font-weight: 600; margin: 12px 0 4px; }
.year:first-of-type { margin-top: 0; }
.places { list-style: none; }
.place { width: 100%; text-align: left; background: none; border: 0; border-radius: var(--r-ctl); padding: 7px 8px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.place:hover { background: var(--well-2); }
.place-name { font-weight: 600; }
.place-note { width: 100%; font-size: 12px; color: var(--text-2); }

/* ── Health ────────────────────────────────────────────────────────── */
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.mini { background: var(--well); border-radius: var(--r-tile); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; transition: background .12s; }
a.mini:hover { background: var(--well-2); }
.mini-value { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.meals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.meal h3 { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; }
.food { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--border); }
.food:first-of-type { border-top: 0; }

.section-title { font-size: 16px; margin: 22px 0 12px; }
.apps { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.app-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 64px; align-items: center; gap: 10px; }
.app-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-icon { position: relative; flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; overflow: hidden;
    font-size: 12px; font-weight: 700; color: #fff; background: hsl(var(--hue) 45% 48%); }
.app-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.app-bar { height: 8px; background: var(--well-2); border-radius: 999px; overflow: hidden; }
.app-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.app-row .muted { text-align: right; }
.phone-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.setup-steps { display: flex; flex-direction: column; gap: 8px; padding-left: 20px; margin-top: 8px; color: var(--text-2); }
.copyable { user-select: all; word-break: break-all; }

.toggle { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--border-2); position: relative; cursor: pointer; padding: 0; border: 0; flex-shrink: 0; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(18px); }
.toggle:disabled { opacity: .4; cursor: default; }

/* ── Evenings ── */
.nights { display: flex; flex-direction: column; }
.night-row { display: grid; grid-template-columns: 44px 1.4fr 1fr 1fr 20px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.night-row:first-child { border-top: 0; }
.night-day { font-weight: 600; }
.night-mark { font-weight: 700; text-align: center; }
.insight { margin-top: 12px; padding: 10px 12px; background: var(--accent-soft); border-radius: var(--r-tile); }
.winddown-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; color: var(--text-2); }
.winddown-form select { height: 32px; }
@media (max-width: 640px) { .night-row { grid-template-columns: 38px 1fr 20px; } .night-row > :nth-child(3), .night-row > :nth-child(4) { grid-column: 2; } }

/* ── Morning check-in ── */
.checkin h2 { margin-bottom: 12px; }
.feel-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.feel { height: 44px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--panel); color: var(--text); font-weight: 600; cursor: pointer; transition: border-color .12s, background .12s; }
.feel:hover { border-color: var(--accent); }
.feel[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.checkin > .muted { margin-top: 10px; }
.call-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.call-text { color: var(--text-2); margin-top: 4px; max-width: 760px; }
.checkin.go .call-title { color: var(--up); }
.checkin.adjust .call-title { color: var(--accent); }
.checkin.easy .call-title { color: var(--text); }
.call-why { margin-top: 10px; }
.call-why summary { cursor: pointer; color: var(--text-3); font-size: 12px; }

/* ── Coach ─────────────────────────────────────────────────────────── */
.brief-headline { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; max-width: 860px; }
.brief-follow { color: var(--text-2); margin-top: 6px; max-width: 860px; }
.brief-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 16px 0; }
.brief-cols h3 { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; }
.brief-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.brief-list li { position: relative; padding-left: 18px; color: var(--text-2); }
.brief-list li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 7px; height: 7px; border-radius: 50%; }
.brief-list.wins li::before { background: var(--up); }
.brief-list.watch li::before { background: var(--amber); }
.brief-focus { background: var(--accent-soft); border-radius: var(--r-tile); padding: 14px 16px; }
.brief-focus-label { font-size: 12px; font-weight: 600; color: var(--accent); }
.brief-focus-action { font-size: 15px; font-weight: 600; margin: 2px 0 4px; }
.brief-foot { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.brief-foot a { color: var(--accent); text-decoration: none; }
.brief-loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 18px 0; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }

.chat { display: flex; flex-direction: column; min-height: calc(100vh - 220px); padding: 0; overflow: hidden; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px; overflow-y: auto; max-height: calc(100vh - 260px); }
.chat-empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 0; }
.chat-empty p { font-size: 18px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 620px; }
.chip { border: 1px solid var(--border-2); background: var(--panel); border-radius: 999px; padding: 8px 14px; cursor: pointer; color: var(--text-2); transition: border-color .12s, color .12s; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(680px, 85%); padding: 10px 14px; border-radius: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.coach .bubble { background: var(--well); border-bottom-left-radius: 6px; }
.bubble.error { color: var(--down); }
.bubble p + p, .bubble p + ul, .bubble ul + p, .bubble p + ol, .bubble ol + p { margin-top: 8px; }
.bubble ul, .bubble ol { padding-left: 20px; }
.bubble li + li { margin-top: 3px; }
.proposal { margin: 10px 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r-tile); display: flex; flex-direction: column; gap: 6px; }
.proposal.applied { border-color: color-mix(in srgb, var(--up) 50%, var(--border)); }
.proposal.declined { opacity: .7; }
.proposal-head { display: flex; justify-content: space-between; gap: 10px; }
.proposal-title { font-weight: 700; color: var(--accent); }
.plan-diff { display: grid; grid-template-columns: 40px 1fr; gap: 2px 10px; font-size: 13px; }
.pd-day { color: var(--text-3); font-weight: 600; }
.pd-new { font-weight: 600; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: pulse 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.chat-input { display: flex; gap: 10px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--panel); }
.chat-input textarea { flex: 1; resize: none; min-height: 40px; max-height: 180px; border-radius: 20px; padding: 10px 14px; line-height: 1.4; }
.chat-input .btn { height: 40px; }

/* ── Dialog and sign-in ────────────────────────────────────────────── */
.modal, .login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(5,8,12,.6); animation: fade .12s ease-out; }
.login { background: var(--bg); visibility: visible; }
.modal-card, .login-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--border-2); border-radius: calc(var(--r-card) + 2px); padding: 20px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 12px; }
.modal-card h3 { font-size: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.field input, .field select, .field textarea { color: var(--text); font-size: 14px; font-weight: 400; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.login-head { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-card .btn { justify-content: center; height: 38px; }
.login-card input { height: 38px; }
.login-intro { color: var(--text-2); }
.login-foot { text-align: center; font-size: 11px; color: var(--text-3); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
@keyframes fade { from { opacity: 0; } }

/* ── Phones and narrow windows ─────────────────────────────────────── */
@media (max-width: 860px) {
    .grid-2, .home-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .workout { grid-template-columns: 60px 1fr 80px; }
    .workout-tops { display: none; }
    .brief-cols { grid-template-columns: 1fr; gap: 12px; }
    .minis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 899px) {
    body { padding-left: 0; }
    .tabbar { top: auto; right: 0; width: auto; height: calc(64px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; gap: 0;
        padding: 4px 4px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border);
        background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
    .tabbar a { flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 0; font-size: 11px; border-radius: 10px; }
    .tabbar a:hover { background: none; }
    .tabbar a.on { background: none; box-shadow: none; color: var(--accent); }
    .tabbar svg { width: 22px; height: 22px; }
    .tabbar .tab-coach svg { width: 46px; height: 46px; padding: 12px; margin-top: -20px; border-radius: 50%; background: var(--accent); stroke: #fff;
        box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent); }
    .tabbar .tab-coach.on svg { stroke: #fff; }
    .save-state { display: none; }
    main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
    .chat { min-height: calc(100dvh - 250px); }
    .chat-log { max-height: calc(100dvh - 300px); }
}
@media (max-width: 640px) {
    main { padding: 16px 16px 48px; }
    .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { padding: 14px; }
    .stat-value { font-size: 22px; }
    .week-strip { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
    .day { padding: 6px 4px; min-height: 76px; }
    .day-head { flex-direction: column; align-items: center; gap: 0; }
    .day-plan, .day-done { font-size: 10px; text-align: center; overflow-wrap: normal; word-break: keep-all; }
    .map { height: 300px; }
    .goal-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
