:root {
  color-scheme: light dark;
  --bg: #f2f1ec;
  --grid: rgb(29 86 184 / 5.5%);
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --ink: #191b1f;
  --ink-2: #444850;
  --muted: #6a6f78;
  --line: #e0ded7;
  --line-strong: #c6c3ba;
  --brand: #1d56b8;
  --accent: #1d56b8;
  --accent-ink: #ffffff;
  --accent-soft: #e7eefb;
  --c-guide: #a35300;
  --c-guide-soft: #fbefe1;
  --c-custom: #2357c6;
  --c-custom-soft: #e8eefc;
  --c-standard: #08715f;
  --c-standard-soft: #e0f2ee;
  --ok: #1e8a4f;
  --warn: #a86400;
  --warn-soft: #fdf3e1;
  --bad: #bf3328;
  --bad-soft: #fcebe9;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(20 22 28 / 6%), 0 6px 20px rgb(20 22 28 / 5%);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
    "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215;
    --grid: rgb(122 160 255 / 4.5%);
    --surface: #181b1f;
    --surface-2: #1e2126;
    --ink: #e8e9ec;
    --ink-2: #c3c6cc;
    --muted: #8d929b;
    --line: #2a2e34;
    --line-strong: #3c414a;
    --brand: #3d73e0;
    --accent: #80a7ff;
    --accent-ink: #0b1323;
    --accent-soft: #1b2741;
    --c-guide: #f0a24f;
    --c-guide-soft: #2e2318;
    --c-custom: #88aaff;
    --c-custom-soft: #1b2541;
    --c-standard: #45caae;
    --c-standard-soft: #12302a;
    --ok: #4cc57f;
    --warn: #e7a743;
    --warn-soft: #2f2615;
    --bad: #ff7a6e;
    --bad-soft: #351c1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 24%);
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.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;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}

.masthead__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand__mark { width: 34px; height: 34px; flex: none; color: var(--brand); }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand__text strong { font-size: 16px; letter-spacing: 0.02em; }
.brand__text span { font-size: 12.5px; color: var(--muted); }

.sync {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sync__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-tone="ok"] .sync__dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.sync[data-tone="busy"] .sync__dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.sync[data-tone="warn"] .sync__dot { background: var(--warn); }
.sync[data-tone="bad"] .sync__dot { background: var(--bad); }
.sync[data-tone="bad"] { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- banner ---------- */

.banner { width: 100%; max-width: 1280px; margin: 16px auto 0; padding: 0 24px; }

.banner__box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 14px;
}

