:root {
  --bg: #07111a;
  --bg-elevated: rgba(9, 21, 33, 0.78);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-shadow: 0 24px 90px rgba(0, 0, 0, 0.34);
  --text: #eef6ff;
  --muted: #93a7bc;
  --accent: #ff8b4a;
  --accent-soft: rgba(255, 139, 74, 0.2);
  --accent-2: #60f0d6;
  --canvas-grid: rgba(255, 255, 255, 0.05);
  --frame-bg: rgba(11, 22, 35, 0.9);
  --frame-shadow: 0 20px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(96, 240, 214, 0.14), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(255, 139, 74, 0.16), transparent 35%),
    linear-gradient(180deg, #07111a 0%, #050c13 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

.noise,
.orb {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.noise {
  opacity: 0.09;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 170px 170px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

.orb {
  filter: blur(70px);
  opacity: 0.55;
}

.orb-a {
  background: rgba(96, 240, 214, 0.22);
  transform: translate(-12%, -12%);
}

.orb-b {
  background: rgba(255, 139, 74, 0.18);
  transform: translate(55%, 18%);
}

.orb-c {
  background: rgba(71, 115, 255, 0.16);
  transform: translate(10%, 65%);
}

.shell {
  position: relative;
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.composer,
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(20px);
}

.hero-copy {
  padding: 34px 36px;
}

.eyebrow,
.overlay-label,
.panel-title,
.composer-label,
.beat-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent-2);
}

.hero h1 {
  margin: 10px 0 16px;
  max-width: 14ch;
  font-size: clamp(3rem, 5vw, 5.9rem);
  line-height: 0.94;
  font-weight: 700;
}

.hero h1 span,
.hero h1 em,
.stage-title em {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
}

.hero-body,
.composer-note,
.panel-subtitle,
.beat-body,
.source-note,
.source-text,
.deck-summary,
.overlay-value {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-body-tight {
  margin-top: 12px;
}

.composer {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.composer textarea {
  min-height: 168px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 18px;
  background: rgba(4, 10, 17, 0.82);
  color: var(--text);
  line-height: 1.55;
}

.composer textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: rgba(255, 139, 74, 0.4);
}

.composer-actions,
.transport,
.stage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button,
.deck-chip,
.beat-chip {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.primary-button {
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--accent), #ffb05c);
  color: #121212;
  font-weight: 700;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.deck-chip:hover,
.beat-chip:hover {
  transform: translateY(-1px);
}

.primary-button.small {
  padding: 10px 14px;
}

.secondary-button,
.icon-button,
.deck-chip,
.beat-chip {
  padding: 12px 15px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.viewer-back-link {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.84rem;
}

.viewer-back-link:hover {
  text-decoration: underline;
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 300px;
  gap: 18px;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 360px;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.panel-header.compact {
  margin-bottom: 12px;
}

.deck-list,
.beat-list,
.source-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deck-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.deck-chip,
.beat-chip {
  width: 100%;
  text-align: left;
}

.deck-chip.active,
.beat-chip.active {
  background: linear-gradient(135deg, rgba(255, 139, 74, 0.26), rgba(96, 240, 214, 0.18));
  border-color: rgba(255, 255, 255, 0.22);
}

.chip-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.chip-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
}

.chip-label {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.deck-summary {
  font-size: 0.88rem;
}

.library-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.library-card.active,
.library-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.library-card-image-wrap,
.selected-image-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.library-card-image-wrap {
  aspect-ratio: 16 / 9;
}

.library-card-image,
.selected-image,
.reference-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-card-title {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.2;
}

.library-card-actions,
.selected-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.small-card-select,
.small-card-open {
  padding: 10px 13px;
  text-decoration: none;
}

.selected-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.selected-image-wrap {
  aspect-ratio: 16 / 10;
}

.selected-image-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.selected-panel-header {
  margin-bottom: 0;
}

.selected-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stage-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.stage-company,
.stage-title {
  margin: 0;
}

.stage-company {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
}

.stage-title {
  margin-top: 6px;
  font-size: clamp(1.5rem, 2vw, 2.35rem);
  line-height: 1.06;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.8rem;
}

.meta-pill-alt {
  color: var(--accent-2);
}

.stage {
  position: relative;
  padding: 22px;
  min-height: 720px;
  overflow: hidden;
}

.stage-overlay {
  position: absolute;
  left: 22px;
  right: 22px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.stage-overlay-top {
  top: 22px;
}

.stage-overlay-bottom {
  bottom: 22px;
}

.overlay-value {
  margin-top: 6px;
  max-width: 42ch;
  color: var(--text);
}

.viewport {
  position: relative;
  height: 100%;
  min-height: 676px;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at top, rgba(96, 240, 214, 0.16), transparent 25%),
    radial-gradient(circle at bottom right, rgba(255, 139, 74, 0.14), transparent 28%),
    #06111b;
  background-size: 140px 140px, 140px 140px, auto, auto, auto;
}

.canvas-track {
  position: absolute;
  width: 4200px;
  height: 3300px;
  transform-origin: top left;
  transition: transform 1050ms cubic-bezier(0.2, 0.9, 0.1, 1);
  will-change: transform;
}

.canvas-track.reduced-motion {
  transition-duration: 120ms;
}

.frame {
  position: absolute;
  border-radius: 42px;
  background: rgba(7, 15, 24, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--frame-shadow);
  overflow: hidden;
  isolation: isolate;
  transform: rotate(var(--frame-tilt, 0deg));
  transition:
    transform 240ms ease,
    border-color 240ms ease,
    box-shadow 240ms ease;
}

.frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(5, 11, 18, 0.18), rgba(5, 11, 18, 0.42));
  pointer-events: none;
  z-index: 5;
}

.frame::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.7;
  z-index: 1;
  pointer-events: none;
}

.frame.active {
  border-color: rgba(255, 255, 255, 0.26);
  box-shadow:
    0 26px 90px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: rotate(var(--frame-tilt, 0deg)) scale(1.015);
}

.frame-grid,
.frame-aura,
.frame-visuals,
.frame-chip-cluster,
.frame-story-card,
.frame-caption-strip {
  position: absolute;
}

.frame-aura {
  inset: auto auto -18% -8%;
  width: 66%;
  height: 62%;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.42;
  z-index: 0;
}

.frame-grid {
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.frame-visuals {
  inset: 0;
  z-index: 2;
}

.frame-shot {
  position: absolute;
  margin: 0;
  overflow: hidden;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.frame-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-shot-secondary,
.frame-shot-tertiary,
.frame-shot-quaternary {
  backdrop-filter: blur(16px);
}

.frame[data-layout="spread"] .frame-shot-primary {
  inset: 48px 176px 72px 48px;
}

.frame[data-layout="spread"] .frame-shot-secondary {
  width: 236px;
  height: 154px;
  top: 48px;
  right: 52px;
  transform: rotate(6deg);
}

.frame[data-layout="spread"] .frame-shot-tertiary {
  width: 214px;
  height: 148px;
  top: 230px;
  right: 72px;
  transform: rotate(-7deg);
}

.frame[data-layout="spread"] .frame-shot-quaternary {
  width: 250px;
  height: 168px;
  bottom: 92px;
  right: 44px;
  transform: rotate(8deg);
}

.frame[data-layout="portrait"] .frame-shot-primary {
  inset: 48px 46px 52px 238px;
}

.frame[data-layout="portrait"] .frame-shot-secondary {
  width: 238px;
  height: 176px;
  top: 68px;
  left: 44px;
  transform: rotate(-6deg);
}

.frame[data-layout="portrait"] .frame-shot-tertiary {
  width: 214px;
  height: 150px;
  bottom: 260px;
  left: 68px;
  transform: rotate(8deg);
}

.frame[data-layout="portrait"] .frame-shot-quaternary {
  width: 230px;
  height: 156px;
  bottom: 72px;
  left: 54px;
  transform: rotate(-3deg);
}

.frame[data-layout="mosaic"] .frame-shot-primary {
  inset: 56px 360px 90px 54px;
}

.frame[data-layout="mosaic"] .frame-shot-secondary {
  width: 280px;
  height: 240px;
  top: 48px;
  right: 56px;
  transform: rotate(5deg);
}

.frame[data-layout="mosaic"] .frame-shot-tertiary {
  width: 290px;
  height: 210px;
  top: 322px;
  right: 92px;
  transform: rotate(-6deg);
}

.frame[data-layout="mosaic"] .frame-shot-quaternary {
  width: 260px;
  height: 178px;
  bottom: 84px;
  right: 72px;
  transform: rotate(7deg);
}

.frame[data-layout="panorama"] .frame-shot-primary {
  inset: 42px 54px 206px 54px;
}

.frame[data-layout="panorama"] .frame-shot-secondary {
  width: 238px;
  height: 144px;
  bottom: 46px;
  left: 74px;
  transform: rotate(-4deg);
}

.frame[data-layout="panorama"] .frame-shot-tertiary {
  width: 238px;
  height: 144px;
  bottom: 64px;
  left: 354px;
  transform: rotate(3deg);
}

.frame[data-layout="panorama"] .frame-shot-quaternary {
  width: 238px;
  height: 144px;
  bottom: 52px;
  left: 636px;
  transform: rotate(-5deg);
}

.frame[data-layout="stack"] .frame-shot-primary {
  inset: 62px 78px 224px 110px;
  transform: rotate(-3deg);
}

.frame[data-layout="stack"] .frame-shot-secondary {
  inset: 138px 122px 150px 78px;
  opacity: 0.56;
  transform: rotate(6deg);
}

.frame[data-layout="stack"] .frame-shot-tertiary {
  width: 220px;
  height: 152px;
  bottom: 56px;
  left: 80px;
  transform: rotate(-9deg);
}

.frame[data-layout="stack"] .frame-shot-quaternary {
  width: 240px;
  height: 168px;
  bottom: 70px;
  right: 86px;
  transform: rotate(7deg);
}

.frame[data-layout="closing"] .frame-shot-primary {
  inset: 34px 34px 34px 34px;
}

.frame[data-layout="closing"] .frame-shot-secondary {
  width: 254px;
  height: 174px;
  top: 54px;
  right: 54px;
  transform: rotate(7deg);
}

.frame[data-layout="closing"] .frame-shot-tertiary {
  width: 262px;
  height: 178px;
  bottom: 62px;
  left: 58px;
  transform: rotate(-8deg);
}

.frame[data-layout="closing"] .frame-shot-quaternary {
  width: 238px;
  height: 162px;
  bottom: 82px;
  right: 88px;
  transform: rotate(5deg);
}

.frame-chip-cluster {
  top: 34px;
  right: 34px;
  z-index: 6;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 46%;
}

.frame-chip {
  display: inline-flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(8, 17, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.frame-chip-accent {
  color: var(--accent-2);
}

.frame-story-card {
  left: 32px;
  bottom: 32px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(420px, calc(100% - 64px));
  padding: 20px 22px;
  border-radius: 28px;
  background: rgba(8, 17, 27, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.frame[data-layout="portrait"] .frame-story-card {
  top: 30px;
  bottom: auto;
  left: 30px;
  width: min(320px, calc(100% - 300px));
}

.frame[data-layout="mosaic"] .frame-story-card {
  width: min(420px, calc(100% - 420px));
}

.frame[data-layout="panorama"] .frame-story-card {
  top: 34px;
  bottom: auto;
  left: 36px;
  width: min(340px, calc(100% - 72px));
}

.frame[data-layout="stack"] .frame-story-card {
  right: 34px;
  left: auto;
  bottom: 228px;
  width: min(300px, calc(100% - 110px));
}

.frame[data-layout="closing"] .frame-story-card {
  left: 50%;
  bottom: 38px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 88px));
  text-align: center;
  align-items: center;
}

.frame-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.frame-title {
  margin: 0;
  font-size: clamp(1.9rem, 2.6vw, 2.8rem);
  line-height: 0.96;
}

.frame-body {
  margin: 0;
  color: rgba(238, 246, 255, 0.82);
  line-height: 1.5;
  max-width: 30ch;
}

.frame[data-layout="closing"] .frame-body {
  max-width: 42ch;
}

.frame-caption-strip {
  right: 32px;
  bottom: 32px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(260px, calc(100% - 64px));
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(8, 17, 27, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
}

.frame-caption-label {
  color: var(--accent-2);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.frame-caption-text {
  color: rgba(238, 246, 255, 0.74);
  font-size: 0.84rem;
  line-height: 1.35;
}

.progress-group {
  flex: 1;
}

.progress-bar {
  margin-top: 8px;
  height: 8px;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 320ms ease;
}

.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.motion-toggle input {
  width: 18px;
  height: 18px;
}

.current-beat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.beat-title {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.05;
}

.source-stack {
  margin-top: 18px;
}

.viewer-page {
  min-height: 100vh;
  overflow: hidden;
}

.viewer-shell {
  width: min(1600px, calc(100vw - 24px));
}

.viewer-stage-fullscreen {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.viewer-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.viewer-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.viewer-title {
  margin: 0;
  font-size: clamp(1.8rem, 2.2vw, 3rem);
  line-height: 1.02;
}

.viewer-chrome {
  position: absolute;
  left: 22px;
  right: 22px;
  z-index: 7;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.viewer-chrome > * {
  pointer-events: auto;
}

.viewer-chrome-top {
  top: 22px;
  align-items: flex-start;
}

.viewer-chrome-bottom {
  bottom: 22px;
  align-items: flex-end;
}

.viewer-page.viewer-chrome-hidden .viewer-chrome {
  opacity: 0;
  pointer-events: none;
}

.viewer-page.viewer-chrome-hidden .viewer-chrome-top {
  transform: translateY(-14px);
}

.viewer-page.viewer-chrome-hidden .viewer-chrome-bottom {
  transform: translateY(14px);
}

.viewer-heading-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewer-hook {
  margin: 0;
  max-width: 48ch;
  color: var(--muted);
  line-height: 1.45;
}

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.viewer-icon-button {
  min-width: 92px;
}

.viewer-viewport-fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at top, rgba(96, 240, 214, 0.12), transparent 25%),
    radial-gradient(circle at bottom right, rgba(255, 139, 74, 0.12), transparent 28%),
    #050d16;
}

.viewer-overlay-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(520px, calc(100vw - 44px));
  padding: 16px 18px;
  border-radius: 24px;
  background: rgba(8, 18, 29, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.34);
}

.viewer-overlay-card-right {
  min-width: min(420px, calc(100vw - 44px));
}

.viewer-timer-row,
.viewer-progress-header,
.viewer-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.timer-value,
.viewer-progress-text,
.timer-help {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.timer-value {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 700;
}

.timer-help,
.viewer-progress-text {
  color: var(--muted);
}

.viewer-progress-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-beat-title {
  display: none;
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-progress-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-thin {
  height: 6px;
}

.viewer-side-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14vw;
  min-width: 80px;
  z-index: 5;
  background: transparent;
  cursor: pointer;
}

.viewer-side-hit-left {
  left: 0;
}

.viewer-side-hit-right {
  right: 0;
}

.viewer-side-hit::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 180ms ease;
}

.viewer-side-hit-left::after {
  left: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent);
}

.viewer-side-hit-right::after {
  right: 0;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.05), transparent);
}

.viewer-side-hit:hover::after {
  opacity: 1;
}

.reference-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reference-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.reference-card img {
  aspect-ratio: 16 / 9;
  border-radius: 14px;
}

.reference-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.missing-panel {
  margin-top: 40px;
}

.missing-title {
  margin: 8px 0 14px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

.shell-narrow {
  width: min(760px, calc(100vw - 24px));
}

.source-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 22px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.source-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.source-name {
  font-weight: 700;
}

.source-text {
  font-size: 0.9rem;
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .studio-grid,
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 640px;
  }

  .right-rail,
  .left-rail {
    order: 2;
  }
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 12px;
  }

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

  .deck-library {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .composer,
  .panel {
    border-radius: 24px;
  }

  .hero h1 {
    max-width: 12ch;
  }

  .stage {
    padding: 14px;
    min-height: 540px;
  }

  .viewer-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-chrome {
    left: 14px;
    right: 14px;
  }

  .viewer-chrome-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-overlay-card,
  .viewer-overlay-card-right {
    max-width: none;
    min-width: 0;
  }

  .stage-overlay {
    position: relative;
    inset: auto;
    margin-bottom: 12px;
  }

  .stage-overlay-bottom {
    margin-top: 12px;
    margin-bottom: 0;
  }

  .viewport {
    min-height: 420px;
  }

  .viewer-viewport-fullscreen {
    min-height: 100vh;
  }
}

@media (max-width: 640px) {
  .hero-copy,
  .composer,
  .panel {
    padding: 16px;
  }

  .stage-title {
    font-size: 1.42rem;
  }

  .viewer-title {
    font-size: 1rem;
    max-width: 52vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stage-overlay,
  .composer-actions,
  .transport {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-side-hit {
    width: 14vw;
    min-width: 42px;
  }

  .viewer-chrome-top {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    gap: 8px;
    align-items: flex-start;
  }

  .viewer-chrome-bottom {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    align-items: stretch;
  }

  .viewer-heading {
    gap: 4px;
    min-width: 0;
  }

  .viewer-heading-copy {
    gap: 2px;
  }

  .viewer-hook {
    display: none;
  }

  #viewer-deck-company,
  #viewer-deck-stage {
    display: none;
  }

  .viewer-back-link {
    font-size: 0.72rem;
  }

  .viewer-toolbar {
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: nowrap;
    max-width: none;
  }

  .viewer-toolbar .meta-pill {
    padding: 6px 8px;
    font-size: 0.68rem;
  }

  .viewer-icon-button,
  .primary-button.small {
    min-width: 38px;
    width: 38px;
    padding: 8px 0;
    font-size: 0.78rem;
  }

  .viewer-overlay-card {
    padding: 10px 12px;
    border-radius: 18px;
    backdrop-filter: blur(12px);
  }

  .viewer-overlay-card-left {
    display: none;
  }

  .viewer-overlay-card-right {
    width: 100%;
    min-width: 0;
    max-width: none;
    gap: 10px;
  }

  .mobile-beat-title {
    display: block;
  }

  .viewer-timer-row,
  .viewer-progress-header,
  .viewer-toggle-row {
    flex-direction: row;
    align-items: center;
  }

  .overlay-label {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }

  .timer-value {
    margin-top: 4px;
    font-size: 1rem;
  }

  .timer-help {
    display: none;
  }

  .viewer-progress-stack {
    gap: 8px;
  }

  .viewer-progress-text {
    font-size: 0.74rem;
  }

  .motion-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .canvas-track {
    width: 3600px;
    height: 3000px;
  }

  .frame {
    border-radius: 26px;
  }

  .frame::after {
    inset: 12px;
    border-radius: 20px;
  }

  .frame-shot {
    border-radius: 18px;
  }

  .frame-story-card {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
    padding: 14px 15px;
    border-radius: 18px;
    gap: 8px;
  }

  .frame[data-layout="portrait"] .frame-story-card,
  .frame[data-layout="panorama"] .frame-story-card,
  .frame[data-layout="stack"] .frame-story-card,
  .frame[data-layout="closing"] .frame-story-card {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    width: auto;
    transform: none;
    text-align: left;
    align-items: flex-start;
  }

  .frame-title {
    font-size: 1.2rem;
  }

  .frame-body,
  .frame-caption-strip {
    display: none;
  }

  .frame-chip-cluster {
    top: 16px;
    left: 16px;
    right: 16px;
    max-width: none;
    justify-content: flex-start;
  }

  .frame-chip {
    padding: 6px 9px;
    font-size: 0.6rem;
  }

  .frame[data-layout="spread"] .frame-shot-primary {
    inset: 20px 72px 20px 20px;
  }

  .frame[data-layout="spread"] .frame-shot-secondary,
  .frame[data-layout="spread"] .frame-shot-tertiary,
  .frame[data-layout="spread"] .frame-shot-quaternary {
    width: 96px;
    height: 66px;
    right: 12px;
  }

  .frame[data-layout="spread"] .frame-shot-secondary {
    top: 18px;
  }

  .frame[data-layout="spread"] .frame-shot-tertiary {
    top: 98px;
  }

  .frame[data-layout="spread"] .frame-shot-quaternary {
    top: 178px;
    bottom: auto;
  }

  .frame[data-layout="portrait"] .frame-shot-primary {
    inset: 18px 18px 18px 102px;
  }

  .frame[data-layout="portrait"] .frame-shot-secondary,
  .frame[data-layout="portrait"] .frame-shot-tertiary,
  .frame[data-layout="portrait"] .frame-shot-quaternary {
    width: 88px;
    height: 70px;
    left: 12px;
  }

  .frame[data-layout="portrait"] .frame-shot-secondary {
    top: 28px;
  }

  .frame[data-layout="portrait"] .frame-shot-tertiary {
    top: 112px;
    bottom: auto;
  }

  .frame[data-layout="portrait"] .frame-shot-quaternary {
    top: 196px;
    bottom: auto;
  }

  .frame[data-layout="mosaic"] .frame-shot-primary {
    inset: 20px 114px 20px 20px;
  }

  .frame[data-layout="mosaic"] .frame-shot-secondary,
  .frame[data-layout="mosaic"] .frame-shot-tertiary,
  .frame[data-layout="mosaic"] .frame-shot-quaternary {
    width: 88px;
    height: 72px;
    right: 12px;
  }

  .frame[data-layout="mosaic"] .frame-shot-secondary {
    top: 18px;
  }

  .frame[data-layout="mosaic"] .frame-shot-tertiary {
    top: 104px;
  }

  .frame[data-layout="mosaic"] .frame-shot-quaternary {
    top: 190px;
    bottom: auto;
  }

  .frame[data-layout="panorama"] .frame-shot-primary {
    inset: 18px 18px 98px 18px;
  }

  .frame[data-layout="panorama"] .frame-shot-secondary,
  .frame[data-layout="panorama"] .frame-shot-tertiary,
  .frame[data-layout="panorama"] .frame-shot-quaternary {
    width: calc((100% - 58px) / 3);
    height: 62px;
    bottom: 18px;
    left: auto;
  }

  .frame[data-layout="panorama"] .frame-shot-secondary {
    left: 18px;
  }

  .frame[data-layout="panorama"] .frame-shot-tertiary {
    left: calc(18px + (100% - 58px) / 3 + 11px);
  }

  .frame[data-layout="panorama"] .frame-shot-quaternary {
    right: 18px;
    left: auto;
  }

  .frame[data-layout="stack"] .frame-shot-primary {
    inset: 24px 32px 108px 34px;
  }

  .frame[data-layout="stack"] .frame-shot-secondary {
    inset: 38px 42px 120px 20px;
  }

  .frame[data-layout="stack"] .frame-shot-tertiary,
  .frame[data-layout="stack"] .frame-shot-quaternary {
    width: 98px;
    height: 68px;
    bottom: 20px;
  }

  .frame[data-layout="stack"] .frame-shot-tertiary {
    left: 20px;
  }

  .frame[data-layout="stack"] .frame-shot-quaternary {
    right: 20px;
  }

  .frame[data-layout="closing"] .frame-shot-primary {
    inset: 14px;
  }

  .frame[data-layout="closing"] .frame-shot-secondary,
  .frame[data-layout="closing"] .frame-shot-tertiary,
  .frame[data-layout="closing"] .frame-shot-quaternary {
    width: 92px;
    height: 64px;
  }

  .frame[data-layout="closing"] .frame-shot-secondary {
    top: 18px;
    right: 18px;
  }

  .frame[data-layout="closing"] .frame-shot-tertiary {
    bottom: 94px;
    left: 18px;
  }

  .frame[data-layout="closing"] .frame-shot-quaternary {
    bottom: 94px;
    right: 18px;
  }
}
