:root {
  color-scheme: light;
  --ink: #191916;
  --muted: #77756d;
  --line: #d8d5ca;
  --paper: #ffffff;
  --note-tint: #faf7ee;
  --note-tint-strong: #f5f0e5;
  --surface: #efede6;
  --dark: #171714;
  --accent: #ff8a12;
  --accent-dark: #dc6f00;
  --shadow: 0 18px 45px rgba(31, 29, 23, 0.15);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 980px;
  background: #dedbd2;
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(270px, 1fr) auto auto minmax(210px, 1fr);
  align-items: center;
  height: 68px;
  padding: 0 20px;
  background: var(--dark);
  color: white;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.24);
}

.workspace-tabs {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #3b3b36;
  border-radius: 10px;
  background: #22221f;
}

.workspace-tab {
  min-height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #96958e;
  font-size: 12px;
  font-weight: 800;
}

.workspace-tab.active { background: #f7f4ec; color: #24231f; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  display: block;
  width: min(320px, 26vw);
  height: 42px;
  object-fit: contain;
  object-position: left center;
}

.brand-name {
  display: none;
  color: #f7f3ea;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-copy {
  display: grid;
  min-width: 110px;
  gap: 1px;
}

.brand-colbtron .brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.brand-colbtron .brand-name {
  display: block;
}

.brand-nedstory .brand-logo {
  width: min(250px, 21vw);
  height: 42px;
}

.brand-nedstory .brand-copy {
  min-width: 110px;
}

.brand-nedstory .recent-logo {
  width: min(430px, 44vw);
  height: 74px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 138, 18, 0.42);
  border-radius: 10px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 198, 86, 0.95), transparent 34%),
    linear-gradient(135deg, #ff9c1a, #d66700);
  color: #151511;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(255, 138, 18, 0.1);
}

.brand div {
  display: flex;
  flex-direction: column;
}

.brand > div {
  min-width: 110px;
}

.brand strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.brand-studio {
  color: #f7f4ec;
  font-weight: 500;
}

.brand-studio::first-letter {
  text-transform: lowercase;
}

.brand-divider {
  color: #85847d;
  font-weight: 300;
}

.brand-product {
  color: #f7f4ec;
  font-size: 17px;
  font-weight: 500;
}

.brand-product span {
  color: var(--accent);
  font-weight: 900;
}

.brand .save-status-label {
  color: #74736d;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand #saveStatus {
  color: #99988f;
  font-size: 11px;
}

.toolbar {
  display: flex;
  gap: 7px;
}

.project-controls {
  justify-self: center;
}

.output-controls {
  justify-self: end;
}

.mode-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-controls > .button {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 11px;
}

.fidelity-switch {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 3px;
  padding: 3px;
  border: 1px solid #393934;
  border-radius: 9px;
  background: #20201d;
}

.fidelity-switch button {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #85847d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fidelity-switch button.active {
  background: #f0ede3;
  color: #23231f;
}

.button,
.icon-button,
.attach-button {
  border: 0;
  border-radius: 8px;
  transition:
    background 140ms ease,
    transform 140ms ease;
}

