/* @override 
	http://localhost:9000/css/style.css */

@import "styles/vendor/reset.css";
@import "styles/typography.css";

/* ── Catppuccin Frappe palette ─────────────────────────────────────────── */
:root {
  --crust: #232634;
  --mantle: #292c3c;
  --base: #303446;
  --surface0: #414559;
  --surface1: #51576d;
  --surface2: #626880;
  --overlay0: #737994;
  --overlay1: #838ba7;
  --subtext0: #a5adce;
  --subtext1: #b5bfe2;
  --text: #c4c5f4;
  --lavender: #babbf1;
  --blue: #8caaee;
  --sapphire: #85c1dc;
  --teal: #81c8be;
  --green: #a6d189;
  --yellow: #e5c890;
  --peach: #ef9f76;
  --mauve: #ca9ee6;
  --pink: #f4b8e4;
  --rosewater: #f2d5cf;
  --maroon: #ea999c;
  --red: #e78284;

  /* layout */
  --sidebar-width: 280px;
  --script-width: 70ch;
  --dialog-width: 36ch;

  /* typography */
  --font: "Iosevka Extended", ui-monospace, monospace;
  --font-size: 16px;
  --line-height: 1.65;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

* {
  -webkit-tap-highlight-color: transparent;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size);
  background: var(--base);
  color: var(--text);
  height: 100%;
}

body {
  font-family: var(--font);
  line-height: var(--line-height);
  height: 100%;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

strong {
  font-weight: 700;
}
em {
  font-style: italic;
}

/* ── App shell ──────────────────────────────────────────────────────────── */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--mantle);
  border-right: 1px solid var(--surface0);
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  overflow: hidden;
  /* width is layout-triggering but unavoidable in flex; promote to GPU layer */
  will-change: transform;
}

.app.is-ready .sidebar {
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 0;
}

.sidebar-toggle {
  position: fixed;
  z-index: 40;
  top: 16px;
  left: 16px; /* never changes — shift is done via transform */
  background: none;
  border: none;
  cursor: pointer;
  color: var(--subtext1);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  will-change: transform;
  transition: color 0.15s, background 0.15s;
}

.app.is-ready .sidebar-toggle {
  transition: color 0.15s, background 0.15s, transform 0.2s ease;
}

/* Shift the toggle with transform (composited) instead of left (layout) */
.app:has(.sidebar:not(.collapsed)) .sidebar-toggle {
  transform: translateX(var(--sidebar-width));
}

.sidebar-toggle:hover {
  color: var(--lavender);
}

.toggle-icon {
  display: block;
  width: 22px;
  height: 22px;
  background: currentColor;
}

.toggle-icon--open {
  mask: url("/img/sidebar.svg") center / contain no-repeat;
  -webkit-mask: url("/img/sidebar.svg") center / contain no-repeat;
}

.toggle-icon--close {
  display: none;
  mask: url("/img/close.svg") center / contain no-repeat;
  -webkit-mask: url("/img/close.svg") center / contain no-repeat;
}

.playback-controls {
  position: fixed;
  z-index: 30;
  top: 64px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 5px 6px;
  border: 1px solid var(--surface1);
  border-radius: 999px;
  background: var(--mantle);
}

.playback-controls[hidden] {
  display: none;
}

.playback-control-button {
  font: var(--font);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  cursor: pointer;
  color: var(--subtext1);
  background: transparent;
  border-radius: 999px;
  padding: 8px 18px 8px 14px;
}

.playback-control-button--stop {
  color: var(--overlay1);
}

.playback-control-button:hover,
.playback-control-button:focus-visible {
  color: var(--text);
  background: var(--surface0);
  outline: none;
}

.playback-control-button:disabled {
  cursor: default;
  color: var(--overlay0);
  opacity: 0.45;
}

.playback-control-button:disabled:hover,
.playback-control-button:disabled:focus-visible {
  background: transparent;
}

.playback-icon {
  display: block;
  width: 1rem;
  height: 1rem;
  background: currentColor;
  flex: 0 0 auto;
}

.playback-icon--toggle {
  mask: url("/img/player-pause.svg") center / contain no-repeat;
  -webkit-mask: url("/img/player-pause.svg") center / contain no-repeat;
}

.playback-control-button--toggle.is-paused .playback-icon--toggle {
  mask-image: url("/img/player-play.svg");
  -webkit-mask-image: url("/img/player-play.svg");
}

.playback-icon--stop {
  mask: url("/img/player-stop.svg") center / contain no-repeat;
  -webkit-mask: url("/img/player-stop.svg") center / contain no-repeat;
}

