:root {
  --bg: #1f2226;
  --bar: #15171a;
  --panel: #1a1d21;
  --line: #2e3238;
  --fg: #eceef0;
  --muted: #9aa1a9;
  --accent: #e3001b;
  --paper: #fbfbf9;
  --field: #0000004d;
  --barh: 52px;
  --bottomh: 34px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--barh) 1fr var(--bottomh);
  height: 100dvh;
}
button, input { font: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- zgornja vrstica ---- */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px; background: var(--bar); border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand {
  flex: 1 1 0; min-width: 0; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 10px; border-left: 3px solid var(--accent);
  color: inherit; text-decoration: none;
}
.nav { display: flex; align-items: center; gap: 4px; }
.tools { flex: 1 1 0; display: flex; justify-content: flex-end; gap: 2px; }
.ico {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--fg);
}
.ico:hover { background: var(--hover, #ffffff14); }
.ico:focus-visible, .edge:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ico[aria-pressed="true"] { background: #ffffff1f; }
.ico:disabled { opacity: .35; cursor: default; background: transparent; }
.ico svg, .edge svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pageno { display: flex; align-items: center; gap: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
#pageInput {
  width: 64px; height: 32px; text-align: center; border-radius: 6px;
  background: var(--field); border: 1px solid var(--line); color: var(--fg);
}

/* ---- oder ---- */
.stage { position: relative; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.book {
  position: absolute; left: 50%; top: 50%;
  perspective: 2600px;
  transition: transform .6s cubic-bezier(.4, .1, .2, 1);
}
.book.noanim { transition: none; }
.slot { position: absolute; top: 0; width: var(--pw); height: var(--ph); }
.slot.left { left: 0; }
.slot.right { left: var(--pw); }
.book.single .slot.left { display: none; }
.book.single .slot.right { left: 0; }
.slot:not(:empty) { box-shadow: 0 10px 30px #0008; }

.page { position: absolute; inset: 0; background: var(--paper); overflow: hidden; }
.page img { width: 100%; height: 100%; display: block; object-fit: cover; -webkit-user-drag: none; pointer-events: none; }
.page.paper { background: linear-gradient(90deg, #e9e9e4, var(--paper) 12%); }
/* senca ob hrbtu */
.slot.left .page::after, .slot.right .page::after, .face .page::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none;
}
.slot.left .page::after { right: 0; background: linear-gradient(270deg, #0000002e, #0000 100%); }
.slot.right .page::after { left: 0; background: linear-gradient(90deg, #0000002e, #0000 100%); }
.book.single .slot.right .page::after { display: none; }

.hot {
  position: absolute; border-radius: 3px; cursor: pointer;
  background: #ffd40000; transition: background .15s;
}
.hot:hover, .hot:focus-visible { background: #ffd4003d; outline: none; box-shadow: 0 0 0 2px #ffd400aa; }
.hot.toc { border-radius: 50%; }
.book.flipping .hot { pointer-events: none; }

/* list, ki se obrača */
.leaf {
  position: absolute; top: 0; left: var(--pw); width: var(--pw); height: var(--ph);
  transform-origin: 0 50%; transform-style: preserve-3d; z-index: 5; will-change: transform;
}
.book.single .leaf { left: 0; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); }
.face .shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.face.front .shade { background: linear-gradient(90deg, #0000 40%, #0006); }
.face.back .shade { background: linear-gradient(270deg, #0000 40%, #0006); }
.face.front .page::after { left: 0; background: linear-gradient(90deg, #0000002e, #0000); }
.face.back .page::after { right: 0; background: linear-gradient(270deg, #0000002e, #0000); }

.edge {
  position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 88px;
  border: 0; border-radius: 10px; background: #0000; color: var(--muted); cursor: pointer; z-index: 6;
}
.edge:hover { background: #ffffff10; color: var(--fg); }
.edge.prev { left: 6px; } .edge.next { right: 6px; }
.edge[disabled] { visibility: hidden; }

.hint {
  position: absolute; left: 50%; bottom: 10px; translate: -50% 0; margin: 0;
  padding: 6px 12px; border-radius: 999px; background: #000a; color: var(--fg); font-size: 13px;
  pointer-events: none; transition: opacity .6s; white-space: nowrap;
}
.hint.gone { opacity: 0; }

/* ---- drsnik ---- */
.bottom { display: flex; align-items: center; padding: 0 16px; }
#slider { width: 100%; accent-color: var(--accent); cursor: pointer; }

/* ---- stranski panel ---- */
.panel {
  position: fixed; top: var(--barh); bottom: 0; left: 0; width: min(360px, 100vw);
  background: var(--panel); border-right: 1px solid var(--line); z-index: 30;
  display: flex; flex-direction: column; box-shadow: 10px 0 40px #0007;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; }
.panel h2 { font-size: 15px; margin: 0; font-weight: 600; }
.thumbs { overflow-y: auto; padding: 4px 16px 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; }
.thumbs button {
  border: 0; padding: 0; background: none; cursor: pointer; color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.thumbs img { width: 100%; aspect-ratio: var(--ratio-inv); object-fit: cover; background: #333; border: 2px solid transparent; border-radius: 2px; }
.thumbs button:hover img { border-color: #fff6; }
.thumbs button.cur img { border-color: var(--accent); }
.thumbs button.cur { color: var(--fg); }

#q {
  margin: 0 16px; height: 38px; padding: 0 12px; border-radius: 8px;
  background: var(--field); border: 1px solid var(--line);
}
.count { margin: 10px 16px 4px; color: var(--muted); font-size: 13px; min-height: 18px; }
.results { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; }
.results button {
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 8px; border-radius: 8px; display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start;
}
.results button:hover, .results button:focus-visible { background: #ffffff10; }
.results img { width: 44px; border-radius: 2px; }
.results b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.results span { font-size: 13px; color: var(--fg); opacity: .85; }
.results mark { background: #ffd400; color: #000; border-radius: 2px; padding: 0 1px; }

/* ---- povečava ---- */
.zoom { position: fixed; inset: 0; background: #0d0e10f2; z-index: 40; }
.zoom[hidden] { display: none; }
.zoom-bar {
  position: absolute; top: 10px; right: 12px; z-index: 2; display: flex; gap: 2px; padding: 4px;
  background: #fff; border-radius: 999px; box-shadow: 0 6px 24px #0006;
}
.zoom-bar .ico { color: #15171a; }
.zoom-bar .ico:hover { background: #0000000f; }
.zoom-scroll { cursor: zoom-out; }
.zoom-scroll { position: absolute; inset: 0; overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.zoom-pages { display: flex; gap: 0; width: max-content; min-width: 100%; min-height: 100%; align-items: center; justify-content: center; padding: 56px 16px 16px; }
.zoom-pages img { display: block; height: var(--zh); width: auto; cursor: zoom-in; background: var(--paper); }
.zoom.big .zoom-pages img { cursor: zoom-out; }

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; }
.noscript a { color: #fff; }

@media (max-width: 640px) {
  :root { --barh: 50px; }
  .bar { gap: 4px; padding: 0 6px; }
  .brand { display: none; }
  .nav { flex: 1; }
  .hide-sm { display: none; }
  .edge { display: none; }
  .tools { flex: 0 0 auto; }
  .ico { width: 36px; }
  #pageInput { width: 52px; }
  .panel { width: 100vw; }
}
/* ---- vgrajeno v stran (?embed) ---- */
html.embed {
  --bg: transparent; --bar: #fff; --panel: #fff; --line: #e4e4e4; --fg: #15171a; --muted: #6b7078;
  --field: #f1f1f1; --hover: #0000000d; color-scheme: light;
}
html.embed body { grid-template-rows: 1fr auto; }
html.embed .stage { grid-row: 1; }
html.embed .bar {
  grid-row: 2; justify-self: center; height: 52px; margin: 4px 0 12px; padding: 0 8px; gap: 8px;
  border: 0; border-radius: 999px; box-shadow: 0 8px 24px #00000014, 0 0 0 1px #0000000a;
}
html.embed .brand, html.embed .bottom { display: none; }
html.embed .nav, html.embed .tools { flex: 0 0 auto; }
html.embed .tools { padding-left: 8px; border-left: 1px solid var(--line); }
html.embed #pageInput { border-color: transparent; }
html.embed .slot:not(:empty) { box-shadow: 0 14px 34px #0000002e; }
html.embed .edge { color: #15171a99; }
html.embed .edge:hover { background: #0000000a; color: #15171a; }
html.embed .panel {
  top: 8px; bottom: 76px; left: 8px; width: min(360px, calc(100vw - 16px));
  border: 0; border-radius: 18px; box-shadow: 0 12px 40px #0000002e;
}
html.embed .hint { bottom: 14px; }

@media (prefers-reduced-motion: reduce) { .book { transition: none; } }
