/* =====================================================================
   REGSDOWN – modern UI
   ===================================================================== */

:root {
  color-scheme: light dark;

  /* raw palette */
  --brand-l: oklch(52% 0.19 258);
  --brand-d: oklch(72% 0.14 250);
  --bg-l: oklch(98.5% 0.004 250);
  --bg-d: oklch(17% 0.012 260);
  --surface-l: #fff;
  --surface-d: oklch(21% 0.014 260);
  --surface-2-l: oklch(96.5% 0.006 250);
  --surface-2-d: oklch(25% 0.016 260);
  --text-l: oklch(23% 0.02 260);
  --text-d: oklch(93% 0.01 250);
  --muted-l: oklch(50% 0.02 260);
  --muted-d: oklch(70% 0.02 255);
  --border-l: oklch(91% 0.008 255);
  --border-d: oklch(31% 0.016 260);

  /* tokens (fallback first, then light-dark) */
  --brand: var(--brand-l);
  --bg: var(--bg-l);
  --surface: var(--surface-l);
  --surface-2: var(--surface-2-l);
  --text: var(--text-l);
  --muted: var(--muted-l);
  --border: var(--border-l);
  @media (prefers-color-scheme: dark) {
    --brand: var(--brand-d);
    --bg: var(--bg-d);
    --surface: var(--surface-d);
    --surface-2: var(--surface-2-d);
    --text: var(--text-d);
    --muted: var(--muted-d);
    --border: var(--border-d);
  }
  @supports (color: light-dark(white, black)) {
    --brand: light-dark(var(--brand-l), var(--brand-d));
    --bg: light-dark(var(--bg-l), var(--bg-d));
    --surface: light-dark(var(--surface-l), var(--surface-d));
    --surface-2: light-dark(var(--surface-2-l), var(--surface-2-d));
    --text: light-dark(var(--text-l), var(--text-d));
    --muted: light-dark(var(--muted-l), var(--muted-d));
    --border: light-dark(var(--border-l), var(--border-d));
  }

  --brand-soft: color-mix(in oklch, var(--brand) 12%, transparent);
  --brand-contrast: light-dark(#fff, oklch(18% 0.03 260));
  --success: light-dark(oklch(55% 0.15 150), oklch(75% 0.15 150));
  --danger: light-dark(oklch(55% 0.2 25), oklch(72% 0.16 25));
  --warning: light-dark(oklch(65% 0.15 75), oklch(80% 0.14 80));

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow: 0 4px 16px -4px rgb(0 0 0 / 0.12), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.28);
  --topbar-h: 60px;
  --sidebar-w: 340px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  accent-color: var(--brand);
  --scroll-thumb: light-dark(oklch(80% 0.01 255), oklch(40% 0.015 260));
  scrollbar-color: var(--scroll-thumb) transparent;

  /* Theme switch: the <meta name="color-scheme"> holds the user's override. */
  &:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
  &:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
}

/* Theme switch button: show the action for the opposite of what is rendered. */
.theme-toggle .to-light { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle {
  .to-dark { display: none; }
  .to-light { display: inline-flex; }
}
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle {
    .to-dark { display: none; }
    .to-light { display: inline-flex; }
  }
}
.theme-toggle span { display: inline-flex; align-items: center; }

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

svg { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

a { color: var(--brand); }

.muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--brand); color: var(--brand-contrast); padding: 8px 14px; border-radius: var(--radius-sm);
  &:focus { top: 12px; }
}

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

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s, box-shadow .15s;
  &:active { transform: translateY(1px); }
  &:disabled { opacity: .5; cursor: not-allowed; }
  &.small { height: 30px; padding: 0 12px; font-size: 13px; }
}
.btn.primary {
  background: var(--brand); color: var(--brand-contrast);
  box-shadow: 0 1px 2px rgb(0 0 0 / .15), inset 0 1px 0 rgb(255 255 255 / .15);
  &:hover { background: color-mix(in oklch, var(--brand) 88%, black); }
}
.btn.ghost {
  background: transparent; color: var(--text); border-color: var(--border);
  &:hover { background: var(--surface-2); }
}
.btn.subtle {
  background: var(--brand-soft); color: var(--brand);
  &:hover { background: color-mix(in oklch, var(--brand) 20%, transparent); }
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  &:hover { background: var(--surface-2); color: var(--text); }
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: var(--brand-contrast);
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}

