:root {
  color-scheme: dark;
  --bg: #141613;
  --panel: #1b1e1a;
  --surface: #232721;
  --border: #353a31;
  --text: #f1f0e9;
  --muted: #aeb5a9;
  --accent: #f6a66c;
  --ink: #27170e;
  --radius: 15px;
  font-family: "Inter", system-ui, sans-serif;
}
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  accent-color: var(--accent);
}
[hidden] { display: none !important; }
.wrap { width: min(100%, 1420px); max-width: none; margin: auto; padding: 0 28px 42px; }
.studio-header {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 20px 0; margin: 0; border-bottom: 1px solid var(--border);
}
.studio-brand { display: flex; gap: 11px; align-items: center; min-width: 0; }
.studio-brand h1 { font-size: 19px; line-height: 1.2; font-weight: 760; letter-spacing: -.025em; margin: 0; }
.studio-brand div span { font-size: 12px; color: var(--muted); }
.studio-mark {
  width: 41px; height: 41px; border-radius: 11px; background: var(--accent);
  display: grid; place-items: center; flex: none;
}
.studio-mark i, .frame-icon span {
  width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  border-left: 10px solid currentColor; transform: translateX(1px);
}
.studio-mark i { color: var(--ink); }
.studio-modes {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); width: fit-content;
  gap: 3px; margin: 14px 0 18px; padding: 3px; border: 1px solid var(--border);
  background: #181b17; border-radius: 11px;
}
.studio-modes .modeTab {
  background: transparent; color: var(--muted); min-height: 44px; padding: 5px 13px;
  border: 0; border-radius: 7px; font-weight: 650; box-shadow: none; font-size: 13px;
}
.studio-modes .modeTab[aria-pressed=true], .tool-tab[aria-pressed=true] {
  background: #32372e; color: var(--text);
}
body.editorMode main.wrap > section:not(#editorPanel) { display: none !important; }
body:not(.editorMode) #exportShortcut { display: none; }
body:not(.editorMode) .wrap { max-width: 920px; }
#editorPanel * { box-sizing: border-box; }
#editorPanel h2, #editorPanel h3 { color: var(--text); margin: 0; }
#editorPanel h2 { font-size: 16px; letter-spacing: -.02em; }
#editorPanel h3 { font-size: 15px; overflow-wrap: anywhere; }
#editorPanel p { margin: 0; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 330px); gap: 16px; align-items: start; }
.workbench { display: grid; gap: 16px; min-width: 0; }
.studio-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 11px 15px; min-height: 54px; }
.panel-heading small { color: var(--muted); font-size: 11px; }
.panel-heading > div:first-child { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.aspect-label { font: 12px ui-monospace, monospace; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; }
.stage {
  display: grid; place-items: center; min-height: 0; padding: 12px;
  background-color: #10120f;
  background-image: radial-gradient(#292c26 0.65px, transparent 0.65px);
  background-size: 13px 13px;
}
.monitor {
  position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 9 / 16;
  height: clamp(250px, 45svh, 505px); max-width: 100%; background: #090a08;
  border: 1px solid #3e4438; border-radius: 8px;
}
.monitor video, .monitor canvas, .empty-stage { position: absolute; inset: 0; width: 100%; height: 100%; }
.monitor video { object-fit: contain; }
.monitor canvas { pointer-events: none; }
.empty-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 13px; padding: 8px; text-align: center; color: var(--text);
  background: radial-gradient(ellipse at 50% 60%, #333a2c, #20251e 73%); font-size: 13px;
}
.frame-icon { width: 47px; height: 40px; display: grid; place-items: center; border: 1px solid #75816e; border-radius: 9px; color: var(--accent); }
.transport { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 14px; }
.transport output { color: var(--muted); font: 12px ui-monospace, monospace; }
.primary, .quiet, .play, .file-button, .tool-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  box-sizing: border-box; min-height: 44px; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 11px; text-decoration: none; cursor: pointer; font: 650 13px system-ui, sans-serif;
  color: var(--text); background: var(--surface); -webkit-tap-highlight-color: transparent;
}
.primary { background: var(--accent); color: var(--ink); font-weight: 760; }
.quiet, .file-button { border-color: var(--border); }
.play { color: var(--accent); font-size: 17px; min-width: 44px; }
:is(.quiet,.primary,.play,.tool-tab,.file-button):hover:not(:disabled) { filter: brightness(1.13); }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .42; cursor: default; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.zoom-label { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 5px; }
.zoom-label input { width: clamp(40px, 7vw, 100px); margin: 0; height: 38px; }
.timeline-grid { display: grid; grid-template-columns: 64px minmax(0,1fr); border-block: 1px solid var(--border); }
.track-labels { display: grid; grid-template-rows: 30px 76px repeat(3, 35px); color: var(--muted); font-size: 11px; }
.track-labels span { display: flex; align-items: center; padding-left: 13px; border-bottom: 1px solid #30352d; }
.timeline-scroll { overflow-x: auto; background: #161915; scrollbar-color: #5c6553 #1a1e18; }
.timeline-inner { position: relative; min-width: 100%; }
.ruler { height: 30px; position: relative; border-bottom: 1px solid #30352d; }
.ruler input { position: absolute; z-index: 1; top: 0; left: 0; height: 30px; margin: 0; opacity: .001; }
.ruler:focus-within { outline: 1px solid var(--accent); outline-offset: -2px; }
#ticks { pointer-events: none; height: 100%; }
.tick { position: absolute; bottom: 0; border-left: 1px solid #576050; height: 8px; color: var(--muted); font: 10px ui-monospace, monospace; padding-left: 4px; }
.tick b { position: relative; top: -13px; font-weight: 500; }
.clips-track { height: 76px; position: relative; border-bottom: 1px solid #30352d; }
.timeline-clip {
  position: absolute; top: 5px; height: 64px; display: flex; align-items: stretch;
  box-shadow: inset 0 0 0 1px #64776d; background: #344c43; color: #f3f5ed;
  border-radius: 6px; user-select: none; touch-action: none;
}
.timeline-clip.selected { z-index: 2; box-shadow: 0 0 0 2px var(--accent); }
.timeline-clip.moving { opacity: .62; }
.timeline-clip.drop-target { outline: 2px dashed #f4dfac; z-index: 3; }
.clip-middle {
  display: flex; align-items: end; min-width: 0; width: 100%; padding: 0;
  border: 0; border-radius: 6px; background-color: transparent; color: inherit;
  background-size: auto 100%; background-repeat: repeat-x;
  text-align: left; overflow: hidden; cursor: grab; touch-action: none;
}
.clip-name {
  display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; width: 100%;
  background: #17231eee; font-size: 11px; padding: 5px 13px; pointer-events: none;
}
.trim-handle {
  position: absolute; top: 0; bottom: 0; width: min(26px, 42%); padding: 0; border: 0;
  background: var(--accent); color: var(--ink); display: grid; place-items: center;
  font-size: 13px; cursor: ew-resize; touch-action: none;
}
.trim-handle.left { left: 0; border-radius: 6px 0 0 6px; }
.trim-handle.right { right: 0; border-radius: 0 6px 6px 0; }
.layer-track { height: 35px; position: relative; border-bottom: 1px solid #30352d; }
.layer-track:last-of-type { border-bottom: 0; }
.layer-item {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left;
  position: absolute; top: 4px; height: 26px; border-radius: 5px; border: 0;
  padding: 0 7px; font-size: 11px; color: #f4f2e9; cursor: pointer;
}
.text-track .layer-item { background: #684728; }
.image-track .layer-item { background: #4a4668; }
.music-track .layer-item { background: #2f5047; }
.playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: #ffcb9f; z-index: 4; pointer-events: none; }
.playhead::before { position: absolute; content: ''; left: -4px; width: 9px; height: 7px; background: #ffcb9f; clip-path: polygon(0 0,100% 0,100% 55%,50% 100%,0 55%); }
.timeline-actions { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px 0; }
.gesture-hint { padding: 7px 12px 11px; font-size: 11px; line-height: 1.45; color: var(--muted); }
.tool-tabs { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; padding: 0 12px 12px; border-bottom: 1px solid var(--border); }
.tool-tab { padding-inline: 2px; font-size: 12px; color: var(--muted); border-color: var(--border); background: transparent; }
.tool-tab[aria-pressed=true] { border-color: #586250; }
.tool-page { display: grid; align-content: start; gap: 11px; padding: 15px 13px; }
.tool-page fieldset { border: 0; display: grid; gap: 11px; min-inline-size: 0; padding: 0; margin: 0; }
.tool-page p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.tool-page label { display: grid; gap: 4px; align-content: start; color: var(--muted); font-size: 12px; min-width: 0; }
.tool-page :is(input:not([type=checkbox],[type=range],[type=color],[type=file]), select, textarea) {
  border: 1px solid var(--border); background: #161915; color: var(--text);
  border-radius: 7px; width: 100%; min-height: 44px; padding: 7px; font: 14px system-ui,sans-serif;
}
.tool-page input[type=range] { width: 100%; margin: 0; min-height: 32px; }
.tool-page input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex: none; }
.tool-page .check { display: flex; align-items: center; gap: 7px; min-height: 38px; }
.tool-page textarea { resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.field-wide { grid-column: 1 / -1; }
.action-row { display: flex; gap: 5px; flex-wrap: wrap; }
.tool-page .file-button { display: inline-flex; justify-self: start; color: var(--text); }
.file-button:has(+ input:focus-visible) { outline: 2px solid var(--accent); }
.accessible-file { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.palette { display: flex; gap: 3px; flex-wrap: wrap; }
.swatch { background: transparent; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; width: 44px; height: 44px; cursor: pointer; }
.swatch::before { content: ''; width: 18px; height: 18px; border-radius: 50%; background: var(--swatch); }
.tool-page .color-picker { display: flex; align-items: center; flex-direction: row; }
.color-picker input { width: 38px; height: 44px; border: 0; background: transparent; cursor: pointer; }
.styled-caption { overflow-wrap: anywhere; white-space: pre-wrap; min-height: 1em; text-align: center; background: #121411; border-radius: 6px; padding: 6px; }
.tool-page details { font-size: 12px; min-width: 0; }
.tool-page summary { cursor: pointer; padding: 11px 0; }
.tool-page pre { padding: 8px; margin: 0; overflow: auto; max-height: 240px; background: #121411; border-radius: 6px; }
.inspector-footer { border-top: 1px solid var(--border); padding: 9px 13px; }
.studio-status, .studio-error { margin: 10px 12px 0 !important; padding: 8px; border-radius: 7px; font-size: 12px; }
.studio-status { background: #2b3027; }
.studio-status > div { display: flex; justify-content: space-between; gap: 8px; }
.studio-status progress { display: block; width: 100%; height: 10px; }
.studio-error { background: #442d28; color: #ffcfb9; overflow-wrap: anywhere; }
.full { width: 100%; }
#previewDialog { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px; width: min(92vw,490px); }
#previewDialog::backdrop { background: #070805d9; }
.dialog-top { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#renderedVideo { display: block; background: black; width: 100%; max-height: 75svh; }
body:not(.editorMode) .section { background: var(--panel); border-color: var(--border); }
body:not(.editorMode) :is(.btn,.batchPick,.pick,.takeCard,.meta,.detailsPane) { background: var(--surface); border-color: var(--border); color: var(--text); }
body:not(.editorMode) :is(.btn:not(.alt)) { background: var(--accent); color: var(--ink); }
@media (max-width: 780px) {
  .wrap { padding: 0 13px 24px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .workbench { gap: 10px; }
  .studio-header { padding: 9px 0; }
  .studio-modes { margin: 8px 0 10px; width: 100%; }
  .studio-modes .modeTab { padding-inline: 2px; font-size: 12px; }
  .monitor { height: clamp(208px, 33svh, 450px); }
  .panel-heading { min-height: 48px; padding: 4px 10px; }
  .panel-heading > div:first-child { gap: 3px 8px; }
  .stage { padding: 7px; }
  .transport { padding: 3px 8px; gap: 5px; }
  .timeline-grid { grid-template-columns: 48px minmax(0,1fr); }
  .track-labels span { padding-left: 5px; font-size: 10px; }
  .timeline-actions { padding-inline: 6px; gap: 4px; }
  .timeline-actions button { padding-inline: 7px; font-size: 12px; }
  .tool-page :is(input:not([type=checkbox],[type=range],[type=color],[type=file]), select, textarea) { font-size: 16px; }
}
@media (max-width: 370px) {
  .wrap { padding-inline: 8px; }
  .studio-brand h1 { font-size: 16px; }
  #exportShortcut, #renderPreview { padding-inline: 6px; font-size: 12px; }
  .transport output { font-size: 10px; }
  .heading-actions { gap: 4px; }
  .zoom-label { gap: 3px; }
  .panel-heading > div:first-child { display: block; }
}
.ruler { touch-action: pan-y; cursor: ew-resize; }
.ruler input { pointer-events: none; }
.clip-middle:disabled { opacity: 1; }
.studio-error { white-space: pre-line; }
.action-row button[aria-pressed=true] { border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
.trim-handle { width: min(44px, 34%); }
.timeline-clip.selected .clip-name { padding-inline: min(46px, 35%); }
.project-bar { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:6px; padding-top:8px; }
.project-buttons { display:flex; flex-wrap:wrap; gap:4px; }
#saveStatus { color:var(--muted); font-size:12px; }
.pwa-message, .global-job { border:1px solid var(--border); background:var(--panel); border-radius:9px; padding:8px; margin:7px 0; font-size:12px; }
.global-job { display:grid; grid-template-columns:minmax(85px,1fr) minmax(42px,120px) auto; gap:8px; align-items:center; }
.global-job progress { width:100%; }
.app-dialog { color:var(--text); background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:15px; width:min(94vw,530px); max-height:85svh; }
.app-dialog::backdrop { background:#070805d9; }
.app-dialog p { color:var(--muted); font-size:13px; line-height:1.5; }
.app-dialog .action-row { margin:8px 0; }
.app-dialog h2 { font-size:17px; margin:0; }
.export-row { display:flex; align-items:center; justify-content:space-between; gap:6px; flex-wrap:wrap; border-top:1px solid var(--border); padding:9px 0; }
.export-row span { font-size:12px; overflow-wrap:anywhere; min-width:0; }
.export-row .action-row { margin:0; }
#editorCompareRows { overflow:auto; max-height:220px; }
@media(max-width:380px) { .project-buttons .quiet { padding-inline:7px; } }
.transport output { white-space:nowrap; }
#exportShortcut { white-space:nowrap; }
@media (max-width:780px) {
  #exportShortcut { font-size:12px; padding-inline:8px; }
  .studio-brand h1 { font-size:17px; }
  .studio-brand div span { font-size:11px; }
  .monitor { height:clamp(200px,30svh,380px); }
  .transport output { font-size:10px; }
  #renderPreview { padding-inline:6px; font-size:12px; }
}
@media (max-width:360px) {
  .studio-brand h1 { font-size:15px; }
}

.quick-edit { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; padding:0 8px 8px; }
.quick-edit button { padding-inline:4px; white-space:nowrap; }
.preview-still { position:absolute; inset:0; width:100%; height:100%; background:#090a08; pointer-events:none; }
.monitor { touch-action:none; }
.preview-selection {
  position:absolute; z-index:4; border:1.5px solid #f6a66c; cursor:move; touch-action:none;
  box-shadow:0 0 0 1px #15141190;
}
#previewResize {
  position:absolute; display:grid; place-items:center; right:-10px; bottom:-10px; width:32px; height:32px;
  padding:0; color:#251910; background:transparent; border:0; cursor:nwse-resize; touch-action:none;
}
#previewResize span { display:grid; place-items:center; width:17px; height:17px; border-radius:4px; background:#f6a66c; font-size:12px; font-weight:bold; }
.rgb-fields { display:grid; grid-template-columns:minmax(0,1.55fr) repeat(3,minmax(0,1fr)); gap:5px; }
.rgb-fields input { padding-inline:3px !important; font-variant-numeric:tabular-nums; }
@media(max-width:390px) { .quick-edit button { font-size:12px; } }
@font-face { font-family:Oswald; src:url('/fonts/oswald.woff2') format('woff2'); font-display:swap; }
@font-face { font-family:Playfair; src:url('/fonts/playfair-display.woff2') format('woff2'); font-display:swap; }
@font-face { font-family:Pacifico; src:url('/fonts/pacifico.woff2') format('woff2'); font-display:swap; }
