:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111216;
  color: #eeedf3;
  --border: #2b2c35;
  --muted: #9a9aa8;
  --accent: #d9f58c;
  --lavender: #b8a5ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button {
  border: 1px solid var(--border); background: #23242c; color: inherit; border-radius: 7px;
  padding: 8px 12px; font-size: 12px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: #30323d; border-color: #515361; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #1b2412; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #e8ffb0; }
button.secondary { background: #2a3322; border-color: #3d4a2e; color: var(--accent); }
button.subtle { background: transparent; border-color: transparent; color: var(--muted); }
button.icon { padding: 0; width: 31px; height: 31px; font-size: 17px; }
button.accent { background: #2b3423; color: var(--accent); border-color: #425030; }
input:not([type=range]), select { min-width: 0; border: 1px solid #383944; background: #17181e; color: inherit; border-radius: 6px; padding: 8px 9px; font-size: 13px; }
h2, h3, p { margin: 0; }
h2 { font-size: 15px; letter-spacing: -.015em; }
h3 { font-size: 13px; }
small, .muted { color: var(--muted); font-size: 11px; }
.topbar { height: 70px; display: flex; align-items: center; gap: 26px; padding: 0 22px; background: #191a20; border-bottom: 1px solid var(--border); }
.brand { display: flex; gap: 11px; align-items: center; font-weight: 750; font-size: 15px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; background: var(--accent); color: #222b17; width: 34px; height: 34px; border-radius: 9px; font-size: 22px; }
.brand small { display: block; margin-top: 2px; font-size: 9px; letter-spacing: .15em; }
.project { display: flex; align-items: center; min-width: 0; gap: 10px; margin: auto; }
.project label { font-size: 11px; color: var(--muted); }
.project input { width: min(25vw, 230px); }
.top-actions { display: flex; gap: 8px; }
.top-actions .primary { min-width: 94px; }
.top-actions .primary span { margin-right: 4px; }
.workspace { display: grid; grid-template-columns: minmax(196px, 232px) minmax(310px, 1fr) minmax(238px, 280px); height: max(480px, calc(100dvh - 274px)); }
.screens, .inspector { background: #191a20; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.screens { border-right: 1px solid var(--border); }
.inspector { border-left: 1px solid var(--border); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 17px 16px 14px; min-height: 68px; border-bottom: 1px solid var(--border); }
.panel-heading .muted { display: block; margin-top: 3px; }
.screen-list { overflow: auto; padding: 12px 10px; flex: 1; }
.screen-card { width: 100%; display: flex; align-items: center; text-align: left; gap: 11px; padding: 8px; margin-bottom: 5px; background: transparent; border-color: transparent; }
.screen-card.selected { background: #29253a; border-color: #64538c; }
.screen-card img { width: 28px; height: 46px; object-fit: contain; background: #111216; border-radius: 4px; }
.screen-card span, .source div { min-width: 0; }
.screen-card strong, .source strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.screen-card small, .source small { display: block; margin-top: 5px; }
.source { padding: 12px 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.source div { flex: 1; }
.source-icon { background: #262733; border-radius: 6px; padding: 6px 7px; color: var(--lavender); }
.source button { padding: 5px 7px; }
.center { min-width: 0; min-height: 0; display: grid; grid-template-rows: 54px minmax(0, 1fr) 49px; }
.canvas-header, .canvas-footer { display: flex; align-items: center; gap: 9px; padding: 0 15px; background: #1b1c22; }
.canvas-header { border-bottom: 1px solid var(--border); }
.canvas-footer { border-top: 1px solid var(--border); justify-content: space-between; color: var(--muted); font-size: 11px; }
.tabs { display: flex; gap: 3px; margin-right: auto; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #14151a; }
.tabs button { border-color: transparent; padding: 5px 10px; background: transparent; color: var(--muted); }
.tabs button[aria-pressed=true] { background: #2e2f39; color: #f5f4fa; }
.tabs span { color: var(--lavender); margin-left: 3px; }
.badge { color: var(--lavender); font-size: 9px; letter-spacing: .1em; border: 1px solid #403551; border-radius: 5px; background: #282133; padding: 5px 7px; white-space: nowrap; }
.preview { position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle, #33343d 1px, transparent 1.2px) center / 18px 18px, #14151a; padding: 12px; }
.phone { position: absolute; background: #101116; border-radius: 15px; box-shadow: 0 0 0 4px #33343e, 0 8px 36px #000b; }
.phone video, .phone img, .regions { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; }
.phone video, .phone img { object-fit: contain; }
.regions { pointer-events: none; touch-action: none; }
.regions.drawing { pointer-events: auto; cursor: crosshair; box-shadow: 0 0 0 2px var(--accent); }
.region { display: block; position: absolute; border: 1.5px solid #9877ff; background: #8162ff26; border-radius: 3px; pointer-events: auto; padding: 0; }
.region.chosen, .region.draft { border-color: var(--accent); background: #adc75832; }
.regions.drawing .region { pointer-events: none; }
.region span { position: absolute; bottom: 100%; left: 0; background: #342956; color: #faf6ff; padding: 3px 6px; font-size: 9px; border-radius: 4px 4px 0 0; white-space: nowrap; }
.region.near-top span { top: 100%; bottom: auto; border-radius: 0 0 4px 4px; }
.region.chosen span { background: var(--accent); color: #212917; }
.region span { max-width: min(160px, var(--phone-width, 160px)); overflow: hidden; text-overflow: ellipsis; }
.region:hover:not(:disabled) { border-color: #fff; background: #8162ff45; }
.placeholder { max-width: 300px; text-align: center; }
.placeholder p, .empty { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 8px 0 12px; }
.empty { padding: 0 5px; }
.inspector-content { padding: 15px; overflow: auto; }
.field { display: grid; gap: 5px; font-size: 11px; color: #bbb9c6; margin-bottom: 11px; }
.field :is(input, select) { width: 100%; }
.inspector-meta { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.inspector-meta .tag { color: var(--accent); background: #293224; border-radius: 4px; font-size: 10px; padding: 3px 6px; }
.inspector-meta button { padding: 3px 6px; font-size: 10px; }
.action-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; }
.action-heading button { padding: 5px 8px; }
.action-card { border: 1px solid #393745; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.action-card.selected { border-color: #75649d; }
.action-summary { display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0; text-align: left; border: 0; border-radius: 0; background: #24242d; }
.action-summary strong { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.action-summary span:first-child { color: var(--lavender); }
.action-fields { padding: 10px; background: #1f1e28; }
.action-tools { display: flex; gap: 5px; flex-wrap: wrap; }
.action-tools button, .remove-screen { padding: 5px 7px; font-size: 10px; }
button.danger { color: #ffb0b6; }
.remove-screen { margin-top: 8px; }
.graph { overflow: auto; background: radial-gradient(circle, #33343d 1px, transparent 1.2px) center / 18px 18px, #14151a; }
.graph > .empty { margin: 20px; }
.graph-board { position: relative; margin: 0 auto; }
.graph-lines { position: absolute; inset: 0; pointer-events: none; }
.graph-node { position: absolute; border: 1px solid #484653; border-radius: 9px; background: #202129; overflow: hidden; box-shadow: 0 5px 14px #08080d55; }
.graph-node.selected { border-color: #9a82cd; }
.graph-node .graph-name { height: 45px; padding: 5px 9px; width: 100%; background: none; border: 0; display: flex; align-items: center; gap: 7px; text-align: left; }
.graph-name span { min-width: 0; }
.graph-name strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.graph-name small { display: block; color: var(--accent); font-size: 9px; margin-top: 2px; }
.graph-name img { width: 18px; height: 34px; object-fit: contain; background: #111216; border-radius: 3px; }
.graph-node ul { margin: 0; padding: 0; list-style: none; }
.graph-node li button, .graph-terminal { width: 100%; height: 28px; padding: 0 8px; display: flex; align-items: center; gap: 6px; text-align: left; font-size: 10px; border: 0; border-radius: 0; border-top: 1px solid #393744; background: #262531; }
.graph-node li button:focus-visible, .graph-node .graph-name:focus-visible { outline-offset: -2px; }
.graph-node li strong { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.graph-action-icon { color: var(--lavender); }
.graph-terminal { color: var(--muted); }
.timeline { height: 204px; background: #191a20; border-top: 1px solid var(--border); }
.transport { height: 47px; padding: 0 16px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.transport-title { font-weight: 700; font-size: 13px; }
.transport-title span { margin-right: 6px; color: var(--lavender); }
.transport-buttons { margin: auto; display: flex; align-items: center; gap: 6px; }
.transport-buttons button { height: 28px; width: 28px; }
.transport-buttons .play { color: var(--accent); font-size: 12px; }
output { font: 12px ui-monospace, Menlo, monospace; color: var(--accent); padding: 0 4px; }
#duration { font: 11px ui-monospace, Menlo, monospace; }
.tracks { display: grid; grid-template-columns: 94px minmax(0, 1fr); padding-right: 16px; height: 140px; }
.track-labels { display: grid; grid-template-rows: 26px 60px 44px; border-right: 1px solid var(--border); }
.track-labels div { padding: 9px 0 0 13px; color: var(--muted); font-size: 11px; }
.track-body { position: relative; min-width: 0; }
.ruler { position: relative; height: 26px; border-bottom: 1px solid #42424e; color: var(--muted); font: 10px ui-monospace, Menlo, monospace; }
.ruler span { position: absolute; top: 5px; transform: translateX(-50%); white-space: nowrap; }
.ruler span:first-child { transform: translateX(4px); }
.ruler span:last-child { transform: translateX(calc(-100% - 4px)); }
.filmstrip { display: flex; height: 60px; overflow: hidden; background: #252833; }
.filmstrip img { min-width: 0; width: 100%; flex: 1 1 0; height: 100%; object-fit: cover; object-position: center 43%; border-right: 1px solid #121318; opacity: .72; }
#scrub { appearance: none; position: absolute; inset: 0 0 auto; height: 86px; width: 100%; margin: 0; background: transparent; cursor: ew-resize; }
#scrub::-webkit-slider-thumb { appearance: none; width: 1px; height: 86px; }
#scrub::-moz-range-thumb { width: 1px; height: 86px; border: 0; background: transparent; }
.markers { height: 44px; position: relative; background: #1f2028; border-top: 1px solid #30313c; }
.marker { position: absolute; top: 7px; width: max-content; max-width: min(19%, 150px); overflow: hidden; text-overflow: ellipsis; padding: 4px 6px; background: #322849; border-color: #51456d; color: #e2d8ff; font-size: 10px; }
.marker.second { top: 24px; }
.marker.late { transform: translateX(-100%); }
.marker.selected { background: #7158ab; border-color: #a58be0; color: white; z-index: 1; }
.playhead { pointer-events: none; position: absolute; top: 0; bottom: 10px; left: 0; width: 1px; background: var(--accent); z-index: 2; }
.playhead::before { content: ''; display: block; width: 9px; height: 8px; transform: translateX(-4px); background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 54%, 50% 100%, 0 54%); }
.notice { position: fixed; bottom: 16px; right: 16px; z-index: 5; max-width: min(500px, calc(100vw - 32px)); background: #2e3430; color: #f3fae8; border: 1px solid #596746; border-radius: 8px; padding: 10px 14px; font-size: 13px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 165px minmax(265px, 1fr) 210px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .canvas-header, .canvas-footer { padding: 0 8px; }
}
@media (max-width: 700px) {
  .topbar { min-height: 100px; height: auto; flex-wrap: wrap; padding: 8px; justify-content: space-between; }
  .project { margin: 0; }
  .project input { width: 135px; }
  .workspace { grid-template-columns: 1fr 1fr; height: auto; }
  .center { grid-column: 1 / -1; grid-row: 1; height: 420px; }
  .screens, .inspector { max-height: 380px; grid-row: 2; border-top: 1px solid var(--border); }
  .source strong { max-width: 90px; }
  .track-labels div { padding-left: 6px; }
  .tracks { grid-template-columns: 65px minmax(0, 1fr); padding-right: 9px; }
  .transport { padding: 0 8px; }
}
.field textarea { width: 100%; resize: vertical; border: 1px solid #383944; background: #17181e; color: inherit; border-radius: 6px; padding: 8px 9px; font: 13px system-ui, sans-serif; }
.field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body .nicegui-content { display: block; padding: 0; color: #eeedf3; }
.editor-shell { width: 100%; }
#upload-progress { width: 100%; height: 3px; accent-color: var(--accent); }
.preview.drop-target { outline: 2px dashed var(--accent); outline-offset: -5px; }
