:root {
  color-scheme: dark;
  --deep: #111110;
  --page: #171716;
  --surface: #1c1c1b;
  --raised: #252524;
  --hover: #2c2b29;
  --ink: #f0eee9;
  --secondary: #b5b1a9;
  --muted: #939087;
  --line: rgb(240 238 233 / 10%);
  --line-strong: rgb(240 238 233 / 16%);
  --accent: #ff9d61;
  --green: #75c991;
  --danger: #ff998b;
  --ease: cubic-bezier(.2,.75,.25,1);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ruler: 28px;
  --track: 38px;
  --track-label: 208px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
button, input, textarea, select { font: inherit; }
button, .button {
  min-height: 32px; display: inline-flex; gap: 8px; align-items: center; justify-content: center;
  color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px;
  text-align: left; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: color 120ms var(--ease), background 120ms var(--ease), border-color 120ms var(--ease);
}
button svg, .button svg { flex: 0 0 16px; color: var(--secondary); }
button:hover:not(:disabled), .button:hover { background: var(--hover); border-color: var(--line-strong); }
button:disabled { opacity: .4; cursor: default; }
button.primary, .button.primary { background: #f1ece4; color: #1e1b17; border-color: transparent; font-weight: 600; }
button.primary svg { color: currentColor; }
button.primary:hover:not(:disabled) { background: #fff7e8; color: #171411; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: 15px; line-height: 1.35; font-weight: 600; }
h3, strong { font-size: inherit; font-weight: 600; }
small, .helper, .meta { color: var(--secondary); font-size: 12px; }
.meta, .mono, #timecode, #total-time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.error { color: var(--danger); }
.row, .between { display: flex; align-items: center; gap: 8px; min-width: 0; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.fit { justify-self: start; }
#studio { min-height: 660px; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar, .projectbar { display: flex; align-items: center; flex: 0 0 auto; gap: 12px; border-bottom: 1px solid var(--line); }
.topbar { height: 60px; padding: 0 20px; justify-content: space-between; background: var(--deep); }
.brand, .top-actions { display: flex; gap: 12px; align-items: center; }
.brand { font-size: 15px; font-weight: 600; white-space: nowrap; }
.brand-mark { display: block; flex: none; width: 52px; height: 22px; object-fit: contain; }
#save-status { display: flex; align-items: center; gap: 6px; min-height: 24px; color: var(--secondary); font-size: 12px; }
#save-status svg { width: 14px; height: 14px; color: var(--muted); }
#save-status .save-error { color: var(--danger); }
.top-actions > button { padding-inline: 12px; }
.projectbar { padding: 0 20px; height: 48px; background: #1a1a19; }
.projectbar > button { background: transparent; flex: 0 0 auto; }
#new-project { border-color: transparent; color: var(--secondary); }
#project-tabs { display: flex; gap: 4px; flex: 0 1 auto; min-width: 0; overflow: auto; scrollbar-width: thin; }
#project-tabs:empty { display: none; }
.project-tab { position: relative; display: flex; align-items: center; min-width: 0; flex: 0 0 auto; border-radius: 8px; border: 1px solid transparent; }
.project-tab.active { background: var(--raised); border-color: var(--line-strong); }
.project-tab.active::after { content: ''; position: absolute; bottom: 0; left: 12px; right: 12px; height: 1px; background: var(--accent); pointer-events: none; }
.project-tab > button { border: 0; background: transparent; max-width: 264px; overflow: hidden; text-overflow: ellipsis; display: block; }
.project-tab > button[draggable=true] { cursor: grab; }
.project-tab.dragging { opacity: .45; }
.project-tab[data-drop]::before { content: ''; position: absolute; top: 4px; bottom: 4px; width: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }
.project-tab[data-drop=before]::before { left: 0; }
.project-tab[data-drop=after]::before { right: 0; }
.project-tab:not(.active) > button { color: var(--secondary); }
.project-tab > .close-tab { padding-inline: 8px; display: grid; }
.project-tab > .dot { margin-left: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.dot.ready { background: var(--green); }
.dot.running { border: 1.5px solid var(--accent); border-right-color: transparent; animation: rotate 900ms linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }
.app-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.workspace { flex: 1; min-height: 235px; display: grid; grid-template-columns: var(--track-label) minmax(310px, .91fr) minmax(340px, 1.09fr); }
.sidebar { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 16px 12px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.side-heading { padding: 0 8px 10px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.side-heading .meta { font-weight: 400; }
#workflow { display: grid; gap: 2px; }
.workflow-item { justify-content: flex-start; border-color: transparent; background: transparent; width: 100%; gap: 8px; padding-inline: 8px; color: var(--secondary); }
.workflow-item.chosen { background: var(--raised); border-color: var(--line); color: var(--ink); }
.workflow-item.chosen svg { color: var(--accent); }
.workflow-check { display: inline-flex; margin-left: auto; }
.workflow-check svg, .workflow-item.chosen .workflow-check svg { color: var(--green); stroke-width: 2; }
.workflow-item.results { margin-top: 4px; border-top-color: var(--line); }
.nav-count { display: flex; align-items: center; gap: 6px; margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.cost-block { margin: auto 8px 0; padding-top: 12px; }
.cost-caption { font-size: 12px; color: var(--muted); }
.cost-button { padding: 0; background: transparent; border: 0; min-height: 28px; font: 13px var(--mono); flex-direction: row-reverse; gap: 6px; }
.cost-button svg { width: 14px; height: 14px; }
.work { overflow-y: auto; min-height: 0; border-right: 1px solid var(--line); background: var(--page); scrollbar-width: thin; }
.work-inner, .welcome { display: grid; align-content: start; gap: 10px; padding: 16px 20px 18px; }
.work-inner > .helper { margin: 0; }
.welcome { align-content: center; min-height: 100%; gap: 12px; max-width: 480px; padding: 24px 32px; }
.welcome h1 { font-size: clamp(28px, 3.15vw, 42px); line-height: 1.05; letter-spacing: -.04em; font-weight: 500; }
.welcome p { color: var(--secondary); max-width: 330px; margin: 1px 0 6px; }
.work-id { display: inline-flex; gap: 8px; align-items: center; color: var(--secondary); font-size: 12px; }
.work-id svg { color: var(--accent); }
.work-heading { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.work-heading p { color: var(--secondary); font-size: 13px; margin-top: 4px; }
.model-chip { width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 11px/1.5 var(--mono); }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { color: var(--secondary); font-size: 13px; font-weight: 500; }
.fields { display: grid; gap: 10px; min-width: 0; }
.columns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.columns.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
input:not([type=checkbox]):not([type=range]):not([type=file]), select, textarea {
  width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid var(--line-strong); background: var(--deep); color: var(--ink); border-radius: 7px;
}
textarea { display: block; resize: vertical; min-height: 56px; line-height: 1.52; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
.reference-input { position: relative; background: var(--deep); border-radius: 7px; }
.reference-input textarea { position: relative; background: transparent; overflow-wrap: break-word; }
.reference-highlights { position: absolute; inset: 0; overflow: hidden; border: 1px solid transparent; padding: 6px 9px;
  pointer-events: none; color: transparent; white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.52; }
.sheet-mention { border-radius: 3px; background: #493323; color: var(--ink); }
.sheet-mention.missing { background: #522d28; }
.reference-highlights .sheet-mention { color: transparent; }
.reference-options { display: grid; gap: 2px; max-height: 184px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); }
.reference-options > p { padding: 4px 6px; }
.reference-option { display: flex; gap: 8px; align-items: center; min-height: 32px; padding: 3px 6px;
  overflow-wrap: anywhere; border-radius: 5px; cursor: pointer; }
.reference-option:hover, .reference-option[aria-selected=true] { background: var(--raised); }
.reference-option img { flex: 0 0 34px; width: 34px; height: 24px; object-fit: cover; border-radius: 3px; }
select { appearance: none; min-width: 0; max-width: 100%; padding-right: 24px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%, transparent 50%);
  background-repeat: no-repeat; background-size: 5px 5px; background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; }
.work-heading select { width: auto; }
.script-editor { height: clamp(100px, 15vh, 240px); min-height: 92px; }
.check-label { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); cursor: pointer; white-space: nowrap; }
input[type=checkbox], input[type=range] { accent-color: var(--accent); }
.compose { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.compose > * + * { margin-top: 8px; }
summary { cursor: pointer; font-weight: 500; color: var(--ink); }
.latest { display: flex; gap: 7px; align-items: center; min-height: 24px; }
.latest > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button { background: transparent; border: 0; padding: 0 2px; color: var(--accent); min-height: 22px; }
.inline-callout { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--secondary); font-size: 13px; }
.inline-callout svg { flex: 0 0 16px; color: var(--accent); }
.inline-callout.ok svg { color: var(--green); }
.inline-callout > button { margin-left: auto; }
.audio-sample { width: 100%; height: 38px; }
.selection-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface); color: var(--secondary); border-left: 2px solid var(--accent); padding: 8px 10px; }
.target-list { display: grid; gap: 4px; max-height: 184px; overflow: auto; }
.target-row > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.ref-chip { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.ref-chip svg { vertical-align: middle; margin-right: 6px; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.compare-tile { display: grid; min-width: 0; align-content: start; gap: 8px; }
.compare-tile > img { width: 100%; max-height: 320px; object-fit: contain; background: var(--deep); border-radius: 6px; }
.style-grid, .asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.style-choice, .asset-tile { min-width: 0; padding: 8px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.style-choice { cursor: pointer; }
.style-choice img, .chosen-style img { width: 43px; height: 30px; object-fit: cover; border-radius: 4px; }
.style-choice span { overflow: hidden; text-overflow: ellipsis; }
.style-choice input { margin-left: auto; }
.chosen-style { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.chosen-style img { width: 68px; height: 44px; }
.asset-tile { flex-direction: column; align-items: stretch; padding: 6px; }
.asset-tile > img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; }
.asset-title { color: var(--secondary); font-size: 12px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.asset-tile button, .asset-tile .button { min-height: 24px; padding: 2px 4px; }
.monitor { display: grid; grid-template-rows: 44px minmax(0, 1fr) 24px 46px; min-height: 0; min-width: 0; background: #151514; }
.monitor-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px; }
.monitor-head select { width: auto; min-height: 28px; font-size: 12px; }
.stage { display: grid; place-items: center; min-height: 0; min-width: 0; padding: 0 12px; container-type: size; }
.frame { container-type: size; width: min(100cqw, calc(100cqh * 16 / 9)); height: auto; max-height: 100%; aspect-ratio: 16/9;
  position: relative; border: 1px solid var(--line); background: #10100f; border-radius: 5px; overflow: hidden; }
.frame.portrait { width: min(100cqw, calc(100cqh * 9 / 16)); aspect-ratio: 9/16; }
.frame > img, .frame > video, #preview-hold { height: 100%; width: 100%; display: block; object-fit: contain; background: #000; }
#preview-hold { position: absolute; inset: 0; pointer-events: none; }
.minimax-zoom { transform: scale(1.03); transform-origin: center; }
#preview-empty, .frame-guides { position: absolute; inset: 0; }
#preview-empty { display: grid; place-items: center; }
.frame-guides { inset: 12px; pointer-events: none; }
.frame-guides span { position: absolute; width: 13px; height: 13px; border-color: #625447; border-style: solid; }
.frame-guides span:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.frame-guides span:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.frame-guides span:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.frame-guides span:nth-child(4) { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.monitor-message { color: var(--muted); display: grid; justify-items: center; text-align: center; padding: 8px; gap: 8px; font-size: 13px; }
.monitor-message svg { width: 27px; height: 27px; color: #998979; }
.monitor-message small { font: 11px var(--mono); color: var(--muted); }
.preview-progress { display: flex; align-items: center; padding: 0 16px; }
#preview-seek { width: 100%; height: 24px; margin: 0; cursor: pointer; }
#preview-seek:disabled { opacity: .45; cursor: default; }
.transport { display: flex; gap: 8px; align-items: center; padding: 0 16px; }
.transport button { padding: 2px 7px; min-height: 28px; }
.transport button:last-child { margin-left: auto; }
#timecode, #total-time, .transport-slash { font-size: 12px; color: var(--muted); }
#timecode { color: var(--ink); }
.monitor:fullscreen { width: 100%; height: 100%; background: #10100f; }
.monitor:fullscreen .stage { padding: 0 24px; }
.timeline { flex: 0 0 auto; border-top: 1px solid var(--line-strong); background: var(--deep); }
.timeline-toolbar { display: flex; align-items: center; height: 44px; gap: 16px; padding: 0 16px; background: var(--surface); }
.timeline-toolbar h2 { margin-right: 4px; }
#edit-tools, #zoom-tools { display: flex; gap: 4px; align-items: center; }
#zoom-tools { margin-left: auto; }
#timeline-fold { margin-left: auto; }
#zoom-tools:not([hidden]) + #timeline-fold { margin-left: 0; }
.timeline-fold-toggle[aria-expanded=false] svg { transform: rotate(180deg); }
.timeline-toolbar button { padding: 3px 7px; min-height: 28px; font-size: 12px; }
.timeline-toolbar button[aria-pressed=true] { color: var(--accent); border-color: #68513e; background: #30271f; }
.timeline-toolbar button[aria-pressed=true] svg { color: currentColor; }
.timeline-zoom input { width: 74px; }
.timeline-body { display: grid; grid-template-columns: var(--track-label) minmax(0, 1fr); }
.track-labels { background: var(--surface); border-right: 1px solid var(--line-strong); z-index: 2; }
.label-ruler, .track-label { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); }
.label-ruler { height: var(--ruler); justify-content: space-between; font-size: 12px; color: var(--secondary); }
.track-label { height: var(--track); color: var(--secondary); position: relative; font-size: 13px; }
.track-label svg { color: var(--muted); }
.track-label button { opacity: .65; min-height: 23px; margin-left: auto; padding: 2px 4px; border-color: transparent; background: transparent; }
.track-label button:hover, .track-label button:focus-visible { opacity: 1; }
#timeline-scroll { overflow-x: auto; min-width: 0; scrollbar-width: thin; }
#timeline-content { position: relative; min-height: calc(var(--ruler) + 7 * var(--track)); touch-action: pan-x; }
.ruler { height: var(--ruler); width: 100%; position: relative; overflow: hidden; cursor: crosshair; z-index: 1; background: #20201e; border-bottom: 1px solid var(--line-strong); touch-action: none; }
.tick { position: absolute; bottom: 0; height: 23px; padding-left: 6px; border-left: 1px solid var(--line-strong); color: var(--muted); font: 10px/1.35 var(--mono); user-select: none; pointer-events: none; }
.track-row { width: 100%; height: var(--track); position: relative; background-image: repeating-linear-gradient(to right, rgb(255 255 255 / 2.5%) 0 1px, transparent 1px var(--tick)),repeating-linear-gradient(to right, rgb(255 255 255 / 5%) 0 1px, transparent 1px var(--major)); border-bottom: 1px solid var(--line); }
.track-row:nth-child(2n) { background-color: #151514; }
.track-row.shot, .track-row.motion { cursor: crosshair; }
.track-row.drop { background-color: #33271c; }
.clip { user-select: none; position: absolute; top: 3px; height: calc(var(--track) - 7px); min-height: 0; padding: 0;
  display: block; overflow: hidden; border-radius: 5px; cursor: grab; text-align: left; touch-action: none; background: #30302f; color: var(--ink); border-color: #51504a; }
.clip:not(:disabled):hover { background: #3a3a35; }
.clip.video { background: #343a3f; border-color: #535f68; }
.clip.motion { background: #322d3b; border-color: #565062; }
.clip.board { background: #43372a; border-color: #74563e; }
.clip.shot { background: #332f29; border-color: #595143; }
.clip.transcript { background: #30312d; border-color: #4c5048; }
.clip.speech { background: #263931; border-color: #446356; }
.clip.music { background: #303446; border-color: #53607c; }
.clip.selected, .clip.dragging { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); z-index: 2; }
.clip.dragging { cursor: grabbing; }
.clip > img { vertical-align: middle; height: 100%; min-width: 28px; max-width: 55%; object-fit: cover; }
.clip-title { display: inline-block; max-width: calc(100% - 8px); padding: 0 7px; line-height: calc(var(--track) - 8px); font-size: 12px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip.board-grouped { border-top: 2px solid #6ecdc6; }
.board-group-badge {
  position: absolute; top: 1px; right: 6px; display: flex; align-items: center; gap: 3px;
  padding: 1px 4px; border-radius: 3px; background: #142b2e; color: #a9f4e9; font-size: 10px;
  line-height: 14px; pointer-events: none;
}
.board-group-badge .icon { width: 11px; height: 11px; }
.clip.board .clip-title, .clip.video .clip-title { max-width: 70%; }
.clip-video-thumb { position: relative; display: inline-grid; place-items: center; vertical-align: middle; height: 100%; width: 48px; max-width: 55%; overflow: hidden; background: #181b1e; }
.clip-video-thumb img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.clip-video-play { position: relative; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgb(0 0 0 / 70%); cursor: pointer; }
.clip-video-play svg { width: 13px; height: 13px; color: #fff; }
.clip-menu { position: fixed; z-index: 12; display: grid; gap: 2px; min-width: 150px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--raised); box-shadow: 0 5px 18px rgb(0 0 0 / 40%); }
.clip-menu button { justify-content: flex-start; min-height: 30px; border-color: transparent; }
.clip-menu button:last-child { color: var(--danger); }
.clip-menu button:focus-visible { outline-offset: -2px; }
.trim { position: absolute; z-index: 3; top: 0; bottom: 0; width: min(8px, 25%); cursor: ew-resize; }
.trim.left { left: 0; }
.trim.right { right: 0; }
.clip.selected .trim, .clip:hover .trim { background: rgb(255 255 255 / 12%); }
.wordline { position: absolute; inset: 0; overflow: hidden; display: none; }
.wordline span { position: absolute; top: 0; font-size: 12px; line-height: calc(var(--track) - 8px); white-space: nowrap; overflow: hidden; }
#timeline-content.words .wordline { display: block; }
#timeline-content.words .word-fallback { display: none; }
.playhead, .snap-guide { top: 0; bottom: 0; position: absolute; left: 0; width: 1px; z-index: 4; pointer-events: none; }
.playhead { background: var(--accent); }
.playhead > span { width: 10px; height: 12px; display: block; margin-left: -4px;
  background: var(--accent); clip-path: polygon(0 0,100% 0,100% 55%,50% 100%,0 55%); }
.snap-guide { background: #e1caae; z-index: 3; }
.timeline-foot { display: flex; justify-content: space-between; align-items: center; min-height: 28px; padding: 0 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.large-timeline { --track: 54px; }
.job-list, .item-list { display: grid; gap: 8px; }
.job-card { min-width: 0; display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 10px; }
.job-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.job-status.done { color: var(--green); }
.job-status.failed { color: var(--danger); }
.result-text { max-height: 260px; overflow: auto; font: 13px/1.55 system-ui, sans-serif; color: var(--secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt-details { min-width: 0; color: var(--muted); font-size: 12px; }
.prompt-details > summary { width: fit-content; cursor: pointer; }
.prompt-content { display: grid; gap: 10px; padding-top: 8px; }
.prompt-content pre { margin: 4px 0; }
.prompt-images { margin: 6px 0 8px; }
.prompt-image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 114px), 1fr)); gap: 8px;
  list-style: none; padding: 0; margin: 4px 0 0;
}
.prompt-image-grid > li { min-width: 0; }
.prompt-image-frame {
  display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 10;
  background: var(--deep); border: 1px solid var(--line); border-radius: 5px;
}
a.prompt-image-frame:hover, a.prompt-image-frame:focus-visible { border-color: var(--accent); }
.prompt-image-frame img { width: 100%; height: 100%; object-fit: contain; }
.prompt-image-missing { padding: 4px; text-align: center; }
.prompt-image-label { color: var(--secondary); margin-top: 3px; overflow-wrap: anywhere; }
.prompt-image-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-image, .dialog-image { display: block; max-width: 100%; max-height: 280px; border-radius: 6px; object-fit: contain; background: var(--deep); }
.issues { display: grid; gap: 8px; }
.grammar-text { max-height: 225px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.grammar-mark { display: inline; min-height: 0; padding: 0; border: 0; border-radius: 2px; background: #3b2b23; color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; white-space: pre-wrap; }
.grammar-issue { display: grid; gap: 6px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.grammar-issue[data-open] { border-left-color: var(--accent); }
.grammar-change { white-space: pre-wrap; overflow-wrap: anywhere; }
.grammar-change del { color: var(--secondary); }
.draft-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 8px; }
.draft-grid > article { align-content: start; }
.draft-text { max-height: 330px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.draft-questions { margin: 0; padding-left: 24px; display: grid; gap: 6px; }
#draft-results:empty { display: none; }
.scene-row { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: start; gap: 12px; padding-block: 8px; border-top: 1px solid var(--line); }
.scene-row p { overflow-wrap: anywhere; white-space: pre-wrap; }
.grammar-change strong { color: var(--green); }
.voice-work #grammar-entry { margin-left: auto; }
.error-details pre { font-family: ui-monospace, monospace; }
.sources { white-space: normal; overflow-wrap: anywhere; padding-left: 20px; }
#dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; padding: 0;
  width: min(520px, calc(100% - 28px)); max-height: min(88dvh, 860px); }
#dialog.wide { width: min(760px, calc(100% - 28px)); }
#dialog::backdrop { background: rgb(0 0 0 / 64%); }
#dialog-content { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(88dvh, 860px); }
.dialog-header, .dialog-actions { padding: 14px 16px; display: flex; align-items: center; gap: 8px; }
.dialog-header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 19px; }
.dialog-header p { color: var(--secondary); margin-top: 4px; }
.dialog-body { padding: 16px; overflow: auto; }
.dialog-actions { justify-content: flex-end; border-top: 1px solid var(--line); flex-wrap: wrap; }
.project-item, .delete-copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.project-choice-name { overflow: hidden; text-overflow: ellipsis; }
.danger-outline, .danger-outline svg { color: var(--danger); }
button.danger-confirm { color: #211915; background: var(--danger); border-color: transparent; font-weight: 600; }
button.danger-confirm:hover:not(:disabled) { background: #ffb3a8; }
button.danger-confirm svg { color: currentColor; }
#delete-project-form p:empty { display: none; }
.project-choice { display: flex; gap: 8px; min-height: 40px; justify-content: flex-start; }
.project-choice .meta { margin-left: auto; }
.empty-inline { color: var(--secondary); }
.cost-row, .export-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cost-row.grand { color: var(--ink); }
.settings-layout { display: grid; gap: 12px; }
.setting-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.setting-tabs button { background: transparent; border-color: transparent; color: var(--secondary); }
.setting-tabs button.active { background: var(--raised); color: var(--accent); border-color: var(--line); }
.settings-section { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.key-row > label { flex: 1; }
.voice-list { max-height: 310px; overflow-y: auto; }
.voice-work .work-heading .row { flex-wrap: wrap; justify-content: flex-end; }
.library-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.library-voice { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.library-voice > audio { height: 34px; }
.library-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.voice-row { width: 100%; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.voice-row .meta { margin-left: auto; }
.style-thumb { position: relative; }
.style-thumb img { width: 70px; height: 44px; object-fit: cover; border-radius: 5px; vertical-align: middle; }
.style-thumb button { position: absolute; top: 2px; right: 2px; min-height: 22px; padding: 2px; }
#notice { display: none; position: fixed; bottom: 16px; right: 16px; z-index: 10; max-width: min(460px, calc(100% - 32px)); padding: 9px 12px;
  align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #292925; color: var(--ink); }
#studio:has(.timeline-fold-toggle[aria-expanded=false]) ~ #notice { bottom: 54px; }
#notice.visible { display: flex; }
#notice svg { flex: 0 0 16px; color: var(--green); }
#notice.error svg { color: var(--danger); }
@media (min-width: 1500px) { :root { --track-label: 228px; --track: 42px; } .work-inner { padding: 20px 24px; } }
@media (max-width: 1120px) { :root { --track-label: 172px; } .workspace { grid-template-columns: var(--track-label) minmax(275px, 1fr) minmax(280px, 1fr); } .work-inner { padding-inline: 12px; } }
@media (max-width: 820px) {
  :root { --track-label: 148px; }
  #studio { height: auto; overflow: visible; }
  .workspace { grid-template-columns: var(--track-label) minmax(0, 1fr); grid-template-rows: minmax(270px, auto) minmax(300px, 48vh); }
  .sidebar { grid-row: 1 / 3; }
  .monitor { grid-column: 2; border-top: 1px solid var(--line); }
  .timeline-toolbar { gap: 6px; }
  .timeline-toolbar h2 { margin-right: 0; }
  .timeline-zoom input { width: 48px; }
}
@media (max-width: 540px) {
  :root { --track-label: 128px; }
  .topbar, .projectbar { padding: 0 8px; gap: 4px; }
  .brand { gap: 6px; font-size: 13px; }
  #save-status { display: none; }
  .top-actions { gap: 4px; }
  .top-actions > button { padding-inline: 6px; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(270px, auto) 285px; }
  .sidebar { grid-row: 1; padding: 6px; }
  .side-heading, .cost-block { display: none; }
  #workflow { display: flex; flex-wrap: wrap; }
  .workflow-item { width: auto; padding: 3px 6px; min-height: 27px; font-size: 12px; }
  .monitor { grid-column: 1; }
  .timeline-toolbar { flex-wrap: wrap; height: auto; min-height: 64px; padding-block: 5px; }
  #zoom-tools { margin-left: 0; }
  .track-label { font-size: 11px; padding-inline: 6px; gap: 4px; }
  .export-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

.track-label.speech, .track-label.music, .track-row.speech, .track-row.music {
  height: calc(var(--track) + 6px);
}
.clip.speech, .clip.music { height: calc(var(--track) - 1px); }
.clip .waveform {
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 100%;
  height: calc(100% - 17px);
  color: #9acdb4;
  pointer-events: none;
}
.clip.music .waveform { color: #a7b9dc; }
.clip.speech .clip-title, .clip.music .clip-title { line-height: 16px; vertical-align: top; }
.clip-properties { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.clip-stepper, .clip-volume { display: flex; min-width: 0; gap: 6px; align-items: center; }
.clip-stepper button { flex: 0 0 26px; min-height: 34px; padding-inline: 3px; }
.clip-stepper input, .clip-volume input { min-width: 0; }
.clip-stepper input[type=number] { appearance: textfield; }
.clip-stepper input::-webkit-inner-spin-button { appearance: none; }
.clip-volume input[type=range] { flex: 1; }
.clip-volume input[type=number] { flex: 0 0 64px; }
.project-cost-details { gap: 5px; }
.project-cost-details > .cost-row { padding-block: 6px; }
.activity-section { display: grid; gap: 8px; margin-top: 8px; }
.activity-section h3 { font-size: 15px; }
.activity-details { gap: 0; }
.activity-details .cost-row { padding-block: 5px; }
@media (max-width: 1050px) {
  .clip-properties.columns.two { grid-template-columns: 1fr; }
}
@media (max-width: 670px) {
  button[aria-controls=work] { max-width: 128px; white-space: normal; line-height: 1.1; }
  .timeline-toolbar { flex-wrap: wrap; height: auto; padding-block: 6px; }
}

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 28px 16px; }
.login-card { display: grid; justify-items: center; gap: 20px; width: min(100%, 440px); }
.login-card > .brand { justify-content: center; }
.login-card > p { text-align: center; color: var(--secondary); }
#clerk-sign-in { max-width: 100%; }
