:root {
  --bg: #070b12;
  --panel: #111a28;
  --panel-2: #162234;
  --line: rgba(255, 255, 255, 0.13);
  --text: #f7f8fb;
  --muted: #aab2c0;
  --purple: #9b6cff;
  --pink: #ef6aa8;
  --amber: #f0a35b;
  --teal: #54c6bf;
  --green: #65d98b;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(120deg, rgba(155, 108, 255, 0.10), transparent 28%), linear-gradient(245deg, rgba(84, 198, 191, 0.12), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 18px 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 18px;
  background: linear-gradient(180deg, rgba(7, 11, 18, 0.96), rgba(7, 11, 18, 0.72));
  backdrop-filter: blur(18px);
}

.brand, .brand-mini {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}
.brand { font-size: 22px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--pink), var(--amber));
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 20, 32, 0.76);
}
.desktop-nav a {
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}
.desktop-nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.route-studio .reader-only,
.route-reader .studio-only,
.route-choice .studio-only,
.route-choice .reader-only,
.route-studio .reader-view,
.route-studio .discover-view,
.route-studio .library-view,
.route-studio .choice-view,
.route-reader .studio-view,
.route-reader .choice-view,
.route-choice .reader-view,
.route-choice .discover-view,
.route-choice .library-view,
.route-choice .studio-view { display: none !important; }

.route-studio .studio-nav { display: none; }
.route-reader .reader-nav { display: none; }

.view {
  min-height: calc(100vh - 110px);
  scroll-margin-top: 96px;
  padding: 10px 0 54px;
}

.choice-view,
.studio-view {
  display: none;
}

.route-choice .choice-view,
.route-studio .studio-view {
  display: block;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(38px, 8vw, 76px);
  line-height: 0.96;
  letter-spacing: 0;
}
h2 {
  margin-bottom: 12px;
  font-size: clamp(27px, 5vw, 46px);
  line-height: 1.04;
}
h3 { margin-bottom: 8px; font-size: 22px; }
p { color: var(--muted); line-height: 1.55; }
.lead { max-width: 760px; font-size: 19px; }

.choice-card, .phone-reader, .reader-meta, .story-card, .library-panel, .studio-main, .studio-side, .admin-card, .model-card, .paywall-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 26, 40, 0.84);
  box-shadow: var(--shadow);
}
.choice-card {
  width: min(720px, 100%);
  margin: 8vh auto;
  padding: 30px;
}
.choice-actions, .reader-actions, .paywall-actions, .login-row {
  display: grid;
  gap: 10px;
}

.solid-button, .ghost-button, .text-button, .icon-button, .tab, .queue-item button, .scene-play {
  border: 0;
  cursor: pointer;
  color: var(--text);
}
.solid-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 17px;
  border-radius: 12px;
  font-weight: 850;
}
.solid-button { background: linear-gradient(135deg, var(--purple), var(--pink)); box-shadow: 0 16px 34px rgba(155, 108, 255, 0.24); }
.solid-button.warm { background: linear-gradient(135deg, var(--purple), var(--amber)); }
.ghost-button { border: 1px solid rgba(155, 108, 255, 0.58); background: rgba(255, 255, 255, 0.04); color: #c6a7ff; }
.text-button { background: transparent; color: var(--teal); font-weight: 850; }
.full { width: 100%; }

@media (max-width: 719px) {
  .top-login { display: none !important; }
  .topbar .ghost-button {
    min-height: 42px;
    padding: 10px 14px;
    white-space: nowrap;
  }
}

.reader-layout { display: grid; gap: 18px; }
.phone-reader {
  overflow: hidden;
  padding: 16px;
  max-width: 760px;
  margin: 0 auto;
}
.friend-banner, .reader-toolbar, .reader-top, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.friend-banner {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(84, 198, 191, 0.24);
  border-radius: 999px;
  background: rgba(84, 198, 191, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.friend-banner b { color: var(--teal); }
.reader-top { align-items: flex-start; margin-bottom: 14px; }
.reader-top h1 { font-size: clamp(30px, 8vw, 48px); }
.reader-top p { margin: 6px 0 0; }
.brand-mini { color: var(--muted); font-size: 14px; }
.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 900;
}
.reader-toolbar { margin-bottom: 14px; }
.mode-pill {
  display: inline-flex;
  padding: 8px 10px;
  border: 1px solid rgba(155, 108, 255, 0.42);
  border-radius: 999px;
  color: #d7c4ff;
}

.scene-list { display: grid; gap: 14px; }
.scene-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a101a;
}
.scene-media {
  position: relative;
  min-height: 186px;
  background: #050810;
}
.scene-media::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.30));
}
video.scene-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.86;
}
.scene-card.is-playing .scene-video { opacity: 1; }
.panorama-view { cursor: grab; touch-action: pan-y; }
.panorama-view:active { cursor: grabbing; }
.pano-surface {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 11, 18, 0.22), rgba(7, 11, 18, 0.00), rgba(7, 11, 18, 0.22)),
    url('/assets/concept-reader.png');
  background-size: 260% auto;
  background-repeat: no-repeat;
  opacity: 0.92;
  transition: background-position 80ms linear;
}
.pano-hint {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(4, 7, 12, 0.75);
  color: #d7c4ff;
  font-size: 12px;
  font-weight: 900;
}
.scene-index, .scene-duration, .scene-play {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 12, 0.75);
  backdrop-filter: blur(8px);
}
.scene-index {
  top: 12px;
  left: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(155, 108, 255, 0.76);
  font-weight: 900;
  font-size: 20px;
}
.scene-duration {
  left: 12px;
  bottom: 12px;
  padding: 7px 9px;
  border-radius: 8px;
  font-weight: 850;
}
.scene-play {
  right: 14px;
  bottom: 12px;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  font-size: 18px;
}
.scene-card.is-playing .scene-play { font-size: 0; opacity: 0.78; }
.scene-card.is-playing .scene-play::before { content: "||"; font-size: 14px; }
.scene-copy {
  min-height: 92px;
  padding: 15px 16px;
  background: rgba(13, 20, 32, 0.96);
}
.scene-copy p {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.38;
}
.voice-note {
  display: inline-flex;
  margin-top: 12px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
}
.paywall-card {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 22px;
  border-color: rgba(155, 108, 255, 0.55);
  background: linear-gradient(135deg, rgba(155, 108, 255, 0.14), rgba(240, 163, 91, 0.08)), var(--panel);
}
.lock-ring {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid rgba(155, 108, 255, 0.70);
  color: #d7c4ff;
  font-weight: 900;
}
.fine-print { color: var(--muted); font-size: 13px; }