/* ------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in oklch, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
}
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), color-mix(in oklch, var(--brand) 60%, oklch(70% 0.15 200)));
  color: #fff; box-shadow: var(--shadow-sm);
  svg { fill: currentColor; stroke: none; width: 20px; height: 20px; transform: rotate(45deg); }
}
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { letter-spacing: .06em; font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.sidebar-toggle { display: none; }

/* ------------------------------------------------------------ layout */
body { display: flex; flex-direction: column; height: 100dvh; }

.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w, 0);
  --rail-w: 340px;
}
.layout.rail-collapsed { --rail-w: 0px; }
@media (max-width: 1560px) { .layout:not(.rail-collapsed) { --rail-w: 300px; --sidebar-w: 300px; } }
.nc-doc { display: inline-flex; gap: 4px; }
.layout.rail-collapsed .notices-rail { display: none; }

/* ------------------------------------------------------------ legal notices rail */
.notices-rail {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--border); background: var(--surface);
}
.rail-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 16px 12px 10px 18px;
  h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; svg { color: var(--brand); } }
  .rail-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
}
.rail-filter {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 10px;
  button {
    flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 999px; height: 28px; padding: 0 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
    font-variant-numeric: tabular-nums;
    &[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
    &:disabled { opacity: .45; cursor: default; }
  }
}
.rail-list {
  list-style: none; margin: 0; padding: 4px 12px 12px; overflow-y: auto; flex: 1; min-height: 0;
  display: grid; gap: 8px; align-content: start; scrollbar-width: thin;
}
.rail-item {
  position: relative; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: grid; gap: 8px;
  &:hover { border-color: color-mix(in oklch, var(--brand) 40%, var(--border)); }
  h3 { margin: 0; font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .ri-meta { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; }
  .ri-actions { display: flex; gap: 6px; flex-wrap: wrap; }
}
/* New notices: amber edge, tinted background, NEW ribbon */
.rail-item.is-new, .notice-card.is-new {
  background: color-mix(in oklch, var(--warning) 9%, var(--surface));
  border-color: color-mix(in oklch, var(--warning) 60%, var(--border));
  box-shadow: inset 4px 0 0 var(--warning);
}
.new-ribbon {
  position: absolute; top: -8px; right: 10px;
  padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  background: var(--warning); color: light-dark(#fff, oklch(20% 0.03 60));
  box-shadow: var(--shadow-sm);
}
.notice-card { position: relative; }
.btn-dl {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--brand); color: var(--brand-contrast); font-size: 12px; font-weight: 700; text-decoration: none;
  svg { width: 13px; height: 13px; }
  &:hover { background: color-mix(in oklch, var(--brand) 88%, black); }
  &.ghost { background: var(--surface-2); color: var(--text); &:hover { background: var(--border); } }
}
.rail-empty { padding: 20px 8px; text-align: center; color: var(--muted); font-size: 13px; }
.rail-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px;
  a { font-weight: 600; text-decoration: none; }
}
.rail-reopen {
  position: fixed; right: 0; top: 50%; translate: 0 -50%; z-index: 15;
  writing-mode: vertical-rl; display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 8px; border: 1px solid var(--border); border-right: 0; border-radius: 12px 0 0 12px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
  svg { color: var(--brand); rotate: 90deg; }
  .badge { writing-mode: horizontal-tb; }
  &:hover { color: var(--brand); }
}
@media (max-width: 1279px) {
  .layout { --rail-w: 0px; }
  .notices-rail, .rail-reopen { display: none !important; }
}

/* ------------------------------------------------------------ risk warning */
.risk-banner {
  --warn: light-dark(oklch(52% 0.14 60), oklch(82% 0.13 75));
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 8px 20px;
  font-size: 13px; line-height: 1.4;
  color: light-dark(oklch(35% 0.08 60), oklch(90% 0.06 80));
  background: color-mix(in oklch, var(--warn) 13%, var(--surface));
  border-bottom: 1px solid color-mix(in oklch, var(--warn) 35%, transparent);
  > svg { color: var(--warn); width: 18px; height: 18px; }
  p { margin: 0; flex: 1 1 320px; min-width: 0; }
  strong { color: light-dark(oklch(40% 0.13 50), oklch(88% 0.12 75)); }
}
.risk-extraction {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-weight: 600;
  background: color-mix(in oklch, var(--warn) 16%, transparent);
  time { font-variant-numeric: tabular-nums; }
}
.risk-link {
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit; font-weight: 600;
  color: inherit; text-decoration: underline; text-underline-offset: 2px;
  &:hover { color: var(--warn); }
}

.extract-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12.5px; color: var(--muted);
  svg { width: 14px; height: 14px; }
}

