:root {
  --paper: #faf6f0; --card: #ffffff; --ink: #231d18; --muted: #7d7166; --line: #e8dfd4;
  --accent: #b4462e; --accent-ink: #ffffff; --accent-soft: #f6e1d8; --hl: #fbe3a6; --ok: #3d7a4f; --err: #a33a2c;
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1714; --card: #24201c; --ink: #ece4d8; --muted: #a8998a; --line: #3a332c;
    --accent: #e0876c; --accent-ink: #1b1714; --accent-soft: #3d2a22; --hl: #5a4720; --ok: #7cc28f; --err: #f08c7c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); }
img, svg { max-width: 100%; }
button, select, input, textarea { font: inherit; color: inherit; }

/* header / footer */
.site-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1120px; margin: 0 auto; padding: 18px 20px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  font: 700 24px/1 Georgia, var(--serif); letter-spacing: -0.4px; }
.logo svg { width: 32px; height: 32px; }
.logo b { color: var(--accent); font-weight: 700; }
.site-nav { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 14.5px; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--accent); }
.site-foot { border-top: 1px solid var(--line); margin-top: 64px; color: var(--muted); font-size: 14px; }
.site-foot .in { max-width: 1120px; margin: 0 auto; padding: 28px 20px 40px; display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.site-foot h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 8px; color: var(--ink); }
.site-foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

main { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font: 700 clamp(30px, 5vw, 50px)/1.1 Georgia, var(--serif); letter-spacing: -0.8px; margin: 0 auto 14px; max-width: 18ch; }
.hero .lede { color: var(--muted); font-size: clamp(16px, 2vw, 19px); max-width: 62ch; margin: 0 auto; }