.playback-label {
  font-size: 0.98rem;
  line-height: 1;
}

.playback-label--play,
.playback-control-button--toggle.is-paused .playback-label--pause {
  display: none;
}

.playback-control-button--toggle.is-paused .playback-label--play {
  display: inline;
}

.sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed .sidebar-body {
  visibility: hidden;
}

/* Prevents text from re-wrapping while the sidebar animates open/closed.
   The sidebar clips via overflow:hidden; content stays at its natural width. */
.sidebar-content {
  min-width: var(--sidebar-width);
  padding-bottom: 1rem;
}

/* sidebar sections */

.sidebar-section-title {
  color: var(--subtext1);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 0.45rem;
  opacity: 0.5;
}

.sidebar-section-title--scenes {
  margin: 18px 16px 6px;
  flex-shrink: 0;
}

/* top actions */

.top-actions {
  position: fixed;
  z-index: 30;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: calc(100vw - 134px);
}

.episode-selector,
.audio-settings {
  position: relative;
  display: inline-block;
}

.episode-selector summary,
.audio-settings summary {
  list-style: none;
}

.episode-selector summary::-webkit-details-marker,
.audio-settings summary::-webkit-details-marker {
  display: none;
}

.episode-trigger {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  width: auto;
  max-width: 100%;
  padding: 0.36rem 0.75rem 0.36rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface0) 88%, var(--base));
  color: var(--lavender);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.episode-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-trigger:hover {
  background: var(--surface0);
  color: var(--text);
}

.episode-trigger:focus {
  outline: none;
}

.episode-trigger:focus-visible {
  color: var(--lavender);
}

.episode-trigger img {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  filter: brightness(0) invert(1);
  opacity: 0.9;
  transition: transform 0.15s ease;
}

.episode-selector[open] .episode-trigger img {
  transform: rotate(180deg);
}

.episode-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  left: auto;
  display: grid;
  width: max-content;
  max-width: calc(100vw - 32px);
  min-width: 100%;
  overflow: hidden;
  gap: 1px;
  padding: 0.35rem;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  background: var(--mantle);
  font-size: 14px;
}

.episode-option {
  display: grid;
  gap: 1px;
  padding: 0.46rem 0.65rem;
  border-radius: 6px;
  color: var(--subtext1);
  font-size: inherit;
  line-height: 1.25;
  transition: background 0.15s, color 0.15s;
}

.episode-option span:first-child {
  font-weight: 700;
}

.episode-option span:last-child {
  color: var(--overlay1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-option:hover,
.episode-option--active {
  background: var(--base);
  color: var(--text);
}

.audio-settings-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--subtext1);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s;
}

.audio-settings-trigger:hover,
.audio-settings-trigger:focus-visible,
.audio-settings[open] .audio-settings-trigger {
  color: var(--text);
  background: color-mix(in srgb, var(--surface0) 88%, var(--base));
  outline: none;
}

.audio-settings-icon {
  width: calc(1rem + 1px);
  height: calc(1rem + 1px);
  display: block;
  transform: translateY(0);
  background: currentColor;
  mask: url("/img/gear.svg") center / contain no-repeat;
  -webkit-mask: url("/img/gear.svg") center / contain no-repeat;
}

.audio-settings-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: auto;
  left: var(--audio-settings-menu-left, 0);
  display: grid;
  width: max-content;
  min-width: 15rem;
  max-width: calc(100vw - 32px);
  gap: 1px;
  padding: 0.35rem;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  background: var(--mantle);
  font-size: 14px;
}

