:root {
  --fons: #f6f7f9;
  --virsma: #ffffff;
  --teksts: #1b1f24;
  --blāvs: #5f6b7a;
  --akcents: #1e5aa8;
  --akcents-teksts: #ffffff;
  --līnija: #dde2e8;
  --kļūda: #b42318;
  --iezīme: #fff0b3;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fons: #111418;
    --virsma: #1b2027;
    --teksts: #e8ecf1;
    --blāvs: #98a4b3;
    --akcents: #6aa3ef;
    --akcents-teksts: #0b1320;
    --līnija: #2c333d;
    --kļūda: #ff8a80;
    --iezīme: #4d4113;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--fons);
  color: var(--teksts);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

h1 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1;
  min-width: 0;
}

a {
  color: var(--akcents);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.josla {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.galvenā-poga {
  background: var(--akcents);
  color: var(--akcents-teksts);
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}

.teksta-poga {
  background: none;
  border: 0;
  color: var(--akcents);
  padding: 10px 8px;
  text-decoration: none;
}

.ikona {
  width: 26px;
  height: 26px;
  fill: currentColor;
  vertical-align: middle;
}

.atskaņot .ikona {
  width: 34px;
  height: 34px;
}

.teksta-poga.bīstama {
  color: var(--kļūda);
}

/* --- Pieteikšanās */

.pieteikšanās {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 15vh auto 0;
}

.pieteikšanās input {
  padding: 12px;
  border: 1px solid var(--līnija);
  border-radius: 10px;
  background: var(--virsma);
  color: var(--teksts);
}

/* --- Bibliotēka */

.saraksts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dokuments {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--virsma);
  border: 1px solid var(--līnija);
  border-radius: 12px;
  padding: 12px;
}

.dokumenta-teksts {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dokumenta-teksts a,
.dokumenta-teksts span {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dokumenta-teksts a {
  color: inherit;
  text-decoration: none;
}

small {
  color: var(--blāvs);
}

small.kļūda {
  color: var(--kļūda);
}

.progresa-josla {
  height: 4px;
  border-radius: 2px;
  background: var(--līnija);
  overflow: hidden;
}

.progresa-josla > div {
  height: 100%;
  background: var(--akcents);
}

.klausīties {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--akcents);
  color: var(--akcents-teksts);
}

.tukšs {
  color: var(--blāvs);
  text-align: center;
  margin-top: 20vh;
}

/* --- Atskaņotājs */

.atskaņotājs {
  background: var(--virsma);
  border: 1px solid var(--līnija);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 8px;
  z-index: 1;
}

.nodaļas-virsraksts {
  font-weight: 600;
  font-size: 1.1rem;
}

.slīdnis {
  width: 100%;
  accent-color: var(--akcents);
}

.laiki {
  display: flex;
  justify-content: space-between;
  color: var(--blāvs);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.vadība {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vadība button {
  background: none;
  border: 0;
  color: var(--teksts);
  min-width: 48px;
  min-height: 48px;
  border-radius: 24px;
  font-size: 1.05rem;
}

.vadība .atskaņot {
  background: var(--akcents);
  color: var(--akcents-teksts);
  min-width: 64px;
  min-height: 64px;
  border-radius: 32px;
  font-size: 1.5rem;
}

.atskaņot {
  position: relative;
}

/* Riņķis ap atskaņošanas pogu, kamēr audio ielādējas. */
.atskaņot.ielādē::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--akcents);
  animation: griezties 0.9s linear infinite;
}

@keyframes griezties {
  to {
    transform: rotate(360deg);
  }
}

.ātrums {
  background: none;
  border: 1px solid var(--līnija);
  border-radius: 16px;
  color: var(--teksts);
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
}

.papildu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--blāvs);
}

.nodaļu-izvēle {
  margin-top: 12px;
}

.nodaļu-izvēle summary {
  cursor: pointer;
  padding: 10px 4px;
  color: var(--akcents);
}

.nodaļas {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nodaļas button {
  display: flex;
  width: 100%;
  gap: 8px;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--līnija);
  color: var(--teksts);
  padding: 12px 4px;
}

.nodaļas button span:first-child {
  flex: 1;
}

.nodaļas button.aktīvā {
  color: var(--akcents);
  font-weight: 600;
}

.nodaļas small {
  font-variant-numeric: tabular-nums;
}

.lasīšana {
  font-size: 1.1rem;
  line-height: 1.65;
  padding: 8px 4px 40vh;
}

.lasīšana h2 {
  font-size: 1.3rem;
}

.lasīšana h3 {
  font-size: 1.1rem;
  margin-top: 1.4em;
}

.teikums {
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.teikums.pašreizējais {
  background: var(--iezīme);
  box-shadow: 0 0 0 2px var(--iezīme);
}

.blāvs {
  color: var(--blāvs);
}

/* --- Oriģinālās lapas skats */

dialog.oriģināls {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--fons);
  color: var(--teksts);
}

dialog.oriģināls::backdrop {
  background: rgb(0 0 0 / 0.6);
}

dialog.oriģināls header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid var(--līnija);
  height: 52px;
}

.oriģināla-ritjosla {
  height: calc(100% - 52px);
  overflow: auto;
}

.oriģināla-ritjosla img {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

/* Pieskāriens palielina; tad lapu var ritināt abos virzienos. */
.oriģināla-ritjosla img.palielināts {
  width: 200%;
  max-width: none;
  cursor: zoom-out;
}

#paziņojums {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--teksts);
  color: var(--fons);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 2;
}
