/* Seed Wheel screen chrome and sheets. Token colours only. */
:root { --control-edge: var(--gold-deep); --sheet-w: 400px; --btn-h: 64px; --nextup-h: 0px; } /* 3:1 on the sheet surface, for control outlines */
[data-theme="dusk"] { --control-edge: #9b9db8; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 24px; overflow: hidden; }
#stage, #map { position: fixed; inset: 0; }
button { font-family: inherit; }

/* Floating controls: only these two. */
#goal-pill, #primary-btn { position: fixed; left: 50%; transform: translateX(-50%); z-index: 20; }
#goal-pill { top: calc(var(--space-4) + env(safe-area-inset-top)); max-width: calc(100% - 32px); min-height: 44px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; box-sizing: border-box; }
#goal-pill strong { overflow: hidden; text-overflow: ellipsis; }
#primary-btn { top: auto; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); }
#primary-btn:active { top: auto; transform: translateX(-50%) translateY(4px); }
.sw-marker { width: 20px; height: 20px; flex: none; }
body.sheet-open #primary-btn { visibility: hidden; }

/* Next-up card: one pick plus up to two alternates. Empty shell filled by JS. */
#nextup-card { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--space-6) + var(--btn-h) + var(--space-3) + env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 32px)); box-sizing: border-box; display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface-raised); color: var(--ink); border: 3px solid var(--line); border-radius: var(--radius-card);
  box-shadow: 0 4px 0 var(--control-edge), 0 8px 14px rgba(40,25,10,.25); padding: var(--space-2) var(--space-3); }
