/* pixelfreund reader · pxl brand 3.1 (monochrome, Inter, dark by default) */
:root {
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Literata", "Iowan Old Style", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs: 19px;
  --measure: 34em;
  --bar: 56px;
  --r: 4px;
}
html[data-theme="dunkel"] { --ground:#000; --surface:#111; --chip:#1a1a1a; --line:#2a2a2a; --line2:#767676; --ink:#fff; --ink2:#c8c8c8; --muted:#8c8c8c; color-scheme: dark; }
html[data-theme="hell"]   { --ground:#fff; --surface:#f5f5f5; --chip:#efefef; --line:#dcdcdc; --line2:#767676; --ink:#0a0a0a; --ink2:#3d3d3d; --muted:#6b6b6b; color-scheme: light; }
html[data-theme="sepia"]  { --ground:#f4ecd8; --surface:#ebe1c8; --chip:#e4d8bb; --line:#d6c8a6; --line2:#7a6a4f; --ink:#2b2216; --ink2:#4a3d2a; --muted:#6e5f47; color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; transition: background .2s, color .2s; }
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ library */
.library { padding: 0 max(20px, 5vw) 64px; }
.lib-head { padding-top: 32px; max-width: 1280px; margin: 0 auto; }
.lib-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.lib-mast { font-size: clamp(88px, 21vw, 300px); font-weight: 900; letter-spacing: -.055em; line-height: .86;
  text-transform: uppercase; margin: 8px 0 24px -.04em; }
.lib-intro { max-width: 40em; font-size: 19px; line-height: 1.5; color: var(--ink2); margin: 0 0 64px; }
.library main, .continue { max-width: 1280px; margin: 0 auto; }
.shelf-title { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 16px; margin: 0 0 24px; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 40px 24px; }
.shelf.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 64px; }
.book { text-decoration: none; display: block; }
.book .cover { position: relative; aspect-ratio: 2 / 3; background: var(--surface); overflow: hidden;
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px rgba(0,0,0,.6); transition: transform .25s ease; }
.book .cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: linear-gradient(90deg, rgba(0,0,0,.35), transparent); z-index: 1; }
.book img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book:hover .cover, .book:focus-visible .cover { transform: translateY(-6px); }
.book .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); display: none; z-index: 2; }
.book .bar i { display: block; height: 100%; background: #fff; width: 0; }
.book.started .bar { display: block; }
.book .meta { padding-top: 14px; }
.book .k { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.book h2 { font-size: 18px; line-height: 1.22; font-weight: 700; letter-spacing: -.01em; margin: 6px 0 8px; }
.book .d { font-size: 14px; color: var(--muted); }
.lib-foot { max-width: 1280px; margin: 104px auto 0; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }

/* ------------------------------------------------------------ reader chrome */
.bar { position: fixed; inset: 0 0 auto 0; height: var(--bar); z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 0 12px; padding-top: env(safe-area-inset-top); background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); transition: transform .25s; }
.bar.hide { transform: translateY(-100%); }
.back { display: flex; align-items: center; gap: 4px; text-decoration: none; font-size: 15px; font-weight: 600; padding: 8px; border-radius: var(--r); }
.runhead { flex: 1; text-align: center; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink2); opacity: 0; transition: opacity .2s; }
.scrolled .runhead { opacity: 1; }
.tools { display: flex; gap: 4px; }
.tbtn { width: 40px; height: 40px; border: 0; background: none; border-radius: var(--r); cursor: pointer; display: grid; place-items: center; }
.tbtn:hover, .back:hover, .tbtn[aria-expanded="true"] { background: var(--chip); }
.aa { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); }

