/* Document — one narrow reading column, like a clean written page. */

:root {
  --bg: #ffffff;
  --text: #1f1f1f;
  --muted: #696969;
  --faint: #8a8a8a;
  --line: #ebebeb;
  --fill: #f4f4f4;
  --fill-hover: #ececec;
  --accent: #2459d6;
  --mark: color-mix(in srgb, var(--accent) 18%, transparent);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --col: 680px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --text: #e6e6e6;
    --muted: #a0a0a0;
    --faint: #8c8c8c;
    --line: #2e2e2e;
    --fill: #252525;
    --fill-hover: #2e2e2e;
    --accent: #7ea6ff;
    --mark: color-mix(in srgb, var(--accent) 28%, transparent);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }
[hidden] { display: none !important; }
html:not(.js) .js-only { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { max-width: calc(var(--col) + 48px); margin: 0 auto; padding: 0 24px; }

/* ── Top line ────────────────────────────────────── */
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0 0; font-size: 15px; color: var(--muted); }
.top a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.top a:hover { color: var(--text); text-decoration: none; }
.top svg { width: 16px; height: 16px; flex: none; }

/* ── Title block ─────────────────────────────────── */
.head { padding-top: 56px; }
h1 { font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; text-wrap: pretty; overflow-wrap: anywhere; }
.byline { display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 12px; font-size: 15px; color: var(--muted); }
.byline > * + *::before { content: "·"; margin: 0 8px; color: var(--faint); }
.opening { margin-top: 24px; font-size: 18px; line-height: 1.65; }
.cover { margin-top: 28px; max-width: 440px; }
.cover a, .cover span.img { display: block; border-radius: 6px; overflow: hidden; aspect-ratio: 16 / 9; background: var(--fill); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* ── Search and filters: quiet until used ────────── */
.tools { margin-top: 48px; }
.bar { display: flex; gap: 8px; }
.field { position: relative; flex: 1; min-width: 0; }
.field svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--fill); color: var(--text); font: inherit; font-size: 15px;
  -webkit-appearance: none; appearance: none;
}
.field input::placeholder { color: var(--muted); opacity: 1; }
.field input:hover { background: var(--fill-hover); }
.field input:focus { outline: none; background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 8px; background: var(--fill);
  font-size: 15px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.toggle:hover { background: var(--fill-hover); }
.toggle svg { width: 16px; height: 16px; color: var(--muted); }
.toggle[aria-expanded="true"] { background: var(--bg); border-color: var(--line); }
.toggle .on { color: var(--accent); font-weight: 600; }
.panel { margin-top: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; }
.facet + .facet { margin-top: 12px; }
.facet h2 { margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); font-size: 14px; line-height: 22px; cursor: pointer;
}
.tag .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tag:hover { background: var(--fill); }
.tag[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); color: var(--accent); }
.tag[aria-pressed="true"] .n { color: var(--accent); }
.tag.more { color: var(--accent); }
.status { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 26px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.status b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.textbtn { padding: 0; border: 0; background: none; color: var(--accent); font-size: 14px; cursor: pointer; }
.textbtn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Sections and references ─────────────────────── */
.sec { margin-top: 40px; }
.sec h2 { font-size: 21px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }
.sec h2 .c { margin-left: 8px; color: var(--faint); font-size: 15px; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.refs { margin-top: 14px; }
.ref { display: grid; grid-template-columns: 2.25em minmax(0, 1fr); padding: 8px 0 10px; scroll-margin-top: 16px; }
.ref:target { background: color-mix(in srgb, var(--accent) 7%, transparent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 2px; }
.rn { color: var(--faint); font-size: 15px; line-height: 1.75; font-variant-numeric: tabular-nums; }
.rn:hover { color: var(--accent); }
.cite { overflow-wrap: anywhere; }
.cite .t { font-weight: 500; }
.cite .src { color: var(--muted); }
.cite .src > span + span::before { content: ", "; }
.cite .src::before { content: " — "; color: var(--faint); }
.note { margin-top: 2px; font-size: 16px; color: var(--muted); }
.act { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.act .dm { overflow-wrap: anywhere; }
.copy { padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.copy:hover { color: var(--accent); }
.copy.done { color: var(--accent); }
.empty { margin-top: 32px; color: var(--muted); }
.empty strong { color: var(--text); font-weight: 600; }
.empty p + p { margin-top: 4px; }

/* ── Older / newer ───────────────────────────────── */
.pn { display: flex; flex-direction: column; gap: 14px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.pn a { display: block; color: var(--text); }
.pn a:hover { text-decoration: none; }
.pn a:hover .t { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.pn .k { display: block; font-size: 14px; color: var(--muted); }
.pn .t { color: var(--accent); font-weight: 500; overflow-wrap: anywhere; }

/* ── Index list ──────────────────────────────────── */
.vlist { margin-top: 8px; }
html:not(.js) .vlist { margin-top: 32px; border-top: 1px solid var(--line); }
.v .yh { margin: 40px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 21px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
html:not(.js) .v .yh { display: none; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 20px; align-items: start; padding: 14px 0; }
.row h3 { font-size: 17px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.row h3 a { color: var(--text); }
.row h3 a:hover { color: var(--accent); }
.row .meta { margin-top: 2px; font-size: 14px; color: var(--muted); }
.row .meta > * + *::before { content: "·"; margin: 0 7px; color: var(--faint); }
.row .desc { margin-top: 4px; font-size: 15px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .th { display: block; width: 104px; aspect-ratio: 16 / 9; margin-top: 4px; border-radius: 4px; overflow: hidden; background: var(--fill); }
.row .th img { width: 100%; height: 100%; object-fit: cover; }
.v + .v .row { border-top: 1px solid var(--line); }
.v .yh:not([hidden]) + .row { border-top: 0; }
.hits { margin: -4px 0 12px; font-size: 15px; }
.hits:empty { display: none; }
.hits li { display: grid; grid-template-columns: 2.25em minmax(0, 1fr); padding: 3px 0; }
.hits .hn { color: var(--faint); font-variant-numeric: tabular-nums; }
.hits .hd { color: var(--muted); }
.hits a { overflow-wrap: anywhere; }
.hits .hmore { display: block; padding-left: 2.25em; }

/* ── Footer ──────────────────────────────────────── */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 72px; padding: 20px 0 40px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.foot ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot .made a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }

@media (max-width: 599px) {
  body { font-size: 16px; }
  .page { padding: 0 18px; }
  .head { padding-top: 32px; }
  h1 { font-size: 26px; }
  .opening { font-size: 17px; }
  .tools { margin-top: 36px; }
  .toggle .w { display: none; }
  .sec { margin-top: 32px; }
  .sec h2, .v .yh { font-size: 19px; }
  .ref { grid-template-columns: 2em minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; }
  .row .th { width: 84px; }
  .row .desc { display: none; }
  .hits li { grid-template-columns: 2em minmax(0, 1fr); }
  .hits .hmore { padding-left: 2em; }
}

@media (prefers-reduced-motion: no-preference) {
  .field input, .toggle, .tag { transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
}
