:root {
  --bg: #faf8f5; --ink: #1d1b19; --muted: #8b857d; --faint: #b9b2a9; --line: #ebe6df; --tile: #f1ece5;
  --accent: #b65c44; --good: #3d7a58;
  --s1: #b65c44; --s2: #5f84b3; --s3: #c99a3e; --s4: #3d7a58;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141312; --ink: #ece8e2; --muted: #8f887f; --faint: #5c5750; --line: #262320; --tile: #1e1c1a;
    --accent: #d9846c; --good: #74b48f; --s1: #d9846c; --s2: #86a6d0; --s3: #d8b062; --s4: #74b48f; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.65 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.label { font-size: 12px; letter-spacing: .04em; color: var(--muted); margin: 0; }

/* nav */
.nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--line); }
.nav-in { display: flex; align-items: center; gap: 28px; height: 52px; }
.brand { font-weight: 600; text-decoration: none; letter-spacing: -.01em; }
.nav-links { display: flex; gap: 22px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav-links a { text-decoration: none; color: var(--muted); font-size: 13.5px; white-space: nowrap; padding: 15px 0 14px;
  border-bottom: 1px solid transparent; }
.nav-links a:hover, .nav-links a.on { color: var(--ink); border-bottom-color: var(--ink); }
.toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.toggle input { accent-color: var(--accent); margin: 0; }

/* hero */
.hero { padding-top: 88px; padding-bottom: 24px; }
h1 { font-size: clamp(32px, 5.2vw, 54px); line-height: 1.07; letter-spacing: -.035em; font-weight: 600; margin: 14px 0 18px; max-width: 800px; }
.lede { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0; }
.strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 48px 0 40px; }
.strip img { width: 100%; aspect-ratio: 1; display: block; border-radius: 3px; cursor: zoom-in; }
.numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 0; border-top: 1px solid var(--line); padding-top: 22px; }
.numbers dt { font-size: 12.5px; color: var(--muted); }
.numbers dd { margin: 2px 0 0; font-size: 40px; font-weight: 500; letter-spacing: -.04em; line-height: 1.1; }
.numbers dd span { color: var(--faint); font-size: 24px; letter-spacing: -.02em; }
.numbers p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.numbers .good dd { color: var(--good); }
.links { display: flex; flex-wrap: wrap; gap: 18px; margin: 30px 0 0; font-size: 14px; }

/* sections */
.section { padding: 96px 0 24px; }
.sh { display: flex; align-items: baseline; gap: 14px; border-top: 1px solid var(--ink); padding-top: 14px; margin-bottom: 18px; }
.num { font: 500 13px var(--mono); color: var(--muted); }
h2 { font-size: clamp(24px, 3.2vw, 32px); letter-spacing: -.025em; font-weight: 600; margin: 0; line-height: 1.2; }
h3 { font-size: 15px; font-weight: 600; margin: 56px 0 6px; letter-spacing: -.005em; }
.prose { max-width: 680px; margin: 0; }
.note { color: var(--muted); font-size: 13.5px; margin: 6px 0 16px; max-width: 680px; }
.code { font: 13.5px/1.6 var(--mono); background: var(--tile); border-radius: 4px; padding: 14px 16px; overflow-x: auto; max-width: 520px; margin: 28px 0 0; }
.cm { color: var(--muted); }

/* replay */
.replay { margin: 44px 0 8px; }
.rp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.rp-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.rp-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.replay svg { width: 100%; height: 190px; display: block; margin-top: 10px; overflow: visible; }
.replay .grid-line { stroke: var(--line); }
.replay .tick { fill: var(--faint); font: 10.5px var(--mono); }
.replay .cursor { stroke: var(--ink); opacity: .35; }
.replay .dot { stroke: var(--bg); stroke-width: 2; }
.rp-controls { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.play { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; font-size: 11px; display: grid; place-items: center; flex: none; }
.play:hover { border-color: var(--ink); }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 20px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--line); }
input[type=range]::-moz-range-track { height: 1px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); margin-top: -6px; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 0; }
.rp-step { font: 12.5px var(--mono); color: var(--muted); min-width: 74px; text-align: right; }
.rp-read { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 14px; }
.rp-read div { font-size: 12px; color: var(--muted); }
.rp-read b { display: block; font: 500 17px var(--mono); color: var(--ink); letter-spacing: -.02em; }
.rp-frames { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 16px; min-height: 40px; }
.rp-frames img { width: 100%; aspect-ratio: 1; display: block; border-radius: 3px; }
.rp-frames .none { grid-column: 1 / -1; font-size: 12.5px; color: var(--faint); }

/* paintings */
.p { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: var(--tile);
  border: 0; padding: 0; cursor: zoom-in; }