.dialog-warning {
  display: flex; gap: 10px; align-items: flex-start; margin: 0;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: color-mix(in oklch, var(--warning) 14%, transparent);
  border: 1px solid color-mix(in oklch, var(--warning) 40%, transparent);
  svg { color: var(--warning); margin-top: 1px; }
}
.dialog-icon.warn { background: color-mix(in oklch, var(--warning) 18%, transparent); color: var(--warning); }
.disclaimer-dialog { width: min(600px, calc(100vw - 24px)); }
.disclaimer-body {
  display: grid; gap: 10px; font-size: 14px; line-height: 1.55; max-height: 50dvh; overflow-y: auto;
  p { margin: 0; }
}
.disclaimer-extraction {
  display: flex; gap: 8px; align-items: center; margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); font-size: 13.5px;
  svg { color: var(--muted); }
}

.sidebar {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 12px 0 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
}

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--surface-2); border-radius: 999px;
  button {
    border: 0; background: transparent; color: var(--muted);
    height: 34px; border-radius: 999px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: background-color .15s, color .15s;
  }
  button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
  .count { font-size: 12px; font-weight: 600; color: var(--muted); }
}

.search {
  position: relative; display: flex; align-items: center;
  > svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
  input {
    width: 100%; height: 40px; padding: 0 40px 0 38px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
    &:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft); }
  }
  kbd {
    position: absolute; right: 10px; font: 600 11px var(--font); color: var(--muted);
    border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--surface);
  }
}

.list-tools {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px; font-size: 13px;
}

.check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
}

.list-panel {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0 4px 96px 0; margin-right: -4px;
  scrollbar-width: thin;
}

