/* Thana round 1. Brand colors: navy #001219, sand #e9d8a6, amber #ee9b00, rust #bb3e03, cream #fdf7eb.
   Look and motion are a later design pass; this is clean and usable for now. */
:root{
  --page:#f1e7d0; --bg:#fdf7eb; --surface:#ffffff; --fg:#001219; --muted:#3b4d54; --line:#e3d5b6; --chip:#f6eed9;
  --accent:#bb3e03; --on-accent:#ffffff; --focus:#ee9b00; --wedge-line:rgba(0,18,25,.28);
  --calm:#e9d8a6; --tender:#ee9b00; --heavy:#bb3e03; --over:#001219;
  --on-calm:#001219; --on-tender:#001219; --on-heavy:#ffffff; --on-over:#fdf7eb;
  --font:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --page:#00080b; --bg:#001219; --surface:#0b2530; --fg:#fdf7eb; --muted:#d3cab6; --line:#21414d; --chip:#10303c;
  --accent:#ee9b00; --on-accent:#001219; --wedge-line:rgba(253,247,235,.6); --over:#fdf7eb; --on-over:#001219; color-scheme:dark}}
:root[data-theme="dark"]{
  --page:#00080b; --bg:#001219; --surface:#0b2530; --fg:#fdf7eb; --muted:#d3cab6; --line:#21414d; --chip:#10303c;
  --accent:#ee9b00; --on-accent:#001219; --wedge-line:rgba(253,247,235,.6); --over:#fdf7eb; --on-over:#001219; color-scheme:dark}

*{box-sizing:border-box}
html,body{margin:0}
body{background:var(--page);color:var(--fg);font-family:var(--font);font-size:16px;line-height:1.5}
button,input,textarea{font:inherit;color:inherit}
:focus-visible{outline:3px solid var(--focus);outline-offset:2px}
[hidden]{display:none !important}

.app{max-width:480px;margin:0 auto;min-height:100dvh;background:var(--bg);display:flex;flex-direction:column}
.bar{position:sticky;top:0;z-index:3;background:var(--bg);display:flex;align-items:center;gap:8px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);min-height:56px}
.bar .title{flex:1;margin:0;font-size:14px;font-weight:600;text-align:center;color:var(--muted)}
.iconbtn{background:none;border:0;padding:6px 10px;border-radius:20px;font-size:14px;font-weight:600;cursor:pointer;min-width:72px;text-align:left}
.exit{background:var(--fg);color:var(--bg);text-align:center}
.viewport{flex:1;padding:20px 16px 32px}
.nav{position:sticky;bottom:0;z-index:3;background:var(--bg);display:flex;border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
.nav button{flex:1;background:none;border:0;padding:12px 4px 14px;font-size:14px;font-weight:500;cursor:pointer;color:var(--muted)}
.nav button[aria-current="page"]{color:var(--fg);font-weight:700}

.screen{display:flex;flex-direction:column;gap:16px;min-height:100%}
.screen h2{font-size:24px;line-height:1.25;margin:0;text-wrap:balance}
.screen h2:focus{outline:none}
.screen p{margin:0}
h3{margin:0;font-size:16px}
.lead{color:var(--muted)}
.small{font-size:14px;color:var(--muted)}
.preview{font-size:12px;color:var(--muted);border:1px dashed var(--muted);border-radius:20px;padding:6px 12px;align-self:flex-start}
.tag{align-self:flex-start;font-size:12px;letter-spacing:.06em;text-transform:uppercase;padding:2px 10px;border-radius:20px;border:1px dashed var(--muted);color:var(--muted)}
.logo{align-self:flex-start;font-weight:700;font-size:28px;letter-spacing:.2em;padding:12px 20px;border:2px solid var(--fg);border-radius:20px}

.btn{display:block;width:100%;padding:14px 20px;border-radius:20px;font-size:16px;font-weight:600;border:2px solid transparent;cursor:pointer;text-align:center}
.btn.auto{width:auto}
.primary{background:var(--accent);color:var(--on-accent)}
.ghost{background:transparent;border-color:var(--fg)}
.ghost[aria-pressed="true"]{background:var(--fg);color:var(--bg)}
.btn:disabled{opacity:.4;cursor:not-allowed}
.link{background:none;border:0;padding:6px 0;font-size:14px;font-weight:600;text-decoration:underline;cursor:pointer;align-self:center}
.link.start{align-self:flex-start}
.stack{display:flex;flex-direction:column;gap:12px}
.push{margin-top:auto}
.row{display:flex;gap:12px;align-items:center}
.row .btn{flex:1}
.spread{justify-content:space-between}

.field{display:flex;flex-direction:column;gap:6px}
.field label,.field .label{font-size:14px;font-weight:600}
input:not([type=checkbox]),textarea{padding:12px 16px;border-radius:20px;border:1.5px solid var(--line);background:var(--surface);font-size:16px;width:100%}
textarea{resize:vertical}
.check{display:flex;gap:12px;align-items:center;font-size:16px;cursor:pointer}
.check input{width:22px;height:22px;flex:none;accent-color:var(--accent)}
.code{font-size:28px;letter-spacing:.5em;text-align:center;font-variant-numeric:tabular-nums}

.choices{display:grid;gap:10px}
.choices.row-wrap{display:flex;flex-wrap:wrap;gap:8px}
.choice{display:flex;flex-direction:column;gap:2px;text-align:left;padding:14px 18px;border-radius:20px;border:1.5px solid var(--line);background:var(--surface);font-size:16px;cursor:pointer}
.choices.row-wrap .choice{padding:8px 16px;font-size:14px}
.choice:hover{border-color:var(--fg)}
.choice[aria-checked="true"]{background:var(--fg);color:var(--bg);border-color:var(--fg)}
.choice-sub{font-size:14px;opacity:.8}

.card{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:16px;display:flex;flex-direction:column;gap:10px}
.cardbtn{text-align:left;cursor:pointer;width:100%}
.notice{background:var(--chip);border-radius:20px;padding:16px;font-size:14px;display:flex;flex-direction:column;gap:6px}
.notice strong{font-size:16px}
.list{margin:0;padding-left:20px;display:grid;gap:6px}
.toggle-row{display:flex;justify-content:space-between;align-items:center;gap:12px}
.toggle-row p{font-size:14px;flex:1;min-width:0}

.progress{display:flex;gap:6px}
.progress span{flex:1;height:8px;border-radius:20px;background:var(--line)}
.progress span.done{background:var(--muted)}
.progress span.now{background:var(--accent)}

.resources{display:grid;gap:8px}
.resource{display:flex;justify-content:space-between;gap:12px;padding:14px 16px;border-radius:20px;background:var(--surface);border:1px solid var(--line);font-size:16px}
.resource b{font-variant-numeric:tabular-nums;text-align:right}

/* Levels: color plus the word, so color is never the only signal. */
.lv-calm{--lv:var(--calm);--on-lv:var(--on-calm)}
.lv-tender{--lv:var(--tender);--on-lv:var(--on-tender)}
.lv-heavy{--lv:var(--heavy);--on-lv:var(--on-heavy)}
.lv-overwhelming{--lv:var(--over);--on-lv:var(--on-over)}
.lv-none{--lv:var(--line);--on-lv:var(--fg)}

.rose{width:100%;max-width:360px;height:auto;align-self:center;display:block}
.rose text{fill:var(--fg);font-family:var(--font)}
.rose-ring{stroke:var(--wedge-line);stroke-dasharray:3 4}
.wedge{fill:var(--lv);stroke:var(--wedge-line);stroke-width:1}
.legend{display:flex;flex-wrap:wrap;gap:8px 16px;font-size:14px;justify-content:center}
.swatch{display:inline-block;width:14px;height:14px;border-radius:4px;margin-right:6px;vertical-align:-2px;border:1px solid var(--wedge-line);background:var(--lv)}

.shelf{display:flex;align-items:flex-end;justify-content:center;gap:8px;min-height:250px;padding:0 8px;border-bottom:10px solid var(--fg)}
.shelf.mini{min-height:110px;border-bottom-width:6px}
.book{position:relative;writing-mode:vertical-rl;transform:rotate(180deg);background:var(--lv);color:var(--on-lv);border:1px solid var(--wedge-line);border-radius:4px;font-weight:700;font-size:14px;letter-spacing:.04em;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:8px 0}
.mini .book{cursor:default}
.book[aria-pressed="true"]{outline:3px solid var(--focus);outline-offset:2px}
/* Bookmark ribbon hangs from the top of the book. The book is rotated 180deg, so bottom here is the top on screen. */
.book.marked::after{content:"";position:absolute;bottom:0;left:6px;width:8px;height:24px;background:var(--focus);clip-path:polygon(0 0,50% 25%,100% 0,100% 100%,0 100%)}
.caption{min-height:96px;text-align:center;display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center}
.caption .word{font-size:20px;font-weight:600}

.toc{list-style:none;margin:0;padding:0}
.toc button{width:100%;display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:12px 0;background:none;border:0;border-bottom:1px solid var(--line);text-align:left;cursor:pointer}
.toc-level{font-size:12px;white-space:nowrap;color:var(--muted)}
.toc-mark{display:inline-block;margin-left:8px;padding:1px 8px;border-radius:999px;font-size:11px;font-weight:600;vertical-align:middle;border:1px solid var(--line);color:var(--muted)}
.toc-mark.working{color:var(--fg);border-color:currentColor}
.size-none,.size-calm{font-size:14px;font-weight:400}
.size-tender{font-size:16px;font-weight:500}
.size-heavy{font-size:20px;font-weight:600}
.size-overwhelming{font-size:24px;font-weight:700}

.quote{margin:0;font-size:16px;font-style:italic;background:var(--chip);border-radius:20px;padding:16px;display:flex;flex-direction:column;gap:4px}
.quote .small{font-style:normal}
.pagerow{width:100%;display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;background:none;border:0;border-bottom:1px solid var(--line);text-align:left;cursor:pointer;font-size:16px}

.toast{position:fixed;left:50%;transform:translateX(-50%);width:min(448px,calc(100% - 32px));bottom:84px;background:var(--fg);color:var(--bg);border-radius:20px;padding:12px 16px;font-size:14px;z-index:9}
.sheet-wrap{position:fixed;inset:0;background:rgba(0,18,25,.45);display:flex;align-items:flex-end;justify-content:center;z-index:8}
.sheet{background:var(--bg);width:100%;max-width:480px;border-radius:20px 20px 0 0;padding:20px 16px max(20px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px;max-height:88dvh;overflow-y:auto}
.sheet h2{margin:0;font-size:20px}
.sheet h2:focus{outline:none}
.add summary{cursor:pointer;font-weight:600;font-size:14px;padding:6px 0}
.add .stack{margin-top:8px}

@media (prefers-reduced-motion:no-preference){.screen{animation:fade .18s ease-out}@keyframes fade{from{opacity:.4}to{opacity:1}}}
.homebtn{text-align:center;min-width:0;border:1.5px solid var(--line);font-size:13px;padding:5px 12px}
.notice.sample{border:1.5px dashed var(--muted)}
.fbbtn{text-align:center;min-width:0;border:1.5px solid var(--line);font-size:13px;padding:5px 12px}
.fb-about{font-size:13px;color:var(--muted);margin:0}

/* All pages: book filter */
.row-wrap{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.row-wrap .btn{width:auto}
