
:root {
  color-scheme: dark;
  --bg: #090d18;
  --surface: #101725;
  --surface-light: #172235;
  --border: rgba(174, 192, 221, 0.13);
  --text: #f3f6fc;
  --muted: #98a5b9;
  --accent: #9aafff;
  --accent-strong: #718cff;
  --green: #72e0b2;
  --radius: 18px;
  --font: "DM Sans", sans-serif;
  --heading: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(ellipse at 50% -15%, rgba(68, 91, 164, 0.17), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Header */

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #9eafff, #6178e9);
  color: #0a1022;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 21px;
}

.brand-name {
  font-family: var(--heading);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.1px;
}

.brand-name span {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.status-dot,
.live-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(114, 224, 178, 0.55);
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 0.2s ease;
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Hero */

.hero-section {
  max-width: 790px;
  margin: 0 auto;
  padding: 105px 0 96px;
  text-align: center;
}

.hero-kicker,
.section-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.7px;
}

.hero-kicker {
  justify-content: center;
}

.kicker-line {
  width: 25px;
  height: 1px;
  background: var(--accent);
}

.hero-section h1 {
  margin: 25px 0 17px;
  font-family: var(--heading);
  font-size: clamp(48px, 8vw, 82px);
  line-height: 1.03;
  letter-spacing: -4px;
}

.hero-section h1 span {
  color: var(--accent);
}

.hero-description {
  max-width: 570px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.search-panel {
  margin-top: 37px;
  padding: 9px;
  border: 1px solid rgba(154, 175, 255, 0.25);
  border-radius: 15px;
  background: rgba(17, 25, 41, 0.92);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.22);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-symbol {
  padding-left: 12px;
  color: var(--accent);
  font-size: 27px;
  line-height: 1;
}

.search-input-wrap input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.search-input-wrap input::placeholder {
  color: #77849b;
}

.search-button,
.export-button {
  min-height: 45px;
  padding: 0 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #10172b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.2s ease;
}

.search-button:hover,
.export-button:hover {
  background: #b8c6ff;
  transform: translateY(-1px);
}

.search-button:disabled {
  cursor: wait;
  transform: none;
}

.search-footer {
  padding: 9px 10px 1px;
  display: flex;
  justify-content: space-between;
  color: #718097;
  font-size: 10px;
}

.topic-examples {
  margin-top: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
}

.examples-label {
  color: #728098;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.topic-chip {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.025);
  color: #aab6ca;
  font-size: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}

.topic-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(154, 175, 255, 0.08);
}

/* Workspace */

.workspace {
  padding: 44px 0 80px;
  animation: appear 0.45s ease both;
}

.workspace-heading {
  margin-bottom: 25px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.workspace-heading h2 {
  margin: 9px 0 7px;
  font-family: var(--heading);
  font-size: clamp(25px, 4vw, 37px);
  letter-spacing: -1.3px;
}

.story-description {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.secondary-button {
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: #c8d3e6;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Main layout */

.story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(245px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.player-column,
.scene-sidebar {
  min-width: 0;
}

.visual-player {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 430px;
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 25px 27px;
  border: 1px solid rgba(174, 192, 221, 0.17);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at 75% 25%, rgba(102, 126, 210, 0.45), transparent 45%),
    linear-gradient(135deg, #172747, #0a1120 72%);
}

.player-background {
  position: absolute;
  z-index: -2;
  inset: 0;
  background-position: center;
  background-size: cover;
  opacity: 0.55;
  transform: scale(1.02);
  transition: opacity 0.7s ease;
}

.player-background.has-image {
  animation: imageDrift 18s ease-in-out infinite alternate;
}

.player-overlay {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 10, 22, 0.9), rgba(5, 10, 22, 0.2)),
    linear-gradient(0deg, rgba(5, 10, 22, 0.88), transparent 48%);
}

.player-topline,
.player-bottomline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #dce4f6;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.player-label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.scene-counter {
  color: #bac6df;
  font-variant-numeric: tabular-nums;
}

.scene-content {
  max-width: 610px;
  margin: auto 0;
  padding: 38px 0;
  animation: sceneEnter 0.55s ease both;
}

.scene-category {
  margin-bottom: 15px;
  color: #b5c5ff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
}

.scene-content h2 {
  max-width: 560px;
  margin: 0 0 15px;
  font-family: var(--heading);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -1.8px;
  text-wrap: balance;
}

.scene-content p {
  max-width: 570px;
  margin: 0;
  color: #d0d8e8;
  font-size: 14px;
  line-height: 1.85;
}

.player-bottomline {
  color: #a9b6cf;
  font-size: 9px;
  letter-spacing: 0.5px;
}

/* Playback */

.playback-controls {
  min-height: 70px;
  padding: 12px 5px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-button,
.play-button {
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: #c6d0e3;
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s ease;
}

.control-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.play-button {
  width: 42px;
  height: 42px;
  border: 0;
  background: var(--accent);
  color: #11182a;
  font-size: 15px;
}

.play-button:hover {
  background: #c0ccff;
  transform: scale(1.05);
}

.progress-area {
  min-width: 0;
  flex: 1;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 10px;
  background: #273247;
  cursor: pointer;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s linear;
}

.progress-labels {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  color: #7d8ba3;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

/* Export */

.export-panel {
  margin-top: 9px;
  padding: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(17, 25, 41, 0.75);
}

.export-panel strong {
  font-size: 12px;
}

.export-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.export-button {
  min-height: 39px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 10px;
}

.export-status {
  min-height: 17px;
  margin: 9px 3px 0;
  color: var(--muted);
  font-size: 10px;
}

/* Sidebar */

.scene-sidebar {
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 23, 37, 0.75);
}

.sidebar-heading {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-heading h3 {
  margin: 7px 0 0;
  font-family: var(--heading);
  font-size: 20px;
}

.chapter-count {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.scene-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-item {
  width: 100%;
  min-height: 66px;
  padding: 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.scene-item:hover {
  background: rgba(154, 175, 255, 0.07);
}

.scene-item.active {
  border-color: rgba(154, 175, 255, 0.3);
  background: rgba(154, 175, 255, 0.09);
}

.scene-number {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #202c42;
  color: #b6c4e3;
  font-size: 10px;
  font-weight: 700;
}

.scene-item.active .scene-number {
  background: var(--accent);
  color: #10172b;
}

.scene-item-text {
  min-width: 0;
}

.scene-item-text strong {
  display: block;
  overflow: hidden;
  color: #dce5f4;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-item-text span {
  display: block;
  margin-top: 5px;
  color: #7f8da4;
  font-size: 9px;
}

.empty-scenes {
  padding: 23px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

.source-card {
  margin-top: 19px;
  padding-top: 17px;
  display: flex;
  gap: 11px;
  border-top: 1px solid var(--border);
}

.source-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--accent);
  font-size: 17px;
}

.source-card strong {
  font-size: 10px;
}

.source-card p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.source-card a {
  color: var(--accent);
  font-size: 10px;
  text-decoration: none;
}

.source-card a:hover {
  text-decoration: underline;
}

/* Feature section */

.how-section {
  padding: 65px 0 80px;
  border-top: 1px solid var(--border);
}

.how-section > .section-eyebrow {
  justify-content: center;
}

.how-section > h2 {
  margin: 14px 0 32px;
  font-family: var(--heading);
  font-size: clamp(25px, 4vw, 37px);
  letter-spacing: -1.2px;
  text-align: center;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.feature-card {
  position: relative;
  min-height: 185px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(16, 23, 37, 0.7);
  transition: 0.25s ease;
}

.feature-card:hover {
  border-color: rgba(154, 175, 255, 0.35);
  transform: translateY(-3px);
}

.feature-number {
  position: absolute;
  top: 22px;
  right: 22px;
  color: #65738d;
  font-family: var(--heading);
  font-size: 11px;
}

.feature-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(154, 175, 255, 0.1);
  color: var(--accent);
  font-size: 21px;
}

.feature-card h3 {
  margin: 18px 0 7px;
  font-family: var(--heading);
  font-size: 16px;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

/* Footer */

.footer {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--border);
}

.footer-brand .brand-mark {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  font-size: 16px;
}

.footer-brand .brand-name {
  font-size: 11px;
}

.footer > p,
.footer-version {
  color: #78869d;
  font-size: 10px;
}

.footer-version {
  letter-spacing: 1px;
}

/* Dialog and toast */

.about-dialog {
  width: min(450px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #121b2c;
  color: var(--text);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
}

.about-dialog::backdrop {
  background: rgba(2, 5, 12, 0.75);
  backdrop-filter: blur(5px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-heading h2 {
  margin: 0;
  font-family: var(--heading);
  font-size: 19px;
}

.about-dialog p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.dialog-close {
  margin-top: 9px;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 13px 17px;
  border: 1px solid rgba(154, 175, 255, 0.3);
  border-radius: 10px;
  background: #17243a;
  color: #eaf0ff;
  font-size: 11px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Animations */

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sceneEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes imageDrift {
  from {
    transform: scale(1.02) translateX(0);
  }
  to {
    transform: scale(1.12) translateX(-1.5%);
  }
}

/* Responsive layouts */

@media (max-width: 850px) {
  .story-layout {
    grid-template-columns: 1fr;
  }

  .scene-sidebar {
    display: block;
  }

  .scene-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .visual-player {
    min-height: 390px;
  }
}

@media (max-width: 600px) {
  .app-shell {
    width: min(100% - 30px, 520px);
  }

  .topbar {
    height: 65px;
  }

  .system-status {
    font-size: 8px;
    letter-spacing: 0.7px;
  }

  .topbar-right {
    gap: 11px;
  }

  .hero-section {
    padding: 75px 0 65px;
  }

  .hero-section h1 {
    font-size: clamp(47px, 12vw, 66px);
    letter-spacing: -2.8px;
  }

  .hero-description {
    font-size: 13px;
  }

  .search-panel {
    padding: 8px;
  }

  .search-input-wrap {
    flex-wrap: wrap;
    gap: 5px;
  }

  .search-symbol {
    padding-left: 8px;
  }

  .search-input-wrap input {
    width: calc(100% - 55px);
    height: 42px;
    font-size: 12px;
  }

  .search-button {
    width: 100%;
    min-height: 42px;
  }

  .search-footer {
    font-size: 9px;
  }

  .topic-examples {
    gap: 7px;
  }

  .examples-label {
    width: 100%;
  }

  .workspace {
    padding-top: 30px;
  }

  .workspace-heading {
    align-items: flex-start;
  }

  .workspace-heading h2 {
    font-size: 25px;
  }

  .workspace-heading .secondary-button {
    min-height: 34px;
    padding: 0 9px;
    font-size: 9px;
  }

  .visual-player {
    min-height: 340px;
    aspect-ratio: auto;
    padding: 18px;
  }

  .scene-content h2 {
    font-size: 34px;
  }

  .scene-content p {
    font-size: 12px;
  }

  .player-topline,
  .player-bottomline {
    font-size: 8px;
  }

  .playback-controls {
    gap: 7px;
  }

  .control-button {
    width: 31px;
    height: 31px;
  }

  .play-button {
    width: 38px;
    height: 38px;
  }

  .export-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-button {
    width: 100%;
  }

  .scene-sidebar {
    padding: 14px;
  }

  .scene-list {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .feature-card {
    min-height: 155px;
  }

  .footer {
    padding: 20px 0;
    flex-wrap: wrap;
  }

  .footer > p {
    width: 100%;
    order: 3;
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
