:root {
  --papir: #efe8d6;
  --tinta: #2c2418;
  --traka: #4a3b2a;
  --traka2: #6b5640;
  --linija: #d4c4a8;
  --priguseno: #7a6a54;
  --tipka: #4a3b2a;
  --tipka-tekst: #efe8d6;
  --font-citaj: Georgia, "Times New Roman", serif;
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --fs: 19px;
  --marg: 28px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
}
body {
  background: var(--papir);
  color: var(--tinta);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body.citam {
  overflow: hidden;
  height: 100dvh;
}

body.noc {
  --papir: #161410;
  --tinta: #d4c4a8;
  --traka: #0e0c0a;
  --traka2: #2a241c;
  --linija: #3a3228;
  --priguseno: #9a8a74;
  --tipka: #d4c4a8;
  --tipka-tekst: #161410;
}

body.bijela {
  --papir: #f7f4ee;
  --tinta: #1a1714;
  --linija: #e4ddd0;
}

#app { min-height: 100%; height: 100%; }

.ekran { min-height: 100%; height: 100%; display: flex; flex-direction: column; position: relative; overflow: hidden; }

.traka {
  background: var(--traka);
  color: #efe8d6;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 52px;
}
.traka h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.traka .tko { font-size: 12px; opacity: 0.75; }
.traka button, .dock button, .panel button, .login form button, .biblio-gumb {
  font: inherit;
  border: 0;
  background: var(--traka2);
  color: #efe8d6;
  padding: 8px 14px;
  cursor: pointer;
}
body.noc .traka button, body.noc .biblio-gumb { background: #2a241c; color: #d4c4a8; }

.login {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 24px;
}
.login h1 { font-size: 22px; margin-bottom: 8px; }
.login p { color: var(--priguseno); font-size: 14px; margin-bottom: 20px; line-height: 1.45; }
.login label { display: block; font-size: 12px; margin: 12px 0 4px; color: var(--priguseno); }
.login input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--linija);
  background: transparent;
  color: inherit;
}
.login form button { width: 100%; margin-top: 18px; padding: 12px; }
.login .err { color: #8b2e1a; font-size: 13px; margin-top: 10px; min-height: 1.2em; }

.mreza {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  padding: 18px;
}
.kartica {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.korice {
  aspect-ratio: 3 / 4.2;
  background: var(--traka);
  color: #efe8d6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--linija);
}
.korice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.korice .k-tekst {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 10px;
  font-size: 14px;
  line-height: 1.25;
}
.korice .k-naslov { font-weight: 600; }
.korice .k-autor { font-size: 11px; opacity: 0.75; margin-top: 6px; }
.kartica .meta { font-size: 12px; color: var(--priguseno); }
.kartica .naslov { font-size: 14px; line-height: 1.3; }
.jezik-sel {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--linija);
  background: transparent;
  color: inherit;
  padding: 4px 6px;
  width: 100%;
}
.postavke-biblio {
  position: absolute;
  top: 52px;
  right: 8px;
  z-index: 7;
  width: 320px;
  max-height: calc(100dvh - 64px);
  overflow: auto;
}
.panel .jezik-sel { width: auto; }
.panel .napomena {
  font-size: 11px;
  color: var(--priguseno);
  line-height: 1.35;
  margin-top: 8px;
}
.drive-blok {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--linija);
}
.drive-blok h2 {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--priguseno);
  margin-bottom: 6px;
}
.drive-blok input[type=text] {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--linija);
  background: transparent;
  color: inherit;
  margin-top: 8px;
}
.drive-blok > button {
  width: 100%;
  margin-top: 8px;
}
.drive-mape {
  list-style: none;
  margin: 8px 0 0;
}
.drive-mape li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin: 4px 0;
}
.drive-mape li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-mape button { width: auto; padding: 4px 8px; font-size: 12px; }
.sazetak {
  font-size: 13px;
  line-height: 1.45;
  color: var(--priguseno);
  padding: 8px 16px 12px;
}
.audio-sazetak {
  font-size: 13px;
  line-height: 1.4;
  color: var(--priguseno);
  max-width: 90%;
  max-height: 7.2em;
  overflow: hidden;
  text-align: center;
}
.traka-pct {
  height: 3px;
  background: var(--linija);
  margin-top: 4px;
}
.traka-pct > i { display: block; height: 100%; background: var(--traka); }

.filter-tip {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--linija);
  flex-shrink: 0;
}
.filter-tip button {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--linija);
  background: transparent;
  color: inherit;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-tip button .n { color: var(--priguseno); }