.group-title {
  position: sticky; top: 0; z-index: 1;
  margin: 10px 0 4px; padding: 6px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  background: var(--surface);
  display: flex; justify-content: space-between;
}

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.doc-item {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px;
  transition: background-color .12s;
  &:hover { background: var(--surface-2); }
  &.active { background: var(--brand-soft); }
  &.active .doc-num { background: var(--brand); color: var(--brand-contrast); }
  input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
  a {
    display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px;
    color: inherit; text-decoration: none; min-width: 0; grid-column: span 2;
  }
}
.doc-num {
  min-width: 42px; height: 28px; padding: 0 6px; border-radius: 8px;
  display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: background-color .12s, color .12s;
}
.doc-item:hover .doc-num { background: var(--surface); }
.doc-name { font-size: 13.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: color-mix(in oklch, var(--warning) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty-list { padding: 32px 12px; text-align: center; color: var(--muted); font-size: 14px; }

.skeleton-list { display: grid; gap: 8px; padding-top: 6px; }
.skeleton-list div, .skeleton {
  height: 36px; border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in oklch, var(--surface-2) 50%, var(--surface)) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  @media (prefers-reduced-motion: reduce) { animation-duration: 6s; }
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ main */
.main { overflow-y: auto; min-width: 0; scroll-padding-top: 16px; }
.main:focus { outline: none; }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 32px 120px; }

/* home */
.hero {
  position: relative; overflow: hidden;
  padding: 40px; border-radius: 20px;
  background:
    radial-gradient(1200px 300px at 100% 0%, color-mix(in oklch, var(--brand) 22%, transparent), transparent 60%),
    radial-gradient(600px 300px at 0% 100%, color-mix(in oklch, oklch(70% 0.15 200) 18%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  h1 { margin: 0 0 8px; font-size: clamp(26px, 3.4vw, 38px); line-height: 1.15; letter-spacing: -.02em; }
  p { margin: 0; max-width: 60ch; color: var(--muted); font-size: 16px; }
}
.hero-plane {
  position: absolute; right: 36px; top: 28px; width: 120px; height: 120px; opacity: .12; color: var(--brand);
  fill: currentColor; stroke: none; transform: rotate(45deg);
}

/* home-page warning panel */
.home-warning {
  --warn: light-dark(oklch(55% 0.15 60), oklch(80% 0.13 75));
  margin-top: 20px; padding: 24px; border-radius: 16px;
  background: color-mix(in oklch, var(--warn) 9%, var(--surface));
  border: 1.5px solid color-mix(in oklch, var(--warn) 55%, transparent);
  border-left-width: 6px;
}
.hw-head {
  display: flex; gap: 14px; align-items: center; margin-bottom: 16px;
  h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; color: light-dark(oklch(40% 0.13 50), oklch(88% 0.12 75)); }
  .hw-sub { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
}
.hw-icon {
  flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in oklch, var(--warn) 20%, transparent); color: var(--warn);
  svg { width: 24px; height: 24px; }
}
.hw-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.hw-text { display: grid; gap: 8px; font-size: 14px; line-height: 1.55; p { margin: 0; } }
.hw-extraction {
  display: grid; gap: 6px; padding: 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid color-mix(in oklch, var(--warn) 35%, var(--border));
  text-align: center;
}
.hw-label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hw-time { font-size: 19px; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.hw-meta { font-size: 12.5px; color: var(--muted); }
.hw-running {
  display: grid; gap: 6px; margin-top: 4px; padding: 10px; border-radius: 10px; text-align: left;
  background: var(--brand-soft); font-size: 12.5px; font-weight: 600;
}
.hw-next {
  display: grid; gap: 2px; margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--border);
  strong { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  span { font-weight: 700; font-variant-numeric: tabular-nums; }
  small { font-size: 12px; color: var(--muted); }
}
.risk-schedule { font-weight: 500; opacity: .85; }
.hw-source { font-size: 12.5px; color: var(--muted); }
@media (max-width: 860px) {
  .home-warning { padding: 18px; }
  .hw-grid { grid-template-columns: minmax(0, 1fr); }
  .hw-extraction { order: -1; }
}

.collection-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.collection-card {
  display: grid; gap: 10px; padding: 22px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  &:hover { border-color: color-mix(in oklch, var(--brand) 50%, var(--border)); box-shadow: var(--shadow); transform: translateY(-2px); }
  .cc-top { display: flex; align-items: center; justify-content: space-between; }
  .cc-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
  .cc-count { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
  h2 { margin: 0; font-size: 18px; }
  p { margin: 0; color: var(--muted); font-size: 14px; }
  .cc-link { color: var(--brand); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
}

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 28px; padding: 0; list-style: none; counter-reset: s; }
.steps li {
  counter-increment: s; padding: 18px; border-radius: 14px; background: var(--surface-2);
  &::before { content: counter(s); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--surface); font-weight: 700; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
  strong { display: block; margin-bottom: 4px; }
  span { color: var(--muted); font-size: 14px; }
}

/* document view */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 12px; padding: 0; list-style: none; }
.crumbs li { display: inline-flex; align-items: center; gap: 6px; }
.crumbs li + li::before { content: "›"; opacity: .6; }
.crumbs a { color: var(--muted); text-decoration: none; &:hover { color: var(--brand); text-decoration: underline; } }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }

.doc-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
  h1 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; letter-spacing: -.015em; }
  .kicker { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
  .doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
}
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }

