/* Shoot board layout. Greys via alias tokens only; person colours via chart tokens. */

html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text-primary); touch-action: manipulation; }

.author-gabriel { --person: var(--chart-1); }
.author-rory    { --person: var(--chart-2); }
.author-alfie   { --person: var(--chart-3); }
.author-nina    { --person: var(--chart-4); }
.author-none    { --person: var(--text-secondary); }

/* top bar */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; }
.topbar-sub { color: var(--text-secondary); font-size: 0.85em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.person-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--person); display: inline-block; margin-right: 6px;
}
.presence-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: color-mix(in oklab, var(--person) 30%, var(--surface-2));
  border: 2px solid var(--person);
  display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 600; color: var(--text-primary);
}

/* logline inside the topbar */
.logline-slot {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 14px;
}
.logline-text {
  font-style: italic; color: var(--text-primary); cursor: text;
  white-space: pre-wrap; overflow-wrap: anywhere;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  min-width: 0; line-height: 1.4; font-size: 0.9em;
}
.logline-text.empty { color: var(--text-secondary); }
.logline-input { width: min(720px, 70vw); min-height: 4.2em; resize: vertical; }
.history-card { width: 560px; max-width: 100%; max-height: 80vh; display: flex; flex-direction: column; gap: 10px; }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.history-entry { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg); }
.history-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.history-head .who { font-weight: 500; }
.history-head .when { color: var(--text-secondary); font-size: 0.8em; margin-left: auto; }
.history-diff { line-height: 1.5; overflow-wrap: anywhere; }
.diff-del {
  background: color-mix(in oklab, var(--danger-text) 18%, transparent);
  text-decoration: line-through; border-radius: 3px; padding: 0 2px;
}
.diff-ins {
  background: color-mix(in oklab, var(--ok-text) 18%, transparent);
  border-radius: 3px; padding: 0 2px;
}

/* stage */
#stage { position: fixed; inset: 0; }
#graph { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#graph.panning { cursor: grabbing; }
#graph.linking { cursor: crosshair; }

.edge { stroke: var(--border); stroke-width: 1.5; }
.edge-link { stroke: var(--person); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: 0.75; cursor: pointer; }
.edge-link.pending-remove { stroke-width: 3; opacity: 1; }

.node { cursor: pointer; }
/* two stacked circles: opaque surface underlay, then a translucent person tint,
   so the fill never falls back to black where color-mix on SVG fill is flaky */
.node circle.under { fill: var(--surface-2); }
.node circle.body {
  fill: var(--person); fill-opacity: 0.22;
  stroke: var(--person); stroke-width: 2;
}
.node.selected circle.body { stroke-width: 3.5; }
.node circle.halo { fill: none; stroke: none; }
.node.selected circle.halo { stroke: var(--person); stroke-width: 1; opacity: 0.35; }
.node.link-source circle.body { stroke-dasharray: 4 3; }
.node text.label {
  fill: var(--text-primary); font-size: 13px;
  text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round;
}
.node text.count {
  fill: var(--text-secondary); font-size: 10px; text-anchor: middle; pointer-events: none;
}
.node.root circle.body { fill-opacity: 0; }
.node.root text.label { font-weight: 600; font-size: 15px; }