.banner__box > span { flex: 1; }
.banner__box[data-tone="bad"] { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner__box[data-tone="warn"] { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner__box[data-tone="info"] { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* ---------- assignment rail ---------- */

.rail { position: sticky; top: 84px; }

.rail__title {
  display: flex;
  justify-content: space-between;
  margin: 2px 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.rail__title span:last-child { font-family: var(--mono); letter-spacing: 0; }
.rail__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rail__empty { padding: 16px; color: var(--muted); font-size: 14px; }

.rail-item {
  position: relative;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rail-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.rail-item[aria-current="page"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.rail-item--skeleton { pointer-events: none; }

.rail-item__no {
  padding-top: 1px;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.1;
}

.rail-item[aria-current="page"] .rail-item__no { color: var(--accent); }
.rail-item__body { display: flex; flex-direction: column; min-width: 0; }
.rail-item__zh { font-size: 15px; font-weight: 600; line-height: 1.35; }
.rail-item__de { color: var(--muted); font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item__meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.rail-item__dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.meter {
  display: flex;
  gap: 2px;
  height: 4px;
  margin: 8px 0 6px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-2);
}

.meter span { display: block; min-width: 3px; border-radius: 1px; }

[data-cat="guide"] { --cat: var(--c-guide); --cat-soft: var(--c-guide-soft); }
[data-cat="custom"] { --cat: var(--c-custom); --cat-soft: var(--c-custom-soft); }
[data-cat="standard"] { --cat: var(--c-standard); --cat-soft: var(--c-standard-soft); }
.meter [data-cat] { background: var(--cat); }

/* ---------- title block ---------- */

.tb {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tb__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }

.tb__no {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 112px;
  padding: 18px 22px;
  border-right: 1px solid var(--line);
  font-family: var(--mono);
}

.tb__no small { color: var(--muted); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; }
.tb__no b { margin-top: 4px; color: var(--accent); font-size: 38px; font-weight: 600; line-height: 1; }

.tb__name { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 18px 24px; }
.tb__name h1 { font-size: 26px; line-height: 1.2; letter-spacing: 0.01em; }
.tb__name p { margin-top: 4px; color: var(--ink-2); font-size: 16px; }

.tb__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, auto));
  margin: 0;
  border-left: 1px solid var(--line);
}

.tb__fact { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tb__fact:nth-child(odd) { border-right: 1px solid var(--line); }
.tb__fact:nth-last-child(-n + 2) { border-bottom: 0; }
.tb__fact dt { color: var(--muted); font-size: 11.5px; letter-spacing: 0.08em; }
.tb__fact dd { margin: 2px 0 0; font-family: var(--mono); font-size: 13.5px; white-space: nowrap; }

.tb__tabs { display: flex; overflow-x: auto; border-top: 1px solid var(--line-strong); scrollbar-width: none; }
.tb__tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: flex;
  flex: 1 0 auto;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.tab:last-child { border-right: 0; }
.tab:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.tab:disabled { color: var(--muted); opacity: 0.55; cursor: default; }
.tab:focus-visible { outline-offset: -3px; }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--cat, var(--accent));
}

.tab__dot { width: 8px; height: 8px; border-radius: 2px; background: var(--cat); }
.tab__count { margin-left: auto; padding-left: 8px; color: var(--muted); font-family: var(--mono); font-size: 13px; font-weight: 400; }

/* ---------- toolbar ---------- */

.toolbar { display: flex; align-items: stretch; gap: 12px; margin: 16px 0 4px; }

.search {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .icon { position: absolute; left: 12px; }

.search input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 38px;
  border: 0;
  border-radius: 8px;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.search input::placeholder { color: var(--muted); }

.search__key {
  position: absolute;
  right: 10px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  font: 12px/18px var(--mono);
}

.search:focus-within .search__key { display: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover { border-color: var(--ink-2); }
.btn:disabled { cursor: default; opacity: 0.6; }
.btn--small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { border-color: var(--line); background: var(--surface-2); color: var(--ink); }

.btn--dl {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}

.btn--dl:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }

.pack {
  --progress: 0;
  position: relative;
  height: auto;
  min-height: 44px;
  padding: 6px 16px;
  overflow: hidden;
  gap: 10px;
}

.pack .icon { width: 18px; height: 18px; }
.pack__text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; }
.pack__label { font-size: 14px; font-weight: 600; }
.pack__sub { font-size: 11.5px; font-weight: 400; opacity: 0.85; font-variant-numeric: tabular-nums; }

.pack.is-busy { opacity: 1; }

.pack.is-busy::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent-ink);
  opacity: 0.7;
  transform: scaleX(var(--progress));
  transform-origin: left;
  transition: transform 0.2s;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
.icon-btn .icon { width: 18px; height: 18px; }

/* ---------- file groups ---------- */

.group { margin-top: 22px; }

.group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 0 4px 8px;
  border-bottom: 2px solid var(--cat, var(--line-strong));
}

.group__head h2 { font-size: 15px; }
.group__count { color: var(--ink-2); font-family: var(--mono); font-size: 12.5px; }
.group__hint { margin-left: auto; color: var(--muted); font-size: 13px; }

.group__list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
}

.file {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  border-top: 1px solid var(--line);
}

.file:first-child { border-top: 0; }
.file:hover { background: var(--surface-2); }
.file[data-mark] { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }

.file__type {
  padding: 5px 0;
  border: 1px solid color-mix(in srgb, var(--cat) 28%, transparent);
  border-radius: 5px;
  background: var(--cat-soft);
  color: var(--cat);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
}

.file__main { min-width: 0; }
.file__name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.file__ext { color: var(--muted); font-weight: 400; white-space: nowrap; }
.file__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }

.tag {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 18px;
}

