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

:root {
  --primary: #003366;
  --primary-deep: #002244;
  --secondary: #0066CC;
  --accent: #FF6600;
  --bg: #f8f9fa;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #333333;
  --muted: #666666;
  --faint: #9CA3AF;
  --footer-text: #CCCCCC;
  --serif: 'Noto Serif JP', 'Hiragino Mincho ProN', serif;
  --sans: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
  --doc-font: var(--sans);
  --sidebar-w: 288px;
  --content-max: 76ch;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex: 1; }

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), box-shadow 0.25s;
}

#sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand { margin-bottom: 18px; text-align: left; }
.brand-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .35em;
  margin-right: -.35em;
  line-height: 1.2;
}
.brand-by {
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 4px;
}

#file-drop-zone {
  border: 1px dashed var(--secondary);
  border-radius: 6px;
  padding: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  background: var(--surface);
}

#file-drop-zone:hover, #file-drop-zone.drag-over {
  border-color: var(--primary);
  background: #F0F6FC;
}

#file-drop-zone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}

.drop-label { font-size: 12px; color: var(--muted); pointer-events: none; }
.drop-label strong { color: var(--primary); display: block; font-size: 13px; margin-bottom: 3px; font-weight: 600; }

#toc-wrapper { flex: 1; overflow-y: auto; padding: 16px 0; }
#toc-wrapper::-webkit-scrollbar { width: 4px; }
#toc-wrapper::-webkit-scrollbar-track { background: transparent; }
#toc-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

#toc-label {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint); padding: 0 20px 10px; font-weight: 600;
}

#toc { list-style: none; }

#toc li a {
  display: block; padding: 6px 20px; font-size: 13px;
  color: var(--muted); text-decoration: none;
  border-left: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  line-height: 1.45; word-break: break-word;
}

#toc li a:hover { color: var(--text); background: rgba(0,51,102,.04); }
#toc li a.active { color: var(--primary); border-left-color: var(--primary); background: rgba(0,51,102,.06); font-weight: 500; }

#toc li[data-level="2"] a { padding-left: 20px; }
#toc li[data-level="3"] a { padding-left: 32px; font-size: 12px; }
#toc li[data-level="4"] a { padding-left: 44px; font-size: 11px; }

#sidebar-footer {
  padding: 14px 20px 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--faint); flex-shrink: 0;
}

#filename-display {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted); margin-bottom: 3px; font-weight: 500;
}

#word-count-side { margin-bottom: 10px; }

#font-select-wrapper { margin-bottom: 12px; }
#font-select-label {
  display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 5px;
}
#font-select {
  width: 100%; font-family: var(--sans); font-size: 12px; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 5px 8px; background: var(--surface); cursor: pointer;
}
#font-select-note { font-size: 10px; color: var(--faint); margin-top: 5px; line-height: 1.5; }

#breaks-toggle-label {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 11px; color: var(--muted); cursor: pointer;
  margin-bottom: 10px; line-height: 1.5;
}
#breaks-toggle-label input { margin-top: 2px; accent-color: var(--primary); cursor: pointer; }

#sidebar-copyright { font-size: 10px; color: var(--faint); }

/* ── Main ─────────────────────────────────────────────── */
#main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

#topbar {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 11px 28px; display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 50;
}

#hamburger { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--muted); }

#topbar-title {
  font-size: 13px; color: var(--muted); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-btn {
  border-radius: 6px;
  padding: 6px 14px; font-size: 12px; cursor: pointer;
  font-family: var(--sans); transition: border-color .2s, color .2s, background .2s, box-shadow .2s;
  white-space: nowrap;
}

.ghost-btn {
  background: none; border: 1px solid var(--border-strong); color: var(--muted);
}
.ghost-btn:hover { border-color: var(--primary); color: var(--primary); }

.primary-btn {
  background: var(--primary); border: 1px solid var(--primary); color: #fff;
  box-shadow: 0 1px 3px rgba(0,51,102,.25);
  font-weight: 500;
}
.primary-btn:hover { background: #00284d; box-shadow: 0 2px 8px rgba(0,51,102,.3); }

#word-count { font-size: 11px; color: var(--faint); white-space: nowrap; }

#content-wrapper {
  flex: 1; padding: 48px 48px 96px;
  width: 100%;
  max-width: calc(var(--sidebar-w) + var(--content-max) + 96px);
  margin-left: auto; margin-right: auto;
}

/* ── Welcome hero ─────────────────────────────────────── */
#welcome {
  position: relative;
  min-height: 62vh;
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at 70% 20%, #0a3a66 0%, var(--primary) 45%, var(--primary-deep) 100%);
  padding: 40px 24px;
}

