/* Layout: green "trailhead" header band with the hillside P that fills gold as you go,
   a sticky tab bar, then one reading column for the list, leaderboard and feed. */
:root {
  --green: #0b3a2a;      /* deep green from the logo */
  --hill: #4f7a3f;
  --sky: #fdf8ea;
  --sky-ink: #0b3a2a;
  --sky-muted: #41594c;
  --green-deep: #0e3123;
  --gold: #bd8b13;       /* Cal Poly Gold */
  --gold-bright: #f0b429;
  --gold-soft: #f2e3b8;
  --paper: #f8f3e4;      /* warm cream */
  --card: #ffffff;
  --ink: #12291f;
  --muted: #55665d;
  --line: #e6dfca;
  --on-green: #f4f1e4;
  --on-green-muted: #cfd9d2;
  --accent: #0b3a2a;     /* buttons, active tabs, checks */
  --link: #0b3a2a;
  --danger: #a3261b;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --step--1: 0.8125rem; --step-0: 1rem; --step-1: 1.25rem; --step-2: 1.75rem; --step-3: 2.6rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --sky: #102b21; --sky-ink: #fdf8ea; --sky-muted: #bcc9bf; --paper: #0f1a15; --card: #16241d; --ink: #e8ede9; --muted: #9db0a5; --line: #2a3b32;
  --gold: #d9a52a; --gold-soft: #3a3016; --accent: #2f7a55; --link: #e3b23c; --danger: #f07a6c; --green-deep: #0a2419; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --sky: #102b21; --sky-ink: #fdf8ea; --sky-muted: #bcc9bf; --paper: #0f1a15; --card: #16241d; --ink: #e8ede9; --muted: #9db0a5; --line: #2a3b32;
  --gold: #d9a52a; --gold-soft: #3a3016; --accent: #2f7a55; --link: #e3b23c; --danger: #f07a6c; --green-deep: #0a2419; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: var(--step-0); line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--sky); }
.wrap { 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)); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* First screen: sign-in. The app stays hidden until the session is known. */
body:not([data-state="app"]) > :is(.band, .controls, main, footer) { display: none; }
body[data-state="app"] > .welcome { display: none; }
body[data-state="loading"] :is(.welcome-card, .welcome-foot) { visibility: hidden; }
.welcome { position: relative; min-height: 100vh; min-height: 100svh; display: grid; grid-template-rows: 1fr auto; overflow: hidden; background: var(--sky); color: var(--sky-ink); padding-top: env(safe-area-inset-top, 0px); }
.welcome .ridge { right: 4%; bottom: 96px; width: 430px; height: 258px; }
.welcome .hills { height: 170px; }
.welcome-inner { position: relative; width: 100%; max-width: 1040px; margin: 0 auto; padding: 40px 24px 150px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 56px; align-items: center; }
.welcome-copy { display: grid; gap: 16px; }
.welcome h1 { font-size: clamp(2.5rem, 5.4vw, 4rem); }
.welcome .lede { margin: 0; max-width: 34ch; color: var(--sky-muted); }
.welcome-card { padding: 24px; border-radius: 22px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.welcome-card h2 { font-size: var(--step-1); }
.welcome-card .notice { margin: 0 0 12px; }
.welcome-note { margin: 12px 0 0; color: var(--muted); font-size: var(--step--1); }
.welcome-foot { position: relative; margin: 0; padding: 0 24px calc(16px + env(safe-area-inset-bottom, 0px)); text-align: right; font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-green); }