.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.doc-grid.no-aside { grid-template-columns: minmax(0, 1fr); }

.toc-card {
  position: sticky; top: 16px;
  max-height: calc(100dvh - var(--topbar-h) - 32px); display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  .toc-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  ol { list-style: none; margin: 0; padding: 8px; overflow-y: auto; scrollbar-width: thin; }
  li { display: flex; align-items: center; gap: 4px; border-radius: 8px; &:hover { background: var(--surface-2); } }
  li.active { background: var(--brand-soft); a { color: var(--brand); font-weight: 600; } }
  a { flex: 1; padding: 7px 8px; color: var(--text); text-decoration: none; font-size: 13px; line-height: 1.35; }
  .icon-btn { width: 30px; height: 30px; opacity: 0; }
  li:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
}

.children-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 24px; }
.child-card {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  &:hover { border-color: color-mix(in oklch, var(--brand) 45%, var(--border)); box-shadow: var(--shadow); }
  a.child-title { color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.35; &::after { content: ""; position: absolute; inset: 0; } }
  .child-foot { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
  .child-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
}
.section-title { margin: 32px 0 0; font-size: 16px; display: flex; align-items: baseline; gap: 8px; }

.reader {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(18px, 4vw, 40px);
  box-shadow: var(--shadow-sm);
}

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.pager a {
  flex: 1; max-width: 48%; display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text);
  &:hover { border-color: var(--brand); }
  small { color: var(--muted); font-size: 12px; }
  span { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  &.next { text-align: right; margin-left: auto; }
}

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: color-mix(in oklch, var(--danger) 10%, transparent); color: var(--text);
  border: 1px solid color-mix(in oklch, var(--danger) 35%, transparent);
  svg { color: var(--danger); margin-top: 2px; }
}

