﻿:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --ink: #eef0ef;
  --muted: #999fa5;
  --canvas: #141619;
  --panel: #1d2024;
  --well: #17191d;
  --line: #32373d;
  --line-subtle: #292d32;
  --accent: #cfed7b;
  --accent-ink: #1b2708;
  --clip: #314d69;
  --audio: #2a5148;
  --title: #4d426a;
  --danger: #f3a1a1;
  --radius: 10px;
  background: var(--canvas);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
p, h1, h2, h3 { margin: 0; }
a { color: inherit; }
svg { width: 1.13em; height: 1.13em; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label:has(+ .file-input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem 1.25rem;
  padding: .65rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: #1a1c20;
}
.project, .topbar-actions, .history { display: flex; align-items: center; gap: .5rem; }
.project { min-width: 0; gap: .75rem; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 2.1rem;
  height: 2.1rem;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand-mark svg { width: 1.28rem; height: 1.28rem; stroke-width: 1.9; }
.brand-name { font-size: 1.05rem; font-weight: 750; letter-spacing: -.025em; white-space: nowrap; }
.topbar-divider { height: 1.55rem; width: 1px; background: var(--line); margin: 0 .15rem; }
.project-name {
  width: min(24vw, 17rem);
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: .38rem .5rem;
  font-size: .88rem;
  text-overflow: ellipsis;
}
.project-name:hover, .project-name:focus { border-color: var(--line); background: var(--well); }
.history { gap: .15rem; padding-right: .35rem; }

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.15rem;
  padding: .35rem .65rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #262a2f;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
}
.button { cursor: pointer; }
.button:hover, button:hover:not(:disabled) { background: #30353b; border-color: #484e55; }
.icon-button { width: 2.15rem; padding: 0; }
.secondary { background: transparent; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.primary:hover:not(:disabled) { background: #dcf6a1; color: var(--accent-ink); border-color: transparent; }
.danger:hover:not(:disabled) { color: var(--danger); }
.muted, .hint, small { color: var(--muted); }
.empty-icon { width: 1.55rem; height: 1.55rem; color: #848b90; }

.editor {
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto 1.5rem;
  gap: .6rem;
  min-height: calc(100dvh - 4rem);
  height: calc(100dvh - 4rem);
  padding: .65rem .85rem .35rem;
}
.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(12rem, 19vw, 17rem) minmax(260px, 1fr) clamp(14rem, 22vw, 21rem);
  gap: .6rem;
}
.panel {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.panel-heading {
  min-height: 2.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  padding: .54rem .75rem;
  border-bottom: 1px solid var(--line-subtle);
}
.panel-heading h1, .panel-heading h2 {
  display: flex;
  gap: .5rem;
  align-items: center;
  font-size: .91rem;
  font-weight: 650;
  white-space: nowrap;
}
.panel-heading svg { color: var(--muted); }
.viewer-format, .timeline-hint { color: var(--muted); font-size: .78rem; white-space: nowrap; }

.library, .inspector-panel, .viewer { display: flex; flex-direction: column; }
.bin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .38rem; padding: .55rem; }
.bin-actions .button { min-width: 0; }
.library-content, .inspector {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: .45rem .55rem .6rem;
}
.library-content.drag-over, .timeline-scroll.drag-over { background-color: #293522; }
.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 6.6rem), 1fr)); gap: .45rem; align-content: start; }
.library-empty {
  display: none;
  min-height: 8.5rem;
  place-content: center;
  justify-items: center;
  gap: .55rem;
  text-align: center;
  color: var(--muted);
  font-size: .87rem;
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: .6rem;
}
.media-list:empty + .library-empty { display: grid; }
.library-empty p { color: var(--ink); }
.library-empty small { font-size: .78rem; }
.asset-card, .media-item {
  display: grid;
  align-content: start;
  gap: .35rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #23272c;
  padding: .4rem;
  overflow: hidden;
  text-align: left;
  cursor: grab;
}
.asset-card:is(:hover, :focus-within), .media-item:is(:hover, :focus-within) { border-color: #626a72; }
.asset-card img, .asset-card video, .media-item img, .media-item video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; border-radius: 4px; background: #0b0c0e; }
.asset-card span, .asset-card strong, .media-item span, .media-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-stage {
  display: grid;
  flex: 1;
  min-height: 0;
  place-items: center;
  container-type: size;
  overflow: hidden;
  background: #111316;
  padding: .6rem;
}
.monitor {
  width: min(100cqw, 177.7778cqh);
  height: min(100cqh, 56.25cqw);
  position: relative;
  overflow: hidden;
  background: #08090a;
  border: 1px solid #25282c;
  border-radius: 5px;
}
#preview-canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .7rem;
  color: var(--muted);
  font-size: .88rem;
  pointer-events: none;
}
.transport {
  flex: none;
  display: grid;
  grid-template-columns: auto max-content minmax(0, 1fr) max-content;
  gap: .65rem;
  align-items: center;
  min-height: 3.3rem;
  border-top: 1px solid var(--line-subtle);
  padding: .45rem .7rem;
}
.play-button { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.play-button:hover:not(:disabled) { background: #dcf6a1; border-color: transparent; }
.time-label { font-variant-numeric: tabular-nums; font-size: .83rem; white-space: nowrap; }
.end-time { color: var(--muted); }
#scrub { width: 100%; min-width: 0; accent-color: var(--accent); }

.inspector { padding: .7rem .72rem; }
.inspector :is(h2,h3) { font-size: .92rem; }
.inspector .muted { font-size: .875rem; line-height: 1.45; }
.inspector > :not(:first-child) { margin-top: .65rem; }
.inspector label { font-size: .875rem; }
.inspector input:not([type="checkbox"],[type="range"],[type="color"]), .inspector select, .inspector textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2rem;
  padding: .35rem .45rem;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 6px;
  line-height: 1.3;
}
.inspector textarea { min-height: 4.3rem; resize: vertical; }
.inspector input:is([type="checkbox"],[type="range"]) { accent-color: var(--accent); }
.inspector input[type="checkbox"] { inline-size: 1rem; block-size: 1rem; margin: 0 .35rem 0 0; }
.inspector details { border-top: 1px solid var(--line); padding-top: .55rem; }
.inspector summary { cursor: pointer; font-size: .875rem; font-weight: 650; }
.inspector fieldset { min-width: 0; margin-inline: 0; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; }
.inspector legend { padding-inline: .25rem; font-size: .87rem; color: var(--muted); }
.inspector .field { display: grid; gap: .28rem; min-width: 0; }
.inspector .field:has(input[type="checkbox"]) { display: flex; align-items: center; }
.inspector .stack, .inspector .fields { display: grid; gap: .48rem; }
.inspector .row, .inspector .control-row, .inspector .inline { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inspector .grid, .inspector .split, .inspector .two-col, .inspector .field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.inspector .help, .inspector .hint { font-size: .8rem; line-height: 1.4; }

.timeline-panel { min-height: 8.65rem; }
.track-area { display: grid; grid-template-columns: 5.55rem minmax(0, 1fr); }
.track-labels { display: grid; grid-template-rows: 1.35rem 3.45rem 2.35rem; background: #1d2024; border-right: 1px solid var(--line); }
.track-labels > span { display: flex; gap: .45rem; align-items: center; padding-inline: .6rem; color: var(--muted); font-size: .78rem; border-bottom: 1px solid var(--line-subtle); }
.timeline-scroll { overflow-x: auto; min-width: 0; background: #15171a; scrollbar-color: #444b52 #1b1e22; }
.timeline-ruler {
  min-height: 1.35rem;
  border-bottom: 1px solid var(--line-subtle);
  background: repeating-linear-gradient(90deg, #31363c 0 1px, transparent 1px 1.5rem) left bottom / 100% 5px no-repeat;
  color: var(--muted);
  font-size: .75rem;
}
.video-lane { position: relative; min-height: 3.45rem; }
.track { display: flex; position: relative; gap: .25rem; align-items: stretch; min-width: 100%; width: max-content; padding: .3rem .36rem; border-bottom: 1px solid var(--line-subtle); }
.timeline { min-height: 3.45rem; }
.audio-lane { min-height: 2.35rem; }
.timeline-empty { position: absolute; inset: 0; display: none; align-items: center; padding-inline: .7rem; color: var(--muted); font-size: .83rem; pointer-events: none; }
.timeline:empty + .timeline-empty { display: flex; }
.clip, .track-clip {
  display: flex;
  position: relative;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: .16rem;
  flex: 0 0 auto;
  min-width: 3rem;
  overflow: hidden;
  padding: .3rem .48rem;
  border: 1px solid #53718d;
  border-radius: 5px;
  background: var(--clip);
  color: var(--ink);
  text-align: left;
  font-size: .82rem;
  cursor: grab;
}
.clip:is(.title, [data-kind="title"]), .track-clip:is(.title, [data-kind="title"]) { background: var(--title); border-color: #72628e; }
.audio-lane :is(.clip, .track-clip) { background: var(--audio); border-color: #477966; min-height: 1.65rem; }
.clip:is(.selected, .active, [aria-pressed="true"]), .track-clip:is(.selected, .active, [aria-pressed="true"]) { outline: 1px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.clip :is(span, small, strong), .track-clip :is(span, small, strong) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip :is(small, .clip-duration), .track-clip :is(small, .clip-duration) { color: #d3dadb; font-size: .75rem; font-variant-numeric: tabular-nums; }
.clip.dragging, .track-clip.dragging { opacity: .55; }
.asset-card { display: grid; grid-template-columns: 1.9rem minmax(0, 1fr) 1.8rem; align-items: center; gap: .55rem; }
.asset-copy { display: grid; gap: .12rem; min-width: 0; }
.asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .89rem; }
.asset-meta { color: var(--muted); font-size: .76rem; }
.asset-add, .frame-button { min-height: 1.8rem; width: 1.8rem; padding: 0; }
.asset-type { color: var(--accent); text-align: center; }
.transport { grid-template-columns: auto auto auto auto minmax(3.5rem,1fr) auto; }
#resolution { border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #25292d; padding: .15rem .28rem; }
.timeline-ruler { position: relative; cursor: crosshair; }
.ruler-tick { position: absolute; top: .08rem; padding-left: .13rem; pointer-events: none; }
.ruler-playhead { position: absolute; top: 0; bottom: -5.8rem; width: 1px; pointer-events: none; background: var(--accent); z-index: 3; }
.ruler-playhead::before { content: ""; position: absolute; left: -3px; width: 7px; height: 6px; background: var(--accent); }
.ruler-marker { position: absolute; top: .2rem; width: .56rem; min-height: .82rem; border: 0; border-radius: 2px; padding: 0; background: #f2bf73; cursor: pointer; z-index: 4; }
#timeline { padding-inline: 0; gap: 0; }
#timeline.drop-target { background: #252f24; }
#timeline .track-clip { position: relative; min-width: 0; padding: 0; display: block; }
.clip-content { display: block; width: 100%; height: 100%; border: 0; padding: 0 .55rem; background: transparent; color: inherit; font: inherit; text-align: left; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.trim-handle { position: absolute; top: 0; bottom: 0; width: .3rem; padding: 0; border: 0; border-radius: 0; background: transparent; z-index: 2; cursor: ew-resize; touch-action: none; }
.trim-in { left: 0; } .trim-out { right: 0; }
.trim-handle:hover, .trim-handle:focus-visible { background: var(--accent); }
.audio-lane .music-clip { position: absolute; top: .26rem; bottom: .22rem; min-width: 0; white-space: nowrap; text-overflow: ellipsis; }
.audio-lane .music-clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; pointer-events: none; }
.audio-lane .music-clip .music-name { position: relative; z-index: 1; }
.inspector .inspector-tabs { display: flex; flex-wrap: wrap; gap: .28rem; }
.inspector-tab { border: 0; border-radius: 4px; padding: .35rem .5rem; font-size: .85rem; background: var(--surface); color: var(--muted); }
.inspector-tab.selected, .inspector-tab[aria-selected="true"] { background: var(--accent); color: #172012; }
.status-bar { display: flex; justify-content: space-between; align-items: center; min-width: 0; gap: .7rem; color: var(--muted); font-size: .79rem; }
#status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status[data-error="true"], #status.error { color: var(--danger); }
#export-progress { width: min(32vw, 16rem); accent-color: var(--accent); }
.local-note { margin-inline-start: auto; white-space: nowrap; }

@media (max-width: 960px) {
  .stage { grid-template-columns: minmax(9.5rem, .75fr) minmax(14rem, 2fr) minmax(11.5rem, .95fr); }
  .bin-actions { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding-inline: .75rem; }
  .topbar-actions { gap: .35rem; }
  .project-name { width: min(52vw, 17rem); }
  .editor { height: auto; min-height: calc(100dvh - 4rem); grid-template-rows: auto auto auto; padding-inline: .55rem; }
  .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(11rem, 16rem); }
  .viewer { grid-column: 1 / -1; grid-row: 1; }
  .preview-stage { min-height: 12rem; height: min(54vw, 24rem); }
  .bin-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 405px) {
  .history { padding-right: 0; }
  .topbar-actions .secondary span { display: none; }
  .topbar-actions .secondary { padding-inline: .5rem; }
  .bin-actions { grid-template-columns: 1fr; }
  .track-area { grid-template-columns: 3.7rem minmax(0, 1fr); }
  .track-labels svg { display: none; }
  .local-note { display: none; }
}
