@font-face{font-family:"Atkinson Hyperlegible Next";font-style:normal;font-weight:400;font-display:swap;src:url("/theme/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2")}
@font-face{font-family:"Atkinson Hyperlegible Next";font-style:normal;font-weight:700;font-display:swap;src:url("/theme/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2")}

:root {
  --bg: #0c0e11;
  --page: #111317;
  --surface: #181b21;
  --surface-2: #20242c;
  --line: #2c3038;
  --ink: #e6e1d5;
  --muted: #8f8b80;
  --accent: #c8a45a;
  --accent-ink: #17130a;
  --danger: #e0705f;
  --radius: 14px;
  --ui: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: 0 1.1em; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: transparent; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bibliothek ---------- */
#library { max-width: 1180px; margin: 0 auto; padding: 0 20px 80px; }
.lib-head { display: flex; align-items: center; gap: 12px; padding: 22px 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand svg { width: 34px; height: 34px; }
.brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: .01em; }
.section-label { margin: 34px 0 14px; font-size: .78rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }

.hero { display: grid; grid-template-columns: 132px 1fr; gap: 22px; align-items: center; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, #1b1e25, #14161b); text-align: left; width: 100%; }
.hero:hover { border-color: #4a4433; }
.hero img, .hero .cover-fallback { width: 132px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.hero h2 { margin: 0 0 4px; font-size: 1.55rem; line-height: 1.2; }
.hero .author { color: var(--muted); }
.hero .where { margin: 14px 0 10px; color: var(--ink); }
.hero .cta { display: inline-flex; margin-top: 14px; }

.bar { height: 5px; border-radius: 3px; background: #2a2e36; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 26px 20px; }
.card { position: relative; }
.card .open { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.card img, .cover-fallback { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,.45); transition: transform .15s ease; }
.cover-fallback { display: grid; place-items: center; padding: 14px; text-align: center; font-weight: 700; color: var(--accent); border: 1px solid var(--line); }
.card .open:hover img, .card .open:hover .cover-fallback { transform: translateY(-3px); }
.card h3 { margin: 12px 0 2px; font-size: 1rem; line-height: 1.25; }
.card .author { font-size: .85rem; color: var(--muted); }
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.card .meta .bar { flex: 1; }
.card .more { position: absolute; top: 6px; right: 6px; background: rgba(12,14,17,.72); backdrop-filter: blur(6px); }
.badge { font-size: .7rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.empty { margin-top: 30px; padding: 54px 24px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.2rem; margin-bottom: 6px; }
body.dragging #library { outline: 3px dashed var(--accent); outline-offset: -10px; }

/* ---------- Menues, Dialoge, Hinweise ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.sheet { width: min(420px, 100%); max-height: 86vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.sheet h2 { margin: 0 0 4px; font-size: 1.15rem; }
.sheet p { margin: 6px 0 16px; color: var(--muted); }
.sheet .actions { display: grid; gap: 10px; }
.sheet .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px; background: #2a2e36; border: 1px solid #3a3f49; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-weight: 700; }
.toast.error { border-color: var(--danger); color: #ffd9d2; }

/* ---------- Reader ---------- */
#reader { background: var(--page); min-height: 100vh; }
.r-top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 8px; padding-top: env(safe-area-inset-top); background: rgba(17,19,23,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); transition: transform .22s ease; }
.r-top.hide { transform: translateY(-110%); }
.r-title { flex: 1; min-width: 0; padding: 0 6px; }
.r-title b { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-title span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-body { padding-top: 56px; }
#frame { display: block; width: 100%; border: 0; min-height: 60vh; background: var(--page); }
.r-nav { display: flex; gap: 12px; justify-content: space-between; max-width: 39em; margin: 0 auto; padding: 10px 20px 90px; }
.r-nav .btn { flex: 1; max-width: 48%; overflow: hidden; }
.r-nav .btn span { overflow: hidden; text-overflow: ellipsis; }
.r-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding-bottom: env(safe-area-inset-bottom); background: rgba(17,19,23,.9); backdrop-filter: blur(10px); transition: transform .22s ease; }
.r-foot.hide { transform: translateY(110%); }
.r-foot .bar { height: 3px; border-radius: 0; }
.r-foot .info { display: flex; justify-content: space-between; gap: 12px; padding: 6px 16px 8px; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.panel { position: fixed; z-index: 30; top: 0; bottom: 0; right: 0; width: min(380px, 92vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -20px 0 60px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.panel header h2 { margin: 0; font-size: 1.05rem; }
.panel .scroll { overflow: auto; padding: 8px 8px 30px; }
.toc-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; line-height: 1.3; }
.toc-item:hover { background: var(--surface-2); }
.toc-item.current { color: var(--accent); font-weight: 700; }
.set { padding: 14px 12px; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set label { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); }
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 30px; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.login h1 { margin: 12px 0 4px; font-size: 1.5rem; }
.login p { margin: 0 0 20px; color: var(--muted); }
.login input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); margin-bottom: 14px; }
.login .btn { width: 100%; }
.login .err { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; }

@media (max-width: 560px) {
  #library { padding: 0 14px 70px; }
  .hero { grid-template-columns: 96px 1fr; gap: 16px; padding: 14px; }
  .hero img, .hero .cover-fallback { width: 96px; }
  .hero h2 { font-size: 1.2rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 22px 14px; }
  .btn .wide { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