#nextup-card[hidden] { display: none; }
.nu-main { display: flex; gap: var(--space-3); align-items: center; width: 100%; min-height: 56px; background: none; border: 0; padding: 0; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.nu-art { width: 52px; height: 52px; flex: none; border-radius: 50%; border: 3px solid var(--gold); background: var(--mint, var(--go)); }
.nu-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nu-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nu-tip { font-size: 14px; line-height: 18px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nu-unlocks { font-size: 13px; line-height: 18px; font-weight: 800; color: var(--gold-ink); }
.nu-alts { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; min-width: 0; }
.nu-or { font-size: 13px; font-weight: 800; color: var(--ink-muted); flex: 1 0 100%; }
@media (min-width: 420px) { .nu-or { flex: none; } }
.nu-chip { min-height: 44px; min-width: 0; flex: 1 1 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; white-space: normal; padding: var(--space-1) var(--space-3); line-height: 18px;
  border: 2px solid var(--control-edge); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font-weight: 800; font-size: 14px; cursor: pointer; }
@media (max-width: 899px) { body.sheet-open #nextup-card { display: none; } }
body.sheet-open:not([data-sheet="trick"]) #nextup-card { display: none; }
@media (min-width: 900px) { body.sheet-open #nextup-card { left: calc((100% - var(--sheet-w)) / 2); } }
@media (max-height: 500px) { .nu-alts { display: none; } }
body.onboarding-open #nextup-card { display: none; }
#map:focus-visible { outline: 3px solid var(--focus); outline-offset: -6px; }
.sw-pill, .sw-btn-secondary { border-color: var(--control-edge); }
.sw-btn-secondary { box-shadow: 0 4px 0 0 var(--control-edge); }

/* Focus ring */
:where(#goal-pill, #primary-btn, #nextup-card button, #sheet button, #sheet input, #sheet select, #sheet summary, #sheet label.linkbtn, #onboarding button):focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
#nextup-card button:focus-visible { outline-offset: 2px; }
#nextup-card .nu-main:focus-visible { outline-offset: -3px; }
#sheet-title:focus, #onboarding h1:focus { outline: none; }

/* Scrim + sheet */
#scrim { position: fixed; inset: 0; z-index: 30; background: rgba(59, 42, 26, 0.35); }
[data-theme="dusk"] #scrim { background: rgba(0, 0, 0, 0.5); }
#scrim[hidden], #sheet[hidden], #onboarding[hidden], #toast[hidden] { display: none; }
#sheet { position: fixed; z-index: 40; background: var(--surface-raised); color: var(--ink); border: 2px solid var(--line); box-sizing: border-box;
  left: 0; right: 0; bottom: 0; max-height: 85dvh; border-radius: var(--radius-card) var(--radius-card) 0 0; box-shadow: var(--sheet);
  overflow-y: auto; overscroll-behavior: contain; padding: var(--space-6) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease-out; }
#sheet.open { transform: none; }
.sheet-grab { position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: var(--radius-pill); background: var(--line); }
.sheet-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: none; color: var(--ink-muted); font-size: 28px; line-height: 1; cursor: pointer; border-radius: var(--radius-button); }
@media (max-width: 899px) { #sheet[data-kind="trick"] { max-height: 55dvh; } }
@media (min-width: 900px) {
  #sheet { left: auto; top: 0; width: var(--sheet-w); max-height: none; border-radius: 0; border-width: 0 0 0 2px; padding-top: var(--space-8); transform: translateX(100%); }
  #sheet.open { transform: none; }
  .sheet-grab { display: none; }
}

/* Sheet content */
#sheet-body { display: flex; flex-direction: column; gap: var(--space-3); padding-right: var(--space-2); }
.sheet-title, #sheet h2 { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 32px; margin: 0; padding-right: var(--space-8); }
.sheet-h { font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 24px; margin: var(--space-3) 0 0; color: var(--ink); }
h4.sheet-h { font-size: 16px; margin-top: var(--space-2); }
#sheet p { margin: 0; }
.muted, .small { color: var(--ink-muted); }
.small { font-size: 14px; line-height: 20px; }
.tag-line { color: var(--ink-muted); font-weight: 700; font-size: 14px; line-height: 20px; }
.trick-head { display: flex; gap: var(--space-4); align-items: center; }
.trick-head-text { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; min-width: 0; }
.trick-art { border-radius: var(--radius-node); flex: none; }
.state-pill { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-3); border-radius: var(--radius-pill); border: 2px solid var(--line); font-weight: 800; font-size: 14px; line-height: 20px; background: var(--surface); color: var(--ink); }
.state-pill.state-landed, .state-pill.state-consistent { border-color: var(--gold-deep); color: var(--gold-ink); }
.state-pill.state-available { border-color: var(--go-deep); color: var(--go-ink); }
.state-pill.state-locked { border-color: var(--locked-deep); color: var(--ink-muted); }
.state-pill .sw-marker { width: 16px; height: 16px; }
.practice { display: flex; flex-direction: column; gap: var(--space-2); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-card); padding: var(--space-3); }
.log-head { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.rate { height: 10px; border-radius: var(--radius-pill); background: var(--surface-sunk); overflow: hidden; }
.rate-fill { height: 100%; background: var(--go); border-radius: var(--radius-pill); }
.log-row, .goal-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.goal-on { font-weight: 800; color: var(--gold-ink); }
.warn { background: var(--surface); border-left: 4px solid var(--gold); padding: var(--space-2) var(--space-3); border-radius: var(--radius-button); font-size: 14px; line-height: 20px; }
.ctx { font-weight: 700; }

/* Buttons inside sheets */
.sheet-btn { font-size: 18px; line-height: 24px; min-height: 48px; padding: var(--space-2) var(--space-4); }
.sheet-btn.wide { width: 100%; }
.sw-btn-go { background: var(--go); color: var(--on-go); box-shadow: 0 4px 0 0 var(--go-deep); }
.linkbtn { background: none; border: 0; padding: 0 var(--space-1); min-height: 44px; display: inline-flex; align-items: center; color: var(--gold-ink); font-weight: 800; font-size: 16px; text-decoration: underline; cursor: pointer; align-self: flex-start; }
.linkbtn.ok { color: var(--go-ink); }
.linkbtn.danger { color: var(--ink); text-decoration-color: #c9473a; text-decoration-thickness: 2px; }
ul.links, ul.tips, ul.plain-list, ul.plan-list, ul.pk-list, ul.mile-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
ul.tips li { padding-left: var(--space-4); position: relative; margin-bottom: var(--space-2); }
ul.tips li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 6px; height: 6px; border-radius: var(--radius-node); background: var(--gold); }
ul.plain-list li { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; }
.none { color: var(--ink-muted); }

/* Checkboxes and segmented radios */
.check { display: flex; gap: var(--space-3); align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--go-deep); flex: none; }
.plan-text { flex: 1; }
.reps { color: var(--ink-muted); font-weight: 800; font-size: 14px; }
.plan-note { color: var(--ink-muted); font-size: 14px; padding: var(--space-1) 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-4); border: 2px solid var(--control-edge); border-radius: var(--radius-pill); background: var(--surface); font-weight: 800; }
.seg-opt input:checked + span { background: var(--gold); border-color: var(--gold-deep); color: var(--on-gold); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 4px; }
.sel { min-height: 44px; border: 2px solid var(--control-edge); border-radius: var(--radius-button); background: var(--surface); color: var(--ink); font: inherit; padding: 0 var(--space-3); }
details.more, details.pk-group { border-top: 2px solid var(--line); padding-top: var(--space-2); }
details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 18px; }
details.more > :not(summary) { margin-top: var(--space-2); }