/* regulation text */
.doc-content {
  font-family: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  font-size: 16px; line-height: 1.6; color: var(--text);
  overflow-wrap: anywhere;
  p { margin-bottom: 0; }
  .LG-annotation, .annotation { color: var(--muted); }
  .parthead, .WD-head1, .Title-x { font-family: var(--font); font-size: 1.35em !important; letter-spacing: -.01em; }
  .AN-head1, .LG-boldhead, .FRG-LevelOne { font-family: var(--font); font-size: 1.1em; }
  .AN-head2, .hed1, .boldhead { font-family: var(--font); }
  table { max-width: 100%; margin-block: 12px; }
  td { padding: 2px 4px; vertical-align: top; }
  img { max-width: 100%; height: auto; }
  a[data-path] { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
  /* Follows the theme switch too (light-dark resolves from color-scheme). */
  td[style*="border"] { border-color: light-dark(#000000, var(--border-d)) !important; }
}

/* ------------------------------------------------------------ selection bar */
.selection-bar {
  position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 10px 10px 20px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 24px);
  animation: rise .2s ease-out;
  .muted { color: color-mix(in oklch, var(--bg) 65%, transparent); font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
  .selection-actions { display: flex; gap: 8px; }
  .btn.ghost { color: var(--bg); border-color: color-mix(in oklch, var(--bg) 30%, transparent); &:hover { background: color-mix(in oklch, var(--bg) 12%, transparent); } }
}
.selection-bar[hidden] { display: none; }
@keyframes rise { from { opacity: 0; translate: -50% 12px; } }

/* ------------------------------------------------------------ downloads tray */
.tray {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  width: min(440px, calc(100vw - 24px)); max-height: min(70dvh, 560px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: tray-in .2s ease-out;
}
.tray[hidden] { display: none; }
@keyframes tray-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.tray-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border);
  h2 { margin: 0; font-size: 15px; }
  > div { display: flex; align-items: center; gap: 4px; }
}
.tray-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; scrollbar-width: thin; }
.tray-empty { margin: 0; padding: 24px; text-align: center; font-size: 14px; }

.job {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px;
  padding: 14px; border-radius: 12px; background: var(--surface-2);
}
.job-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.job[data-status="done"] .job-icon { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.job[data-status="error"] .job-icon, .job[data-status="cancelled"] .job-icon { background: color-mix(in oklch, var(--danger) 12%, transparent); color: var(--danger); }
.job-body { min-width: 0; display: grid; gap: 6px; }
.job-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.job-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-percent { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); }
.job[data-status="done"] .job-percent { color: var(--success); }
.job-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.job-stage { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job[data-status="error"] .job-stage { color: var(--danger); white-space: normal; }
.job-actions { grid-column: 2; display: flex; gap: 8px; justify-content: flex-end; }

.job-steps {
  display: flex; gap: 4px; margin: 2px 0 0; padding: 0; list-style: none; font-size: 11px; color: var(--muted);
  li { flex: 1; display: grid; gap: 4px; }
  li::before { content: ""; height: 3px; border-radius: 3px; background: var(--border); }
  li.current { color: var(--text); font-weight: 600; }
  li.current::before { background: color-mix(in oklch, var(--brand) 50%, var(--border)); }
  li.complete::before { background: var(--brand); }
}
.job[data-status="done"] .job-steps li::before { background: var(--success); }

/* progress bar (fully custom) */
progress {
  appearance: none;
  border: 0 solid;
  overflow: clip;
  inline-size: 100%;
  block-size: 8px;
  --progress-bar-radius: 1e5px;
  border-radius: var(--progress-bar-radius);
  background: var(--progress-bar-track, var(--border));
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.1);
  container-type: inline-size;
  --progress-bar-indeterminate-size: 30%;
  --progress-bar-indeterminate-animation-duration: 1.5s;
  @media (prefers-reduced-motion: reduce) {
    --progress-bar-indeterminate-animation-duration: 10s;
  }
}
progress:indeterminate {
  --progress-bar-animation: var(
      --progress-bar-indeterminate-animation,
      progress-bar-indeterminate var(--progress-bar-indeterminate-animation-duration) infinite linear
    );
}
progress:dir(rtl) {
  --progress-bar-indeterminate-animation: progress-bar-indeterminate var(--progress-bar-indeterminate-animation-duration) infinite linear reverse;
}
progress::-webkit-progress-bar { background: transparent; }
progress::-webkit-progress-value {
  background: var(--progress-bar-fill, linear-gradient(90deg, var(--brand), color-mix(in oklch, var(--brand) 60%, oklch(75% 0.14 200))));
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
  animation: var(--progress-bar-animation, revert-rule);
}
progress::-moz-progress-bar {
  background: var(--progress-bar-fill, linear-gradient(90deg, var(--brand), color-mix(in oklch, var(--brand) 60%, oklch(75% 0.14 200))));
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
  animation: var(--progress-bar-animation, revert-rule);
}
@keyframes progress-bar-indeterminate {
  from, to {
    inline-size: var(--progress-bar-indeterminate-size);
    margin-right: auto;
  }
  from { translate: -100%; }
  to { translate: 100cqi; }
}
.job[data-status="done"] progress { --progress-bar-fill: var(--success); }
.job[data-status="error"] progress, .job[data-status="cancelled"] progress { --progress-bar-fill: var(--danger); }

/* ------------------------------------------------------------ legal notices */
.badge.warn { background: var(--warning); color: light-dark(#fff, oklch(20% 0.03 60)); }
.notices-link { text-decoration: none; }
.notices-link[aria-current="page"] { background: var(--brand-soft); border-color: transparent; color: var(--brand); }

.notice-status {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted);
  span { display: inline-flex; align-items: center; gap: 6px; }
  svg { width: 14px; height: 14px; }
  a { color: var(--brand); }
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }
.dot.err { background: var(--danger); }
.dot.busy { background: var(--warning); animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .35; } }

.part-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 8px; }
.part-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
  transition: background-color .15s, border-color .15s;
  &:hover { border-color: color-mix(in oklch, var(--brand) 45%, var(--border)); }
  &[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
  &[aria-pressed="true"] .pc-num { background: color-mix(in oklch, var(--brand-contrast) 22%, transparent); color: inherit; }
  .pc-num { min-width: 34px; height: 24px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--surface-2); font-variant-numeric: tabular-nums; }
  .pc-count { font-weight: 500; opacity: .8; }
  &.empty { opacity: .65; }
}
.notice-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.notice-tools .search { flex: 1 1 280px; max-width: 420px; }