#welcome-sky {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.welcome-moon {
  position: absolute; top: 12%; right: 13%;
  width: 68px; height: 68px; border-radius: 50%;
  background: #F5F2E8; opacity: .9;
  box-shadow: 0 0 0 18px rgba(245,242,232,.12), 0 0 0 36px rgba(245,242,232,.07);
  pointer-events: none;
}
@media (max-width: 768px) {
  .welcome-moon { width: 44px; height: 44px; top: 8%; right: 10%; box-shadow: 0 0 0 12px rgba(245,242,232,.12), 0 0 0 24px rgba(245,242,232,.07); }
}

.welcome-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  max-width: 560px;
}

.welcome-title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(24px, 4vw, 30px);
  letter-spacing: .06em;
  color: #ffffff;
}

.welcome-sub {
  font-size: 13px; color: #B9C9DC; max-width: 46ch; line-height: 1.9;
}

.welcome-cta {
  margin-top: 4px; display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--primary);
  border-radius: 7px; padding: 12px 26px; font-size: 13px;
  cursor: pointer; font-family: var(--sans); font-weight: 600;
  transition: background .2s, color .2s;
  position: relative; overflow: hidden;
}
.welcome-cta input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.welcome-cta:hover { background: var(--accent); color: #fff; }

.welcome-sample-btn {
  background: none; border: 1px solid rgba(255,255,255,.55); color: #fff; opacity: .85;
  border-radius: 7px; padding: 10px 22px; font-size: 13px; cursor: pointer;
  font-family: var(--sans); transition: opacity .2s, border-color .2s, background .2s;
}
.welcome-sample-btn:hover { opacity: 1; border-color: #fff; background: rgba(255,255,255,.08); }

.welcome-note { font-size: 11px; color: #7E96AF; margin-top: 2px; }

/* ── Markdown paper card ──────────────────────────────── */
#md-output {
  font-family: var(--doc-font);
  font-size: 16.5px; line-height: 1.95; color: var(--text);
  max-width: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,34,68,.06);
  padding: 64px 72px;
  font-feature-settings: "palt";
}

#md-output h1, #md-output h2, #md-output h3,
#md-output h4, #md-output h5, #md-output h6 {
  color: var(--primary); scroll-margin-top: 80px;
}

#md-output h1 {
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  margin: 0 0 .8em; padding-bottom: .35em; border-bottom: 2px solid var(--primary);
  line-height: 1.35;
}

#md-output h2 {
  font-family: var(--serif); font-size: 23px; font-weight: 600;
  margin: 2em 0 .8em; padding-bottom: .3em; position: relative;
  border-bottom: 1px solid var(--border); line-height: 1.4;
}
#md-output h2::after {
  content: ''; position: absolute; left: 0; bottom: -1px; width: 56px; height: 2px; background: var(--primary);
}

#md-output h3 { font-family: var(--serif); font-size: 18.5px; font-weight: 600; color: #1A3A5C; margin: 1.7em 0 .55em; line-height: 1.4; }
#md-output h4 { font-family: var(--sans); font-size: 15px; font-weight: 700; color: #444; letter-spacing: .02em; margin: 1.5em 0 .45em; }
#md-output h5 { font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: var(--muted); margin: 1.4em 0 .4em; }
#md-output h6 { font-family: var(--sans); font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 1.4em 0 .4em; }

/* 本文フォントを変更した場合は見出しも合わせて追従させる（標準時は既存の明朝/ゴシック使い分けのまま） */
body.custom-doc-font #md-output h1, body.custom-doc-font #md-output h2, body.custom-doc-font #md-output h3,
body.custom-doc-font #md-output h4, body.custom-doc-font #md-output h5, body.custom-doc-font #md-output h6 {
  font-family: var(--doc-font);
}

#md-output p { margin: 0 0 1.2em; }

#md-output a {
  color: var(--secondary); text-decoration: none;
  border-bottom: 1px solid rgba(0,102,204,.35); transition: border-color .15s, color .15s;
}
#md-output a:hover { color: var(--accent); border-bottom-color: var(--accent); }

#md-output strong { font-weight: 700; color: #1F2937; }
#md-output em { font-style: italic; }

#md-output ul, #md-output ol { margin: 0 0 1.2em 1.6em; }
#md-output ul { list-style: none; }
#md-output ul li::before { content: '–'; color: var(--primary); position: absolute; margin-left: -1.4em; }
#md-output ul li.task::before { content: none; }
#md-output ul li, #md-output ol li { position: relative; margin-bottom: .45em; }
#md-output ol { list-style: decimal; }
#md-output ol li::marker { color: var(--primary); }
#md-output ul ul, #md-output ol ol, #md-output ul ol, #md-output ol ul { margin: .35em 0 .35em 1.6em; }

