/* Content engine editor. Tokens and recipes from the UCA UI Design SOP (starter/tokens.css, starter/recipes.css).
   Brief: people and agents editing a static design · one action: change the design on the canvas · selling: every
   change is live and shared with Claude. Visual idea: Differentiate → contrast: the chrome is quiet and monochrome so
   the design on the canvas is the only colourful thing. Palette: Chalk White #F3F2EE + Ink Black #0B0B0C (quiet),
   Studio Cobalt #1655D8 (accent: selection, focus, the one primary button). */
@font-face { font-family: "Inter"; src: url("/ui/fonts/Inter.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light dark;
  --base-1: oklch(95.8% 0.006 95);      /* Chalk White #F3F2EE */
  --base-2: oklch(14.5% 0.003 285);     /* Ink Black #0B0B0C */
  --accent: oklch(51.5% 0.21 264);      /* Studio Cobalt #1655D8 */
  --accent-ink: oklch(98% 0.01 264);
  --accent-soft: oklch(51.5% 0.21 264 / 0.12);

  --bg: oklch(92.5% 0.006 95);          /* the workspace around the canvas */
  --surface: oklch(97.5% 0.004 95);     /* panels */
  --surface-raised: oklch(99.4% 0.002 95);
  --text: var(--base-2);
  --text-muted: oklch(42% 0.008 285);   /* stays AA on every surface */
  --border: rgb(0 0 0 / 0.1);
  --danger: oklch(52% 0.19 27);
  --ok: oklch(52% 0.13 155);

  --font-ui: "Inter", system-ui, sans-serif;
  --step--1: 12px; --step-0: 13.5px; --step-1: 15px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --radius-outer: 14px; --pad-card: 6px; --radius-inner: calc(var(--radius-outer) - var(--pad-card)); --radius-control: 8px; --radius-pill: 999px;
  --shadow-tint: 285 10% 10%;
  --shadow-1: 0 1px 2px hsl(var(--shadow-tint) / 0.06), 0 2px 6px hsl(var(--shadow-tint) / 0.06);
  --shadow-2: 0 1px 2px hsl(var(--shadow-tint) / 0.05), 0 4px 12px hsl(var(--shadow-tint) / 0.08), 0 16px 32px hsl(var(--shadow-tint) / 0.1);

  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 150ms; --dur-menu: 200ms; --dur-menu-exit: 160ms; --dur-panel: 300ms; --stagger: 30ms; --scale-start: 0.96;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(14% 0.004 285); --surface: oklch(19% 0.005 285); --surface-raised: oklch(25% 0.006 285);
    --text: oklch(95% 0.006 95); --text-muted: oklch(76% 0.006 95); --border: rgb(255 255 255 / 0.1);
    --accent: oklch(62% 0.19 264); --accent-soft: oklch(62% 0.19 264 / 0.18);
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-press: 0ms; --dur-menu: 0ms; --dur-menu-exit: 0ms; --dur-panel: 0ms; --stagger: 0ms; --scale-start: 1; }
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 var(--step-0)/1.45 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.meta-label { display: block; font-size: var(--step--1); color: var(--text-muted); font-weight: 500; margin: var(--space-4) 0 var(--space-2); }

/* Icons: Lucide, drawn in the text colour (one family everywhere). */
.ico { display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 272px 1fr 300px; grid-template-rows: 56px 1fr; height: 100dvh; }
.topbar { grid-column: 1 / -1; position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0 var(--space-4); background: var(--surface-raised); border-bottom: 1px solid var(--border); z-index: 5; }
.left, .right { background: var(--surface); overflow: auto; }
.left { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.right { border-left: 1px solid var(--border); }
.viewport { position: relative; overflow: auto; display: grid; place-items: center; padding: 48px; }

/* ---------- Top bar ---------- */
.tb-left, .tb-mid, .tb-right { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
a.mark { text-decoration: none; }
.mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--text); color: var(--surface-raised); font-weight: 700; font-size: 12px; letter-spacing: 0.02em; }
.doc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26ch; }
.dims { color: var(--text-muted); font-size: var(--step--1); }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--space-1); }
.zoom { min-width: 56px; height: 36px; border: 0; background: transparent; border-radius: var(--radius-control); cursor: pointer; }
.zoom:hover, .icon-btn:hover:not(:disabled), .mini:hover { background: var(--accent-soft); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: var(--step--1); color: var(--text-muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.live.on .dot { background: var(--ok); box-shadow: 0 0 0 3px oklch(52% 0.13 155 / 0.18); }
.activity { font-size: var(--step--1); color: var(--text-muted); max-width: 30ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons: one primary per view (Export) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45em; min-height: 36px; padding: 0 14px; border-radius: var(--radius-pill);
  font-weight: 600; border: 1px solid var(--border); background: transparent; cursor: pointer; text-decoration: none;
  transition: scale var(--dur-press) ease-out, background-color var(--dur-menu) var(--ease-out); }
.btn:hover { background: var(--accent-soft); }
.btn:active, .icon-btn:active, .tile:active { scale: 0.97; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: color-mix(in oklch, var(--accent), black 10%); }
.btn.block { width: 100%; margin-top: var(--space-4); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-control); background: transparent; cursor: pointer; transition: scale var(--dur-press) ease-out; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
:where(button, a, input, select, textarea, [role="switch"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Left panel ---------- */
.tabs { display: flex; gap: var(--space-1); padding: var(--space-2); border-bottom: 1px solid var(--border); }
.tab { display: inline-grid; flex: 1; height: 34px; place-items: center; border: 0; border-radius: var(--radius-control); background: transparent; cursor: pointer; color: var(--text-muted); }
.tab > *, .tab::after { grid-area: 1 / 1; }
.tab::after { content: attr(data-text); font-weight: 650; visibility: hidden; height: 0; }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-1); }
.tab[aria-selected="true"] > * { font-weight: 650; }
.panel { padding: var(--space-2) var(--space-3) var(--space-5); overflow: auto; flex: 1; }
.empty-note { color: var(--text-muted); padding: var(--space-3) var(--space-2); margin: 0; }

.layers { list-style: none; margin: 0; padding: 0; }
.layer { display: flex; align-items: center; gap: var(--space-2); height: 36px; padding-right: var(--space-1); border-radius: var(--radius-control); cursor: default; }
.layer:hover { background: var(--accent-soft); }
.layer.selected { background: var(--accent); color: var(--accent-ink); }
.layer.selected .layer-id { color: color-mix(in oklch, var(--accent-ink), transparent 30%); }
.layer.is-hidden .layer-name { opacity: 0.45; }
.layer-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-id { font-size: var(--step--1); color: var(--text-muted); }
.mini { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; opacity: 0.7; }
.mini.text { width: auto; padding: 0 8px; font-weight: 600; font-size: var(--step--1); opacity: 1; }
.layer .mini { opacity: 0; }
.layer:hover .mini, .layer.selected .mini, .layer.is-hidden .mini { opacity: 0.8; }

.add-text { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface-raised); border-radius: var(--radius-control); padding: 10px 12px; margin-bottom: var(--space-2); cursor: pointer; transition: scale var(--dur-press) ease-out; }
.add-text:hover { border-color: var(--accent); }
.add-text.h { font-size: 22px; font-weight: 700; } .add-text.s { font-size: 16px; font-weight: 600; } .add-text.b { font-size: 13px; }
.grid-icons { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-2); }
.grid-icons.wide { grid-template-columns: repeat(3, 1fr); }
.tile { display: grid; place-items: center; gap: 4px; aspect-ratio: 1; border: 1px solid var(--border); background: var(--surface-raised); border-radius: var(--radius-control); cursor: pointer; padding: 6px; transition: scale var(--dur-press) ease-out, border-color var(--dur-menu) var(--ease-out); }
.tile span { font-size: var(--step--1); color: var(--text-muted); }
.tile:hover { border-color: var(--accent); }
.tile .ico { width: 22px; height: 22px; }
.tile.asset img { width: 70%; height: 70%; object-fit: contain; }
@media (prefers-color-scheme: dark) { .tile.asset img { filter: invert(1); } }
.asset-word { font-size: 10px; text-align: center; line-height: 1.1; overflow: hidden; }
.upload { width: 100%; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-top: var(--space-3); }
.photo { aspect-ratio: 1; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-control); overflow: hidden; cursor: pointer; background: var(--surface-raised); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search { display: flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-raised); margin: var(--space-2) 0 var(--space-3); }
.search input { flex: 1; border: 0; background: transparent; outline: none; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { display: grid; grid-template-columns: auto 1fr auto; gap: 2px var(--space-2); align-items: center; padding: var(--space-2); border-radius: var(--radius-control); }
.history li.current { background: var(--accent-soft); }
.history .what { grid-column: 1 / -1; grid-row: 2; font-size: var(--step--1); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history .when { font-size: var(--step--1); color: var(--text-muted); }
.history .mini.text { grid-column: 3; grid-row: 2; }
.who { font-weight: 600; font-size: var(--step--1); }

/* ---------- Canvas ---------- */
.board { position: relative; flex: none; box-shadow: var(--shadow-2); border-radius: 2px; touch-action: none; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.host { position: absolute; inset: 0; }
.overlay { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.overlay .handle { pointer-events: all; fill: white; stroke: var(--accent); }
.overlay .h-n, .overlay .h-s { cursor: ns-resize; } .overlay .h-e, .overlay .h-w { cursor: ew-resize; }
.overlay .h-nw, .overlay .h-se { cursor: nwse-resize; } .overlay .h-ne, .overlay .h-sw { cursor: nesw-resize; } .overlay .h-rot { cursor: grab; }
.overlay .sel { fill: none; stroke: var(--accent); }
.overlay .hover { fill: none; stroke: var(--accent); opacity: 0.6; }
.overlay .guide { stroke: oklch(62% 0.22 20); }
.overlay .marquee { fill: var(--accent-soft); stroke: var(--accent); }
.canvas-empty { position: absolute; left: 50%; top: 50%; translate: -50% -50%; max-width: 34ch; text-align: center; color: var(--text-muted); pointer-events: none; }
.text-edit { position: fixed; z-index: 20; padding: 6px 8px; border: 2px solid var(--accent); border-radius: 6px; background: var(--surface-raised); box-shadow: var(--shadow-2); resize: both; font-size: 15px; }

/* ---------- Inspector ---------- */
.inspector { padding: var(--space-2) var(--space-3) var(--space-5); }
.insp-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-1) var(--space-3); border-bottom: 1px solid var(--border); }
.insp-head .meta-label { margin: 0; text-transform: capitalize; }
.flow-note { margin: var(--space-3) var(--space-1) 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); background: var(--accent-soft); font-size: var(--step--1); }
.insp-id { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { border-bottom: 1px solid var(--border); }
.group-head { display: flex; width: 100%; align-items: center; justify-content: space-between; height: 40px; border: 0; background: transparent; padding: 0 var(--space-1); font-weight: 600; cursor: pointer; }
.group .chev { width: 16px; height: 16px; transition: rotate var(--dur-menu) var(--ease-out); rotate: -90deg; }
.group.open .chev { rotate: 0deg; }
.group-body { padding: 0 var(--space-1) var(--space-2); }
.field { display: grid; gap: 4px; margin-bottom: var(--space-3); min-width: 0; }
.field.row { grid-template-columns: 1fr auto; align-items: center; }
.f-label { font-size: var(--step--1); color: var(--text-muted); }
.num-row { display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.field :where(input:not([type="range"]):not([type="color"]), select, textarea) { width: 100%; min-height: 32px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-raised); }
.field textarea { resize: vertical; }
.field input.num { width: 78px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.field input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.field input[type="color"] { width: 32px; height: 32px; flex: none; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 2px; background: var(--surface-raised); }
.switch { width: 36px; height: 22px; border-radius: 99px; border: 0; background: var(--border); position: relative; cursor: pointer; transition: background-color var(--dur-menu) var(--ease-out); }
.switch span { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: var(--shadow-1); transition: translate var(--dur-menu) var(--ease-in-out); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { translate: 14px 0; }

/* ---------- Popovers and toasts (enter from the trigger, top right) ---------- */
@keyframes enter { from { opacity: 0; scale: var(--scale-start); } }
.popover { position: absolute; right: var(--space-4); top: 52px; width: 320px; padding: var(--space-4); border-radius: var(--radius-outer); background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-2); transform-origin: top right; animation: enter var(--dur-menu) var(--ease-out); }
.popover.check { width: 420px; max-height: 60vh; overflow: auto; }
.popover.connect { width: 460px; }
.popover p { margin: 0 0 var(--space-3); }
.popover .meta-label:first-child { margin-top: 0; }
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-control); background: var(--bg); }
.segmented button { flex: 1; height: 32px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-weight: 600; }
.segmented button[aria-pressed="true"] { background: var(--surface-raised); box-shadow: var(--shadow-1); }
.line { display: block; padding: var(--space-3); margin-bottom: var(--space-3); border-radius: var(--radius-control); background: var(--bg); font: 12px/1.5 ui-monospace, monospace; word-break: break-all; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.issues li { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-2); align-items: start; padding: var(--space-2); border-radius: var(--radius-control); background: var(--bg); }
.issues li.error b { color: var(--danger); }
.issue-layer { border: 0; background: var(--surface-raised); border-radius: 6px; padding: 2px 6px; cursor: pointer; font-weight: 600; }
.ok-note { display: flex; gap: var(--space-2); align-items: center; color: var(--ok); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; display: flex; gap: var(--space-3); align-items: flex-start; max-width: 520px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-outer); background: var(--text); color: var(--surface-raised); box-shadow: var(--shadow-2); animation: enter var(--dur-menu) var(--ease-out); z-index: 30; }
.toast p { margin: 2px 0 0; opacity: 0.8; }
.toast.error .ico { color: oklch(75% 0.15 27); }
.toast.done .ico { color: oklch(78% 0.13 155); }

/* Loading */
.skeleton { background: linear-gradient(90deg in oklch, var(--surface), var(--surface-raised), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-control); }
@keyframes shimmer { to { background-position: -200% 0; } }
.app.loading .viewport { place-items: center; }