/* intake */
.bv-app { max-width: 820px; margin: 26px auto 0; }
.bv-reading .bv-app { max-width: 1120px; margin-top: 0; }
.bv-drop { border: 2px dashed var(--line); border-radius: 18px; background: var(--card); padding: 44px 24px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.bv-drop:hover, .bv-drop:focus-visible, .dragging .bv-drop { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dragging .bv-drop { transform: scale(1.01); }
.bv-drop svg { width: 54px; height: 54px; color: var(--accent); }
.bv-drop-title { font: 600 21px/1.3 Georgia, var(--serif); margin: 10px 0 8px; }
.bv-drop-sub { margin: 0; color: var(--muted); }
.bv-trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.bv-trust span::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.bv-status { min-height: 1.5em; text-align: center; margin: 12px 0 0; }
.bv-status.error { color: var(--err); }
.bv-status.busy::before, .bv-note.busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.bv-btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 18px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; text-decoration: none; }
.bv-btn:hover { filter: brightness(1.07); }
.bv-btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.bv-btn.small { padding: 6px 12px; font-size: 14px; }
.bv-link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.bv-lib-h { font: 600 18px/1.3 Georgia, var(--serif); margin: 30px 0 10px; }
.bv-lib { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bv-lib li { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.bv-lib a { flex: 1; text-decoration: none; color: var(--ink); display: grid; min-width: 0; }
.bv-lib a b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bv-lib a span { color: var(--muted); font-size: 13.5px; }
.bv-lib a:hover b { color: var(--accent); }
.bv-lib-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* reader */
.bv-reading .bv-content { display: none; }
.bv-top { padding: 8px 0 6px; }
.bv-back { color: var(--muted); text-decoration: none; font-size: 14.5px; }
.bv-back:hover { color: var(--accent); }
.bv-title { font: 700 clamp(26px, 4vw, 38px)/1.15 Georgia, var(--serif); margin: 8px 0 4px; }
.bv-sub { color: var(--muted); margin: 0 0 12px; }
.bv-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; align-items: start; }
.bv-toc { position: sticky; top: 12px; max-height: calc(100vh - 200px); overflow: auto; font-size: 14.5px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.bv-toc summary { font-weight: 600; cursor: pointer; padding: 4px; }
.bv-toc ol { list-style: none; padding: 0; margin: 4px 0 0; }
.bv-toc li { display: flex; align-items: center; gap: 6px; border-radius: 8px; padding: 2px 4px; }
.bv-toc li.current { background: var(--accent-soft); }
.bv-toc li.skipped button { color: var(--muted); text-decoration: line-through; }
.bv-toc li button { flex: 1; text-align: left; border: 0; background: none; padding: 5px 2px; cursor: pointer; line-height: 1.35; }
.bv-toc li button:hover { color: var(--accent); }
.bv-dur { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.bv-page { font: 19px/1.8 var(--serif); max-width: 68ch; padding-bottom: 220px; }
.bv-page p { margin: 0 0 1.05em; }
.bv-h { font: 700 26px/1.3 Georgia, var(--serif); margin: 0 0 18px; }
.bv-ck { cursor: pointer; border-radius: 4px; transition: background-color .2s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.bv-ck:hover { background: color-mix(in srgb, var(--hl) 45%, transparent); }
.bv-ck.on { background: var(--hl); }

/* player */
.bv-player { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(1080px, calc(100vw - 20px));
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 34px rgba(30, 20, 10, .18);
  padding: 0 14px 10px; z-index: 20; }
.bv-bar { height: 4px; background: var(--line); border-radius: 0 0 4px 4px; margin: 0 -14px 8px; overflow: hidden; }
.bv-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.bv-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; }
.bv-transport { display: flex; align-items: center; gap: 4px; }
.bv-transport button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.bv-transport button svg { width: 22px; height: 22px; fill: currentColor; }
.bv-transport button:hover { background: var(--accent-soft); }
.bv-transport .bv-play { width: 54px; height: 54px; background: var(--accent); color: var(--accent-ink); }
.bv-transport .bv-play:hover { background: var(--accent); filter: brightness(1.08); }
.bv-transport .bv-play svg { width: 28px; height: 28px; }
.bv-options { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.bv-sel { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.bv-sel select { max-width: 260px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); padding: 7px 8px; font-size: 14px; }
.bv-dl { position: relative; }
.bv-dl summary { list-style: none; cursor: pointer; border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 14px; font-weight: 600; }
.bv-dl summary::-webkit-details-marker { display: none; }
.bv-dl summary:hover { border-color: var(--accent); color: var(--accent); }
.bv-dl-menu { position: absolute; right: 0; bottom: calc(100% + 8px); width: 290px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 26px rgba(30, 20, 10, .16); padding: 8px; display: grid; gap: 4px; }
.bv-dl-menu button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.bv-dl-menu button:hover { background: var(--accent-soft); }
.bv-dl-menu p { margin: 4px 10px 6px; font-size: 12.5px; color: var(--muted); }
.bv-note { font-size: 14px; color: var(--muted); padding-top: 6px; min-height: 0; }
.bv-note:empty { display: none; }
.bv-note.error { color: var(--err); }
.bv-note.ask { color: var(--ink); }
.bv-actions { display: inline-flex; gap: 8px; margin-left: 8px; vertical-align: middle; }
.bv-mini { display: block; height: 4px; background: var(--line); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bv-mini i { display: block; height: 100%; background: var(--accent); }

/* paste dialog */
.bv-dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); width: min(640px, calc(100vw - 32px)); padding: 22px; }
.bv-dialog::backdrop { background: rgba(20, 14, 8, .45); }
.bv-dialog h2 { margin: 0 0 12px; font: 600 21px/1.3 Georgia, var(--serif); }
.bv-dialog label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.bv-dialog input, .bv-dialog textarea { border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); padding: 10px; color: var(--ink); }
.bv-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* content */
.prose { max-width: 760px; margin: 52px auto 0; }
.prose h2 { font: 700 27px/1.25 Georgia, var(--serif); margin: 44px 0 12px; }
.prose h3 { font: 600 19px/1.35 Georgia, var(--serif); margin: 26px 0 8px; }
.prose p, .prose li { color: var(--ink); }
.prose .muted { color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--muted); font-size: 15px; }
.step b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 16px; }
.compare { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 15px; margin: 14px 0; }
.compare th, .compare td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.compare thead th { border-top: 0; background: var(--accent-soft); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 8px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 8px 0 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 12px 0; }
.cards a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--ink); }
.cards a span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.cards a:hover { border-color: var(--accent); }
.tip { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; margin: 16px 0; }
.crumbs { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.crumbs a { color: var(--muted); }
.article h1 { font: 700 clamp(28px, 4.5vw, 42px)/1.15 Georgia, var(--serif); margin: 10px 0 10px; }
.article .prose { margin-top: 18px; }
.cta-box { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 18px; margin: 26px 0; }

@media (max-width: 860px) {
  .bv-grid { grid-template-columns: 1fr; }
  .bv-toc { position: static; max-height: none; }
  .bv-toc details:not([open]) { padding-bottom: 0; }
  .bv-page { font-size: 18px; }
  .bv-controls { justify-content: center; }
  .bv-options { justify-content: center; }
  .bv-sel span { display: none; }
  .bv-sel select { max-width: 46vw; }
  .bv-dl-menu { right: auto; left: 50%; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