.audio-settings-heading {
  padding: 0.35rem 0.65rem 0.25rem;
  color: var(--overlay1);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.audio-settings-separator {
  height: 1px;
  margin: 0.25rem 0;
  background: var(--surface0);
}

.audio-mode-option {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--subtext1);
  cursor: pointer;
  font: inherit;
  line-height: 1.25;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.audio-mode-option span:first-child {
  font-weight: 700;
}

.audio-mode-option span:last-child {
  color: var(--overlay1);
}

.audio-mode-option:hover,
.audio-mode-option:focus-visible,
.audio-mode-option.is-active {
  background: var(--base);
  color: var(--text);
  outline: none;
}

.audio-settings-action,
.audio-settings-logout {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--subtext1);
  cursor: pointer;
  line-height: 1.25;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.audio-settings-action:hover,
.audio-settings-action:focus-visible,
.audio-settings-logout:hover,
.audio-settings-logout:focus-visible {
  background: var(--base);
  color: var(--text);
  outline: none;
}

.pill {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.8rem;
  background: var(--surface0);
  color: var(--subtext1);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.pill:hover {
  background: var(--surface1);
  color: var(--text);
}

.pill--active {
  background: var(--blue);
  color: var(--crust);
}

/* scene list */

.scene-list {
  padding: 0 0 6px;
  scroll-behavior: smooth;
}

.scene-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.scene-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.45rem;
  padding: 5px 16px;
  font-size: 0.73rem;
  color: var(--overlay1);
  line-height: 1.4;
  transition: color 0.1s, background 0.1s;
  cursor: pointer;
}

.scene-item-kicker {
  color: var(--surface2);
  min-width: 2ch;
  text-align: right;
  transition: color 0.1s;
}

.scene-item-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.scene-item-title--with-prefix {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.45rem;
}

.scene-item-prefix {
  color: var(--surface2);
}

.scene-item-title-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.scene-item:hover {
  color: var(--text);
  background: var(--surface0);
}

.scene-item:hover .scene-item-kicker,
.scene-item:focus-visible .scene-item-kicker {
  color: var(--pink);
}

.scene-item.active {
  color: var(--lavender);
  background: var(--surface0);
}

.scene-item.active .scene-item-kicker {
  color: var(--green);
}

/* ── Script area ────────────────────────────────────────────────────────── */

.script {
  position: relative;
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.mobile-top-fade {
  display: none;
}

.script-column {
  max-width: var(--script-width);
  margin: 0 auto;
  padding: 4rem 2rem 10rem;
}

.title-page {
  text-align: center;
  color: var(--text);
  margin-bottom: 10rem;
  margin-top: 5rem;
}

.title-page h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 2rem;
}

.title-page p {
  margin: 0;
  color: var(--subtext1);
}

.episode-title-line {
  font-style: italic;
}

.next-episode-wrap {
  display: flex;
  justify-content: center;
  margin-top: 5rem;
}

.next-episode-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(100%, 24rem);
  padding: 0.6rem 0.8rem 0.6rem 1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface0) 88%, var(--base));
  color: var(--subtext1);
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.next-episode-pill:hover,
.next-episode-pill:focus-visible {
  background: var(--surface0);
  color: var(--text);
  outline: none;
}

.next-episode-label {
  color: var(--overlay1);
  white-space: nowrap;
}

.next-episode-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--subtext1);
}

.next-episode-pill:hover .next-episode-title,
.next-episode-pill:focus-visible .next-episode-title {
  color: var(--text);
}

.next-episode-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
  background: currentColor;
  mask: url("/img/next-episode.svg") center / contain no-repeat;
  -webkit-mask: url("/img/next-episode.svg") center / contain no-repeat;
}

.next-episode-pill--disabled {
  cursor: default;
  opacity: 0.75;
}

.next-episode-pill--disabled:hover {
  background: color-mix(in srgb, var(--surface0) 88%, var(--base));
  color: var(--subtext1);
}

.next-episode-coming {
  color: var(--mauve);
  white-space: nowrap;
}

.next-episode-pill--disabled .next-episode-icon {
  opacity: 0.45;
}

.next-episode-pill--disabled:hover .next-episode-title {
  color: var(--subtext1);
}

/* ── Scene ──────────────────────────────────────────────────────────────── */

.scene {
  position: relative;
  scroll-margin-top: 4.5rem;
}

.scene-number-marker {
  position: absolute;
  top: 1.2rem;
  right: -5.5rem;
  display: block;
  width: 2rem;
  color: var(--green);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1;
  opacity: 0.5;
  pointer-events: none;
  text-align: right;
}

.scene-number-marker::before {
  content: "";
  display: block;
  width: 2rem;
  height: 1px;
  margin-bottom: 0.18rem;
  background: currentColor;
  opacity: 0.8;
}

[data-audio-src] {
  scroll-margin-top: 7rem;
}

[data-audio-src].is-reading {
  color: var(--rosewater);
  text-shadow: 0 0 16px rgb(242 213 207 / 0.18);
}

.dialog-block.is-reading .character-name,
.dialog-block.is-reading .dialog-text {
  color: var(--rosewater);
}

.scene-heading.is-reading {
  color: var(--rosewater);
}

.scene + .scene {
  margin-top: 4.5rem;
}

.scene-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 400;
  color: var(--blue);
  letter-spacing: 0.04em;
  margin-bottom: 2rem;
}