.panel { position: fixed; z-index: 30; top: calc(var(--bar) + 8px); right: 12px; width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - var(--bar) - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 20px 20px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
.panel h3 { margin: 0 0 16px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 7px 0; text-decoration: none; font-size: 15px; line-height: 1.35; border-bottom: 1px solid var(--line); }
.toc li.l3 a { padding-left: 16px; color: var(--ink2); font-size: 14px; }
.toc li.here > a { font-weight: 700; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.row > span { font-size: 14px; color: var(--ink2); }
.seg { display: flex; border: 1px solid var(--line2); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: none; padding: 7px 11px; font-size: 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.on { background: var(--ink); color: var(--ground); }
.downloads { display: grid; gap: 8px; }
.dl { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line2); border-radius: var(--r); text-decoration: none; font-size: 15px; }
.dl:hover { background: var(--chip); }
.fmt { font-family: var(--mono); font-weight: 700; font-size: 13px; min-width: 44px; }
.kindle { font-size: 14px; line-height: 1.5; color: var(--ink2); margin: 16px 0 0; }

/* ------------------------------------------------------------ text */
.viewport { padding: calc(var(--bar) + 40px) 20px 120px; }
.book-text { max-width: var(--measure); margin: 0 auto; font-size: var(--fs); line-height: 1.62; }
html[data-font="serif"] .book-text { font-family: var(--serif); line-height: 1.6; }
html[data-font="serif"] .book-text :is(h1, h2, h3, h4, .kicker, .byline, table, figcaption) { font-family: var(--sans); }
.opener { text-align: center; padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--line); }
.opener-cover { width: min(220px, 52vw); height: auto; aspect-ratio: 2 / 3; object-fit: cover; box-shadow: 0 24px 50px -24px rgba(0,0,0,.7); margin: 0 auto 32px; display: block; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.book-text h1 { font-size: clamp(32px, 5.4vw, 52px); line-height: 1.05; letter-spacing: -.03em; font-weight: 800; margin: 0 0 16px; }
.byline { font-size: 15px; color: var(--ink2); margin: 0; }
.player { margin-top: 24px; } .player audio { width: 100%; }
.book-text h2 { font-size: 1.35em; line-height: 1.2; letter-spacing: -.015em; margin: 2em 0 .6em; font-weight: 750; }
.book-text h3 { font-size: 1.08em; margin: 1.7em 0 .4em; font-weight: 700; }
.book-text p { margin: 0 0 1em; hyphens: auto; -webkit-hyphens: auto; }
.book-text :is(ul, ol) { padding-left: 1.3em; margin: 0 0 1em; }
.book-text li { margin: .25em 0; }
.book-text blockquote { hyphens: manual; -webkit-hyphens: manual; margin: 1.4em 0; padding: 0 0 0 1em; border-left: 3px solid var(--ink); font-size: 1.08em; color: var(--ink2); }
.book-text hr { border: 0; height: 1px; background: var(--line); width: 40%; margin: 2.2em auto; }
.book-text img { max-width: 100%; height: auto; display: block; margin: 1.4em auto; }
.book-text figure { margin: 1.6em 0; } .book-text figcaption { font-size: 14px; color: var(--muted); text-align: center; }
.book-text code { font-family: var(--mono); font-size: .84em; background: var(--chip); padding: .1em .3em; border-radius: 3px; }
.book-text pre { font-family: var(--mono); font-size: 13px; line-height: 1.45; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px; overflow-x: auto; margin: 1.4em 0; }
.book-text pre code { background: none; padding: 0; font-size: inherit; }
.table { overflow-x: auto; margin: 1.4em 0; }
.book-text table { border-collapse: collapse; font-family: var(--sans); font-size: 15px; line-height: 1.4; min-width: 100%; }
.book-text th, .book-text td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.book-text th { font-weight: 700; border-bottom: 1px solid var(--ink); }
.colophon { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink2); font-family: var(--sans); }
.colophon .credit { font-size: 13px; color: var(--muted); }
.downloads.end { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 24px 0; }
.back-lib a { text-decoration: none; font-weight: 600; }

.status { position: fixed; inset: auto 0 0 0; z-index: 15; display: flex; justify-content: space-between; padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); background: linear-gradient(transparent, var(--ground) 45%); pointer-events: none; }

/* ------------------------------------------------------------ paged mode */
html[data-mode="paged"], html[data-mode="paged"] body.reading { overflow: hidden; height: 100vh; height: 100dvh; overscroll-behavior: none; }
html[data-mode="paged"] .book-text hr { width: 30%; margin-left: 0; }
html[data-mode="paged"] .viewport { position: fixed; inset: var(--bar) 0 36px 0; padding: 32px 0 0; overflow: hidden; }
html[data-mode="paged"] .book-text { --gap: 64px; height: 100%; max-width: none; margin: 0; column-gap: var(--gap);
  column-fill: auto; transition: transform .35s cubic-bezier(.2,.7,.2,1); will-change: transform; }
html[data-mode="paged"] .book-text img, html[data-mode="paged"] .book-text pre, html[data-mode="paged"] .table { break-inside: avoid; max-height: 70vh; }
html[data-mode="paged"] .opener { break-after: column; border: 0; }
html[data-mode="paged"] .bar.hide { transform: none; }

@media (max-width: 640px) {
  :root { --fs: 18px; }
  .back span { display: none; }
  .viewport { padding-left: 20px; padding-right: 20px; }
  .shelf { grid-template-columns: repeat(2, 1fr); gap: 32px 16px; }
  .lib-intro { font-size: 17px; margin-bottom: 40px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .bar, .status, .panel, .downloads, .back-lib { display: none !important; }
  .viewport { padding: 0; }
}