/* bottom toolbar */
.toolbar {
  position: fixed; z-index: 20; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: 0 8px 24px color-mix(in oklab, var(--bg) 55%, transparent);
  max-width: calc(100vw - 20px);
}
.toolbar .input { width: 260px; max-width: 42vw; }
.toolbar-target {
  color: var(--text-secondary); font-size: 0.8em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.toolbar-target b { color: var(--text-primary); font-weight: 500; }
#link-btn[aria-pressed="true"], #move-btn[aria-pressed="true"] { border-color: var(--accent-edge); color: var(--accent-fill); }

@media (min-width: 641px) {
  body.panel-open .toolbar { left: calc(50% - 190px); }
}

/* side panel */
.panel-drawer {
  position: fixed; z-index: 30; top: var(--chrome-h, 92px); right: 12px; bottom: 12px;
  width: 360px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; overflow-y: auto;
}
.panel-head-row { display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 1.05em; font-weight: 600; }
.panel-meta { color: var(--text-secondary); font-size: 0.8em; }
.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.panel-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

/* artifacts */
.artifact-list { display: flex; flex-direction: column; gap: 8px; }
.artifact {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  background: var(--bg);
}
.artifact-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.artifact-head .title { font-weight: 500; flex: 1; overflow-wrap: anywhere; }
.artifact-head .kind { color: var(--text-secondary); font-size: 0.75em; }
.artifact-preview {
  color: var(--text-secondary); font-size: 0.85em;
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 4.5em; overflow: hidden;
}
.artifact-preview.script { font-family: ui-monospace, monospace; }
.artifact img, .artifact video { max-width: 100%; border-radius: 6px; margin-top: 6px; display: block; }
.artifact-foot { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.artifact-foot .size { color: var(--text-secondary); font-size: 0.75em; margin-left: auto; }

/* checklist artifact */
.check-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.check-item { display: flex; align-items: center; gap: 8px; }
.check-item .text { flex: 1; font-size: 0.9em; overflow-wrap: anywhere; }
.check-item.done .text { color: var(--text-secondary); text-decoration: line-through; }
.check-item .remove-item {
  border: 0; background: none; color: var(--text-secondary); cursor: pointer;
  font-size: 0.85em; padding: 2px 4px;
}
.check-item .remove-item:hover { color: var(--danger-text); }
.check-add { display: flex; gap: 6px; margin-top: 6px; }
.check-add .input { flex: 1; }

@media (min-width: 1100px) {
  body.panel-open .assets-drawer { right: 384px; }
}

/* asset library */
.assets-drawer { width: 420px; }
.asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.asset-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  background: var(--bg); display: flex; flex-direction: column; gap: 6px;
}
.asset-card img, .asset-card video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.asset-card .name { font-size: 0.85em; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }
.asset-card .meta { color: var(--text-secondary); font-size: 0.75em; }
.asset-card .actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; }