.scene-play {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.25rem;
  padding: 0;
  border: 0;
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--blue);
}

.play-icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  background: currentColor;
  mask: url("/img/speaker.svg") center / contain no-repeat;
  -webkit-mask: url("/img/speaker.svg") center / contain no-repeat;
}

.scene-play:hover,
.scene-play:focus-visible {
  color: var(--lavender);
  outline: none;
}

/* ── Narration ──────────────────────────────────────────────────────────── */

.narration {
  color: var(--text);
  margin-bottom: 2rem;
}

.narration p {
  margin-bottom: 1.5rem;
}

.narration p.super-block {
  margin-bottom: 2rem;
}

.narration p:last-child {
  margin-bottom: 0;
}

.super-line {
  color: var(--rosewater);
}

.super-label {
  font-weight: 700;
}

/* ── Dialog ─────────────────────────────────────────────────────────────── */

.dialog-block {
  max-width: var(--dialog-width);
  margin: 0 auto 2rem;
}

.character-name {
  text-align: center;
  color: var(--lavender);
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.qualifier {
  color: var(--subtext0);
  letter-spacing: 0;
  margin-left: 0.5em;
}

.indication {
  text-align: center;
  color: var(--subtext0);
  font-style: italic;
}

.dialog-text {
  color: var(--text);
}

.dialog-line {
  display: block;
}

.dialog-translation-wrap {
  display: block;
}

.dialog-translation-trigger {
  display: grid;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dialog-translation-trigger .dialog-text {
  grid-area: 1 / 1;
  transition: opacity 300ms ease, color 0.2s ease;
}

.dialog-translation-highlight {
  display: inline;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: color-mix(in srgb, var(--lavender) 8%, transparent);
  text-underline-offset: 0.4em;
}

.dialog-translation-original {
  opacity: 1;
}

.dialog-translation-english {
  opacity: 0;
  pointer-events: none;
}

.dialog-translation-wrap.is-translated .dialog-translation-original {
  opacity: 0;
}

.dialog-translation-wrap.is-translated .dialog-translation-english {
  opacity: 1;
}

.dialog-line--indication {
  text-align: center;
  color: var(--subtext0);
  font-style: italic;
  opacity: 0.5;
}

@media (max-width: 720px) {
  :root {
    --font-size: 17.5px;
  }

  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  /* Strip all non-transform transitions — width/left animations repaint on mobile */
  .sidebar,
  .sidebar-toggle {
    transition: none;
  }

  /* Slide in/out with translateX — GPU composited, no layout repaints */
  .sidebar {
    position: fixed;
    z-index: 25;
    inset: 0 auto 0 0;
    width: 100vw;
    border-right: none;
    box-shadow: 0 0 0 100vw rgb(35 38 52 / 0.5);
    transform: translateX(0);
    background: var(--base);
  }

  .app.is-ready .sidebar {
    transition: transform 0.25s ease;
  }

  .sidebar.collapsed {
    width: 100vw; /* keep width, only translate */
    transform: translateX(-100%);
    box-shadow: none;
  }

  /* Push content below the fixed toggle button — double for visual alignment */
  .sidebar-content {
    padding-top: 50px;
    padding-right: 5px;
    padding-left: 5px;
  }

  .sidebar-section-title {
    font-size: 0.82rem;
  }

  .scene-item {
    font-size: 0.88rem;
    padding: 8px 18px;
    line-height: 1.5;
    column-gap: 0.55rem;
  }

  /* Toggle is always top-left on mobile — reset the desktop translateX shift */
  .app:has(.sidebar:not(.collapsed)) .sidebar-toggle {
    transform: translateX(0);
  }

  /* Show close icon when sidebar is open */
  .app:has(.sidebar:not(.collapsed)) .toggle-icon--open {
    display: none;
  }
  .app:has(.sidebar:not(.collapsed)) .toggle-icon--close {
    display: block;
  }

  .sidebar-toggle {
    width: 2rem;
    height: 2rem;
    padding: 0.3rem;
    border-radius: 50%;
    background: var(--base);
  }

  .top-actions {
    top: 16px;
    right: 16px;
    max-width: calc(100vw - 64px);
    align-items: center;
  }

  .episode-selector {
    max-width: calc(100vw - 120px);
  }

  .episode-trigger {
    max-width: 100%;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }

  .audio-settings-menu,
  .episode-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 32px);
    z-index: 100;
  }

  .audio-settings-menu {
    right: auto;
    left: var(--audio-settings-menu-left, 0);
  }

  .sidebar-toggle:hover {
    background: var(--base);
  }

  .script-column {
    padding: 4.5rem 1.25rem 8rem;
  }

  .script {
    width: 100%;
    flex: none;
    overflow: visible;
  }

  .scene-number-marker {
    display: none;
  }

  .app:has(.sidebar:not(.collapsed)) .top-actions {
    display: none;
  }

  .playback-controls {
    top: 64px;
    right: 16px;
  }
}

