:root {
  color-scheme: light dark;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #e7ece7;
  --ink: #18201e;
  --muted: #5b6864;
  --line: #cbd4cf;
  --accent: #287d6e;
  --accent-strong: #176354;
  --signal: #8a5a00;
  --danger: #a23932;
  --shadow: 0 12px 30px rgb(26 40 36 / 10%);
  --radius: 8px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111615;
  --surface: #1a211f;
  --surface-2: #242d2a;
  --ink: #f1f4ee;
  --muted: #aebbb6;
  --line: #3b4743;
  --accent: #63c7b2;
  --accent-strong: #8ad9c8;
  --signal: #f2c66d;
  --danger: #f49a91;
  --shadow: 0 14px 34px rgb(0 0 0 / 28%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111615;
    --surface: #1a211f;
    --surface-2: #242d2a;
    --ink: #f1f4ee;
    --muted: #aebbb6;
    --line: #3b4743;
    --accent: #63c7b2;
    --accent-strong: #8ad9c8;
    --signal: #f2c66d;
    --danger: #f49a91;
    --shadow: 0 14px 34px rgb(0 0 0 / 28%);
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); line-height: 1.55; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select, input[type="file"]::file-selector-button { min-height: 44px; }
button, a, select, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; background: var(--ink); color: var(--bg); transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.topbar {
  position: sticky; z-index: 10; top: 0; min-height: calc(64px + env(safe-area-inset-top));
  display: flex; align-items: end; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 700 1.05rem ui-rounded, system-ui, sans-serif; }
.brand svg { width: 28px; height: 28px; fill: var(--accent); }
.playthrough-picker { min-width: 0; }
.playthrough-picker select { max-width: 48vw; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 26px 6px 6px; color: var(--ink); background: transparent; }

main { width: min(100%, 760px); min-height: calc(100dvh - 136px); margin: 0 auto; padding: 26px max(20px, env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; font-family: ui-rounded, system-ui, sans-serif; line-height: 1.14; letter-spacing: 0; }
h1 { font-size: clamp(1.85rem, 7vw, 3rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.eyebrow { color: var(--accent-strong); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 18px; }
.cluster { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.intro { padding: 7vh 0 24px; }
.intro h1 { max-width: 12ch; margin-top: 10px; }
.intro > p:last-child { max-width: 52ch; margin-top: 14px; color: var(--muted); font-size: 1.08rem; }
.setup { display: grid; gap: 20px; padding-top: 24px; border-top: 1px solid var(--line); }

.objective { position: relative; display: grid; gap: 22px; padding-left: 28px; }
.objective::before { content: ""; position: absolute; top: 8px; bottom: 4px; left: 5px; width: 2px; background: var(--line); }
.objective::after { content: ""; position: absolute; top: 6px; left: 0; width: 12px; height: 12px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.objective-header { display: grid; gap: 12px; }
.objective-title { max-width: 16ch; }
.brief { max-width: 48ch; font-size: clamp(1.08rem, 4vw, 1.28rem); color: var(--muted); }
.resume-line { display: grid; gap: 4px; padding: 12px 0 16px; border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.tag.important { border-color: var(--signal); color: var(--signal); }

.progress-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; }
progress { width: 100%; height: 7px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

details { border-top: 1px solid var(--line); }
details p { white-space: pre-line; }
summary { min-height: 50px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 700; }
summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); }
details[open] summary::after { content: "−"; }
details > :not(summary) { margin: 0 0 18px; }
.spoiler { border-left: 3px solid var(--signal); padding-left: 14px; }
.note { width: 100%; min-height: 100px; resize: vertical; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); color: var(--ink); }

.actions { position: sticky; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 4; display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 2px -8px 0; padding: 10px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); }
.primary, .secondary, .quiet, .danger { border-radius: var(--radius); padding: 10px 16px; cursor: pointer; font-weight: 750; }
.primary { border: 1px solid var(--accent); background: var(--accent); color: #0b2420; }
:root[data-theme="light"] .primary { color: #fff; }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.quiet { border: 0; background: transparent; color: var(--accent-strong); }
.danger { border: 1px solid var(--danger); background: transparent; color: var(--danger); }
.more-actions { display: flex; flex-wrap: wrap; gap: 4px; }

.tabbar {
  position: fixed; z-index: 9; right: 0; bottom: 0; left: 0; height: calc(70px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px);
}
.tabbar[hidden] { display: none; }
.tabbar a { min-height: 58px; display: grid; place-content: center; gap: 1px; color: var(--muted); text-align: center; text-decoration: none; font-size: .7rem; font-weight: 700; }
.tabbar a span { color: currentColor; font-size: 1.15rem; }
.tabbar a[aria-current="page"] { color: var(--accent-strong); }

.chapter { border-bottom: 1px solid var(--line); padding: 20px 0; }
.chapter-head { display: grid; gap: 8px; margin-bottom: 14px; }
.task-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.task-link { width: 100%; min-height: 52px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; border: 0; border-radius: 4px; padding: 8px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.task-link:hover { background: var(--surface-2); }
.status-mark { color: var(--muted); font-weight: 800; }
.task-link small { color: var(--muted); }
.search { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 13px; background: var(--surface); color: var(--ink); }

.guide { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.guide-mark { width: 64px; aspect-ratio: 1; display: grid; place-content: center; border-radius: var(--radius); background: var(--surface-2); color: var(--accent); font-size: 1.6rem; }
.guide-content { display: grid; gap: 9px; min-width: 0; }
.form-row { display: grid; gap: 8px; }
label > span:first-child { display: block; margin-bottom: 5px; font-size: .84rem; font-weight: 750; }
input[type="text"], select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); color: var(--ink); }
.file-control { display: block; border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; }
.file-control input { width: 100%; margin-top: 8px; }
.notice { border-left: 3px solid var(--signal); padding: 10px 14px; background: color-mix(in srgb, var(--signal) 8%, transparent); }
.error { border-left-color: var(--danger); color: var(--danger); }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }

@media (min-width: 760px) {
  main { padding-top: 40px; }
  .tabbar { right: auto; top: 50%; bottom: auto; left: 18px; width: 76px; height: auto; grid-template-columns: 1fr; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); transform: translateY(-50%); }
  .actions { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
