/* Jene: quiet monochrome tool UI. Three columns: library · stage · inspector. */
:root {
  color-scheme: dark;
  /* neutral greys with a hair of warmth; panels are floating cards on a darker ground */
  --bg: #0c0c0d; --panel: #18181a; --raise: #222225; --field: #222225; --fill: #2d2d31; --line: rgba(255, 255, 255, .065);
  --text: #f1f1f2; --soft: #a6a6ab; --muted: #6f6f75; --ink: #0c0c0d;
  --radius: 8px;
  --accent: #0d99ff; --accent-hover: #0a87e3;   /* Figma's selection blue: canvas selection, hover and the active tool */
  --line2: rgba(255, 255, 255, .1); --stage: #111112; --menu: #1f1f22; --overlay: rgba(24, 24, 26, .92); --primary-hover: #fff;
  --pop-shadow: 0 0 0 .5px rgba(255, 255, 255, .08), 0 18px 48px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .35);
  --card-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .28);
  --ui-font: "Inter", "Inter var", system-ui, -apple-system, "Segoe UI", sans-serif;
}
/* Light theme: <html data-theme="light"> (lib/theme.js follows the system setting unless you pick one) */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9e9ea; --panel: #f7f7f7; --raise: #eeeeef; --field: #ececed; --fill: #e3e3e5; --line: rgba(0, 0, 0, .06); --line2: rgba(0, 0, 0, .1);
  --text: #18181b; --soft: #5d5d65; --muted: #9a9aa2; --ink: #ffffff;
  --stage: #f6f6f7; --menu: #ffffff; --overlay: rgba(255, 255, 255, .94); --primary-hover: #000;
  --pop-shadow: 0 0 0 .5px rgba(0, 0, 0, .08), 0 18px 44px rgba(0, 0, 0, .14), 0 3px 10px rgba(0, 0, 0, .06);
  --card-shadow: 0 0 0 1px rgba(0, 0, 0, .045), 0 1px 2px rgba(0, 0, 0, .03), 0 8px 24px rgba(0, 0, 0, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 12px/1.45 var(--ui-font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11" 1; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 6px; padding: 6px 10px; background: var(--raise); color: var(--soft); transition: background-color .12s, color .12s; }
button:hover { background: var(--fill); color: var(--text); }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--text); color: var(--ink); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: var(--raise); }
button.wide { width: 100%; padding: 8px; }
.icon-btn { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; font-size: 13px; }
input[type=search], input[type=number], select, .project-name { background: var(--field); border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; outline: none; color: var(--text); }
input:focus-visible, select:focus-visible, button:focus-visible, .field:focus-visible { outline: 1px solid var(--soft); outline-offset: 1px; }
input[type=color] { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; }
::placeholder { color: var(--muted); }

/* thin monochrome range (timeline, background angle) */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: none; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--fill); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; border-radius: 50%; background: var(--text); }
input[type=range]::-moz-range-track { height: 2px; background: var(--fill); }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--text); }

/* top bar */
.top { height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; letter-spacing: -.01em; white-space: nowrap; }
.brand .mark { height: 19px; width: auto; display: block; color: var(--text); }
.project-name { width: 200px; background: transparent; color: var(--soft); }
.project-name:hover, .project-name:focus { background: var(--field); color: var(--text); }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.top-actions .primary { padding: 6px 12px; }