/* Header band */
.band { position: relative; overflow: hidden; background: var(--sky); color: var(--sky-ink); padding-top: env(safe-area-inset-top, 0px); }
.ridge { position: absolute; right: 0; bottom: 60px; width: 160px; height: 96px; overflow: visible; }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 104px; }
#sun { transition: transform .8s cubic-bezier(.3,.9,.4,1); }
.band .wrap { position: relative; padding-block: 12px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow { font-size: 0.875rem; font-weight: 700; color: var(--sky-ink); margin: 0; }
.account-btn { border: none; background: var(--sky-ink); color: var(--sky); border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: var(--step--1); font-weight: 700; white-space: nowrap; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; }
h1 { font-size: 1.9rem; line-height: 1.1; }
h1 span { color: var(--sky-muted); display: block; font-family: var(--font-body); font-size: 0.875rem; font-weight: 500; letter-spacing: 0; margin-top: 3px; }
.lede { margin: 12px 0 0; max-width: 46ch; }
.tally { margin-top: 44px; display: grid; gap: 6px; color: #fdf8ea; }
.tally-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.count { margin: 0; font-family: var(--font-display); font-size: var(--step-1); font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.count small { font-family: var(--font-body); font-size: var(--step--1); font-weight: 500; margin-left: 5px; }
.pct { margin: 0; font-size: var(--step--1); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: rgba(253,248,234,0.22); border-radius: 5px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--gold-bright); border-radius: 5px; transition: width .5s cubic-bezier(.3,.9,.4,1); }

/* Tabs + filter */
.controls { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); }
.controls .wrap { padding-block: 0 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 0 max(16px, env(safe-area-inset-left, 0px)); overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: none; border-bottom: 3px solid transparent; padding: 12px 10px 9px; cursor: pointer; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--line); border-radius: 999px; }
.seg { border: none; background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 8px; font-size: var(--step--1); font-weight: 700; cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* Notices */
main .wrap { padding-block: 8px 40px; }
.notice { margin: 16px 0 0; padding: 10px 14px; border: 1px dashed var(--gold); background: var(--gold-soft); border-radius: 8px; font-size: var(--step--1); }
.linkish { background: none; border: none; padding: 0; color: var(--link); font-weight: 700; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* List */
section > .block { margin-top: 28px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 10px; }
h2 { font-size: 1.4rem; }
.sec-head p { margin: 0; font-family: var(--font-body); font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
ol, ul { list-style: none; margin: 0; padding: 0; }
ol { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 2.5rem 1fr; gap: 12px; padding: 12px; background: var(--card); border-radius: 16px; box-shadow: 0 1px 2px rgba(11,58,42,.08); }
.box { width: 2.5rem; height: 2.5rem; border: 2px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; transition: transform .15s; }
.box:active { transform: scale(.9); }
.box svg { width: 1.4rem; height: 1.4rem; display: none; }
.item.done .box { background: var(--gold-bright); border-color: var(--gold-bright); color: #0b3a2a; }
.item.pop .box { animation: pop .42s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.item.done .box svg { display: block; }
.item.done .box .num { display: none; }
.body { min-width: 0; }
.title { font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.item.done .title { color: var(--muted); }
.tip { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; align-items: center; }
.stamp { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.share { background: none; border: 1px solid var(--accent); color: var(--link); border-radius: 999px; padding: 1px 10px; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.shared { font-size: 0.75rem; color: var(--muted); }
.del { background: none; border: none; color: var(--muted); font-size: 0.75rem; text-decoration: underline; cursor: pointer; padding: 0; }
.empty { color: var(--muted); padding: 20px 0; }
form.add { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
form.add input { flex: 1; min-width: 0; }
input:not([type="checkbox"]), textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); width: 100%; }
textarea { resize: vertical; }
.btn { border: 2px solid var(--ink); background: var(--card); border-radius: 12px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.wide { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.ms { width: 18px; height: 18px; }

/* Leaderboard */
.board-me { margin-top: 24px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.board-me .big { font-family: var(--font-display); font-size: var(--step-2); line-height: 1; }
.board-me p { margin: 4px 0 0; color: var(--muted); font-size: var(--step--1); }
.ranks { margin-top: 20px; }
.rank { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rank .place { font-family: var(--font-body); font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.rank.top .place { color: var(--gold); font-weight: 700; }
.rank .who { min-width: 0; }
.rank .who b { display: block; overflow-wrap: anywhere; }
.rank .who .bar { background: var(--line); margin-top: 6px; }
.rank .who .bar > div { background: var(--accent); }
.rank.me { background: var(--gold-soft); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 6px; }
.rank .n { font-family: var(--font-body); font-variant-numeric: tabular-nums; font-weight: 500; }

/* Feed */
.feed-head { margin-top: 24px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.post { padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 2.4rem 1fr; gap: 12px; }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--green); color: var(--gold-bright); display: grid; place-items: center; font-family: var(--font-display); font-size: 1.1rem; }
.post .body > p { margin: 0; }
.who-line { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.who-line b { overflow-wrap: anywhere; }
.when { color: var(--muted); font-size: var(--step--1); }
.did { margin-top: 2px !important; }
.numtag { font-family: var(--font-body); font-size: 0.75rem; color: var(--muted); }
.caption { margin-top: 8px !important; overflow-wrap: anywhere; white-space: pre-wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.act { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: var(--step--1); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.act svg { width: 15px; height: 15px; }
.act.kudos[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); font-weight: 700; }
.act[disabled] { cursor: default; opacity: .7; }
.spacer { flex: 1; }
.comments { margin-top: 12px; padding-left: 12px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.comment p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.comment .who-line { font-size: var(--step--1); }
.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; min-width: 0; padding: 8px 10px; }
.more { margin-top: 16px; }
.gate { margin-top: 28px; padding: 24px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; display: grid; gap: 12px; justify-items: start; }
.gate p { margin: 0; color: var(--muted); max-width: 52ch; }

/* Dialogs */
dialog { border: none; border-radius: 12px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(14,49,35,.55); }
dialog h2 { font-size: var(--step-1); padding-right: 28px; }
.dlg-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.dlg-close button { background: none; border: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.dlg-sub { color: var(--muted); font-size: var(--step--1); margin: 6px 0 16px; overflow-wrap: anywhere; }
.stack { display: grid; gap: 8px; }
.stack label { font-size: var(--step--1); font-weight: 700; }
.check-row { display: flex !important; gap: 8px; align-items: center; font-weight: 500 !important; margin: 4px 0 8px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--green); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--step--1); margin: 18px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.status { margin: 12px 0 0; font-size: var(--step--1); min-height: 1.2em; }
.status.error { color: var(--danger); font-weight: 700; }
.hint { margin: 0; font-size: 0.75rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.row-actions, .confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#accountExtras { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-size: var(--step--1); font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }

/* Footer / Honors nod */
footer { border-top: 1px solid var(--line); }
footer .wrap { padding-block: 28px calc(40px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.seal { width: 84px; height: 84px; }
.seal text { font-family: var(--font-body); font-size: 7.4px; letter-spacing: 1.6px; fill: var(--link); }
.seal .seal-num { font-size: 13px; letter-spacing: 0; }
.seal .ring { fill: none; stroke: var(--link); }
.foot-copy { font-size: var(--step--1); color: var(--muted); min-width: 0; }
.foot-copy strong { color: var(--ink); }
.foot-copy p { margin: 0 0 8px; max-width: 60ch; }

@media (max-width: 560px) {
  .welcome-inner { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px 16px 104px; align-content: start; }
  .welcome h1 { font-size: 2.1rem; }
  .welcome .lede { max-width: none; }
  .welcome .ridge { right: 0; bottom: 56px; width: 200px; height: 120px; }
  .welcome .hills { height: 112px; }
  .welcome-foot { padding-inline: 16px; }
  footer .wrap { grid-template-columns: 1fr; }
}
/* Floating glass tab bar on phones, as in Ferda. Desktop keeps the top tabs. */
.tabbar { display: none; }
@media (max-width: 760px) {
  body[data-state="app"] { padding-bottom: calc(max(10px, calc(env(safe-area-inset-bottom, 0px) - 12px)) + 82px); }
  .tabs { display: none; }
  .controls .wrap { padding-block: 10px; }
  .controls:has(#filters[hidden]) { display: none; }
  body[data-state="app"] .tabbar { display: grid; }
  .tabbar { position: fixed; z-index: 90; left: 50%; bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) - 12px)); width: min(280px, calc(100vw - 48px)); margin-left: calc(min(280px, calc(100vw - 48px)) / -2); grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; border: 1px solid rgba(255,255,255,.7); border-radius: 999px; background: rgba(255,253,244,.78); -webkit-backdrop-filter: saturate(1.8) blur(24px); backdrop-filter: saturate(1.8) blur(24px); box-shadow: inset 0 1px 0 rgba(255,255,255,.85), inset 0 -1px 0 rgba(11,58,42,.05), 0 12px 32px rgba(11,58,42,.18), 0 2px 6px rgba(11,58,42,.07); touch-action: none; user-select: none; -webkit-user-select: none; transform-origin: 50% 100%; transition: transform .32s cubic-bezier(.3,.9,.4,1); }
  .tabbar button { position: relative; z-index: 1; display: grid; place-items: center; height: 50px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; transition: color .2s, transform .15s; }
  .tabbar button[aria-current="page"], .tabbar button.is-under { color: var(--green); }
  .tabbar button:active { transform: scale(.94); }
  .tabbar.is-scrubbing button { transform: none; }
  .tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar button[aria-current="page"] svg { stroke-width: 2.2; }
  .tab-glass { position: absolute; z-index: 0; border-radius: 999px; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.55) 55%, rgba(253,240,200,.7)); border: 1px solid rgba(255,255,255,.9); box-shadow: inset 0 1px 1px #fff, inset 0 -2px 6px rgba(11,58,42,.06), 0 4px 14px rgba(11,58,42,.14), 0 1px 3px rgba(11,58,42,.08); transition: transform .42s cubic-bezier(.34,1.45,.55,1); will-change: transform; }
  .tabbar.is-scrubbing .tab-glass { transition: transform .08s linear; }
  .tabbar.no-anim .tab-glass { transition: none; }
  .tabbar.is-compact { transform: scale(.86); }
  .toast { bottom: calc(max(10px, calc(env(safe-area-inset-bottom, 0px) - 12px)) + 84px); }
}
@media (max-width: 760px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tabbar { background: rgba(22,36,29,.72); border-color: rgba(255,255,255,.12); }
  :root:not([data-theme="light"]) .tab-glass { background: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.08)); border-color: rgba(255,255,255,.16); }
  :root:not([data-theme="light"]) .tabbar button[aria-current="page"], :root:not([data-theme="light"]) .tabbar button.is-under { color: var(--gold-bright); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
