:root {
  --bg: #f6f3ee; --card: #fffdf9; --ink: #1f1c18; --muted: #70685e; --line: #e4ddd2;
  --accent: #b4492d; --accent-ink: #fff; --chip: #ede7dc; --shadow: 0 1px 2px rgba(60,40,20,.06), 0 12px 32px rgba(60,40,20,.10);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16140f; --card: #201d17; --ink: #efe9df; --muted: #a39a8c; --line: #342f27;
    --accent: #e0825f; --accent-ink: #1a120d; --chip: #2b2720; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--accent); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

#app { height: 100dvh; display: flex; flex-direction: column; padding-left: var(--sal); padding-right: var(--sar); }
#top { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--sat) + 10px) 20px 6px; font-size: .8rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; min-height: 44px; }
.top-l { display: flex; align-items: center; min-width: 0; }
#topBack { display: inline-flex; align-items: center; gap: 2px; margin: -8px 0 -8px -8px; padding: 8px 10px 8px 4px; color: var(--accent); font-size: inherit; letter-spacing: inherit; text-transform: inherit; font-weight: 600; }
#topBack svg { width: 18px; height: 18px; stroke-width: 2; }
#prog { font-variant-numeric: tabular-nums; }
#view { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
#nav { display: flex; justify-content: center; gap: 4px; padding: 6px 12px calc(var(--sab) + 6px); border-top: 1px solid var(--line); }
#nav button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: .7rem; color: var(--muted); border-radius: 10px; }
#nav button.on { color: var(--accent); }
body.setup #nav { display: none; }

/* Feed */
.feed { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; align-items: stretch; width: 100%; max-width: 680px; margin: 0 auto; padding: 8px 16px 14px; }
.stage { position: relative; min-height: 0; max-width: 560px; width: 100%; margin: 0 auto; }
.edge { display: none; }
.edge.off { visibility: hidden; }
.feed.hinted { grid-template-rows: minmax(0, 1fr) auto; }
.hint { grid-column: 1 / -1; justify-self: center; margin-top: 10px; padding: 8px 12px; display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); border-radius: 99px; }
.hint svg { width: 16px; height: 16px; color: var(--accent); }
.card { position: absolute; inset: 0; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform; border: 1px solid var(--line); }
.media { flex: 0 0 34%; position: relative; background: var(--chip); overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s; -webkit-user-drag: none; }
.media img.in { opacity: 1; }
.media img.backdrop { position: absolute; inset: 0; filter: blur(18px) brightness(.85); transform: scale(1.15); }
.media img.whole { position: relative; object-fit: contain; }
.media.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.25) 50%, transparent 70%); animation: sh 1.4s infinite; }
@keyframes sh { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.credit { position: absolute; right: 8px; bottom: 8px; font-size: .66rem; background: rgba(0,0,0,.5); color: #fff; padding: 2px 8px; border-radius: 99px; text-decoration: none; }
.card.noimg .media { display: none; }
.body { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 20px 26px; text-align: center; overflow: hidden; }
.hook { font-family: var(--serif); font-size: clamp(1.4rem, 5.6vw, 2rem); line-height: 1.3; margin: 0; font-weight: 500; text-wrap: balance; }
.hook b { font-weight: 600; color: var(--accent); }
.item b { font-weight: 600; }
.actions { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px calc(10px); border-top: 1px solid var(--line); }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 10px; font-size: .85rem; color: var(--muted); border-radius: 12px; min-height: 44px; }
.act:hover { color: var(--ink); }
.act.on { color: var(--accent); }
.act.on svg { fill: currentColor; }
.act.deep { color: var(--accent); font-weight: 500; }
.burst { position: absolute; left: 50%; top: 42%; width: 96px; height: 96px; margin: -48px 0 0 -48px; color: var(--accent); pointer-events: none; opacity: 0; }
.burst svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
.burst.go { animation: pop .8s ease-out; }
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: 1; transform: scale(1.15); } 60% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }

/* Generic screens */
/* Plain pages (privacy): the app locks page scrolling, these scroll normally. */
html.doc { height: auto; overflow: auto; }
html.doc body, html.doc .screen { height: auto; overflow: visible; } /* not scroll boxes of their own, so a swipe scrolls the page */
html.doc .screen { padding-top: calc(var(--sat) + 16px); line-height: 1.55; }
.screen { flex: 1; overflow-y: auto; padding: 8px 20px 28px; width: 100%; max-width: 620px; margin: 0 auto; }
.screen h1 { font-family: var(--serif); font-size: 1.7rem; font-weight: 500; margin: 8px 0 6px; }
.screen h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 0 8px; line-height: 1.5; }
.topics { display: flex; flex-direction: column; gap: 8px; }
.topic { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); min-height: 60px; }
.topic-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topic-text b { font-weight: 600; }
.topic-text span { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.tick-box { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; }
.tick-box svg { width: 16px; height: 16px; stroke-width: 2.4; }
.topic.on { border-color: var(--accent); background: var(--chip); }
.topic.on .tick-box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.gobar { margin-top: 22px; }
.gobar.sticky { position: sticky; bottom: 0; margin: 14px -20px 0; padding: 12px 20px 10px; background: linear-gradient(transparent, var(--bg) 22%); }
.chip { padding: 9px 14px; border-radius: 99px; background: var(--chip); border: 1px solid transparent; font-size: .9rem; min-height: 40px; }
.chip small { color: var(--muted); margin-left: 4px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .8; }
.seg { display: flex; gap: 8px; }
.seg .chip { flex: 1; text-align: center; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 13px 22px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; min-height: 48px; text-decoration: none; }
.btn.ghost { background: var(--chip); color: var(--ink); font-weight: 500; }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.block { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.code { font-family: ui-monospace, monospace; font-size: .75rem; word-break: break-all; background: var(--chip); padding: 10px 12px; border-radius: 10px; flex: 1; min-width: 0; user-select: all; }
input.field { flex: 1; min-width: 0; font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.small { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.topic-tag { margin: 14px 0 0; text-align: center; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; }
.item p { font-family: var(--serif); margin: 0 0 8px; font-size: 1.05rem; line-height: 1.4; }
.item .row { justify-content: space-between; align-items: center; }
.link-btn { color: var(--accent); font-size: .85rem; padding: 6px 0; }
.link-btn.mute { color: var(--muted); }
.explored h3.day { margin: 18px 0 8px; }
.exp { border-bottom: 1px solid var(--line); padding: 8px 0; }
.exp-row { display: flex; align-items: center; gap: 4px; }
.exp-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.exp .thumb { flex: none; width: 48px; height: 48px; border-radius: 8px; background: var(--chip); overflow: hidden; }
.exp .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.exp-text { display: flex; flex-direction: column; min-width: 0; }
.exp-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp .desc { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-btn { flex: none; width: 32px; height: 32px; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.exp .via { margin: 6px 0 0 60px; font-size: .78rem; color: var(--muted); line-height: 1.4; }
.exp .via a { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; line-height: 1.6; }
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 24px; gap: 12px; max-width: 460px; margin: 0 auto; width: 100%; }
.center h1 { font-family: var(--serif); font-weight: 500; font-size: 2rem; margin: 0; }
.center .stack { width: 100%; margin-top: 12px; }
.tick { width: 56px; height: 56px; border-radius: 50%; background: var(--chip); color: var(--accent); display: grid; place-items: center; }
.tick svg { width: 28px; height: 28px; }
.donate { font-size: .85rem; color: var(--muted); }

/* Sheet */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 78dvh; overscroll-behavior: contain; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 20px calc(var(--sab) + 20px); overflow-y: auto; transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow); max-width: 640px; margin: 0 auto; }
#sheet.open .backdrop { opacity: 1; }
#sheet.open .panel { transform: none; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 6px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; margin: 6px 0; }
.icon-btn { font-size: 1.8rem; line-height: 1; width: 44px; height: 44px; color: var(--muted); }
.art { padding: 14px 0; border-top: 1px solid var(--line); }
.art h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.art p { margin: 0 0 10px; font-size: .9rem; line-height: 1.5; color: var(--muted); }
.art .btn { padding: 9px 16px; min-height: 40px; font-size: .88rem; }

#toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 84px); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: .88rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: calc(100vw - 32px); display: flex; gap: 14px; align-items: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: var(--accent-ink); background: var(--accent); padding: 4px 10px; border-radius: 8px; font-weight: 600; }

/* Desktop */
@media (hover: hover) and (min-width: 700px) {
  .feed { grid-template-columns: 56px minmax(0, 560px) 56px; justify-content: center; gap: 14px; padding: 12px 24px 24px; max-width: none; }
  .edge { display: grid; place-self: center; width: 48px; height: 48px; border-radius: 50%; place-items: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .edge:hover { color: var(--accent); }
  .edge:disabled { opacity: .3; cursor: default; }
}
@media (min-width: 900px) {
  #sheet .backdrop { background: rgba(0,0,0,.18); }
  #sheet .panel { left: auto; top: 0; bottom: 0; right: 0; width: 400px; max-width: none; max-height: none; border-radius: 0; padding-top: calc(var(--sat) + 16px); transform: translateX(100%); }
  #sheet.open .panel { transform: none; }
  .grab { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.points { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 16px; text-align: left; line-height: 1.45; }
.points li { display: flex; align-items: center; gap: 14px; }
.points .tick { width: 44px; height: 44px; flex: none; }
.points .tick svg { width: 22px; height: 22px; }
.restore-row { margin-top: 10px; }