/* layout */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr) 288px; grid-template-rows: minmax(0, 1fr); height: 100%; }
[hidden] { display: none !important; }
.library, .inspector { background: var(--panel); overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.library { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.inspector { border-left: 1px solid var(--line); }

/* library: tabs + search, then a category list you drill into */
.library { overflow: hidden; }
.lib-head { padding: 10px 10px 6px; display: grid; gap: 8px; }
.search { position: relative; display: block; }
.search input { width: 100%; padding-right: 40px; }
.search kbd { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font: 10px/1 system-ui; color: var(--muted); background: var(--raise); padding: 3px 5px; border-radius: 4px; pointer-events: none; }
.lib-body { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.cats { display: grid; padding: 4px 6px 12px; }
.cats hr { border: 0; border-top: 1px solid var(--line); margin: 6px 10px; }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: none; color: var(--soft); font-size: 12px; text-align: left; border-radius: 6px; }
.cat-row span { flex: 1; }
.cat-row small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cat-row::after { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-top: 1.5px solid var(--muted); transform: rotate(45deg); margin-right: 2px; }
.cat-row:hover { background: var(--raise); color: var(--text); }
.lib-title { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; padding: 6px 8px; background: var(--panel); font-size: 12px; text-align: center; color: var(--text); }
.lib-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { width: 28px; height: 28px; padding: 0; background: none; display: grid; place-items: center; }
.back::before { content: ""; width: 6px; height: 6px; border-left: 1.5px solid var(--soft); border-bottom: 1.5px solid var(--soft); transform: rotate(45deg); margin-left: 3px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 2px 8px 12px; }
.tile { display: grid; gap: 6px; padding: 6px; background: none; text-align: center; border-radius: 10px; color: var(--soft); }
.tile:hover { background: var(--raise); }
.tile.on { background: var(--raise); color: var(--text); }
.tile canvas { width: 100%; aspect-ratio: 3 / 4; border-radius: 7px; background: #000; display: block; }
.tile span { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .fav { color: var(--text); font-weight: 400; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 20px 6px; }
.lib-foot { padding: 8px 10px 10px; border-top: 1px solid var(--line); }
.dashed { width: 100%; padding: 9px; background: none; border: 1px dashed var(--line2); color: var(--soft); border-radius: 8px; }
.dashed:hover { border-color: var(--soft); background: none; color: var(--text); }
.projects { display: grid; gap: 2px; padding: 4px 6px 12px; }
.pad { padding: 8px 6px; }
.proj-row { position: relative; display: grid; gap: 2px; padding: 9px 10px; background: none; text-align: left; border-radius: 6px; color: var(--soft); }
.proj-row:hover, .proj-row.on { background: var(--raise); color: var(--text); }
.proj-name { font-size: 12px; padding-right: 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-row small { color: var(--muted); font-size: 10px; }
.proj-row .x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 3px 7px; font-size: 11px; background: none; color: var(--muted); }
.proj-row .x:hover, .proj-row .x.armed { background: var(--fill); color: var(--text); }

/* stage */
.stage-wrap { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; background: var(--bg); }
.stage { position: relative; display: grid; place-items: center; padding: 40px 24px 76px; min-height: 0; overflow: hidden; }
.stage.tool-text canvas { cursor: text; }
.stage canvas { display: block; }
.drop-hint { position: absolute; inset: 12px; border: 1px dashed var(--soft); border-radius: 12px; display: none; place-items: center; font-size: 13px; color: var(--text); background: color-mix(in srgb, var(--text) 3%, transparent); pointer-events: none; }
.stage.dragging .drop-hint { display: grid; }
.transport { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.transport .play { background: var(--text); color: var(--ink); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 96px; text-align: right; font-size: 11px; }

/* inspector */
.panel { padding: 2px 0; }
.panel + .panel { border-top: 1px solid var(--line); }
.panel h2 { margin: 0; padding: 12px 12px 8px; font-size: 11px; font-weight: 600; color: var(--text); cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
.panel h2::after { content: ""; margin-left: auto; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.panel[data-open="false"] h2::after { transform: rotate(-45deg); }
.panel[data-open="false"] .body { display: none; }
.panel .body { padding: 0 12px 12px; display: grid; gap: 6px; }
.count { color: var(--soft); text-transform: none; letter-spacing: 0; font-weight: 400; }
.tpl-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.badge { font-size: 11px; color: var(--muted); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > button { flex: 1; }
.row.end { justify-content: flex-end; } .row.end > button { flex: 0; }
.row label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.row label select, .row label input[type=number] { width: 70px; }
.seg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; background: var(--field); padding: 2px; border-radius: 7px; }
.seg.two { grid-template-columns: 1fr 1fr; } .seg.three { grid-template-columns: repeat(3, 1fr); } .seg.four { grid-template-columns: repeat(4, 1fr); }
.seg button { padding: 5px 0; background: none; font-size: 11px; color: var(--muted); border-radius: 5px; }
.seg button:hover { color: var(--text); background: none; }
.seg button.on { background: var(--fill); color: var(--text); }
.opts { display: grid; gap: 5px; margin-bottom: 4px; }
.opts > span { color: var(--soft); font-size: 11px; }
.opts .seg { grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); }
.group-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text); margin: 8px 0 2px; font-weight: 600; }
.group-title:first-child { margin-top: 0; }
.group-title.rule { border-top: 1px solid var(--line); padding-top: 12px; margin: 8px -12px 2px; padding-left: 12px; padding-right: 12px; }
.group-title.rule:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.reset-all { margin-top: 12px; padding: 9px; }

/* value field: drag across to set, arrows to nudge, click the number to type it */
.field { position: relative; height: 28px; border-radius: 6px; background: var(--field); overflow: hidden; cursor: ew-resize; touch-action: none; user-select: none; display: flex; align-items: center; justify-content: space-between; padding: 0 9px; }
.field .fill { position: absolute; inset: 0 auto 0 0; background: var(--fill); pointer-events: none; }
.field .name, .field .val { position: relative; font-size: 11px; }
.field .name { color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.field .val { color: var(--text); font-variant-numeric: tabular-nums; cursor: text; padding-left: 8px; }
.field:hover .name { color: var(--text); }
.field input { position: relative; width: 64px; height: 20px; padding: 0 4px; text-align: right; font-size: 11px; background: var(--bg); border: 1px solid var(--fill); border-radius: 4px; }
.ctl { display: grid; grid-template-columns: 96px 1fr 52px; gap: 8px; align-items: center; }
.ctl > span { color: var(--soft); font-size: 11px; }
.ctl input[type=number] { width: 52px; padding: 3px 4px; font-size: 11px; text-align: right; }
.color { gap: 8px; }

/* media */
.dropzone { display: grid; place-items: center; gap: 1px; padding: 12px; border: 1px dashed var(--line2); border-radius: var(--radius); cursor: pointer; text-align: center; color: var(--soft); }
.dropzone:hover, .dropzone.over { border-color: var(--soft); color: var(--text); }
.dropzone small { color: var(--muted); font-size: 10px; }
.media-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.media-list:empty { display: none; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 5px; overflow: hidden; background: #000; cursor: grab; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-item .n { position: absolute; left: 3px; top: 1px; font-size: 9px; text-shadow: 0 1px 2px #000; }
.media-item .x { position: absolute; right: 2px; top: 2px; width: 16px; height: 16px; padding: 0; font-size: 10px; line-height: 16px; border-radius: 50%; background: rgba(0, 0, 0, .75); color: #fff; display: none; }
.media-item:hover .x { display: block; }
.media-item.dragging { opacity: .35; }

/* curve */
#curve { width: 100%; height: auto; max-height: 260px; background: var(--field); border-radius: var(--radius); touch-action: none; }
#curve .frame { fill: none; stroke: var(--line2); }
#curve .guide { stroke: var(--line2); stroke-dasharray: 2 4; }
#curve .path { fill: none; stroke: var(--text); stroke-width: 2; }
#curve .arm { stroke: var(--muted); stroke-width: 1; }
#curve .handle { fill: var(--text); cursor: grab; }
#curve .handle:active { cursor: grabbing; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.grid4 label { display: grid; gap: 2px; font-size: 10px; color: var(--muted); }
.grid4 input { width: 100%; padding: 4px 5px; font-size: 11px; }

/* export */
.progress { height: 3px; background: var(--field); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--text); transition: width .1s; }

/* stock */
.stock-filters { display: grid; gap: 4px; padding: 0 8px 6px; }
.stock-tier { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
.stock-count { color: var(--muted); font-size: 10px; padding: 2px 2px 0; }
.stock-brands { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; }
.stock-brands::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: baseline; gap: 5px; padding: 5px 9px; border-radius: 999px; background: var(--field); color: var(--muted); font-size: 11px; white-space: nowrap; }
.chip small { font-size: 10px; opacity: .7; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--fill); color: var(--text); }
.stock-sortrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stock-sortrow label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.stock-sortrow .seg { width: 168px; }
.stock-group { column-span: all; margin: 6px 0 8px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stock-more { display: block; width: calc(100% - 16px); margin: 0 8px 14px; }
.stock-tier-badge { position: absolute; left: 6px; top: 6px; font-size: 9px; padding: 2px 5px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: #ddd; }
.cat-note { font-style: normal; font-size: 10px; color: var(--muted); margin-right: 4px; }
.stock-grid { columns: 2; column-gap: 6px; padding: 2px 8px 12px; }
.stock-tile { position: relative; display: block; width: 100%; padding: 0; margin: 0 0 6px; break-inside: avoid; border-radius: 8px; overflow: hidden; background: var(--raise); }
.stock-tile img { display: block; width: 100%; height: auto; transition: opacity .15s, transform .3s; }
.stock-tile:hover img { opacity: .85; }
.stock-tile.loading img { opacity: .4; }
.stock-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.stock-tier-badge.video { z-index: 1; font-variant-numeric: tabular-nums; }
.stock-brand { position: absolute; left: 6px; bottom: 5px; font-size: 9px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); opacity: 0; transition: opacity .15s; }
.stock-tile:hover .stock-brand { opacity: 1; }
.stock-check { position: absolute; right: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--text); color: var(--ink); opacity: 0; transform: scale(.7); transition: opacity .15s, transform .15s; }
.stock-tile.on { outline: 2px solid var(--text); outline-offset: -2px; }
.stock-tile.on .stock-check { opacity: 1; transform: scale(1); }

/* mockup model + light pad */
.model-box { display: grid; gap: 6px; margin: 2px 0 6px; }
.model-box .file-btn { display: block; text-align: center; padding: 9px; }
.model-box small { font-size: 10px; }
.model-name { font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-box select { width: 100%; }
.credit { font-size: 10px; color: var(--muted); }
.credit a { color: var(--soft); }
.pad-wrap { display: grid; gap: 4px; }
.pad { position: relative; height: 150px; border-radius: var(--radius); background: var(--field); cursor: crosshair; touch-action: none; overflow: hidden; }
.pad i { position: absolute; background: var(--line2); }
.pad .h { left: 0; right: 0; top: 50%; height: 1px; } .pad .v { top: 0; bottom: 0; left: 50%; width: 1px; }
.pad-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 8%, transparent); pointer-events: none; }
.pad-vals { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.pad-vals span { background: var(--field); border-radius: 6px; padding: 5px; text-align: center; font-size: 11px; color: var(--soft); font-variant-numeric: tabular-nums; }

/* export overlay */
.export-overlay { position: absolute; inset: 0; display: grid; place-items: end center; padding: 24px; pointer-events: none; }
.export-card { pointer-events: auto; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; width: min(360px, 90%); padding: 12px 14px; border-radius: 10px; background: var(--overlay); border: 1px solid var(--line); backdrop-filter: blur(8px); font-variant-numeric: tabular-nums; }
.export-card .progress { grid-column: 1 / -1; grid-row: 2; }
.export-card button { padding: 4px 10px; }

/* dialog, toast */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(500px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 16px; display: grid; gap: 12px; }
.dlg h2 { margin: 0; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); margin: 0; }
.file-btn { padding: 6px 10px; border-radius: 6px; cursor: pointer; flex: 1; justify-content: center; color: var(--soft) !important; background: var(--raise); }
.proj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.proj-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--raise); border-radius: 7px; }
.proj-list li span { flex: 1; } .proj-list li small { color: var(--muted); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(16px); background: var(--text); color: var(--ink); padding: 8px 12px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-weight: 500; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (width < 1100px) { .app { grid-template-columns: 220px minmax(0, 1fr) 280px; } }
@media (width < 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 62vh auto auto; height: auto; }
  .library, .inspector { border: 0; }
  .library { order: 2; } .stage-wrap { order: 1; } .inspector { order: 3; }
  .tiles { grid-template-columns: repeat(3, 1fr); max-height: 50vh; overflow: auto; }
  .project-name { display: none; }
}

/* colour picker (replaces the system picker) */
.swatch { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 5px; box-shadow: inset 0 0 0 2px var(--panel); }
.swatch:hover { border-color: var(--soft); }
.swatch[aria-expanded=true] { border-color: var(--text); }
.cp { position: fixed; z-index: 50; width: 220px; padding: 10px; display: grid; gap: 10px; background: var(--raise); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); }
.cp-sv { position: relative; height: 140px; border-radius: 6px; cursor: crosshair; touch-action: none; }
.cp-hue { position: relative; height: 12px; border-radius: 6px; cursor: ew-resize; touch-action: none; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-sv i, .cp-hue i { position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); transform: translate(-50%, -50%); pointer-events: none; }
.cp-hue i { top: 50%; }
.cp-row { display: flex; gap: 8px; align-items: center; }
.cp-now { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line); flex: none; }
.cp-hex { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; text-transform: lowercase; }
.cp-presets { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cp-presets button { aspect-ratio: 1; padding: 0; border-radius: 4px; border: 1px solid var(--line); }
.cp-presets button:hover { border-color: var(--text); }

/* inspector tabs: Design / Text */
.insp-tabs { position: sticky; top: 48px; z-index: 3; padding: 0 6px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; }
.tabs button { padding: 12px 8px 11px; background: none; border-radius: 0; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabs button:hover { background: none; color: var(--soft); }
.tabs button.on { color: var(--text); }
.panel[hidden] { display: none; }
.insp-tabs + .panel, .insp-tabs ~ .panel[hidden] + .panel { border-top: 0; }

/* text panel */
.tx-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.tx-presets button { padding: 7px 8px; background: var(--raise); font-size: 11px; text-align: left; border-radius: 6px; color: var(--soft); }
.tx-presets button:hover { color: var(--text); }
.tx-layers { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.tx-layer { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; cursor: pointer; color: var(--soft); font-size: 12px; }
.tx-layer:hover { background: var(--raise); }
.tx-layer.on { background: var(--fill); color: var(--text); }
.tx-layer.off span { opacity: .45; }
.tx-layer span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-layer button { padding: 0; width: 20px; height: 20px; background: none; color: var(--muted); font-size: 11px; border-radius: 4px; flex: none; }
.tx-layer button:hover { color: var(--text); background: var(--raise); }
.tx-layer .tx-mini { opacity: 0; }
.tx-layer:hover .tx-mini, .tx-layer.on .tx-mini, .tx-layer:focus-within .tx-mini { opacity: 1; }
.tx-hint { font-size: 11px; margin: 4px 0 0; }
.tx-text { width: 100%; resize: vertical; min-height: 44px; background: var(--field); border: 1px solid transparent; border-radius: 6px; padding: 8px; color: var(--text); font: inherit; font-size: 13px; line-height: 1.45; outline: none; }
.tx-text:focus { border-color: var(--soft); }
.tx-font { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 10px; background: var(--field); border-radius: 6px; font-size: 16px; text-align: left; }
.tx-font span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-font small { font: 10px system-ui, sans-serif; color: var(--muted); flex: none; }
.tx-row { display: flex; gap: 6px; align-items: center; }
.tx-row > select { flex: 1; min-width: 0; }
.tx-row > .seg { flex: 1; }
.tx-label { color: var(--soft); font-size: 11px; width: 70px; flex: none; }
.tx-toggle { padding: 6px 10px; background: var(--field); color: var(--muted); font-size: 11px; border-radius: 6px; }
.tx-toggle.on { background: var(--fill); color: var(--text); }
.tx-toggle:disabled { opacity: .35; }
.tx-fx { display: flex; align-items: center; justify-content: space-between; color: var(--soft); font-size: 11px; margin-top: 4px; }
.tx-fx .tx-toggle { width: 52px; }
.seg.tx-anims { grid-template-columns: repeat(4, 1fr); }

/* font picker */
.fp { position: fixed; z-index: 60; width: 320px; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; padding: 10px; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--pop-shadow); }
.fp input[type=search] { width: 100%; }
.fp-tabs { grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); }
.fp-list { overflow: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.fp-group { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; padding: 10px 6px 4px; }
.fp-row { display: grid; gap: 2px; width: 100%; padding: 8px; background: none; text-align: left; border-radius: 7px; }
.fp-row:hover { background: var(--fill); }
.fp-row.on { background: var(--fill); outline: 1px solid var(--soft); outline-offset: -1px; }
.fp-sample { font-size: 20px; line-height: 1.3; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-row small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-row small b { font-weight: 500; color: var(--soft); }
.fp-missing .fp-sample { opacity: .35; }
.fp-more { width: 100%; margin: 6px 0; }
.fp-empty { font-size: 11px; padding: 12px 6px; }
.fp-upload { display: block; text-align: center; padding: 8px; border: 1px dashed var(--line2); border-radius: 7px; color: var(--soft); font-size: 11px; cursor: pointer; }
.fp-upload:hover { color: var(--text); border-color: var(--soft); }

/* text selection on the canvas */
.text-ui { position: absolute; pointer-events: none; }
.tx-frame, .tx-hover { position: absolute; border: 1px solid var(--accent); transform-origin: center; }
.tx-frame { pointer-events: auto; cursor: default; }
.tx-hover { pointer-events: none; border-width: 2px; }
.tx-draw { position: absolute; border: 1px solid var(--accent); background: rgba(13, 153, 255, .08); pointer-events: none; }
.text-ui.editing .tx-frame { pointer-events: none; }
.text-ui.editing .tx-frame i { display: none; }
.text-ui.dragging .tx-frame { border-style: dashed; }
.tx-frame i { position: absolute; width: 8px; height: 8px; background: #fff; border: 1px solid var(--accent); border-radius: 1px; }
.tx-scale { right: -5px; bottom: -5px; cursor: nwse-resize; }
.tx-rotate { left: 50%; top: -24px; margin-left: -4px; border-radius: 50% !important; cursor: grab; }
.tx-rotate::after { content: ""; position: absolute; left: 3px; top: 8px; width: 1px; height: 15px; background: var(--accent); }
.guide { position: absolute; background: #ff3b7f; pointer-events: none; }
.guide.v { left: 50%; top: 0; bottom: 0; width: 1px; }
.guide.h { top: 50%; left: 0; right: 0; height: 1px; }
#textBody { grid-template-columns: minmax(0, 1fr); }
#textBody .tx-row > *, #textBody .seg, #textBody .seg button { min-width: 0; }
#textBody .seg button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 2px; padding-right: 2px; }

/* ───── Figma-style workspace ───── */
/* frame name above the canvas */
.frame-label { position: absolute; display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--soft); pointer-events: none; white-space: nowrap; }
.frame-label span { overflow: hidden; text-overflow: ellipsis; }
.frame-label small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* floating toolbar at the bottom of the canvas */
.toolbar { position: absolute; left: calc(50% - var(--side, 0px) / 2); bottom: 16px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--raise); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.toolbar button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; background: none; color: var(--soft); border-radius: 8px; }
.toolbar button svg { width: 17px; height: 17px; }
.toolbar button:hover { background: var(--fill); color: var(--text); }
.toolbar button.on { background: var(--accent); color: #fff; }
.toolbar .tool-more { width: 16px; margin-left: -2px; border-radius: 6px; }
.toolbar .tool-more svg { width: 8px; height: 8px; }
.tool-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line2); }
.style-menu { position: fixed; z-index: 60; width: 240px; display: grid; padding: 6px; background: var(--raise); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--pop-shadow); }
.style-menu button { display: grid; gap: 1px; padding: 7px 9px; background: none; text-align: left; border-radius: 6px; color: var(--text); }
.style-menu button:hover { background: var(--accent); color: #fff; }
.style-menu small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.style-menu button:hover small { color: rgba(255, 255, 255, .8); }
/* typing on the canvas: see-through text, real caret and selection */
.tx-edit { position: absolute; margin: 0; padding: 0; border: 0; outline: 0; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--accent); white-space: pre-wrap; overflow-wrap: normal; word-break: normal; pointer-events: auto; }
.tx-edit::selection { background: rgba(13, 153, 255, .35); color: transparent; }
/* compact two-column property rows */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.pair > select { min-width: 0; height: 28px; }
.hexf { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 3px 0 4px; background: var(--field); border-radius: 6px; min-width: 0; }
.hexf .swatch { width: 20px; height: 20px; flex: none; border-radius: 4px; box-shadow: none; }
.hexf .hex { flex: 1; min-width: 0; padding: 0; background: none; border: 0; outline: 0; font-size: 11px; color: var(--text); text-transform: uppercase; font-variant-numeric: tabular-nums; }
.tx-aligns { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 2px; background: var(--field); border-radius: 7px; }
.tx-aligns button { height: 24px; padding: 0; display: grid; place-items: center; background: none; color: var(--soft); border-radius: 5px; }
.tx-aligns button:hover { background: var(--fill); color: var(--text); }
.tx-aligns svg { width: 14px; height: 14px; }
.tx-add { width: 22px; height: 22px; padding: 0; font-size: 15px; line-height: 1; background: none; color: var(--soft); border-radius: 5px; }
.tx-add:hover { background: var(--fill); color: var(--text); }
.tx-glyph { flex: none; width: 14px; font: 600 11px/1 system-ui, sans-serif; color: var(--muted); text-align: center; font-style: normal; }
.tx-layer.on .tx-glyph { color: var(--text); }
.tx-ital { flex: none; width: 30px; padding: 6px 0; font-style: italic; font-family: Georgia, serif; }

/* live projects (lib/collab.js): faces + Share in the top bar, cursors and comment pins over the canvas */
.lb-live { display: flex; align-items: center; gap: 8px; margin-right: 4px; }
.lb-faces { display: flex; flex-direction: row-reverse; }
.lb-faces:empty { display: none; }
.lb-avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; border: 2px solid var(--panel); margin-left: -6px; user-select: none; }
.lb-avatar.more { background: var(--fill) !important; color: var(--soft); }
.lb-share { padding: 6px 12px; }
.lb-share.on { background: var(--accent); color: #fff; }
.stage.tool-comment canvas { cursor: crosshair; }
.lb-layer { position: absolute; z-index: 4; pointer-events: none; }
.lb-cursor { position: absolute; display: flex; align-items: flex-start; pointer-events: none; transition: left .08s linear, top .08s linear; }
.lb-cursor svg { width: 16px; height: 16px; fill: currentColor; margin: -1px 0 0 -1px; }
.lb-cursor span { margin: 14px 0 0 -4px; padding: 2px 6px; border-radius: 4px; color: #fff; font-size: 11px; font-weight: 500; white-space: nowrap; }
.lb-pins { position: absolute; inset: 0; }
.lb-pin { position: absolute; width: 30px; height: 30px; padding: 2px; transform: translate(0, -100%); border-radius: 50% 50% 50% 0; background: var(--raise); border: 1px solid var(--line2); box-shadow: 0 4px 12px rgba(0, 0, 0, .4); pointer-events: auto; }
.lb-pin:hover, .lb-pin.on { background: var(--accent); border-color: var(--accent); }
.lb-pin-face { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; }
.lb-pin i { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--text); color: var(--ink); font: 600 10px/16px system-ui, sans-serif; font-style: normal; }
.lb-pin.draft { pointer-events: none; }
.lb-pop { position: absolute; z-index: 30; width: 280px; background: var(--raise); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); pointer-events: auto; }
.lb-thread { margin-left: 38px; transform: translateY(-100%); }
.lb-name { position: fixed; display: grid; gap: 8px; padding: 14px; }
.lb-name small { color: var(--soft); }
.lb-name input { background: var(--field); border: 1px solid transparent; border-radius: 6px; padding: 7px 8px; outline: none; color: var(--text); }
.lb-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line2); }
.lb-head b { margin-right: auto; }
.lb-head button { padding: 4px 8px; background: none; }
.lb-comments { max-height: 260px; overflow: auto; }
.lb-comments:empty { display: none; }
.lb-comment { padding: 10px 12px 0; }
.lb-comment p { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.lb-meta { display: flex; align-items: center; gap: 8px; }
.lb-meta .lb-avatar { width: 20px; height: 20px; margin: 0; border: 0; font-size: 9px; }
.lb-meta small { color: var(--muted); }
.lb-del { margin-left: auto; padding: 2px 6px; background: none; color: var(--muted); font-size: 11px; }
.lb-compose { display: flex; gap: 6px; align-items: flex-end; padding: 10px; }
.lb-compose textarea { flex: 1; resize: none; min-height: 30px; max-height: 120px; background: var(--field); border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; outline: none; color: var(--text); font: inherit; }
.lb-compose button { padding: 6px 10px; }

/* ───── Layers, shapes and effects ───── */
.stage.tool-draw canvas { cursor: crosshair; }
/* selection handles: four corners and the rotate knob */
.tx-frame .hd { position: absolute; width: 8px; height: 8px; background: #fff; border: 1px solid var(--accent); border-radius: 1px; }
.hd.nw { left: -5px; top: -5px; cursor: nwse-resize; } .hd.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.hd.ne { right: -5px; top: -5px; cursor: nesw-resize; } .hd.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.tx-frame.line .hd.nw, .tx-frame.line .hd.ne { display: none; }
.tx-frame.line .hd.sw { top: 50%; bottom: auto; margin-top: -5px; cursor: ew-resize; } .tx-frame.line .hd.se { top: 50%; bottom: auto; margin-top: -5px; cursor: ew-resize; }
/* left panel: Layers | Assets */
.side-tabs { padding: 0 6px; border-bottom: 1px solid var(--line); flex: none; }
.layers-panel { flex: 1; min-height: 0; overflow: auto; padding: 4px 6px 12px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.ly-head { margin: 6px 6px 4px; }
.ly-list { display: grid; gap: 1px; }
.ly-row { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border-radius: 6px; color: var(--soft); cursor: default; font-size: 12px; position: relative; }
.ly-row:hover { background: var(--raise); }
.ly-row.on { background: rgba(13, 153, 255, .18); color: var(--text); }
.ly-row.hidden-layer .ly-name, .ly-row.hidden-layer .ly-ico { opacity: .4; }
.ly-row.dragging { opacity: .4; }
.ly-row[data-drop=above]::before, .ly-row[data-drop=below]::after { content: ""; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--accent); }
.ly-row[data-drop=above]::before { top: -1px; } .ly-row[data-drop=below]::after { bottom: -1px; }
.ly-ico { flex: none; width: 16px; height: 16px; color: var(--muted); display: grid; place-items: center; }
.ly-row.on .ly-ico { color: var(--accent); }
.ly-ico svg { width: 14px; height: 14px; }
.ly-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ly-rename { flex: 1; min-width: 0; height: 22px; padding: 0 4px; font-size: 12px; background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; outline: 0; }
.ly-btn { width: 22px; height: 22px; padding: 0; display: grid; place-items: center; background: none; color: var(--muted); opacity: 0; border-radius: 4px; }
.ly-btn svg { width: 14px; height: 14px; }
.ly-row:hover .ly-btn, .ly-btn.on { opacity: 1; }
.ly-btn:hover { background: var(--fill); color: var(--text); }
.ly-card { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; padding-top: 1px; }
.ly-card small { color: var(--muted); font-size: 10px; }
.ly-hint { padding: 8px 6px; font-size: 11px; }
/* add grid in the Layer tab */
.add-grid { grid-template-columns: repeat(3, 1fr) !important; }
.add-grid button { display: grid; justify-items: center; gap: 4px; padding: 10px 4px 8px; text-align: center; }
.add-grid svg { width: 18px; height: 18px; }
.add-grid span { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* menus with icons */
.style-menu button > span { display: flex; align-items: center; gap: 8px; }
.style-menu button > span b { font-weight: 500; }
.style-menu svg { width: 15px; height: 15px; flex: none; }
/* effect rows */
.fx-row { display: flex; align-items: center; gap: 6px; height: 28px; font-size: 11px; color: var(--text); }
.fx-row span { flex: 1; }
.fx-eye, .fx-del { width: 22px; height: 22px; padding: 0; background: none; color: var(--muted); font-size: 11px; border-radius: 4px; }
.fx-eye.on { color: var(--text); }
.fx-del { font-size: 15px; line-height: 1; }
.fx-eye:hover, .fx-del:hover { background: var(--fill); color: var(--text); }
.group-title .tx-toggle { padding: 3px 9px; font-weight: 400; }
/* shader backgrounds */
.shader-box { display: grid; gap: 6px; }
.shader-kinds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.shader-kinds button { display: grid; gap: 3px; padding: 3px; background: none; border-radius: 7px; color: var(--muted); }
.shader-kinds button canvas { width: 100%; aspect-ratio: 3 / 2; border-radius: 5px; display: block; }
.shader-kinds button span { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shader-kinds button.on { background: var(--fill); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.shader-pal { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.shader-pal button { display: grid; grid-template-columns: repeat(4, 1fr); height: 18px; padding: 0; overflow: hidden; border-radius: 4px; background: none; }
.shader-pal button:hover { outline: 1px solid var(--soft); }
.shader-pal i { display: block; }
/* effect presets */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
#postBody .group-title { margin-top: 8px; font-size: 10px; color: var(--muted); }
/* photo mockups: the design's frame and the surface corners over the canvas */
.pm-ui { position: absolute; pointer-events: none; z-index: 4; }
.pm-ui svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pm-ui .pm-surface { fill: none; stroke: rgba(13, 153, 255, .35); stroke-width: 1; stroke-dasharray: 4 4; }
.pm-ui.editing .pm-surface { fill: rgba(13, 153, 255, .08); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: none; }
.pm-ui .pm-design { fill: none; stroke: var(--accent); stroke-width: 1; }
.pm-ui .pm-stem { stroke: var(--accent); stroke-width: 1; }
.pm-ui i { position: absolute; pointer-events: auto; touch-action: none; }
.pm-corner { width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); cursor: grab; }
.pm-size { width: 8px; height: 8px; margin: -4px 0 0 -4px; background: #fff; border: 1px solid var(--accent); border-radius: 1px; cursor: nwse-resize; }
.pm-rot { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; background: #fff; border: 1px solid var(--accent); border-radius: 50%; cursor: grab; }
.stage:not(.tool-text):not(.tool-draw) canvas { cursor: default; }
.tx-hint a { color: var(--soft); }
/* effect groups in the Effects panel */
.fx-group { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 2px; margin-top: 2px; background: none; border-top: 1px solid var(--line); border-radius: 0; color: var(--text); font-size: 11px; font-weight: 600; }
.fx-group::after { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); margin: 0 4px 0 6px; transition: transform .15s; }
.fx-group.open::after { transform: rotate(45deg); }
.fx-group small { margin-left: auto; color: var(--accent); font-weight: 500; font-size: 10px; }
.fx-group:hover { background: none; }
.fx-group-body { display: grid; gap: 6px; }
.fx-group-body:empty { display: none; }
.seg.five { grid-template-columns: repeat(5, 1fr); }

/* ───── Figma-style shell: no top bar; both side panels carry a 48px head ───── */
.panel-head { flex: none; height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.inspector .panel-head { position: sticky; top: 0; z-index: 4; }
.menu-btn { flex: none; display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 7px; background: none; color: var(--text); border-radius: 7px; }
.menu-btn .mark { height: 15px; width: auto; display: block; }
.menu-btn .chev { width: 8px; height: 8px; color: var(--muted); }
.menu-btn:hover, .menu-btn[aria-expanded=true] { background: var(--raise); }
.file-meta { display: grid; min-width: 0; flex: 1; }
.file-meta .project-name { width: 100%; height: 20px; padding: 0 4px; font-size: 12px; font-weight: 600; color: var(--text); background: none; border-radius: 4px; }
.file-meta .project-name:hover, .file-meta .project-name:focus { background: var(--field); }
.file-meta small { padding: 0 4px; color: var(--muted); font-size: 10px; line-height: 14px; }
.top-actions { display: flex; align-items: center; gap: 4px; width: 100%; margin: 0; }
.top-actions .spacer { flex: 1; order: 1; }
.top-actions #undo, .top-actions #redo { order: 0; background: none; }
.top-actions #undo:hover:not(:disabled), .top-actions #redo:hover:not(:disabled) { background: var(--raise); }
.top-actions .icon-btn svg { width: 15px; height: 15px; }
.top-actions .lb-live { order: 2; }
.top-actions #quickExport { order: 3; padding: 6px 14px; border-radius: 7px; }
.library .side-tabs { border-bottom: 1px solid var(--line); }
.stage { background: var(--stage); }
.transport { border-top: 0; background: var(--bg); padding: 6px 14px 10px; }
/* main menu: categories with submenus, Figma style */
.main-menu { position: fixed; z-index: 70; min-width: 200px; padding: 6px; background: var(--menu); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--pop-shadow); display: grid; }
.main-menu button { display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: none; color: var(--text); border-radius: 6px; font-size: 12px; text-align: left; }
.main-menu button small { margin-left: auto; color: var(--muted); font-size: 11px; }
.main-menu button.sub::after { content: ""; margin-left: auto; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-top: 1.5px solid var(--muted); transform: rotate(45deg); }
.main-menu button:hover, .main-menu button.on { background: var(--accent); color: #fff; }
.main-menu button:hover small, .main-menu button.on small { color: rgba(255, 255, 255, .8); }
.main-menu button:hover::after, .main-menu button.on::after { border-color: #fff; }
.main-menu hr { border: 0; border-top: 1px solid var(--line2); margin: 5px 4px; }
.shortcuts { width: min(560px, 92vw); }
.shortcuts dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; max-height: 60vh; overflow: auto; }
.shortcuts dt { color: var(--soft); } .shortcuts dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
.shortcuts h3 { grid-column: 1 / -1; margin: 10px 0 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
/* ⌘\ hides both panels, as in Figma */
body.ui-hidden .app { grid-template-columns: 0 minmax(0, 1fr) 0; }
body.ui-hidden .library, body.ui-hidden .inspector { display: none; }

/* the AI assistant: a chat panel floating over the right of the canvas (⌘J, ✦ in the toolbar) */
.ai { position: absolute; top: 12px; right: 12px; bottom: 70px; z-index: 6; width: 330px; max-width: calc(100% - 24px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--pop-shadow); overflow: hidden; }
.ai[hidden] { display: none; }
.ai header { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.ai header b { font-size: 12px; font-weight: 600; }
.ai-mark svg, #toolAi svg { width: 15px; height: 15px; display: block; }
.ai-mark { color: var(--accent); }
.ai-icon { width: 26px; height: 26px; padding: 0; display: grid; place-items: center; background: none; color: var(--soft); border-radius: 6px; }
.ai-icon:hover { background: var(--fill); color: var(--text); }
.ai-icon svg { width: 14px; height: 14px; }
.ai-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; line-height: 1.5; }
.ai-hello p { margin: 0 0 12px; color: var(--soft); }
.ai-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ai-chips button { padding: 6px 10px; background: var(--raise); border: 1px solid var(--line2); border-radius: 8px; color: var(--text); text-align: start; font-size: 12px; }
.ai-chips button:hover { border-color: var(--accent); }
.ai-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.me { align-self: flex-end; max-width: 85%; padding: 7px 10px; background: var(--fill); border-radius: 10px 10px 2px 10px; }
.ai-msg.bot { color: var(--text); }
.ai-msg.error { color: #ff8a80; }
.ai-act { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ai-act::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.ai-act.failed::before { background: #ff8a80; }
.ai-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.ai-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--soft); animation: ai-dot 1s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.ai-input { display: flex; align-items: flex-end; gap: 6px; margin: 8px; padding: 6px 6px 6px 10px; background: var(--field); border: 1px solid var(--line2); border-radius: 10px; }
.ai-input:focus-within { border-color: var(--accent); }
.ai-input textarea { flex: 1; min-height: 20px; max-height: 140px; padding: 3px 0; background: none; border: 0; outline: 0; resize: none; color: var(--text); font: inherit; font-size: 12.5px; line-height: 1.45; }
.ai-send { width: 28px; height: 28px; padding: 0; flex: none; display: grid; place-items: center; background: var(--accent); color: #fff; border-radius: 7px; }
.ai-send svg { width: 15px; height: 15px; }
.ai-send:disabled { background: var(--fill); color: var(--muted); }
.ai.busy .ai-send svg { display: none; }
.ai.busy .ai-send::after { content: ''; width: 9px; height: 9px; border-radius: 2px; background: #fff; }
.ai-msg p { margin: 0; } .ai-msg p + p { margin-top: 8px; }

/* ───── Bento (left panel → Bento) and Brand kit (left panel → Brand) ───── */
body.bento-mode #toolbar, body.bento-mode #textUi, body.bento-mode .pm-ui { display: none !important; }
.side-panel { flex: 1; min-height: 0; overflow: auto; padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.side-panel > * { flex: none; }
.side-panel .group-title { margin: 6px 0 0; }
.side-panel .group-title small { color: var(--muted); font-weight: 400; }
.side-panel .tx-hint { margin: 0; }
.checker { background-color: #7c7c7c; background-image: linear-gradient(45deg, #8a8a8a 25%, transparent 25%, transparent 75%, #8a8a8a 75%), linear-gradient(45deg, #8a8a8a 25%, transparent 25%, transparent 75%, #8a8a8a 75%); background-size: 12px 12px; background-position: 0 0, 6px 6px; }
.bt-genrow { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 6px; }
.bt-genrow .seg button { font-size: 13px; padding: 4px 0; }
.bt-info { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.bt-info span { flex: 1; }
.bt-info button { padding: 4px 8px; font-size: 11px; }
.bt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.bt-tile { position: relative; display: grid; gap: 0; padding: 0; overflow: hidden; background: var(--raise); border-radius: 6px; text-align: left; outline: 2px solid transparent; outline-offset: -2px; }
.bt-tile:hover { background: var(--fill); }
.bt-tile.on { outline-color: var(--accent); }
.bt-thumb { display: block; aspect-ratio: 4 / 3; background-color: var(--stage); overflow: hidden; position: relative; }
.bt-thumb img, .bt-thumb video, .bt-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.bt-thumb.checker img { object-fit: contain; padding: 12%; }
.bt-play { position: absolute; left: 4px; bottom: 3px; font-size: 8px; font-style: normal; color: #fff; text-shadow: 0 0 3px #000; }
.bt-name { display: block; padding: 4px 6px 5px; font-size: 10px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-n { position: absolute; top: 4px; left: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; display: grid; place-items: center; }
.bt-x { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; font-style: normal; line-height: 15px; text-align: center; opacity: 0; }
.bt-tile:hover .bt-x { opacity: 1; }
.bt-add { border: 1px dashed var(--line2); background: none; place-items: center; align-content: center; min-height: 72px; cursor: pointer; color: var(--muted); gap: 2px; }
.bt-add span { font-size: 18px; line-height: 1; }
.bt-add small { font-size: 10px; }
.bt-saverow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.bt-namein, .br-name { min-width: 0; background: var(--field); border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; outline: none; color: var(--text); }
.bt-namein:focus, .br-name:focus { border-color: var(--soft); }
.bt-cellbtns button { flex: 1; }
.bt-cellbtns button.armed { background: var(--accent); color: #fff; }
.seg.bt-aspects button { font-size: 10px; }
.seg.bt-scales { flex: 1; grid-template-columns: repeat(8, 1fr); }
.seg.bt-scales button { font-size: 10px; padding-left: 0; padding-right: 0; }
.tx-lbl { flex: none; width: 44px; font-size: 11px; color: var(--muted); }
.tx-ramp > .seg { flex: 1; }
.cp-brand { display: flex; gap: 4px; align-items: center; }
.cp-brand select { width: 64px; flex: none; padding: 2px 4px; font-size: 10px; height: 22px; }
.cp-brand button { flex: 1; min-width: 0; max-width: 22px; aspect-ratio: 1; padding: 0; border-radius: 4px; border: 1px solid var(--line); }
.cp-brand button:hover { border-color: var(--text); }
.fp-row { position: relative; }
.fp-pin { position: absolute; right: 8px; top: 8px; font-size: 13px; color: var(--muted); opacity: 0; cursor: pointer; }
.fp-row:hover .fp-pin, .fp-pin.on { opacity: 1; }
.fp-pin.on { color: #f5c542; }
.br-setrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.br-setrow button { padding: 6px 8px; font-size: 11px; }
.br-swatches { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.br-sw { position: relative; width: 100%; aspect-ratio: 1; height: auto; border-radius: 7px; border: 1px solid var(--line); display: block; padding: 0; }
.br-sw.edit .swatch { width: 100%; height: 100%; border-radius: 6px; border: 0; }
.br-plus { background: none; border: 1px dashed var(--line2); color: var(--muted); font-size: 16px; }
.br-x { position: absolute; top: -5px; right: -5px; width: 14px; height: 14px; border-radius: 7px; background: var(--fill); color: var(--text); font-size: 10px; font-style: normal; line-height: 13px; text-align: center; cursor: pointer; opacity: 0; }
.br-sw:hover .br-x { opacity: 1; }
.br-logos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.br-logo { display: grid; grid-template-rows: 1fr auto; padding: 0; border-radius: 6px; overflow: hidden; aspect-ratio: 1; outline: 2px solid transparent; outline-offset: -2px; }
.br-logo.on { outline-color: var(--accent); }
.br-logo img { width: 100%; height: 100%; min-height: 0; object-fit: contain; padding: 14%; }
.br-logo span { padding: 3px 5px; font-size: 10px; background: rgba(0, 0, 0, .55); color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.br-logo.br-add { border: 1px dashed var(--line2); background: none; place-items: center; align-content: center; cursor: pointer; color: var(--muted); }
.br-logo.br-add b { font-size: 18px; font-weight: 400; }
.br-logo.br-add span { background: none; }
.br-ramp { display: grid; gap: 4px; padding: 10px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.br-ramp div { line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.br-ramp small { margin-left: 8px; font: 10px system-ui, sans-serif; color: var(--muted); }
.br-fonts { display: grid; gap: 2px; }
.br-frow { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; background: var(--raise); }
.br-fsample { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.br-frow small { color: var(--muted); font-size: 10px; }
.br-unpin { padding: 0 6px; background: none; color: var(--muted); }
.br-brand { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.br-brand b { width: 100%; font-size: 11px; font-weight: 500; color: var(--soft); margin-top: 4px; }
.br-pin { padding: 3px 8px; font-size: 11px; background: var(--raise); }
.br-pin.on { color: #f5c542; }

/* ───── Premium shell (v28): floating cards on a quiet ground, one type family, softer depth ───── */
.app { padding: 8px; gap: 8px; background: var(--bg); }
.library, .inspector { border: 0 !important; border-radius: 12px; box-shadow: var(--card-shadow); }
.stage-wrap { border-radius: 12px; overflow: hidden; background: var(--stage); box-shadow: var(--card-shadow); }
.stage { background: var(--stage); }
.transport { background: var(--stage); border-top: 1px solid var(--line); padding: 8px 14px; }
.panel-head { background: var(--panel); border-bottom-color: var(--line); }
.inspector .panel-head { border-radius: 12px 12px 0 0; }
.insp-tabs { top: 48px; }
.toolbar { background: var(--panel); border: 0; border-radius: 12px; box-shadow: var(--pop-shadow); padding: 4px; }
.toolbar .ws-switch { margin-left: 2px; }
.toolbar .ws-switch button { width: auto; padding: 0 11px; height: 28px; color: var(--soft); }
.toolbar .ws-switch button:hover { background: none; color: var(--text); }
.toolbar .ws-switch button.on { background: var(--panel); color: var(--text); }
button.primary { border-radius: 7px; }
.top-actions #quickExport { background: var(--accent); color: #fff; }
.top-actions #quickExport:hover { background: var(--accent-hover); }
.panel h2 { font-size: 11px; letter-spacing: 0; }
.tile canvas { border-radius: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.main-menu, .style-menu, .fp, .cp, .lb-pop { border: 0 !important; box-shadow: var(--pop-shadow) !important; border-radius: 12px; }
.main-menu button:hover, .main-menu button.on, .style-menu button:hover { background: var(--accent); }
.toast { font-weight: 500; border-radius: 9px; box-shadow: var(--pop-shadow); }
input[type=search], input[type=number], select, .project-name { border-radius: 6px; }
input:focus-visible, select:focus-visible, button:focus-visible, .field:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 1px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
body.ui-hidden .app { gap: 0; }

/* tooltips (lib/tooltip.js) */
.tip { position: fixed; left: 0; top: 0; z-index: 200; display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 5px 8px; border-radius: 7px; background: #111113; color: #f2f2f2; font: 500 11px/1.35 var(--ui-font); box-shadow: 0 6px 20px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(255, 255, 255, .08); pointer-events: none; opacity: 0; transition: opacity .08s; }
.tip.on { opacity: 1; }
.tip kbd { font: 500 10.5px/1 var(--ui-font); color: #a8a8ae; letter-spacing: .02em; }
:root[data-theme="light"] .tip { background: #1d1d20; }

/* ── the Animate view: this stage, opened on one animation from the canvas ── */
body:not(.anim-focus) .when-focus, .focus-back, .focus-tabs { display: none !important; }
body.anim-focus .no-focus, body.anim-focus .menu-btn { display: none !important; }
body.anim-focus .focus-back { display: grid !important; color: var(--soft); border-radius: 7px; }
body.anim-focus .focus-back:hover { background: var(--raise); color: var(--text); }
body.anim-focus .focus-back svg { width: 16px; height: 16px; }
body.anim-focus .focus-tabs { display: flex !important; gap: 2px; padding: 0 8px 6px; border-bottom: 1px solid var(--line); }
.focus-tabs button { height: 26px; background: none; padding: 0 9px; color: var(--muted); font-weight: 600; border-radius: 6px; }
.focus-tabs button.on { color: var(--text); background: var(--raise); }
.focus-tabs button:hover { color: var(--text); }
body.anim-focus #quickExport { background: var(--raise) !important; color: var(--text) !important; order: 8; }
body.anim-focus #quickExport:hover { background: var(--fill); }
#focusDone { background: var(--text); color: var(--panel); padding: 6px 14px; order: 9; }
#focusDone:hover { background: var(--primary-hover); }
body.anim-focus .lb-share, body.anim-focus .lb-faces { display: none !important; }
.export-overlay { position: fixed; z-index: 100; }

/* card styles (Scene tab) */
.cs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.cs-row + .cs-row, .ctl + .cs-row { border-top: 1px solid var(--line); }
.cs-name { display: grid; }
.cs-name strong { font-weight: 600; color: var(--text); }
.cs-name small { color: var(--muted); }
.cs-switch { position: relative; width: 30px; height: 18px; padding: 0; border-radius: 9px; background: var(--fill); flex: none; }
.cs-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--soft); transition: transform .15s, background-color .15s; }
.cs-switch.on { background: var(--text); }
.cs-switch.on::after { transform: translateX(12px); background: var(--panel); }
.cs-switch:hover { background: var(--line2); }
.cs-switch.on:hover { background: var(--text); }
.ai-signin { display: grid; gap: 8px; }
.ai-signin p { margin: 0; color: var(--soft); }
.ai-email { height: 32px; padding: 0 10px; background: var(--field); border: 1px solid var(--line2); border-radius: 8px; color: var(--text); font: inherit; }
.ai-go { height: 32px; border-radius: 8px; background: var(--text); color: var(--panel, #111); font-weight: 600; }
.ai-go:disabled { opacity: .5; }
.ai-note { font-size: 11.5px; }
.ai-code { letter-spacing: .3em; font-variant-numeric: tabular-nums; text-align: center; font-size: 16px; }
.ai-link { background: none; color: var(--soft); font-size: 11.5px; text-decoration: underline; padding: 0; justify-self: start; }