.filter-tip button.aktivan {
  background: var(--traka);
  color: #efe8d6;
  border-color: var(--traka);
}
.filter-tip button.aktivan .n { color: inherit; opacity: 0.75; }
body.noc .filter-tip button.aktivan { background: #2a241c; color: #d4c4a8; border-color: #2a241c; }

.polica { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.lista { padding: 0; }
.red {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--linija);
  cursor: pointer;
  min-height: 52px;
}
.red .ime { flex: 1; font-size: 16px; line-height: 1.3; min-width: 0; }
.red .broj, .red .rb {
  color: var(--priguseno);
  font-size: 13px;
  flex-shrink: 0;
}
.red .rb { width: 2.2em; text-align: right; }
.nastavak {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--linija);
}
.nastavak .jezik-sel { width: auto; }
.kartica .k-x {
  font: inherit;
  font-size: 12px;
  border: 0;
  background: transparent;
  color: var(--priguseno);
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.prazno { padding: 48px 24px; text-align: center; color: var(--priguseno); }

.citac {
  position: relative;
  flex: 1;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.citac:fullscreen, .citac:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--papir);
}
.platno {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.platno .epub-container,
.platno .epub-view,
.platno iframe {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  border: 0;
  display: block;
}
.platno.docx, .platno.pdf-wrap {
  overflow: hidden;
  padding: var(--marg);
  font-family: var(--font-citaj);
  font-size: var(--fs);
  line-height: 1.55;
}
.platno.docx p { margin: 0 0 0.8em; }
.platno.audio-platno {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px 110px;
  gap: 8px;
  pointer-events: none;
  z-index: 4;
}
.audio-cover {
  width: min(52vw, 240px);
  aspect-ratio: 3 / 4.2;
  object-fit: cover;
  border: 1px solid var(--linija);
}
.audio-ime {
  font-family: var(--font-citaj);
  font-size: 20px;
  text-align: center;
  max-width: 90%;
  line-height: 1.3;
}
.audio-tko { font-size: 13px; color: var(--priguseno); }
.audio-platno #rngSeek {
  pointer-events: auto;
  width: min(82vw, 380px);
  margin-top: 10px;
  z-index: 5;
}
.audio-vrijeme {
  width: min(82vw, 380px);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--priguseno);
}
.tap-l, .tap-d, .tap-c {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  cursor: pointer;
  touch-action: manipulation;
  background: transparent;
}
.tap-l { left: 0; width: 28%; }
.tap-d { right: 0; width: 28%; }
.tap-c { left: 28%; right: 28%; }

.chrome {
  position: absolute;
  left: 0; right: 0;
  z-index: 5;
  background: var(--traka);
  color: #efe8d6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.chrome.gore { top: 0; flex-wrap: wrap; }
.chrome.dolje { bottom: 0; font-size: 12px; }
.chrome button { background: transparent; color: inherit; border: 0; font: inherit; padding: 6px 8px; cursor: pointer; }
.chrome .naslov { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.skriveno { display: none !important; }

.dock {
  position: absolute;
  left: 0; right: 0;
  bottom: 40px;
  z-index: 6;
  background: var(--traka);
  color: #efe8d6;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.dock button { background: var(--traka2); }
.dock select {
  font: inherit;
  background: var(--traka2);
  color: #efe8d6;
  border: 0;
  padding: 6px;
}
.dock .status { flex: 1; font-size: 12px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel {
  position: absolute;
  top: 48px; right: 8px;
  z-index: 7;
  background: var(--papir);
  color: var(--tinta);
  border: 1px solid var(--linija);
  padding: 14px;
  width: 260px;
  font-size: 14px;
}
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.panel.postavke-biblio {
  width: 320px;
  max-height: calc(100dvh - 64px);
  overflow: auto;
}
.panel input[type=range] { width: 110px; }
.panel select {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--linija);
  background: transparent;
  color: inherit;
  padding: 4px 6px;
}
.ladica {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: min(320px, 86vw);
  background: var(--papir);
  z-index: 8;
  border-right: 1px solid var(--linija);
  overflow: auto;
  padding: 12px 0;
}
.ladica h2 { font-size: 13px; padding: 8px 16px; color: var(--priguseno); }
.ladica button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}
.ladica button:hover { background: var(--linija); }
.ladica button.aktivan { background: var(--linija); }
.ladica .ob-red {
  display: flex;
  align-items: stretch;
}
.ladica .ob-red > button:first-child { flex: 1; min-width: 0; }
.ladica .ob-x {
  width: auto;
  padding: 10px 14px;
  color: var(--priguseno);
}

.pdf-str { display: flex; justify-content: center; }
.pdf-str canvas { max-width: 100%; height: auto; }

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}
#overlay > * { pointer-events: auto; }
.ladica button.aktivan { background: var(--linija); }
.poglavlje-sel {
  margin-top: 8px;
  max-width: 90%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--linija);
  background: var(--papir);
  color: inherit;
  pointer-events: auto;
}
.audio-platno input,
.audio-platno select { pointer-events: auto; }

.err-toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: #4a3b2a;
  color: #efe8d6;
  padding: 12px;
  font-size: 13px;
  z-index: 20;
}