.reader-meta, .library-panel, .studio-main, .studio-side, .admin-card, .model-card { padding: 22px; }
.stat-stack { display: grid; gap: 10px; margin: 24px 0; }
.stat-stack span, .split-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.stat-stack strong, .split-row strong { color: var(--text); }

.section-head { align-items: end; margin-bottom: 18px; }
.search-box { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.search-box input, .studio-side select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 18px; }
.tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 800;
}
.tab.active { border-color: rgba(239, 106, 168, 0.62); color: white; background: linear-gradient(135deg, rgba(155, 108, 255, 0.28), rgba(239, 106, 168, 0.20)); }
.story-grid { display: grid; gap: 14px; }
.story-card { overflow: hidden; background: var(--panel); }
.story-art {
  min-height: 178px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.62)), var(--story-image);
  background-size: cover;
  background-position: center;
}
.story-body { padding: 15px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag-row span { padding: 6px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--muted); font-size: 12px; font-weight: 750; }
.card-footer { display: flex; justify-content: space-between; margin-top: 16px; color: var(--muted); font-size: 13px; }

.studio-grid, .admin-grid, .model-grid, .pipeline-grid { display: grid; gap: 16px; }
.upload-panel { display: grid; gap: 12px; margin: 24px 0; }
.upload-zone {
  display: grid;
  gap: 8px;
  min-height: 152px;
  place-items: center;
  padding: 24px;
  border: 1px dashed rgba(84, 198, 191, 0.62);
  border-radius: 8px;
  background: rgba(84, 198, 191, 0.06);
  text-align: center;
}
.upload-zone input { width: 1px; height: 1px; opacity: 0; position: absolute; }
.upload-zone span { font-size: 22px; font-weight: 850; }
.upload-zone small { color: var(--muted); }
.workflow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0 22px; }
.workflow div, .beat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}
.workflow div { display: flex; align-items: center; gap: 10px; padding: 12px; }
.workflow b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(155, 108, 255, 0.65);
}
.beat-planner { display: grid; gap: 10px; }
.beat-item { display: grid; gap: 8px; padding: 14px; }
.beat-item header { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 850; }
.studio-side { display: grid; align-content: start; gap: 16px; }
.studio-side label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 850; }
.check-row { grid-template-columns: auto 1fr; align-items: start; }
.check-row input { width: 18px; height: 18px; margin-top: 2px; }
.model-card span { color: var(--teal); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
.model-card.recommended { border-color: rgba(84, 198, 191, 0.45); }
.model-card.caution { border-color: rgba(240, 163, 91, 0.48); }
.pipeline-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 18px;
}
.pipeline-grid b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: rgba(155, 108, 255, 0.65);
}
.queue-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.queue-item p { margin: 4px 0 0; }
.queue-item button { padding: 9px 11px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); }

.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(10, 16, 26, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}
.bottom-nav a {
  padding: 11px 4px;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}
.bottom-nav a.active { color: white; background: rgba(155, 108, 255, 0.26); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}
.modal-card {
  position: relative;
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.modal-close { position: absolute; top: 12px; right: 12px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 70;
  width: min(92vw, 420px);
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 20, 32, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .app-shell { padding: 20px 28px 42px; }
  .desktop-nav { display: flex; }
  .route-studio .studio-nav, .route-reader .reader-nav { display: flex; }
  .bottom-nav { display: none; }
  .choice-actions, .reader-actions, .paywall-actions, .login-row, .upload-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head { display: grid; grid-template-columns: 1fr minmax(280px, 420px); }
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .admin-grid, .model-grid, .pipeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1040px) {
  .reader-layout { grid-template-columns: minmax(540px, 760px) minmax(280px, 0.5fr); align-items: start; }
  .reader-meta { position: sticky; top: 100px; }
  .studio-grid { grid-template-columns: 1fr 360px; align-items: start; }
  .story-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .model-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pipeline-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