.p img { width: 100%; height: 100%; display: block; transition: transform .25s ease; }
.p:hover img { transform: scale(1.03); }
.p.empty { cursor: default; display: grid; place-items: center; color: var(--faint); font-size: 11.5px; }
.r { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; }
.r.love { background: var(--accent); }
.r.okay { border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--bg) 60%, transparent); }
.r.no { background: var(--faint); opacity: .7; width: 7px; height: 7px; top: 8px; right: 8px; }
body.hide-ratings .p .r { display: none; }

.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 28px 18px; margin-top: 18px; }
.pair .two { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pair .cap { font-size: 12.5px; margin-top: 8px; line-height: 1.45; }
.pair .cap span { color: var(--muted); display: block; font-family: var(--mono); font-size: 11.5px; }

.grid { overflow-x: auto; margin-top: 18px; }
.grid table { border-collapse: separate; border-spacing: 6px 6px; width: 100%; min-width: 600px; table-layout: fixed; margin: -6px; }
.grid col.subj { width: 140px; }
.grid th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 0 4px; }
.grid td.subj { font-size: 12.5px; color: var(--muted); vertical-align: middle; line-height: 1.4; padding-right: 8px; }
.grid td { padding: 0; }
.grid th.hl { color: var(--ink); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 18px 10px; margin-top: 18px; }
.gallery figure { margin: 0; }
.gallery figcaption { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }

/* tables */
.t { border-collapse: collapse; margin: 40px 0 8px; font-size: 14px; min-width: min(560px, 100%); }
.t th { font-weight: 500; color: var(--muted); font-size: 12.5px; text-align: right; padding: 0 0 8px 28px; border-bottom: 1px solid var(--ink); }
.t th:first-child, .t td:first-child { text-align: left; padding-left: 0; }
.t td { padding: 9px 0 9px 28px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.t .strong, .t tr.good td { font-weight: 600; }
.t tr.good td { color: var(--good); }

/* how */
.flow { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; counter-reset: s; border-top: 1px solid var(--line); }
.flow li { padding: 18px 22px 22px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); counter-increment: s; }
.flow li::before { content: "0" counter(s); font: 500 11.5px var(--mono); color: var(--faint); display: block; margin-bottom: 8px; }
.flow b { display: block; color: var(--ink); font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 56px; padding-bottom: 64px; color: var(--muted); font-size: 12.5px; }
.legend-r { display: flex; align-items: center; gap: 6px; }
.legend-r .r { position: static; display: inline-block; margin-left: 8px; }

/* viewer */
dialog { border: 0; padding: 0; background: var(--bg); color: var(--ink); border-radius: 6px; width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 18, 16, .55); backdrop-filter: blur(3px); }
.v-in { display: grid; grid-template-columns: 1.15fr 1fr; height: min(600px, calc(100vh - 32px)); }
.v-img { background: var(--tile); display: grid; place-items: center; min-height: 0; height: 100%; }
.v-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.v-side { padding: 22px 24px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.v-head { display: flex; justify-content: space-between; gap: 12px; }
.v-head h4 { margin: 4px 0 0; font-size: 18px; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
.icon { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 4px; height: 28px; }
.icon:hover { color: var(--ink); }
.v-rating { font-size: 13px; color: var(--muted); margin: 10px 0 18px; display: flex; align-items: center; gap: 8px; }
.v-rating .r { position: static; }
.v-code-head { display: flex; justify-content: space-between; align-items: baseline; }
.text-btn { border: 0; background: none; color: var(--muted); font: 500 12.5px Inter, sans-serif; cursor: pointer; padding: 4px 0; }
.text-btn:hover { color: var(--ink); }
.text-btn:disabled { opacity: .35; cursor: default; }
.v-code { font: 11.5px/1.55 var(--mono); background: var(--tile); border-radius: 4px; padding: 12px 14px; margin: 8px 0 0;
  overflow: auto; flex: 1; min-height: 120px; white-space: pre; }
.v-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .nav-in { gap: 16px; }
  .toggle { display: none; }
  .hero { padding-top: 48px; }
  .strip { grid-template-columns: repeat(3, 1fr); margin: 32px 0 28px; }
  .numbers { grid-template-columns: 1fr; gap: 18px; }
  .flow { grid-template-columns: 1fr; }
  .rp-frames { grid-template-columns: repeat(4, 1fr); }
  .section { padding-top: 64px; }
  .v-in { grid-template-columns: 1fr; height: auto; max-height: calc(100vh - 32px); overflow: auto; }
  .v-img { height: auto; }
  .v-img img { aspect-ratio: 1; height: auto; }
  .v-side { overflow: visible; }
  .v-code { max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .p img { transition: none; } }