.tag--sw { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tag--fresh { border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.hash {
  padding: 0 2px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: copy;
}

.hash:hover { color: var(--ink); background: var(--surface-2); }

.file__side { display: flex; align-items: center; gap: 14px; }

.file__size {
  min-width: 64px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.file__actions { display: flex; justify-content: flex-end; gap: 4px; }

/* ---------- states ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 48px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.state h3 { font-size: 16px; }
.state p { max-width: 42ch; color: var(--muted); font-size: 14px; }
.state .btn { margin-top: 8px; }
.state__icon { width: 36px; height: 36px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.state[data-tone="bad"] .state__icon { stroke: var(--bad); }

.skel {
  display: inline-block;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- viewer ---------- */

.viewer {
  width: min(960px, calc(100vw - 32px));
  height: min(88vh, 1000px);
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 70px rgb(0 0 0 / 28%);
}

.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgb(12 14 18 / 48%); backdrop-filter: blur(2px); }

.viewer__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.viewer__heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.viewer__heading h2 { font-size: 15px; overflow-wrap: anywhere; }

.viewer__type {
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--c-guide-soft);
  color: var(--c-guide);
  font: 700 10.5px var(--mono);
  letter-spacing: 0.05em;
}

.viewer__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.viewer__body { flex: 1; min-height: 0; overflow: auto; background: var(--surface); }
.viewer__body .state { margin: 24px; }
.viewer__loading { padding: 40px; color: var(--muted); text-align: center; }
.viewer__pdf { display: block; width: 100%; height: 100%; border: 0; background: #525659; }

.plain {
  margin: 0;
  padding: 24px 28px;
  font: 13px/1.7 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prose { max-width: 72ch; margin: 0 auto; padding: 28px 32px 48px; font-size: 15.5px; line-height: 1.8; }
.prose > * + * { margin-top: 14px; }
.prose h2 { font-size: 22px; line-height: 1.3; }
.prose h3 { margin-top: 28px; font-size: 17px; }
.prose h4, .prose h5, .prose h6 { margin-top: 22px; font-size: 15.5px; }
.prose code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font: 0.9em var(--mono); }
.prose pre { padding: 14px 16px; overflow: auto; border-radius: 8px; background: var(--surface-2); }
.prose pre code { padding: 0; background: none; }
.prose ul { padding-left: 1.4em; }
.prose ol { padding: 0; list-style: none; counter-reset: step var(--start, 0); }

.prose ol > li {
  position: relative;
  padding: 2px 0 2px 44px;
  counter-increment: step;
}

.prose ol > li + li { margin-top: 12px; }

.prose ol > li::before {
  content: counter(step);
  position: absolute;
  top: 3px;
  left: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 13px var(--mono);
}

/* ---------- toast & footer ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 50;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 10px 30px rgb(0 0 0 / 22%);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="bad"] { background: var(--bad); color: #fff; }

.clipboard { position: fixed; top: 0; left: 0; opacity: 0; }

.foot { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); }

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px 20px;
  color: var(--muted);
  font-size: 12.5px;
}

.noscript { max-width: 640px; margin: 40px auto; padding: 0 24px; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .tb__head { grid-template-columns: auto minmax(0, 1fr); }
  .tb__facts { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 0; }
  .tb__fact { border-bottom: 0; border-right: 1px solid var(--line); }
  .tb__fact:nth-child(odd) { border-right: 1px solid var(--line); }
  .tb__fact:last-child { border-right: 0; }
  .group__hint { display: none; }
}

@media (max-width: 860px) {
  .masthead__inner { padding: 10px 16px; }
  .banner { padding: 0 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .rail { position: static; }
  .rail__title { display: none; }

  .rail__list {
    flex-direction: row;
    margin: 0 -16px;
    padding: 2px 16px 6px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 16px;
    scrollbar-width: none;
  }

  .rail__list::-webkit-scrollbar { display: none; }
  .rail__list > li { flex: 0 0 auto; width: 196px; scroll-snap-align: start; }
  .rail-item { grid-template-columns: 1fr; gap: 2px; height: 100%; padding: 10px 12px; }
  .rail-item__no { font-size: 15px; }
  .rail-item__de { display: none; }
  .meter { margin: 6px 0 4px; }

  .tb__no { min-width: 84px; padding: 14px 16px; }
  .tb__no b { font-size: 30px; }
  .tb__name { padding: 14px 16px; }
  .tb__name h1 { font-size: 21px; }
  .tb__name p { font-size: 14.5px; }
  .tb__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb__fact { padding: 8px 14px; border-bottom: 1px solid var(--line); }
  .tb__fact:nth-child(even) { border-right: 0; }
  .tb__fact:nth-last-child(-n + 2) { border-bottom: 0; }
  .tab { flex: 0 0 auto; padding: 10px 14px; }

  .toolbar { flex-direction: column; gap: 10px; }
  .pack { justify-content: flex-start; }
  .search__key { display: none; }

  .file { grid-template-columns: 50px minmax(0, 1fr); gap: 6px 12px; padding: 12px; align-items: start; }
  .file__type { margin-top: 2px; font-size: 9.5px; }
  .file__side { grid-column: 2; justify-content: space-between; gap: 8px; }
  .file__size { min-width: 0; text-align: left; }
  .hash { display: none; }
}

@media (max-width: 420px) {
  .brand__text span { display: none; }
  .sync { padding: 5px 10px; font-size: 12px; }
  .viewer { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .prose { padding: 20px 18px 40px; }
}

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

@media print {
  body { background: none; }
  .masthead, .rail, .toolbar, .file__actions, .foot, .toast { display: none !important; }
  .layout { display: block; padding: 0; }
}