/* Session */
.pick-card, .alt-row { display: flex; gap: var(--space-3); align-items: center; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-card); padding: var(--space-3); }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-name { font-family: var(--font-display); font-size: 20px; line-height: 24px; }
.alt-row { width: 100%; text-align: left; color: var(--ink); cursor: pointer; min-height: 44px; font-size: 16px; box-sizing: border-box; }
.alt-cta { color: var(--gold-ink); font-weight: 800; }
.timer { display: flex; flex-direction: column; gap: var(--space-2); }
.timer-display { font-family: var(--font-display); font-weight: 700; font-size: 40px; line-height: 44px; font-variant-numeric: tabular-nums; }

/* Goal picker */
.pk-item { display: flex; justify-content: space-between; gap: var(--space-3); width: 100%; min-height: 44px; align-items: center; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 16px; text-align: left; cursor: pointer; padding: 0 var(--space-1); box-sizing: border-box; }
.pk-item.current { color: var(--gold-ink); font-weight: 800; }
.pk-item:disabled { color: var(--ink-muted); cursor: default; }
.pk-steps { color: var(--ink-muted); font-size: 14px; font-weight: 700; }

/* Celebration */
.celebrate { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-4) 0; overflow: hidden; }
.cel-art { display: flex; gap: var(--space-4); position: relative; }
.burst { position: absolute; top: 24px; left: 50%; width: 200px; height: 200px; margin-left: -100px; border-radius: var(--radius-node); background: radial-gradient(circle, var(--glow) 0%, transparent 70%); animation: sw-burst 1.2s ease-out both; pointer-events: none; }
@keyframes sw-burst { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* Onboarding */
#onboarding { position: fixed; inset: 0; z-index: 60; background: var(--surface); overflow-y: auto; display: flex; padding: calc(var(--space-8) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom)); box-sizing: border-box; }
.ob-box { margin: auto; max-width: 960px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); }
.ob-title { font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 40px; margin: 0; }
.ob-copy { margin: 0; max-width: 480px; color: var(--ink-muted); }
.ob-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 160px)); gap: var(--space-6) var(--space-4); justify-content: center; }
@media (min-width: 560px) { .ob-grid { grid-template-columns: repeat(3, 160px); } }
@media (min-width: 900px) { .ob-grid { grid-template-columns: repeat(5, 160px); } }
.ob-grid .sw-seed-art { width: 160px; max-width: 100%; height: auto; aspect-ratio: 1; }