.part-group { margin-top: 28px; }
.part-group > h2 {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 17px;
  .doc-num { background: var(--brand); color: var(--brand-contrast); }
  a { margin-left: auto; font-size: 13px; font-weight: 600; text-decoration: none; }
}
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.notice-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: start;
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  &.is-new { border-color: color-mix(in oklch, var(--warning) 55%, var(--border)); box-shadow: inset 4px 0 0 var(--warning); }
  h3 { margin: 0; font-size: 15px; line-height: 1.35; }
  .nc-text { margin: 4px 0 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
  .nc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; }
  .nc-docs { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
}
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-weight: 600;
  &.new { background: color-mix(in oklch, var(--warning) 22%, transparent); color: light-dark(oklch(42% 0.12 60), oklch(85% 0.12 75)); }
  &.part { background: var(--brand-soft); color: var(--brand); }
}
.doc-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  &:hover { background: color-mix(in oklch, var(--brand) 20%, transparent); }
  svg { width: 14px; height: 14px; }
}
.empty-part { padding: 14px 18px; border-radius: var(--radius); border: 1px dashed var(--border); color: var(--muted); font-size: 14px; }
@media (max-width: 860px) {
  .notices-link span:not(.badge) { display: none; }
  .part-chip .pc-name { display: none; }
  .notice-card { grid-template-columns: minmax(0, 1fr); }
  .notice-card .nc-docs { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
}

/* ------------------------------------------------------------ dialog */
dialog {
  width: min(520px, calc(100vw - 24px));
  padding: 0; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgb(10 15 30 / .45);
  backdrop-filter: blur(3px);
  overflow: hidden;
  overscroll-behavior: contain;
}
dialog form { display: grid; gap: 16px; padding: 24px; }
.dialog-head {
  display: flex; gap: 14px; align-items: flex-start;
  h2 { margin: 0; font-size: 19px; }
  p { margin: 2px 0 0; font-size: 14px; }
}
.dialog-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; svg { width: 22px; height: 22px; } }
.export-items {
  list-style: none; margin: 0; padding: 8px; display: grid; gap: 4px;
  max-height: 160px; overflow-y: auto; border-radius: 12px; background: var(--surface-2); font-size: 13.5px;
  li { display: flex; gap: 8px; align-items: center; padding: 4px 6px; }
  .doc-num { min-width: 36px; height: 24px; font-size: 12px; background: var(--surface); }
}
.field {
  display: grid; gap: 6px; font-size: 14px; font-weight: 600;
  input {
    width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit; font-weight: 400;
    &:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
    &:user-invalid { border-color: var(--danger); }
  }
}
.input-suffix {
  display: flex; align-items: center;
  input { border-radius: 10px 0 0 10px; }
  span { height: 42px; display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--muted); font-weight: 500; }
}
.switch-row { align-items: flex-start; font-size: 14px; small { display: block; font-size: 12.5px; } input { margin-top: 3px; } }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 14px); translate: -50% 0; z-index: 60;
  padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .toc-card { position: static; max-height: 360px; order: -1; }
}
@media (max-width: 860px) {
  .sidebar-toggle { display: inline-grid; }
  .brand-text small { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: var(--topbar-h) auto 0 0; z-index: 25; width: min(360px, 88vw);
    translate: -100% 0; transition: translate .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { translate: 0 0; }
  .container { padding: 20px 16px 120px; }
  .hero { padding: 28px 22px; }
  .downloads-toggle span:not(.badge) { display: none; }
  .risk-banner { padding: 8px 14px; font-size: 12.5px; }
  .risk-text, .risk-schedule { display: none; }
  .selection-bar { gap: 10px; padding-left: 14px; .muted { display: none; } }
}