.button {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button-quiet {
  background: #2b2b27;
  color: #e9e8e2;
}

.button-quiet:hover {
  background: #3a3a35;
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-danger {
  border: 1px solid #d5a89e;
  background: transparent;
  color: #9e3924;
}

.workspace {
  display: grid;
  grid-template-columns: 154px minmax(760px, 1fr);
  grid-template-rows: auto auto;
  min-height: calc(100vh - 68px);
}

.recent-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  overflow: auto;
  background:
    radial-gradient(circle at 20% 8%, rgba(223, 91, 57, 0.24), transparent 30%),
    radial-gradient(circle at 82% 86%, rgba(255, 210, 130, 0.13), transparent 32%),
    #171714;
  backdrop-filter: blur(11px);
}

.recent-overlay[hidden] {
  display: none;
}

.recent-dialog {
  width: min(980px, 100%);
  height: min(780px, calc(100vh - 56px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background: #f4f1e8;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.35);
}

.recent-hero {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 22px 28px 18px;
  border-bottom: 1px solid #d7d2c5;
  background:
    linear-gradient(135deg, #fffdf7, #ece6d8);
}

.recent-logo {
  display: block;
  width: min(360px, 42vw);
  height: 58px;
  object-fit: contain;
  object-position: left center;
}

.brand-colbtron .recent-logo {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px #d8d2c5;
}

.recent-hero .recent-brand-mark {
  flex: 0 0 auto;
  background: #171714;
}

.recent-hero p {
  max-width: 620px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.recent-body {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  min-height: 0;
}

.recent-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-right: 1px solid #d7d2c5;
  background: #e8e2d4;
}

.recent-sidebar .button {
  width: 100%;
  min-height: 32px;
}

.recent-sidebar p {
  margin: 8px 0 0;
  color: #6f6b60;
  font-size: 12px;
  line-height: 1.45;
}

.recent-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 28px;
  background: #f6f2e9;
  scrollbar-gutter: stable;
}

.recent-list::after {
  content: "";
  height: 2px;
}

.recent-loading,
.recent-empty,
.recent-card {
  border: 1px solid #d0ccc1;
  border-radius: 12px;
  background: #fffefa;
}

.recent-loading,
.recent-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.recent-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: 11px 13px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 5px 18px rgba(40, 36, 29, 0.06);
  transition:
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.recent-card:hover,
.recent-card:focus-visible {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(40, 36, 29, 0.11);
}

.recent-card.empty-draft {
  opacity: 0.82;
}

.recent-card-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  aspect-ratio: 16 / 10;
  padding: 7px;
  border: 1px solid #cbc5b7;
  border-radius: 8px;
  background: #eee8dc;
}

.recent-card-preview span {
  border: 1px solid #c8c0b0;
  border-radius: 2px;
  background: #fffaf0;
}

.recent-card-preview span.filled {
  border-color: #c76d50;
  background: linear-gradient(135deg, #ef8a67, #a9412c);
}

.recent-card-copy {
  min-width: 0;
}

.recent-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
  line-height: 1.15;
}

.recent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 11px;
}

.recent-progress {
  display: block;
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ded0;
}

.recent-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.recent-progress-label {
  display: block;
  margin-top: 4px;
  color: #8a8274;
  font-size: 10px;
}

.recent-card-actions {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.recent-pill {
  padding: 4px 7px;
  border-radius: 999px;
  background: #e9e5da;
  color: #5d5a52;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.recent-trash {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #948b7a;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.72;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.recent-trash:hover,
.recent-trash:focus-visible {
  border-color: #ead0c6;
  background: #fff0e8;
  color: #b64a2e;
  opacity: 1;
  outline: none;
}

.page-rail {
  grid-row: 1 / span 2;
  padding: 19px 14px;
  border-right: 1px solid #c5c1b7;
  background: #d5d2c9;
}

.script-workspace {
  grid-column: 1 / -1;
  grid-row: 1 / span 2;
  min-height: calc(100vh - 68px);
  overflow: auto;
  padding: 34px 28px 70px;
  background: #e7e3da;
}

.script-shell { width: min(1120px, 100%); margin: 0 auto; }
.script-hero, .scene-list-heading, .script-finish-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.script-hero h1 { margin: 4px 0 7px; font-size: 34px; }
.script-hero p { max-width: 680px; margin: 0; color: #68655d; line-height: 1.45; }
.script-hero-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.script-draft-card { margin: 24px 0 34px; padding: 22px; border: 1px solid #cec9bc; border-radius: 14px; background: #fff; box-shadow: 0 10px 28px rgba(44, 39, 29, .08); }
.script-draft-card > label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.script-draft-card textarea { width: 100%; resize: vertical; border: 1px solid #d4d0c5; border-radius: 9px; padding: 18px; color: #272620; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; line-height: 1.65; }
.script-draft-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 10px; color: #77736a; font-size: 11px; }
.scene-list-heading { margin-bottom: 12px; }
.scene-list-heading h2 { margin: 3px 0 0; font-size: 22px; }
.script-scene-list { display: grid; gap: 12px; }
.script-scene-card { display: grid; grid-template-columns: 78px minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; padding: 18px; border: 1px solid #cec9bc; border-radius: 12px; background: #faf9f5; }
.script-scene-number { display: grid; align-content: center; justify-items: center; border-right: 1px solid #ddd8cc; color: #77736a; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.script-scene-number strong { color: var(--accent-dark); font-size: 28px; line-height: 1.1; }
.script-scene-card label span { display: block; margin-bottom: 6px; color: #5f5c54; font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.script-scene-card textarea { width: 100%; min-height: 92px; resize: vertical; border: 1px solid #d5d1c6; border-radius: 8px; padding: 11px; background: #fff; line-height: 1.45; }
.script-finish-bar { position: sticky; bottom: 12px; margin-top: 22px; padding: 13px 16px; border-radius: 12px; background: #25241f; color: #d7d3ca; box-shadow: 0 12px 28px rgba(0,0,0,.2); font-size: 12px; }
.script-finish-actions { display: flex; align-items: center; gap: 8px; }
.script-finish-actions .button-quiet { border-color: #55534c; background: #36352f; color: #f3efe6; }

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 14px;
  color: #5c5a53;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-actions {
  display: flex;
  gap: 5px;
}

.icon-button {
  width: 28px;
  height: 28px;
  background: #bebbb1;
  color: #33322d;
  font-size: 18px;
}

.icon-button-delete {
  color: #8f3929;
}

.icon-button-delete:hover:not(:disabled) {
  background: #cfa99e;
  color: #6f2418;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.page-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-thumb {
  width: 100%;
  padding: 7px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #626057;
  text-align: left;
}

.page-thumb.active {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.3);
  color: var(--ink);
}

.thumb-sheet {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  aspect-ratio: 16 / 10;
  margin-bottom: 6px;
  padding: 6px;
  background: #fbfaf5;
  box-shadow: 0 3px 8px rgba(39, 37, 31, 0.12);
}

.thumb-sheet span {
  border: 1px solid #cfccc2;
  background: #e9e7df;
}

.thumb-sheet span.filled {
  border-color: #c76d50;
  background: linear-gradient(135deg, #ef8a67, #a9412c);
}

.page-thumb strong {
  font-size: 11px;
}

.page-thumb small {
  display: block;
  margin-top: 2px;
  color: #8a857a;
  font-size: 9px;
  font-weight: 800;
}

.canvas-wrap {
  overflow: auto;
  padding: 22px 24px 56px;
}

.canvas-topline {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(300px, 1fr);
  align-items: end;
  gap: 18px;
  width: min(100%, 1280px);
  margin: 0 auto 12px;
}

.canvas-heading-block {
  display: grid;
  justify-items: start;
}

.canvas-undo {
  min-height: 26px;
  margin-top: 7px;
  padding: 5px 9px;
  font-size: 10px;
}

.canvas-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-self: center;
}

.canvas-mode-controls {
  justify-self: end;
}

.canvas-mode-controls > .button {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 10px;
}

.frame-dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 18, 16, 0.58);
}

.frame-dialog-backdrop[hidden] {
  display: none;
}

.frame-dialog {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid #d3cec2;
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.frame-dialog h2 {
  margin-bottom: 8px;
  color: var(--ink);
}

.frame-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.frame-dialog label {
  display: grid;
  gap: 6px;
  color: #77746b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.frame-dialog input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #cbc4b7;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.frame-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast-message {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 26px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(25, 24, 21, 0.92);
  color: #fffaf0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast-message.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 3px 0 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.character-library,
.reference-library {
  padding: 14px 16px;
  border: 1px solid #d1cec4;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.48);
}

.story-context {
  padding: 14px 16px;
  border: 1px solid #d1cec4;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
}

.story-context-heading,
.character-library-heading,
.reference-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-context-heading .button,
.character-library-heading .button,
.reference-library-heading .button {
  padding: 7px 9px;
  font-size: 10px;
}

.story-context textarea {
  width: 100%;
  min-height: 178px;
  margin-top: 10px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #c7c2b5;
  border-radius: 8px;
  outline: 0;
  background: #fffefa;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.42;
}

.story-context textarea:focus {
  border-color: var(--accent);
}

.story-context-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.character-library-help,
.reference-library-help {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.character-list,
.reference-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.character-empty,
.reference-empty {
  padding: 12px;
  border: 1px dashed #c4c0b5;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.character-card,
.reference-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 7px;
  border: 1px solid #c9c5bb;
  border-radius: 8px;
  background: #fffefa;
}

.character-card.inactive,
.reference-card.inactive {
  opacity: 0.55;
}

.character-card img,
.reference-card img {
  width: 58px;
  height: 58px;
  border-radius: 5px;
  object-fit: cover;
  background: #ddd9cf;
}

.character-fields,
.reference-fields {
  display: grid;
  gap: 5px;
}

.character-fields input,
.character-fields textarea,
.reference-fields input,
.reference-fields textarea {
  width: 100%;
  padding: 4px 5px;
  border: 1px solid #d0ccc1;
  border-radius: 4px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
}

.character-fields textarea,
.reference-fields textarea {
  min-height: 40px;
  resize: vertical;
}

.character-actions,
.reference-actions {
  display: grid;
  gap: 5px;
}

.character-actions button,
.reference-actions button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: #e7e4db;
  color: #625f57;
  cursor: pointer;
}

.storyboard-page {
  width: min(100%, 1280px);
  margin: auto;
  padding: 32px 38px 36px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.print-pages {
  display: none;
}

.page-header {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1fr 1fr 0.8fr auto;
  gap: 12px;
  align-items: end;
  min-height: 58px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.field span,
.panel-fields label > span {
  color: #77746b;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  min-width: 0;
  padding: 3px 0 5px;
  border: 0;
  border-bottom: 1px solid #b8b4aa;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.field input:focus {
  border-color: var(--accent);
}

.field-title input {
  font-size: 17px;
  font-weight: 800;
}

.page-number {
  padding-bottom: 5px;
  color: #716f67;
  font-size: 10px;
  text-transform: uppercase;
}

.page-number strong {
  color: var(--ink);
  font-size: 14px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
}

.story-panel {
  display: grid;
  min-width: 0;
  grid-template-rows: auto auto;
  border: 1px solid #bbb8af;
  background: white;
  box-shadow: 0 3px 9px rgba(48, 45, 37, 0.08);
  transition:
    border-color 140ms ease,
    opacity 140ms ease,
    box-shadow 140ms ease;
}

.story-panel.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(223, 91, 57, 0.22);
}

.story-panel.dragging {
  opacity: 0.46;
}

.story-panel.drag-over {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(223, 91, 57, 0.28),
    0 8px 20px rgba(48, 45, 37, 0.16);
}

.panel-image {
  position: relative;
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid #c8c5bb;
  cursor: grab;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent),
    #2c2c29;
}

.story-panel.dragging .panel-image {
  cursor: grabbing;
}

.panel-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.story-panel.using-cached-image .panel-image::after,
.story-panel.image-unavailable .panel-image::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  padding: 4px 7px;
  border-radius: 999px;
  color: white;
  background: rgba(24, 24, 21, 0.78);
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

.story-panel.using-cached-image .panel-image::after {
  content: "Cached copy";
}

.story-panel.image-unavailable .panel-image::after {
  content: "Image unavailable";
}

body.image-viewer-open {
  overflow: hidden;
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: #f5f3eb;
  background: rgba(12, 12, 10, 0.96);
  backdrop-filter: blur(12px);
}

.image-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 750;
}

.image-viewer-actions {
  display: flex;
  gap: 7px;
}

.image-viewer-actions button {
  min-width: 40px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  font: inherit;
  cursor: pointer;
}

.image-viewer-actions button:hover,
.image-viewer-actions button:focus-visible {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.image-viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.image-viewer-stage.dragging {
  cursor: grabbing;
}

.image-viewer-stage img {
  display: block;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 145px);
  object-fit: contain;
  user-select: none;
  transform-origin: center;
  will-change: transform;
}

.image-viewer-help {
  margin: 0;
  padding: 10px 18px 13px;
  color: #aaa89f;
  text-align: center;
  font-size: 11px;
}

.panel-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  color: #c9c7be;
  text-align: center;
}

.story-panel.has-image .panel-placeholder {
  display: none !important;
}

.panel-placeholder-icon {
  color: #f47755;
  font-size: 20px;
}

.panel-placeholder strong {
  margin: 5px 0;
  color: #f0efe9;
  font-size: 11px;
}

.panel-placeholder span:last-child {
  max-width: 180px;
  color: #8f8e86;
  font-size: 9px;
  line-height: 1.35;
}

.panel-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  display: grid;
  min-width: 24px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
  background: rgba(18, 18, 16, 0.76);
  color: white;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.panel-badge:hover,
.panel-badge:focus-visible {
  outline: 0;
  background: rgba(223, 91, 57, 0.9);
}

.panel-tools {
  position: absolute;
  top: 6px;
  right: 7px;
  z-index: 4;
  display: flex;
  gap: 4px;
}

.generation-progress {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  z-index: 5;
  display: grid;
  gap: 5px;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(18, 18, 16, 0.78);
  color: #fff8ed;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.generation-progress[hidden] {
  display: none;
}

.generation-progress-label {
  overflow: hidden;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.generation-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.generation-progress-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8a16, #ffd166);
  transition: width 700ms ease;
}

.story-panel.generating .panel-image {
  box-shadow: inset 0 0 0 2px rgba(255, 138, 22, 0.55);
}

.panel-menu,
.panel-version-prev,
.panel-version-next {
  width: 24px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: rgba(18, 18, 16, 0.72);
  color: #dddcd5;
  font-size: 13px;
}

.panel-version-prev:disabled,
.panel-version-next:disabled {
  display: none;
}

.panel-fields {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 92px;
  background: var(--note-tint);
}

.panel-fields label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px 5px;
  background: var(--note-tint);
}

.panel-fields label + label {
  border-top: 1px solid #dedbd2;
  background: #fffdf8;
}

.panel-fields .panel-prompt-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 8px;
  grid-column: 1 / -1;
  border-top: 1px solid #dedbd2;
  border-left: 0;
  background: var(--note-tint-strong);
}

.panel-continuity-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid #dedbd2;
  background: #f7f1e4;
}

.panel-continuity-title {
  display: block;
  margin-bottom: 4px;
  color: #777166;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.panel-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.panel-chip {
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid #d7cdbc;
  border-radius: 999px;
  background: #fffdf8;
  color: #625b50;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.panel-chip.selected {
  border-color: rgba(255, 138, 18, 0.55);
  background: #ff8a12;
  color: #1d170d;
}

.panel-chip-empty {
  color: #a49b8c;
  font-size: 10px;
  font-style: italic;
}

.story-panel.prompts-collapsed .panel-prompt-field {
  display: none;
}

.panel-prompt-field span {
  grid-column: 1 / -1;
}

.panel-prompt-field span::after {
  content: " · saved with history";
  color: #b17943;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.panel-prompt-field .panel-generate {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

.panel-fields textarea {
  width: 100%;
  min-height: 44px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.28;
}

.panel-fields label:first-child textarea {
  min-height: 52px;
}

.panel-prompt-field textarea {
  grid-column: 1;
  grid-row: 2;
}

.ai-dock {
  grid-column: 2;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, auto);
  width: min(calc(100% - 48px), 1280px);
  margin: 0 auto 42px;
  border-top: 1px solid #292924;
  border-radius: 0 0 14px 14px;
  background: #1e1e1b;
  color: #f4f2ea;
  box-shadow: 0 12px 32px rgba(31, 29, 23, 0.14);
}

.ai-heading {
  grid-row: 1 / span 2;
  display: block;
  padding: 22px 20px 15px;
  border-right: 1px solid #33332e;
}

.ai-heading .eyebrow {
  color: #8d8c84;
}

.ai-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 16px;
}

.ai-heading .mode-controls {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.ai-heading .mode-controls > .button {
  width: 100%;
}

.ai-heading .fidelity-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.ai-heading .fidelity-switch button {
  min-width: 0;
  padding-inline: 4px;
  font-size: 8px;
}

.ai-heading-actions .button {
  min-height: 28px;
  padding: 6px 10px;
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e3a035;
  box-shadow: 0 0 0 4px rgba(227, 160, 53, 0.12);
}

.selection-context {
  max-width: 170px;
  margin-top: 10px;
  color: #a9a79f;
  font-size: 11px;
  line-height: 1.45;
}

.director-chat {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  gap: 10px;
  margin: 14px 14px 0;
  padding: 12px;
  border: 1px solid #3a3934;
  border-radius: 10px;
  background: #242420;
}

.director-chat h3 {
  color: #f5f2e8;
}

.chat-messages {
  display: none;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding: 4px 2px 2px;
}

.chat-messages.has-messages {
  display: grid;
  min-height: 118px;
}

.message {
  width: min(82%, 680px);
  padding: 9px 11px;
  border-radius: 9px;
  white-space: pre-wrap;
  color: #ede9dd;
  font-size: 13px;
  line-height: 1.42;
}

.message-ai {
  justify-self: start;
  border: 1px solid #3b3932;
  background: #2f2e29;
}

.message-user {
  justify-self: end;
  background: #f28a2e;
  color: #20150a;
  font-weight: 700;
}

.director-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.director-chat-form textarea {
  min-height: 48px;
  max-height: 130px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #46443d;
  border-radius: 8px;
  background: #f9f5ea;
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
}

.director-chat-form .button {
  min-height: 48px;
}

.art-director-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  color: var(--ink);
}

.art-director-grid > section {
  min-width: 0;
}

@media (max-width: 1250px) {
  .workspace {
    grid-template-columns: 118px minmax(760px, 1fr);
  }

  .recent-dialog {
    max-height: calc(100vh - 36px);
  }

  .recent-body {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .canvas-wrap {
    padding-inline: 16px;
  }

  .ai-dock {
    width: calc(100% - 32px);
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .selection-context {
    max-width: 150px;
  }

  .art-director-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fidelity-switch button {
    padding-inline: 7px;
  }

  .canvas-mode-controls > .button {
    padding-inline: 8px;
    font-size: 10px;
  }
}

@media print {
  @page {
    size: 11in 8.5in;
    margin: 0;
  }

  html {
    width: 11in;
    height: 8.5in;
  }

  body {
    width: 11in;
    min-height: 8.5in;
    min-width: 0;
    background: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-bar,
  .image-viewer,
  .recent-overlay,
  .page-rail,
  .ai-dock,
  .canvas-topline {
    display: none !important;
  }

  .workspace,
  .canvas-wrap {
    display: block;
    width: 11in;
    min-height: 8.5in;
    padding: 0;
    overflow: visible;
  }

  #storyboardPage {
    display: none;
  }

  .print-pages {
    display: block;
    width: 11in;
  }

  .print-pages .storyboard-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 11in;
    height: 8.5in;
    margin: 0;
    padding: 0.25in;
    overflow: hidden;
    background: white;
    box-shadow: none;
    break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }

  .print-pages .page-header {
    min-height: 0;
    margin-bottom: 0.14in;
    padding-bottom: 0.08in;
    gap: 0.1in;
  }

  .print-pages .panel-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 0.16in;
    min-height: 0;
  }

  .print-pages .story-panel {
    display: grid;
    grid-template-rows: auto minmax(0.95in, auto);
    min-height: 0;
    overflow: hidden;
    background: white;
    box-shadow: none;
  }

  .print-pages .panel-image {
    aspect-ratio: 16 / 9;
  }

  .print-pages .panel-fields {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0.95in;
    background: var(--note-tint);
  }

  .print-pages .panel-fields label {
    padding: 0.045in 0.07in;
    background: var(--note-tint);
  }

  .print-pages .panel-fields label + label {
    border-top: 1px solid #dedbd2;
    border-left: 0;
    background: #fffdf8;
  }

  .panel-tools {
    display: none;
  }

  .panel-prompt-field {
    display: none !important;
  }

  .panel-continuity-controls {
    display: none !important;
  }

  .print-value {
    min-height: 18px;
    padding: 3px 0 5px;
    border-bottom: 1px solid #b8b4aa;
    font-size: 12px;
  }

  .field-title .print-value {
    font-size: 17px;
    font-weight: 800;
  }

  .print-copy {
    min-height: 0.3in;
    color: var(--ink);
    font-size: 12.5px;
    line-height: 1.18;
    white-space: pre-wrap;
  }
}