/* Toast: always in the DOM (screen readers hear text changes); faded in and out. Above the sheet's edge on small screens. */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--space-12) + 56px + env(safe-area-inset-bottom)); z-index: 70; max-width: calc(100% - 32px); box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--ink); color: var(--surface-raised); padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .15s; }
#toast.show { opacity: 1; }
body:has(#nextup-card:not([hidden])) #toast { bottom: calc(var(--space-6) + var(--btn-h) + var(--nextup-h) + var(--space-3) * 2 + env(safe-area-inset-bottom)); }
@media (max-width: 899px) { body:has(#nextup-card:not([hidden])) #toast, body.sheet-open #toast { bottom: auto; top: calc(var(--space-4) + 56px + env(safe-area-inset-top)); } }

@media (prefers-reduced-motion: reduce) {
  #sheet, .sw-btn, #toast { transition: none; }
  .burst { animation: none; opacity: 0; }
}

/* QA round 1: alternates two-up under the pick, warp row, data panels */
#goal-pill { background: var(--pill-bg); color: var(--pill-ink); border-color: var(--pill-edge); box-shadow: 0 3px 8px rgba(40,25,10,.3); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); width: max-content; }
#goal-pill .sw-pill-progress { color: var(--glow); }
#primary-btn { white-space: nowrap; width: max-content; max-width: calc(100% - 32px); border-color: var(--gold-deep); background: linear-gradient(var(--gold-light), #e0953e); box-shadow: 0 5px 0 #8a5a14, 0 8px 14px rgba(40,25,10,.35); }
#primary-btn:active { box-shadow: 0 1px 0 #8a5a14; }
@media (max-width: 599px) {
  #primary-btn { font-size: 22px; line-height: 26px; min-height: 56px; padding: 12px 32px; }
  #goal-pill { font-size: 17px; min-height: 44px; }
}
@media (max-width: 899px) { #sheet[data-kind="session"] { max-height: 70dvh; } }
.alt-h { margin: var(--space-3) 0 var(--space-2); }
.alt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-bottom: var(--space-3); }
.alt-grid .alt-row { flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); }
.alt-grid .pick-name { font-size: 16px; line-height: 20px; }
.alt-grid .trick-art { width: 40px; height: 40px; }
.alt-row.upcoming { cursor: default; opacity: .85; border-style: dashed; }
.warp-row { margin: var(--space-2) 0; }
.log-note { margin: var(--space-1) 0 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.data-panel { display: flex; flex-direction: column; gap: var(--space-2); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-card); padding: var(--space-3); }
.data-text { width: 100%; box-sizing: border-box; font: 12px/16px ui-monospace, Menlo, monospace; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-button); padding: var(--space-2); resize: vertical; }
.sheet-btn.danger { border-color: #b5382b; color: #b5382b; }
[data-theme="dusk"] .sheet-btn.danger { color: #ff9a8c; border-color: #ff9a8c; }

/* Sign-in screen (shown before the app when accounts are on). Same surface as onboarding, above it. */
.auth-screen { position: fixed; inset: 0; z-index: 80; display: flex; background: var(--surface); color: var(--ink); overflow-y: auto; box-sizing: border-box;
  padding: calc(var(--space-8) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom)); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(440px, 100%); margin: auto; box-sizing: border-box; text-align: center; background: var(--surface-raised); border: 2px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--sheet); padding: var(--space-6) var(--space-4); } /* margin:auto keeps the top reachable when it overflows */
.auth-title { margin: 0 0 var(--space-1); font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 40px; }
.auth-tag { margin: 0 0 var(--space-4); color: var(--ink-muted); }
#auth-mount { display: flex; justify-content: center; }
#auth-mount:empty { display: none; }
.auth-msg { margin: var(--space-3) 0 0; color: var(--ink-muted); }
.legal-links { margin: var(--space-4) 0 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.legal-links a { color: var(--gold-ink); font-weight: 800; text-decoration: underline; display: inline-block; padding: 12px var(--space-2); } /* 44px tap target */
.legal-links a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.auth-msg:focus { outline: none; }
.auth-msg.error { color: #b5382b; font-weight: 800; }
[data-theme="dusk"] .auth-msg.error { color: #ff9a8c; }
.auth-msg:empty { display: none; }
#auth-retry { margin-top: var(--space-3); }
#auth-retry[hidden] { display: none; }
.auth-screen :where(button):focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

/* Account block in the More section */
.account .small { overflow-wrap: anywhere; margin: var(--space-1) 0; }
.sync-line.problem { color: #b5382b; font-weight: 800; }
[data-theme="dusk"] .sync-line.problem { color: #ff9a8c; }
/* Small dot on the goal pill while changes wait to upload (offline or retrying); red when sync has a problem. */
.sync-pending #goal-pill::after, .sync-problem #goal-pill::after { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--pill-ink); }
.sync-problem #goal-pill::after { background: #e5594a; }