/* editor overlay */
.editor-overlay, .identity-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.editor-card { width: 640px; max-width: 100%; max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.editor-card.script-mode { width: min(1100px, 96vw); }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.editor-body-field .textarea { min-height: 40vh; }
.script-mode .editor-body-field .textarea, .script-mode .editor-preview { min-height: clamp(200px, 48vh, 640px); }
#editor-body.script { font-family: ui-monospace, monospace; }
.editor-preview {
  min-height: 40vh; max-height: 70vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 16px;
  background: var(--bg);
}
.editor-buttons { display: flex; justify-content: flex-end; gap: 8px; }

/* screenplay preview */
.screenplay { font-family: ui-monospace, monospace; max-width: 42em; margin: 0 auto; }
.screenplay .scene { font-weight: 700; margin: 1.4em 0 0.6em; }
.screenplay .character { text-align: center; margin: 1em 0 0; }
.screenplay .paren { text-align: center; font-style: italic; color: var(--text-secondary); margin: 0; }
.screenplay .action { margin: 0.6em 0; white-space: pre-wrap; }
.screenplay .dialogue { max-width: 24em; margin: 0 auto; }

/* markdown-lite preview */
.md-preview { max-width: 38em; margin: 0 auto; line-height: 1.6; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 0.8em 0 0.4em; }
.md-preview p { margin: 0.5em 0; }
.md-preview ul { margin: 0.5em 0; padding-left: 1.4em; }
.md-preview code {
  font-family: ui-monospace, monospace; font-size: 0.9em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 4px;
}

/* identity */
.identity-card { width: 380px; max-width: 100%; }
.identity-sub { color: var(--text-secondary); margin: 4px 0 14px; }
.identity-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.identity-choices .btn { justify-content: flex-start; padding: 14px; }

/* small screens: panels become bottom sheets */
@media (max-width: 640px) {
  .panel-drawer {
    top: auto; left: 8px; right: 8px; bottom: 8px;
    max-height: 62vh; width: auto;
  }
  .toolbar { bottom: auto; top: 92px; }
  .toolbar-target { display: none; }
  .toolbar .input { max-width: 40vw; }
  .asset-grid { grid-template-columns: 1fr 1fr; }
  .logline-text { max-width: 55vw; }
}

/* satellite artifact nodes */
.edge-sat { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.sat { cursor: pointer; }
.sat .shape { fill: var(--surface-2); stroke: var(--person); stroke-width: 1.5; }
.sat.kind-item .shape { fill: var(--person); fill-opacity: 0.25; }
.sat .slabel {
  fill: var(--text-secondary); font-size: 10px; text-anchor: middle;
  pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round;
}
.sat .tick {
  fill: none; stroke: var(--person); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; display: none;
}
.sat.done .tick { display: block; }
.sat.done .shape { opacity: 0.55; }
.sat.done .slabel { opacity: 0.8; }

.edge-hit { stroke: transparent; stroke-width: 16; cursor: pointer; }

/* screenwriting aids */
.editor-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.editor-hint { color: var(--text-secondary); font-size: 0.8em; margin-top: 6px; }

.sat .hit { fill: transparent; stroke: none; }

/* screenplay surface */
.screenplay-wrap { position: relative; }
.screenplay-surface {
  font-family: var(--font-mono); font-size: 0.92em; line-height: 1.55;
  color: var(--text-primary); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 20px 24px; outline: none;
  min-height: clamp(200px, 48vh, 640px); max-height: 60vh; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.screenplay-surface:focus { border-color: var(--focus-ring); }
.sline { min-height: 1.55em; }
.el-scene { font-weight: 700; margin-top: 1em; }
.el-action { max-width: 62ch; }
.el-character { margin-left: 20ch; margin-top: 0.9em; max-width: 34ch; }
.el-paren { margin-left: 14ch; max-width: 28ch; font-style: italic; color: var(--text-secondary); }
.el-dialogue { margin-left: 10ch; max-width: 38ch; }
.el-transition { text-align: right; margin-top: 0.9em; }
.char-menu {
  position: absolute; z-index: 5; min-width: 170px;
  display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px color-mix(in oklab, var(--bg) 55%, transparent);
}
.char-menu .menu-item.active { background: var(--fill-hover); }
@media (max-width: 640px) {
  .el-character { margin-left: 6ch; }
  .el-paren { margin-left: 4ch; }
  .el-dialogue { margin-left: 3ch; }
}

.check-item .item-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--person, var(--text-secondary));
}

/* drawing engine */
.draw-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 0;
}
.draw-toolbar .btn[aria-pressed="true"] { border-color: var(--accent-edge); color: var(--accent-fill); }
.draw-swatches, .draw-sizes { display: flex; gap: 4px; align-items: center; }
.draw-swatch {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border);
}
.draw-swatch[aria-pressed="true"] { border-color: var(--text-primary); }
.draw-stage { position: relative; flex: 1; min-height: 0; }
.draw-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair;
}

/* storyboard */
.sb-create-card { width: 460px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; }
.sb-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sb-editor-card {
  width: min(1200px, 96vw); max-width: 100%; max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.sb-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.sb-cell { display: flex; flex-direction: column; gap: 6px; }
.sb-frame {
  position: relative; width: 100%; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
}
.sb-frame img, .sb-frame canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.sb-frame.empty::after {
  content: "Tap to draw"; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-placeholder); font-size: 0.8em;
}
.sb-num {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0 6px; font-size: 0.75em; color: var(--text-secondary);
}
.sb-caption { font-size: 0.85em; }
.sb-cell-actions { display: flex; gap: 4px; }
.sb-add-frame {
  border: 1px dashed var(--border); border-radius: 8px; background: none;
  color: var(--text-secondary); cursor: pointer; width: 100%;
}
.sb-add-frame:hover { color: var(--text-primary); border-color: var(--border-hover); }

