:root {
  --ink: #24202c;
  --muted: #756f7d;
  --paper: #f7f4ee;
  --panel: #fffdf9;
  --line: rgba(36, 32, 44, .11);
  --purple: #4a4057;
  --coral: #fa725d;
  --yellow: #f4b72a;
  --cyan: #52bed2;
  --shadow: 0 24px 64px rgba(34, 28, 42, .2), 0 4px 14px rgba(34, 28, 42, .12);
  --ease: cubic-bezier(.22, .8, .24, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--ink);
  background: var(--paper);
  font: 500 14px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { color: inherit; }

.topbar {
  height: 66px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 238, .94);
  backdrop-filter: blur(18px);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; box-shadow: 0 4px 12px #2a21351f; }
.brand-copy { min-width: 0; }
.brand-title { font-weight: 820; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-title b { color: var(--coral); }
.brand-subtitle, .edition { color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.edition { font-size: 11px; }
.top-actions { display: flex; justify-content: flex-end; gap: 7px; }

.ui-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
}
.ui-button:hover { background: #fff; border-color: #4a40574d; transform: translateY(-1px); }
.ui-button:active { transform: scale(.98); }
.ui-button svg { width: 17px; height: 17px; }
.ui-button.icon { width: 38px; padding: 0; }
.mobile-panel-button { display: none; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 300px;
  background: #dfdbd4;
}

.side-panel {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: rgba(249, 247, 242, .92);
  scrollbar-width: thin;
}
.sponsor-panel { border-right: 1px solid var(--line); }
.media-panel { border-left: 1px solid var(--line); }
.panel-kicker { margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.panel-heading { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.panel-copy { margin: 5px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.panel-close { display: none; position: absolute; top: 12px; right: 12px; }

.sponsor-list { display: grid; gap: 14px; }
.sponsor-card {
  min-height: 215px;
  padding: 18px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  color: white;
  text-decoration: none;
  box-shadow: 0 12px 30px #2a213521;
}
.sponsor-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 15%, #ffffff42, transparent 34%); }
.sponsor-card.gold { background: linear-gradient(145deg, #44394f 15%, #a66f27); }
.sponsor-card.coral { background: linear-gradient(145deg, #4b3b57, #ef6c62); }
.sponsor-label { position: absolute; top: 15px; left: 15px; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .72; }
.sponsor-card strong { position: relative; font-size: 20px; letter-spacing: -.03em; }
.sponsor-card span { position: relative; margin-top: 5px; color: #ffffffc7; font-size: 12px; }
.sponsor-card em { position: relative; margin-top: 14px; font-style: normal; font-size: 11px; font-weight: 780; }

.viewer-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px 52px;
  background:
    radial-gradient(circle at 12% 12%, #ffffffcc, transparent 26%),
    radial-gradient(circle at 86% 82%, #4a405714, transparent 28%),
    linear-gradient(135deg, #e9e5df, #d8d3cc);
}
.viewer-stage::before { content: ""; position: absolute; inset: 0; opacity: .24; pointer-events: none; background-image: radial-gradient(#241f2b30 .6px, transparent .6px); background-size: 7px 7px; }
.book-area { position: relative; z-index: 2; display: grid; place-items: center; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.book-area::after { content: ""; position: absolute; z-index: -1; bottom: -4px; width: 76%; height: 28px; border-radius: 50%; background: #29223033; filter: blur(18px); }
#book { width: min(100%, 1400px); height: min(100%, 700px); filter: drop-shadow(var(--shadow)); }
#book .stf__wrapper { margin: auto; }
#book .stf__item { background: white !important; }

.edge-button {
  position: absolute;
  z-index: 8;
  top: 50%;
  translate: 0 -50%;
  width: 43px;
  height: 58px;
  border: 1px solid #ffffffad;
  border-radius: 14px;
  background: #ffffffc7;
  box-shadow: 0 8px 24px #221c2a1f;
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.edge-button:hover:not(:disabled) { color: var(--coral); background: white; }
.edge-button:disabled { opacity: .25; cursor: default; }
.edge-button svg { width: 20px; height: 20px; }
#prev { left: 10px; }
#next { right: 10px; }

.media-player-shell { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.media-placeholder { min-height: 96px; display: grid; place-items: center; padding: 14px; border-radius: 10px; color: var(--muted); background: #f3f0eb; text-align: center; font-size: 12px; }
#spotifyPlayer { width: 100%; height: 152px; border: 0; border-radius: 12px; display: block; }
.podcast-list { display: grid; gap: 7px; }
.podcast-button {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
}
.podcast-button:hover:not(:disabled), .podcast-button.active { border-color: #1db95466; background: #1db9540c; }
.podcast-button:disabled { cursor: default; opacity: .62; }
.play-dot { width: 32px; height: 32px; border-radius: 50%; background: #1db954; color: white; display: grid; place-items: center; font-size: 12px; }
.podcast-button:disabled .play-dot { background: #aaa5ae; }
.podcast-copy strong, .podcast-copy small { display: block; }
.podcast-copy strong { font-size: 12px; }
.podcast-copy small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.pending-badge { color: var(--muted); font-size: 9px; }
.context-section { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.context-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.context-link { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: white; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; font-size: 11px; cursor: pointer; }
.context-link:hover { border-color: #fa725d66; color: #b74637; }
.empty-actions { color: var(--muted); font-size: 11px; }

.bottombar {
  min-height: 70px;
  padding: 9px 22px max(9px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 15px;
  border-top: 1px solid var(--line);
  background: rgba(247, 244, 238, .96);
  z-index: 30;
}
.page-label { font-weight: 780; }
.page-count { margin-top: 2px; color: var(--muted); font-size: 11px; }
.progress { width: min(160px, 100%); height: 3px; margin-top: 6px; border-radius: 10px; background: #241f2b19; overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--coral), var(--yellow)); transition: width .25s var(--ease); }
.nav-cluster { display: flex; align-items: center; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 7px 20px #221b2b12; }
.nav-button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.nav-button:hover:not(:disabled) { color: var(--coral); background: #fa725d12; }
.nav-button:disabled { opacity: .24; cursor: default; }
.nav-button svg { width: 17px; height: 17px; }
.page-number { min-width: 66px; color: var(--muted); text-align: center; font-size: 11px; }
.footer-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }

.contents-panel {
  position: fixed;
  z-index: 60;
  inset: 0 auto 0 0;
  width: min(390px, 94vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: #faf8f4fa;
  box-shadow: 22px 0 70px #221b2b30;
  transform: translateX(-105%);
  transition: transform .28s var(--ease);
}
.contents-panel.open { transform: translateX(0); }
.panel-header { height: 66px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 17px; }
.thumb-grid { overflow: auto; padding: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px 10px; align-content: start; }
.thumb { padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border: 2px solid transparent; border-radius: 5px; box-shadow: 0 4px 13px #221b2b1c; }
.thumb:hover img, .thumb.active img { border-color: var(--coral); }
.thumb span { display: block; margin-top: 5px; }
.scrim { position: fixed; inset: 0; z-index: 55; background: #17121e66; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.visible { opacity: 1; pointer-events: auto; }

.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; color: white; background: #28222f; }
.loading.done { display: none; }
.loading-card { width: min(280px, 80vw); text-align: center; }
.loading-card img { width: 62px; height: 62px; border-radius: 15px; object-fit: cover; }
.loading-title { margin: 15px 0 4px; font-size: 16px; font-weight: 780; }
.loading-copy { color: #ffffff99; font-size: 11px; }
.loading-track { height: 3px; margin-top: 17px; border-radius: 10px; background: #ffffff1a; overflow: hidden; }
.loading-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--coral), var(--yellow)); }

.zoom-overlay { position: fixed; inset: 0; z-index: 85; padding: 62px 24px 24px; overflow: auto; background: #17131bef; }
.zoom-overlay[hidden] { display: none; }
.zoom-close { position: fixed; z-index: 2; top: 14px; right: 16px; color: white; background: #ffffff14; border-color: #ffffff2c; }
.zoom-pages { min-height: 100%; display: flex; justify-content: center; align-items: flex-start; gap: 2px; }
.zoom-pages img { width: min(85vh, 92vw); height: auto; display: block; background: white; box-shadow: 0 18px 60px #0008; }
.consent-banner { position: fixed; z-index: 90; left: 18px; right: 18px; bottom: 18px; max-width: 720px; margin: auto; padding: 15px; border: 1px solid #ffffff22; border-radius: 17px; background: #28222ff2; color: white; box-shadow: 0 18px 60px #0005; display: grid; grid-template-columns: 1fr auto; gap: 15px; align-items: center; }
.consent-banner[hidden] { display: none; }
.consent-banner strong { display: block; font-size: 13px; }
.consent-banner p { margin: 3px 0 0; color: #ffffffa8; font-size: 11px; line-height: 1.5; }
.consent-banner a { color: white; }
.consent-actions { display: flex; gap: 7px; }
.consent-actions button { min-height: 36px; padding: 0 11px; border-radius: 10px; border: 1px solid #ffffff2b; background: #ffffff10; color: white; cursor: pointer; }
.consent-actions .accept { border-color: var(--yellow); background: var(--yellow); color: #28222f; font-weight: 780; }


@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side-panel { position: fixed; z-index: 70; top: 0; bottom: 0; width: min(330px, 92vw); padding-top: 65px; box-shadow: 0 0 60px #211a2933; transition: transform .28s var(--ease); }
  .sponsor-panel { left: 0; transform: translateX(-105%); border-right: 1px solid var(--line); }
  .media-panel { right: 0; transform: translateX(105%); border-left: 1px solid var(--line); }
  .side-panel.open { transform: translateX(0); }
  .panel-close, .mobile-panel-button { display: inline-flex; }
}

@media (max-width: 760px) {
  .topbar { height: 58px; padding: 0 10px; grid-template-columns: minmax(0, 1fr) auto; }
  .edition, .button-text { display: none; }
  .brand img { width: 35px; height: 35px; }
  .viewer-stage { padding: 14px 6px 25px; }
  .edge-button { width: 38px; height: 48px; border-radius: 12px; }
  #prev { left: 4px; } #next { right: 4px; }
  .bottombar { min-height: 64px; padding-inline: 10px; grid-template-columns: 1fr auto; }
  .footer-actions { display: none; }
  .page-number { display: none; }
  .consent-banner { grid-template-columns: 1fr; left: 10px; right: 10px; bottom: 10px; }
  .consent-actions { justify-content: flex-end; }
  .zoom-overlay { padding: 58px 8px 18px; }
  .zoom-pages { display: block; }
  .zoom-pages img { width: 100%; margin: 0 auto 10px; }
}

@media (max-height: 620px) {
  .topbar { height: 54px; }
  .bottombar { min-height: 58px; padding-block: 5px; }
  .viewer-stage { padding-block: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