@media (pointer: coarse) and (max-width: 1194px) {
  .mobile-top-fade {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    left: 0;
    display: block;
    height: 6rem;
    pointer-events: none;
    background: linear-gradient(
      to bottom,
      var(--base) 0%,
      color-mix(in srgb, var(--base) 92%, transparent) 42%,
      color-mix(in srgb, var(--base) 72%, transparent) 68%,
      transparent 100%
    );
  }
}

/* ── Transitions / Markup ───────────────────────────────────────────────── */

.markup {
  text-align: right;
  color: var(--overlay1);
  margin: 1.5rem 0;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

/* ── Source music ───────────────────────────────────────────────────────── */

.music-markup {
  color: var(--mauve);
  font-style: italic;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.music-markup--stops,
.music-markup--continues {
  color: var(--overlay1);
}

.music-markup {
  position: relative;
}

.music-link-title {
  display: inline;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.music-link-title:hover,
.music-link-title:focus-visible {
  color: var(--lavender);
  outline: none;
}

.music-store-wrapper {
  position: relative;
  display: inline-block;
}

.music-store-menu {
  position: absolute;
  z-index: 35;
  top: calc(100% + 0.4rem);
  left: var(--music-store-menu-left, 0);
  display: none;
  min-width: 13rem;
  max-width: calc(100vw - 20px);
  padding: 0.35rem;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  background: var(--mantle);
  font-size: 14px;
}

.music-markup.is-open .music-store-menu {
  display: grid;
  gap: 1px;
}

.music-store-heading {
  display: block;
  padding: 0.35rem 0.65rem 0.25rem;
  color: var(--overlay1);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.music-store-menu a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--subtext1);
  line-height: 1.25;
}

.music-store-menu a:hover,
.music-store-menu a:focus-visible {
  background: var(--base);
  color: var(--text);
  outline: none;
}

/* ── Print / PDF ───────────────────────────────────────────────────────── */

@media print {
  @page {
    size: letter;
    margin: 0.7in 0.75in;
  }

  :root {
    --text: #111;
    --subtext0: #555;
    --subtext1: #333;
    --overlay0: #666;
    --overlay1: #444;
    --blue: #111;
    --lavender: #111;
    --rosewater: #111;
    --green: #555;
    --font-size: 11pt;
    --line-height: 1.35;
    --script-width: none;
    --dialog-width: 32em;
  }

  html,
  body {
    height: auto;
    overflow: visible;
    background: #fff;
    color: #111;
  }

  body {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .app {
    display: block;
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .sidebar-toggle,
  .top-actions,
  .playback-controls,
  .scene-play,
  .play-icon {
    display: none !important;
  }

  .script {
    display: block;
    overflow: visible;
    height: auto;
  }

  .script-column {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .title-page {
    display: flex;
    min-height: calc(100vh - 1.4in);
    flex-direction: column;
    justify-content: center;
    margin: 0;
    color: #111;
    break-after: page;
    page-break-after: always;
  }

  .title-page h1,
  .title-page p {
    color: #111;
  }

  .scene {
    position: relative;
    margin: 0;
    break-inside: auto;
    page-break-inside: auto;
  }

  .scene + .scene {
    margin-top: 2.2rem;
  }

  .scene-heading {
    display: block;
    margin: 0 0 1.2rem;
    color: #111;
    font-weight: 700;
    letter-spacing: 0;
    break-after: avoid;
    page-break-after: avoid;
  }

  .scene-number-marker {
    top: 0.1rem;
    right: 0;
    color: #777;
    opacity: 1;
  }

  .scene-number-marker::before {
    background: #777;
  }

  .narration,
  .dialog-block,
  .insert,
  .markup,
  .music-markup {
    color: #111;
    text-shadow: none;
  }

  .narration,
  .insert,
  .markup,
  .music-markup {
    margin-bottom: 1.1rem;
  }

  .narration p {
    margin-bottom: 0.45rem;
  }

  .dialog-block {
    max-width: var(--dialog-width);
    margin-bottom: 1.15rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .character-name {
    color: #111;
    margin-bottom: 0;
  }

  .qualifier,
  .indication,
  .dialog-line--indication {
    color: #555;
    opacity: 1;
  }

  .super-line,
  .super-label {
    color: #111;
  }

  .insert {
    padding: 0;
    border-left: 0;
  }

  .insert-label {
    color: #111;
    font-weight: 700;
  }

  [data-audio-src],
  [data-audio-src].is-reading,
  .dialog-block.is-reading .character-name,
  .dialog-block.is-reading .dialog-text,
  .scene-heading.is-reading {
    color: inherit;
    text-shadow: none;
  }
}

/* ── Insert ─────────────────────────────────────────────────────────────── */

.insert {
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 2px solid var(--surface1);
  color: var(--subtext1);
}

.insert-label {
  font-size: 0.78rem;
  color: var(--overlay0);
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.insert-content {
  font-style: italic;
}

.insert-content p {
  margin-bottom: 0.4rem;
}

.insert-content p:last-child {
  margin-bottom: 0;
}

/* ── Montage ────────────────────────────────────────────────────────────── */

.montage {
  margin: 1rem 0;
}

.montage-label {
  color: var(--overlay1);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.montage-items {
  list-style: none;
  padding: 0;
}

.montage-items li {
  position: relative;
  padding-left: 1.5rem;
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
  color: var(--text);
}

.montage-items li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--overlay0);
}

/* ── Feature Tips ───────────────────────────────────────────────────────── */

.feature-lightbox {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.feature-lightbox.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.feature-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--crust) 72%, transparent);
}

.feature-card {
  position: relative;
  width: min(100%, 25rem);
  display: grid;
  gap: 1.3rem;
  padding: 20px;
  border: 1px solid var(--surface0);
  border-radius: 8px;
  background: color-mix(in srgb, var(--mantle) 80%, var(--base));
  color: var(--text);
  transform: translateY(8px) scale(0.985);
  transition: transform 180ms ease;
}

.feature-lightbox.is-visible .feature-card {
  transform: translateY(0) scale(1);
}

.feature-copy {
  display: grid;
  gap: 0.45rem;
}

.feature-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.feature-description {
  margin: 0;
  color: var(--subtext0);
  font-size: 0.94rem;
  line-height: 1.55;
}

.feature-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.feature-button {
  border: 0;
  border-radius: 999px;
  background: var(--surface1);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 10px 25px 11px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.feature-button:hover,
.feature-button:focus-visible {
  background: var(--surface2);
  outline: none;
}

.feature-button--ghost {
  background: transparent;
  color: var(--subtext0);
}

.feature-button--ghost:hover,
.feature-button--ghost:focus-visible {
  background: var(--surface0);
  color: var(--subtext1);
}

@media (max-width: 720px) {
  .feature-lightbox {
    padding: 1rem;
  }

  .feature-card {
    width: 100%;
    gap: 1.1rem;
    padding: 20px;
    border-radius: 14px;
  }

  .feature-description {
    font-size: 0.92rem;
  }

  .feature-button {
    padding: 12px 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feature-lightbox,
  .feature-card {
    transition: none;
  }
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-page {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--base);
  color: var(--text);
  overflow: hidden;
}

.login-form {
  width: min(100%, 23rem);
  display: grid;
  gap: 1rem;
}

.login-title {
  display: grid;
  gap: 0.35rem;
  text-align: center;
}

.login-title strong {
  color: var(--lavender);
  letter-spacing: 0.15em;
}

.login-title span {
  color: var(--subtext0);
  font-size: 0.9rem;
}

.login-error {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--red) 16%, transparent);
  color: var(--rosewater);
  font-size: 0.9rem;
}

.login-field {
  display: grid;
  gap: 0.35rem;
  color: var(--subtext1);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0;
}

.login-field input {
  width: 100%;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  background: var(--mantle);
  color: var(--text);
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
}

.login-field input:focus {
  border-color: var(--blue);
  outline: none;
}

.login-button {
  border: 0;
  border-radius: 999px;
  background: var(--surface0);
  color: var(--text);
  cursor: pointer;
  padding: 0.75rem 1rem;
  transition: background 0.15s, color 0.15s;
}

.login-button:hover,
.login-button:focus-visible {
  background: var(--surface1);
  outline: none;
}

@media (max-width: 720px) {
  html:has(.login-page),
  body:has(.login-page) {
    height: 100%;
    overflow: hidden;
  }

  .login-page {
    min-height: 100%;
    padding: 1.25rem;
  }
}