.sb-frame-card {
  width: 98vw; height: 96vh; max-width: none; max-height: 96vh; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
}
.sb-frame-stage {
  position: relative; width: 100%; margin-block: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.sb-frame-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
.sb-frame-stage .draw-stage { position: absolute; inset: 0; }
.sb-frame-buttons { flex-wrap: wrap; }

.sb-pick-card { width: min(760px, 96vw); max-height: 86vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sb-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.sb-pick-item {
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  padding: 0; background: var(--bg); cursor: pointer; aspect-ratio: 16/9;
}
.sb-pick-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-pick-item:hover { border-color: var(--accent-edge); }

.sb-card { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sb-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.sb-thumb { cursor: default; }

.sat.kind-storyboard .scount, .sat .scount {
  fill: var(--text-secondary); font-size: 9px; text-anchor: middle; pointer-events: none;
}
.asset-drawing { width: 100%; aspect-ratio: 16/9; display: block; border-radius: 6px; background: var(--bg); }

@media (max-width: 640px) {
  .sb-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* live co-editing */
.editor-live { display: flex; align-items: center; gap: 10px; }
.save-status { color: var(--text-secondary); font-size: 0.8em; }
.peer-cursors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.peer-cursor {
  position: absolute; width: 2px; background: var(--person);
  transition: top 0.12s ease, left 0.12s ease;
}
.peer-cursor .flag {
  position: absolute; top: -15px; left: -2px;
  background: var(--person); color: var(--bg);
  font-size: 10px; font-weight: 600; line-height: 1;
  padding: 2px 5px; border-radius: 4px 4px 4px 0; white-space: nowrap;
}
.peer-cursor.idle { opacity: 0.35; }

/* node description + inline renames */
.panel-desc { font-size: 0.9em; min-height: 3em; resize: vertical; }
.artifact-head .title-editable { cursor: text; }
.artifact-head .title-edit { flex: 1; font-size: 0.95em; padding: 2px 6px; }

/* rich notes */
.rn-card {
  width: min(900px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; gap: 10px;
}
.rn-head { display: flex; align-items: center; gap: 12px; }
.rn-title { flex: 1; font-size: 1.1em; font-weight: 600; }
.rn-scroll { position: relative; overflow-y: auto; min-height: 40vh; }
.rn-blocks { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 30vh; }
.rn-block { display: flex; gap: 4px; align-items: flex-start; border-radius: 8px; }
.rn-handle {
  display: flex; gap: 0; opacity: 0; flex-shrink: 0;
  transition: opacity 0.12s ease;
}
.rn-block:hover .rn-handle, .rn-block:focus-within .rn-handle { opacity: 1; }
@media (pointer: coarse) { .rn-handle { opacity: 0.55; } }
.rn-handle .btn { padding: 2px 5px; min-width: 0; }
.rn-body { flex: 1; display: flex; align-items: flex-start; gap: 8px; min-width: 0; padding: 3px 4px; }
.rn-text { flex: 1; outline: none; min-height: 1.4em; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.rn-text:empty::before { content: attr(data-placeholder); color: var(--text-placeholder); }
.rn-h1 .rn-text { font-size: 1.45em; font-weight: 700; }
.rn-h2 .rn-text { font-size: 1.15em; font-weight: 600; }
.rn-bullet .rn-body::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); margin: 0.6em 2px 0; flex-shrink: 0; }
.rn-check { margin-top: 0.35em; }
.rn-todo.done .rn-text { color: var(--text-secondary); text-decoration: line-through; }
.rn-divider { border-top: 1px solid var(--border); margin: 8px 0; width: 100%; }
.rn-media { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.rn-media img, .rn-canvas { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.rn-canvas { width: 100%; height: auto; cursor: pointer; background: var(--bg); }
.rn-media .btn { align-self: flex-start; }
.rn-menu { z-index: 80; }
.rn-flag-layer { position: absolute; inset: 0; pointer-events: none; }
.rn-flag {
  position: absolute; right: 4px;
  background: var(--person); color: var(--bg);
  font-size: 10px; font-weight: 600; line-height: 1;
  padding: 2px 5px; border-radius: 4px; white-space: nowrap;
  transition: top 0.12s ease;
}
.rn-flag.idle { opacity: 0.35; }
.rn-draw-card { width: min(1000px, 96vw); max-height: 92vh; display: flex; flex-direction: column; gap: 10px; }
.rn-draw-stage { position: relative; flex: 1; min-height: 52vh; }
.rn-draw-stage .draw-stage { position: absolute; inset: 0; }
.rn-picker-card { width: min(720px, 96vw); max-height: 84vh; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.rn-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.rn-picker-cell { border: 1px solid var(--border); border-radius: 8px; padding: 0; overflow: hidden; background: var(--bg); cursor: pointer; }
.rn-picker-cell img { width: 100%; height: 90px; object-fit: cover; display: block; }

/* rich note static renders (panel preview + preview tab) */
.rn-preview { display: flex; flex-direction: column; gap: 3px; font-size: 0.85em; color: var(--text-secondary); }
.rn-full { display: flex; flex-direction: column; gap: 6px; }
.rn-static { line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.rn-static.rn-h1 { font-size: 1.3em; font-weight: 700; color: var(--text-primary); }
.rn-static.rn-h2 { font-size: 1.1em; font-weight: 600; color: var(--text-primary); }
.rn-static.rn-bullet { padding-left: 14px; position: relative; }
.rn-static.rn-bullet::before { content: ""; position: absolute; left: 2px; top: 0.55em; width: 5px; height: 5px; border-radius: 50%; background: var(--text-secondary); }
.rn-static.rn-todo.done { text-decoration: line-through; }
.rn-static-check {
  display: inline-block; width: 11px; height: 11px; margin-right: 6px;
  border: 1.5px solid var(--text-secondary); border-radius: 3px; vertical-align: -1px;
}
.rn-static-check.checked { background: var(--text-secondary); }
.rn-static-media img, .rn-static-media canvas { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.rn-static-media.small img, .rn-static-media.small canvas { max-width: 160px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .logline-slot { order: 3; flex-basis: 100%; padding: 4px 0 2px; }
  .rn-head { flex-wrap: wrap; }
  .rn-card { max-height: 96vh; }
}

/* pen-friendly surfaces: nothing selectable, no long-press callout */
.sb-frame, .sb-frame-stage, .draw-stage, .draw-toolbar, .sb-view-frame, .sb-grid .sb-num {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.draw-canvas { -webkit-touch-callout: none; }
.draw-text-input {
  position: absolute; z-index: 3; max-width: 92%;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  border: 1px dashed var(--border); border-radius: 4px;
  padding: 0 3px; font-weight: 600; line-height: 1.15;
}

/* storyboard view mode */
.sb-viewer-card {
  width: 98vw; height: 96vh; max-width: none; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; outline: none;
}
.sb-viewer-card .panel-head-row { gap: 10px; }
.sb-viewer-card .panel-head-row .btn { margin-left: auto; }
.sb-viewer-card .panel-head-row .btn-icon { margin-left: 0; }
.sb-view-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 26px; align-items: center;
  padding: 8px 4px 30vh;
}
.sb-view-cell { width: min(1100px, 96%); }
.sb-view-frame { cursor: default; }
.sb-view-num { opacity: 0.6; }
.sb-view-caption {
  color: var(--text-secondary); text-align: center; margin-top: 8px;
  font-size: 0.95em;
}

/* blame tints in the script surface */
.blame-on .sline[data-blame="gabriel"] { background: color-mix(in oklab, var(--chart-1) 12%, transparent); border-radius: 3px; }
.blame-on .sline[data-blame="rory"]    { background: color-mix(in oklab, var(--chart-2) 12%, transparent); border-radius: 3px; }
.blame-on .sline[data-blame="alfie"]   { background: color-mix(in oklab, var(--chart-3) 12%, transparent); border-radius: 3px; }
.blame-on .sline[data-blame="nina"]    { background: color-mix(in oklab, var(--chart-4) 12%, transparent); border-radius: 3px; }
#script-blame[aria-pressed="true"] { border-color: var(--accent-edge); color: var(--accent-fill); }

/* script history */
.script-history-card { width: min(860px, 96vw); }
.script-line-diff {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.8em;
  max-height: 16em; overflow-y: auto; white-space: pre-wrap;
}
.script-line-diff > div { padding: 0 4px; border-radius: 3px; }
.diff-line-ins { background: color-mix(in oklab, var(--ok-text) 14%, transparent); }
.diff-line-del { background: color-mix(in oklab, var(--danger-text) 14%, transparent); text-decoration: line-through; }
.diff-line-same { color: var(--text-secondary); }