#md-output input[type=checkbox] { accent-color: var(--primary); margin-right: .5em; }

#md-output blockquote {
  margin: 1.6em 0; padding: .9em 1.3em; border-left: 3px solid var(--primary);
  background: #F4F7FA; border-radius: 0 6px 6px 0;
  color: #4B5563; font-style: normal;
}
#md-output blockquote p:last-child { margin-bottom: 0; }
#md-output blockquote blockquote { margin: .8em 0 0; }

#md-output hr {
  border: none; border-top: 1px solid var(--border); margin: 2.4em 0; position: relative;
  overflow: visible;
}
#md-output hr::after {
  content: '◆'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--primary); background: var(--surface); padding: 0 14px; font-size: 10px;
}

#md-output code:not(pre code) {
  font-family: var(--mono); font-size: .82em;
  background: #F1F5F9; border: 1px solid #E2E8F0;
  border-radius: 4px; padding: .15em .42em; color: #B45309;
}

.code-block-wrap {
  margin: 1.4em 0; border: 1px solid #E2E8F0;
  border-radius: 8px; overflow: hidden; background: #F8FAFC;
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; font-family: var(--mono); font-size: 11px;
  color: var(--muted); border-bottom: 1px solid #E2E8F0; background: #EEF2F7;
}

.copy-btn {
  background: var(--surface); border: 1px solid #E2E8F0; border-radius: 4px;
  padding: 2px 9px; font-size: 11px; color: var(--muted); cursor: pointer;
  font-family: var(--sans); transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.copy-btn.copied { color: #16794f; border-color: #16794f; }

#md-output pre { margin: 0; overflow-x: auto; background: #F8FAFC; }
#md-output pre code {
  display: block; padding: 1.1em 1.4em; font-family: var(--mono);
  font-size: 13.5px; line-height: 1.65; background: none; border: none; border-radius: 0; color: #334155;
}

.mermaid-block {
  margin: 1.6em 0; padding: 18px 14px;
  text-align: center; overflow-x: auto;
  background: #FBFCFE; border: 1px solid var(--border);
  border-radius: 8px;
}
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-block.mermaid-error {
  padding: 0; background: none; border: none; text-align: left;
}
.mermaid-error-note {
  margin-top: 8px; font-size: 12.5px; color: var(--muted);
  font-family: var(--sans); font-style: italic;
}

/* ── LaTeX数式（MathJax） ── */
.math-block { margin: 1.1em 0; text-align: center; overflow-x: auto; }
.math-block svg { max-width: 100%; height: auto; }
.math-inline svg { display: inline-block; }
.math-error-note {
  margin-top: 8px; font-size: 12.5px; color: var(--muted);
  font-family: var(--sans); font-style: italic;
}
.math-block.math-error, .math-inline.math-error { text-align: left; }

#md-output table {
  width: 100%; border-collapse: collapse; margin: 1.4em 0;
  font-family: var(--sans); font-size: 14px;
}
#md-output th {
  text-align: left; padding: 9px 14px; background: #EEF2F7;
  border-bottom: 2px solid var(--primary); color: var(--primary); font-weight: 600;
}
#md-output td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
#md-output tr:last-child td { border-bottom: none; }
#md-output tbody tr:hover td { background: rgba(0,51,102,.03); }

#md-output img { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); display: block; margin: 1.4em auto; }
#md-output figure { margin: 1.4em auto; text-align: center; }
#md-output figure img { margin: 0 auto; }
#md-output figcaption { font-size: 12px; color: var(--muted); margin-top: .6em; text-align: center; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

#lib-warning {
  display: none; background: #FFF4E5; border: 1px solid #FFD8A8;
  border-radius: 8px; padding: 13px 16px; margin-bottom: 26px;
  font-size: 13px; color: #8A5300; font-family: var(--sans); line-height: 1.6;
}

/* ── Print (fallback when SakuoliaPDF unavailable) ────── */
@media print {
  #sidebar, #topbar, #lib-warning, #welcome,
  #overlay, #export-modal-overlay { display: none !important; }
  #main { margin-left: 0 !important; }
  #content-wrapper { padding: 0 !important; max-width: 100% !important; }
  #app { display: block; }
  body { background: #fff; }
  #md-output {
    color: #000 !important; background: #fff !important; border: none !important;
    box-shadow: none !important; max-width: 100% !important; padding: 0 !important;
  }
  #md-output h1, #md-output h2, #md-output h3, #md-output h4, #md-output h5, #md-output h6 { color: #000 !important; }
  #md-output a { color: #000 !important; border-bottom: none !important; text-decoration: underline; }
}

/* ── Export modal ─────────────────────────────────────── */
#export-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,20,40,.5);
  align-items: center; justify-content: center; padding: 20px;
}
#export-modal-overlay.show { display: flex; }

