:root {
  color-scheme: dark;
  --navy: #050d18;
  --panel: #111827;
  --panel-2: #172033;
  --gold: #d8b35a;
  --text: #f8fafc;
  --muted: #aeb9c9;
  --danger: #f87171;
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 0 20px;
  color: #08111f;
  background: var(--gold);
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
}

button.ghost {
  min-height: 42px;
  color: var(--text);
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid var(--border);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 14px;
}

input::placeholder {
  color: var(--muted);
}

select {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color-scheme: dark;
}

select option {
  background: var(--panel);
  color: var(--text);
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 36px);
}

.topbar img {
  width: min(210px, 46vw);
  height: auto;
  cursor: pointer;
}

.account {
  color: var(--gold);
  font-weight: 800;
  white-space: nowrap;
}

.screen {
  width: min(980px, 100%);
  margin: 0 auto;
  flex: 1;
  padding: 14px 16px 118px;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
}

.auth-logo {
  width: min(300px, 72vw);
  margin: 0 auto 22px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row > * {
  flex: 1;
}

.phone-grid {
  display: grid;
  grid-template-columns: 0.7fr 0.9fr 1.4fr;
  gap: 10px;
}

.play-link {
  display: block;
  text-align: center;
  color: var(--gold);
  font-weight: 800;
  text-decoration: none;
  padding: 8px;
}

.play-link:hover {
  text-decoration: underline;
}

.home-logo {
  display: block;
  width: min(420px, 82vw);
  margin: 22px auto 36px;
}

.menu-grid {
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  margin: 0 auto;
  padding-bottom: 118px;
}

.jatanium-menu-button {
  display: grid;
  place-items: center;
  min-height: 52px;
  background: #000;
  border: 1px solid var(--border);
}

.jatanium-menu-button img {
  display: block;
  width: min(220px, 68%);
  max-height: 44px;
  object-fit: contain;
}

.notice {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
}

.subscription-gate {
  display: grid;
  gap: 18px;
}

.subscription-gate button {
  justify-self: start;
}

.error {
  color: var(--danger);
  min-height: 24px;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin: 8px 0 18px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.media-status {
  margin-bottom: 14px;
}

.media-list,
.book-list {
  display: grid;
  gap: 10px;
}

.item-button {
  width: 100%;
  min-height: 68px;
  text-align: left;
  display: block;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
}

.item-title {
  display: block;
  font-size: 17px;
  font-weight: 800;
}

.item-meta {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.status-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px 56px;
  align-items: center;
  gap: 8px;
  margin: 18px 0 12px;
}

.status-pager .message {
  margin: 0;
}

.status-pager .button {
  min-height: 48px;
  padding: 0;
}

.ad-slot {
  width: min(720px, calc(100vw - 32px));
  min-height: 90px;
  margin: 12px auto;
  display: grid;
  place-items: center;
  overflow: visible;
}

.video-ad-slot {
  width: min(420px, calc(100vw - 32px));
  min-height: 260px;
  margin: 14px auto 18px;
  display: grid;
  place-items: center;
}

.radio-box {
  width: min(720px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  padding: 18px;
}

.radio-title {
  font-size: 22px;
  font-weight: 900;
}

.radio-box audio {
  width: 100%;
}

.radio-ad-slot {
  width: min(300px, calc(100vw - 32px));
  min-height: 300px;
  margin: 26px auto 0;
  display: grid;
  place-items: center;
  overflow: visible;
}

.broadcast-ad-slot {
  width: min(300px, calc(100vw - 32px));
  min-height: 300px;
  margin: 26px auto 0;
  display: grid;
  place-items: center;
  overflow: visible;
}

.book-ad-slot {
  width: min(300px, calc(100vw - 32px));
  min-height: 300px;
  margin: 4px auto 18px;
  display: grid;
  place-items: center;
  overflow: visible;
}

.player-page {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-box {
  position: relative;
  flex: 1;
  width: min(1180px, 100%);
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 150px);
  min-height: 260px;
  margin: 0 auto;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}

.player-box video,
.player-box img,
.player-box audio {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-box.broadcast video {
  object-fit: contain;
}

.overlay-logo {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  width: min(160px, 38vw);
  min-height: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(5, 13, 24, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay-logo.visible,
.overlay-logo:hover {
  opacity: 0.78;
  pointer-events: auto;
}

.overlay-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.overlay-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
}

.reader-page {
  min-height: calc(100dvh - 82px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reader-controls {
  display: none;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reader-controls.visible {
  display: grid;
}

.reader-frame {
  flex: 1;
  min-height: 70dvh;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.control-toggle {
  position: fixed;
  z-index: 20;
  top: 12px;
  right: 12px;
}

.site-ad {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px));
  min-height: 90px;
  display: grid;
  place-items: center;
  pointer-events: auto;
  overflow: visible;
}

.ad-slot [data-sorpentor-ad-slot],
.site-ad [data-sorpentor-ad-slot],
.video-ad-slot [data-sorpentor-ad-slot],
.radio-ad-slot [data-sorpentor-ad-slot],
.broadcast-ad-slot [data-sorpentor-ad-slot],
.book-ad-slot [data-sorpentor-ad-slot] {
  overflow: visible;
}

.ad-slot a[href*="marketing.jastorm.com"],
.site-ad a[href*="marketing.jastorm.com"],
.video-ad-slot a[href*="marketing.jastorm.com"],
.radio-ad-slot a[href*="marketing.jastorm.com"],
.broadcast-ad-slot a[href*="marketing.jastorm.com"],
.book-ad-slot a[href*="marketing.jastorm.com"] {
  top: -20px !important;
  right: 0 !important;
  z-index: 5 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.fullscreen .topbar,
.fullscreen .site-ad {
  display: none;
}

.fullscreen .screen {
  width: 100%;
  padding: 0;
}

.fullscreen .player-page,
.fullscreen .reader-page {
  min-height: 100dvh;
}

.fullscreen .player-box,
.fullscreen .reader-frame {
  min-height: 100dvh;
  width: 100%;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

.player-box:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  min-height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
}

@media (orientation: landscape) {
  .site-ad {
    bottom: 12px;
    height: auto;
    aspect-ratio: 8 / 1;
    min-height: 0;
    max-height: 90px;
  }

  .radio-ad-slot {
    width: min(720px, calc(100vw - 32px));
    min-height: 0;
    aspect-ratio: 8 / 1;
  }

  .broadcast-ad-slot {
    width: min(720px, calc(100vw - 32px));
    min-height: 0;
    aspect-ratio: 8 / 1;
  }

  .book-ad-slot {
    width: min(720px, calc(100vw - 32px));
    min-height: 0;
    aspect-ratio: 8 / 1;
  }

  .screen {
    padding-bottom: 88px;
  }

  .media-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 70px;
  }

  .row,
  .pager {
    flex-direction: column;
  }

  .reader-controls.visible {
    grid-template-columns: 1fr;
  }

  .phone-grid {
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }
}