#export-modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,20,40,.35);
  padding: 24px 28px 26px;
}

.export-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.export-modal-header h2 {
  font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--primary);
}
#export-modal-close {
  background: none; border: none; font-size: 22px; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 2px 6px;
}
#export-modal-close:hover { color: var(--primary); }

#export-pdf-missing-notice {
  background: #FFF4E5; border: 1px solid #FFD8A8; border-radius: 8px;
  padding: 10px 14px; font-size: 12px; color: #8A5300; margin-bottom: 16px; line-height: 1.6;
}

.export-section { margin-bottom: 20px; }
.export-section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.export-section-title {
  font-size: 13px; font-weight: 700; color: var(--text); display: block; margin-bottom: 10px;
}
.export-section-head .export-section-title { margin-bottom: 0; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px;
  cursor: pointer; transition: background .2s;
}
.switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

.cover-cards { display: flex; gap: 12px; }
.cover-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; padding: 8px; border: 2px solid var(--border); border-radius: 8px;
  transition: border-color .2s, opacity .2s;
}
.cover-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.cover-card:has(input:checked) { border-color: var(--primary); }
.cover-cards.disabled .cover-card { opacity: .4; pointer-events: none; }

.cover-mini { width: 92px; height: 128px; border-radius: 6px; position: relative; display: block; overflow: hidden; border: 1px solid var(--border); }
.cover-caption { font-size: 11px; color: var(--muted); }

.cover-mini-moonlight { background: linear-gradient(#002244,#003366); }
.cover-mini-moonlight .moon { position: absolute; top: 14px; right: 12px; width: 16px; height: 16px; border-radius: 50%; background: #F5F2E8; opacity: .9; }
.cover-mini-moonlight .bar { position: absolute; left: 18px; right: 18px; height: 3px; background: #fff; border-radius: 2px; }
.cover-mini-moonlight .b1 { top: 58px; opacity: .8; }
.cover-mini-moonlight .b2 { top: 68px; opacity: .4; }
.cover-mini-moonlight .b3 { top: 78px; opacity: .3; width: 60%; left: 20%; }

.cover-mini-classic { background: #fff; }
.cover-mini-classic .rule { position: absolute; left: 12px; right: 12px; height: 2px; background: var(--primary); }
.cover-mini-classic .rule.top { top: 14px; }
.cover-mini-classic .rule.bottom { bottom: 14px; }
.cover-mini-classic .title-bar { position: absolute; left: 22px; right: 22px; top: 58px; height: 3px; background: #333; border-radius: 2px; }
.cover-mini-classic .accent-bar { position: absolute; left: 40px; top: 70px; width: 12px; height: 2px; background: var(--accent); }

.cover-mini-minimal { background: #fff; }
.cover-mini-minimal .side-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.cover-mini-minimal .side-accent { position: absolute; left: 0; top: 0; width: 4px; height: 24px; background: var(--accent); }
.cover-mini-minimal .line { position: absolute; left: 16px; height: 3px; background: #333; border-radius: 2px; }
.cover-mini-minimal .line.l1 { top: 34px; width: 50px; }
.cover-mini-minimal .line.l2 { top: 44px; width: 34px; }

.export-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text); }
.export-row select {
  font-family: var(--sans); font-size: 12px; color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 5px 8px; background: #fff; cursor: pointer;
}

.export-checkbox {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text);
  margin-bottom: 8px; cursor: pointer;
}
.export-checkbox input { accent-color: var(--primary); cursor: pointer; }

.export-progress { margin: 6px 0 14px; }
.progress-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--primary); transition: width .25s; }
.progress-fill.indeterminate { width: 40% !important; animation: progress-indeterminate 1.2s ease-in-out infinite; }
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.progress-status { font-size: 12px; color: var(--muted); margin-top: 8px; }

.export-error { font-size: 12px; color: #B91C1C; margin: 0 0 14px; line-height: 1.6; }

.export-modal-footer { display: flex; gap: 10px; justify-content: flex-end; }
.export-modal-footer .topbar-btn { padding: 9px 18px; font-size: 13px; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 282px; }
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.15); }
  #main { margin-left: 0; }
  #hamburger { display: block; }
  #content-wrapper { padding: 28px 22px 60px; }
  #md-output { font-size: 16px; padding: 28px 22px; border-radius: 0; border-left: none; border-right: none; }
  .welcome-sub { font-size: 12.5px; }
  .cover-cards { gap: 8px; }
  .cover-mini { width: 72px; height: 100px; }
  #overlay { display: none; position: fixed; inset: 0; background: rgba(0,20,40,.35); z-index: 99; }
  #overlay.show { display: block; }
}
