/* Dallas3D - the design system: tokens, typography and primitives.
   Loaded by every page (studio, public site, admin), so this file owns the look of the product.
   The product is dark only; <html data-theme="dark"> is set by theme.js before first paint.

   THE IDEA
   A game engine's HUD, not a dashboard. Panels are layered slabs with a lit top edge; important
   actions glow; empty space carries a faint technical grid instead of being blank. It is a night
   rig: cinematic graphite, lit by the accent - there is no light mode.

   TOKENS
   Nothing below this block should invent a colour. Use these, in this order of preference:
     surfaces   --bg --surface --raised --hover --input --stage
     lines      --border --border-strong --hud-line
     type       --text --text-2 --muted
     brand      --accent --accent-2 --accent-hover --accent-ink --accent-soft --tint
     state      --good --bad --warn
     depth      --glow --glow-2 --shadow --shadow-lift --grid
     shape      --radius-sm --radius --radius-lg --dur --ease
*/

:root {
  /* ---- dark: a cinematic night rig. Graphite, never pure black. ---- */
  --bg: #0a0d13;              /* behind everything */
  --bg-2: #070a0f;            /* the darkest well, for insets */
  --surface: #11151d;         /* panels */
  --raised: #171d27;          /* rows, cards, inputs on panels */
  --hover: #1e2532;
  --input: #0c1016;
  --stage: #06080c;           /* the game's own frame */

  --border: #222a37;
  --border-strong: #33404f;
  --hud-line: rgba(122, 176, 255, .22);   /* the lit top edge of a panel */

  --text: #eaeef6;
  --text-2: #b6c0d0;
  --muted: #7b8798;

  --accent: #4d8dff;          /* electric blue - the brand's primary */
  --accent-2: #a06bff;        /* violet - the secondary, for depth in gradients */
  --accent-3: #2fd8d0;        /* cyan - sparingly, for live/running states */
  --accent-hover: #6ba3ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(77, 141, 255, .15);
  --tint: rgba(77, 141, 255, .17);

  --good: #37d99b;
  --bad: #ff6b6b;
  --warn: #f5b13f;

  --glow: 0 0 0 1px rgba(77, 141, 255, .35), 0 6px 22px rgba(77, 141, 255, .30);
  --glow-2: 0 0 26px rgba(77, 141, 255, .22);
  --shadow: 0 24px 64px rgba(0, 0, 0, .58), 0 2px 8px rgba(0, 0, 0, .40);
  --shadow-lift: 0 18px 38px rgba(0, 0, 0, .55), 0 0 0 1px rgba(122, 176, 255, .14);
  --grid: rgba(150, 185, 240, .05);
  --grid-lit: rgba(120, 170, 255, .28);   /* the same lines, lit by the pointer lamp */
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, 0) 60%);

  --graph-node: #1b2740; --graph-node-line: #6f9bff; --graph-text: #e9edf4; --graph-line: #33404f;

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;
  --dur: 180ms;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: dark;
}
/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  /* the bench: a faint engineering grid, so large empty areas are never a flat void */
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--bg);
}
/* ---- the lines come alive ----
   Two extra layers of the same grid, drawn in the accent and masked so only part of them shows:
   one follows the pointer (theme.js adds `.bench-lamp` and moves its mask), one drifts slowly on its own so
   the bench never sits perfectly still. Both live behind the content (body isolates its stacking
   context, so z-index -1 is "above the bench, below the panels") and neither catches the mouse. */
body { position: relative; isolation: isolate; }
.bench-lamp, body::after {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(var(--grid-lit) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--grid-lit) 1px, transparent 1px) 0 0 / 56px 56px;
}
.bench-lamp {                                   /* the pointer's lamp: a real element theme.js adds and moves.
                                                   The mask is fixed; only its position changes, set straight on
                                                   the element's style - Safari does not reliably repaint a mask
                                                   whose gradient reads a custom property. */
  -webkit-mask: radial-gradient(460px circle at 50% 50%, #000, transparent 72%) -9999px -9999px / 920px 920px no-repeat;
          mask: radial-gradient(460px circle at 50% 50%, #000, transparent 72%) -9999px -9999px / 920px 920px no-repeat;
  opacity: 0; transition: opacity .5s var(--ease);
}
.bench-lamp.is-on { opacity: 1; }
body::after {                                   /* the slow drift */
  content: "";
  -webkit-mask: linear-gradient(115deg, transparent 38%, #000 50%, transparent 62%) 0 0 / 260% 100%;
          mask: linear-gradient(115deg, transparent 38%, #000 50%, transparent 62%) 0 0 / 260% 100%;
  opacity: .55; animation: drift 18s linear infinite;
}
@keyframes drift { from { -webkit-mask-position: 120% 0; mask-position: 120% 0; } to { -webkit-mask-position: -60% 0; mask-position: -60% 0; } }
@media (prefers-reduced-motion: reduce) { .bench-lamp, body::after { display: none; } }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
p { margin: 0; }
button, textarea, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--tint); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* Headings carry the gaming personality; body text stays plain and readable. */
.display, .brand h1, .welcome h2, .preview-empty h2 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif; letter-spacing: -.025em;
}
/* small caps labels: the HUD's voice - section names, statuses, metadata */
.eyebrow, .side-toggle h2, .stat-label, .hud-label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.eyebrow { color: var(--accent); }

/* ---------- surfaces ----------
   A panel is a lit slab: a soft sheen down the top, a brighter hairline across it. */
.panel-face {
  position: relative; background: var(--sheen), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.panel-face::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--hud-line) 18%, var(--hud-line) 82%, transparent);
  pointer-events: none;
}

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--sheen), var(--raised); color: var(--text);
  font-weight: 550; font-size: 13px; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 90ms var(--ease);
}
.btn:hover { background: var(--sheen), var(--hover); border-color: var(--accent); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 15px; height: 15px; flex: none; }

/* primary: luminous, with a lit inner edge and a glow that answers the pointer */
.btn-primary {
  border-color: transparent; color: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff 12%), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 2px 10px rgba(0, 0, 0, .28);
}
.btn-primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-hover) 88%, #fff 12%), var(--accent-hover));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), var(--glow);
  color: var(--accent-ink);
}
.btn-primary:disabled { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-primary.is-stop { background: transparent; border-color: var(--bad); color: var(--bad); box-shadow: none; }
.btn-primary.is-stop:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); box-shadow: none; }

/* secondary: technical, quiet, HUD-like */
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--tint); border-color: var(--accent); color: var(--text); }

.btn-small { height: 29px; padding: 0 11px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { width: 30px; padding: 0; color: var(--muted); background: transparent; border-color: transparent; box-shadow: none; }
.btn-icon:hover { color: var(--text); background: var(--hover); border-color: var(--border); }
.btn-warn { border-color: var(--warn); color: var(--warn); background: transparent; }
.btn-warn:hover { background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: var(--warn); color: var(--warn); }

:is(.btn, .tab, .chip-btn, .side-toggle, .folder-toggle, .thumb, .help-button):focus-visible,
textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 10px; border-radius: 999px;
  background: var(--raised); border: 1px solid var(--border); color: var(--text-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge.is-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent);
                 background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.is-good::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.badge.is-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent);
                background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.is-bad::before { background: var(--bad); }
.badge.is-busy { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
                 background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge.is-busy::before { background: var(--warn); animation: pulse 1s infinite; }
#kind-badge::before { display: none; }
#kind-badge {
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-2) 12%, transparent));
  border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent);
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 11px;
}

/* ---------- top bar ---------- */
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 54px; padding: 0 16px; position: relative;
  background: var(--sheen), var(--surface); border-bottom: 1px solid var(--border);
}
/* the lit rail under the bar: the signature line of the whole interface */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--hud-line) 12%, var(--hud-line) 88%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 30px; height: 30px; flex: none; object-fit: contain; }
.brand h1 { font-size: 16.5px; font-weight: 700; }
.brand-label {
  padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border); color: var(--muted);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.brand-sub { color: var(--muted); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar .badge { background: transparent; border-color: transparent; padding: 0 4px; color: var(--muted); }
.banner {
  flex: none; padding: 10px 16px; font-size: 13px; color: var(--text);
  background: color-mix(in srgb, var(--bad) 14%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--bad) 45%, var(--border));
}

/* ---------- shell: three docked panels ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 372px minmax(0, 1fr) 328px; }
.chat, .preview, .side { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.chat { border-right: 1px solid var(--border); }
.side { border-left: 1px solid var(--border); overflow-y: auto; }
.preview { background: transparent; }

/* ---------- chat ---------- */
.chat-head {
  flex: none; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px;
  background: var(--sheen), var(--surface); border-bottom: 1px solid var(--border);
}
.chat-head .btn { flex: none; }
.chat-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px; font-size: 0;
  background: var(--accent-soft) url("assets/logo-64.png") center / 22px no-repeat;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.chat-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chat-title strong { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chats { flex: 1; min-height: 0; display: flex; }
.messages { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }

.welcome { margin: auto 0; padding: 8px 4px; display: flex; flex-direction: column; gap: 10px; }
.welcome + .msg-note { margin-bottom: auto; }
.welcome h2 { font-size: 23px; font-weight: 700; line-height: 1.2; }
.welcome p { color: var(--text-2); }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.chip-btn {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 11px 13px; text-align: left; cursor: pointer; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--sheen), var(--raised);
  color: var(--text); font-weight: 600; font-size: 13px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chip-btn small { font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.35; }
.chip-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--sheen), var(--tint);
  transform: translateY(-1px); box-shadow: var(--glow-2);
}

.msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.msg-user {
  align-self: flex-end; max-width: 88%; padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff 12%), var(--accent));
  color: var(--accent-ink); white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 2px 10px rgba(0, 0, 0, .18);
}
.msg-agent { align-self: stretch; }
.msg-agent::before {
  content: "Dallas agent"; padding-left: 24px; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  background: url("assets/logo-64.png") left center / 18px no-repeat; line-height: 18px;
}
.msg-agent p { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.msg-error {
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; white-space: pre-wrap; color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
}
.msg-note { align-self: center; max-width: 92%; text-align: center; color: var(--muted); font-size: 12.5px; }

/* the agent's steps: a quiet telemetry timeline, not boxes */
.step { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 0 8px; min-height: 24px;
        font-size: 13px; color: var(--text-2); }
.step + .step { margin-top: -4px; }
.step-icon { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; font-weight: 700;
             background: var(--raised); color: var(--muted); }
.step.is-running { color: var(--text); }
.step.is-running .step-icon { background: transparent; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.step.is-ok .step-icon { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.step.is-fail .step-icon { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.step-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.working::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
                   box-shadow: 0 0 10px var(--accent); animation: pulse 1s infinite; }

.ask {
  display: flex; flex-direction: column; gap: 10px; padding: 13px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-2) 8%, transparent));
  box-shadow: var(--glow-2);
}
.ask-head { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.ask-mark { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0; }
.ask-q { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.ask-options { display: flex; flex-direction: column; gap: 6px; }
.ask-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left;
              border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer;
              transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.ask-option:hover:not(:disabled), .ask-option.is-open { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.ask-option:disabled { cursor: default; opacity: .7; }
.ask-option.is-chosen { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.ask-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-2); }
.ask-option:hover:not(:disabled) .ask-dot, .ask-option.is-open .ask-dot { border-color: var(--accent); }
.ask-option.is-chosen .ask-dot { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 45%, transparent 50%); }
.ask-block { display: flex; flex-direction: column; gap: 8px; }
.ask-block[hidden] { display: none; }
.ask-more { font-weight: 400; color: var(--text-2); font-size: 12px; }
.ask-option.is-multi .ask-dot { border-radius: 4px; }
.ask-option.is-multi.is-chosen .ask-dot { background: var(--accent); }
.ask-send { align-self: flex-end; }
.ask-form { display: flex; gap: 6px; margin-top: 2px; }
.ask-form { flex-wrap: wrap; align-items: flex-end; }
.ask-form textarea { resize: none; line-height: 1.4; max-height: 180px; overflow-y: auto; }
.ask-count { flex-basis: 100%; font-size: 11px; color: var(--muted); text-align: right; }
.ask-count:empty { display: none; }
.ask-form input, .ask-form textarea { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; }
.ask-form input:focus, .ask-form textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.ask .btn { background: var(--surface); }
.ask.is-answered { border-color: var(--border); background: transparent; box-shadow: none; opacity: .6; }

.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 8px 8px 8px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--input);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--glow-2); }
.composer textarea { flex: 1; min-height: 40px; max-height: 160px; padding: 4px 0; resize: none; border: 0; background: transparent; outline: none; }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: var(--muted); }
.composer-hint { flex: none; padding: 6px 16px 12px; color: var(--muted); font-size: 11.5px; }

/* ---------- preview ---------- */
.toolbar {
  flex: none; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px;
  background: var(--sheen), var(--surface); border-bottom: 1px solid var(--border);
}
.toolbar-actions { margin-left: auto; display: flex; gap: 4px; }
.toolbar-actions .btn { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.toolbar-actions .btn:hover { background: var(--hover); border-color: var(--border); color: var(--text); }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--input); border: 1px solid var(--border); }
.tab {
  position: relative; height: 26px; padding: 0 15px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 var(--hud-line); }
.tab.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -4px; height: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}

.stage {
  flex: 1; min-height: 0; position: relative; margin: 16px; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--stage); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stage iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--stage); }
.preview-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; color: #aeb8c8;
  background:
    radial-gradient(62% 52% at 50% 44%, rgba(77, 141, 255, .18), transparent 70%),
    linear-gradient(rgba(150, 185, 240, .05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(150, 185, 240, .05) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--stage);
}
.preview-empty h2 { font-size: 23px; font-weight: 700; line-height: 1.25; color: #f1f4f9; }
.preview-empty p { max-width: 320px; color: #8f9bb0; }
.preview-empty .eyebrow { color: #7aa3ff; }
.preview-symbol {
  width: 58px; height: 58px; margin-bottom: 8px; display: grid; place-items: center; border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(122, 176, 255, .22); color: #7aa3ff;
  box-shadow: 0 0 30px rgba(77, 141, 255, .22);
}
.preview-symbol svg { width: 28px; height: 28px; }
.preview-foot { display: none; }
.crash {
  flex: none; display: flex; align-items: center; gap: 10px; margin: 0 16px 16px; padding: 9px 13px;
  border-radius: var(--radius-sm); font-size: 13px; color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
}
.crash span { margin-right: auto; }

/* ---------- loading ---------- */
.loader { position: relative; width: 104px; height: 104px; display: grid; place-items: center; }
.loader::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .10);
  border-top-color: #ffb21e; border-right-color: #35b6ff; animation: spin 1.1s linear infinite;
}.loader img { width: 78%; height: 78%; object-fit: contain; animation: bob 1.6s ease-in-out infinite; }
.loader-big { width: 148px; height: 148px; }
.loader-dots { display: flex; gap: 8px; }
.loader-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: hop 1s ease-in-out infinite; }
.loader-dots span:nth-child(2) { animation-delay: .15s; background: #ffb21e; }
.loader-dots span:nth-child(3) { animation-delay: .3s; background: #35b6ff; }
.splash {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: var(--bg); transition: opacity .35s, visibility .35s;
}
.splash.is-done { opacity: 0; visibility: hidden; }
.building {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; text-align: center; color: #e9edf4;
  background: rgba(6, 8, 12, .86); backdrop-filter: blur(4px);
}
.building strong { font: 700 16px "Space Grotesk", "Inter", sans-serif; letter-spacing: -.01em; }
.building-time { color: #8f9bb0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* the build's own progress rail: indeterminate, because a compile has no honest percentage */
.building::after {
  content: ""; position: absolute; left: 50%; bottom: 22%; width: 190px; height: 3px; margin-left: -95px;
  border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, .10);
  background-image: linear-gradient(90deg, transparent, #35b6ff, #ffb21e, transparent);
  background-size: 55% 100%; background-repeat: no-repeat; animation: sweep 1.4s var(--ease) infinite;
}

/* graph: the scene graph editor (scenegraph.css) fills this frame */
.graph-view {
  flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 12px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow);
}
.layout.is-graph { grid-template-columns: 300px minmax(0, 1fr) 0; }
.layout.is-graph .side { display: none; }

/* ---------- inspector (right) ---------- */
.side-section { border-bottom: 1px solid var(--border); }
.side-section:last-of-type { border-bottom: 0; }
.side-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; height: 44px;
  padding: 0 10px 0 12px; background: var(--sheen), var(--surface); border-bottom: 1px solid var(--border);
}
.side-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 4px; border: 0; border-radius: 6px;
               background: none; cursor: pointer; text-align: left; }
.side-toggle h2 { color: var(--text-2); }
.chevron { width: 7px; height: 7px; margin: 0 2px 3px 2px; flex: none; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
           transform: rotate(45deg); transition: transform .15s var(--ease); }
.side-section.is-collapsed .chevron, .folder.is-collapsed .chevron { transform: rotate(-45deg); margin-bottom: 0; }
.side-section.is-collapsed .side-body { display: none; }
.side-body { padding: 8px 8px 12px; }
.count {
  min-width: 19px; padding: 0 6px; border-radius: 999px; text-align: center; font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.count:empty { display: none; }
.side-hint { padding: 4px 8px 8px; color: var(--muted); font-size: 12.5px; }

/* an empty section explains itself, instead of being a blank box */
.cards:empty::before, .asset-tree:empty::before {
  display: block; margin: 0 4px; padding: 16px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--muted); font-size: 12.5px; line-height: 1.45; text-align: center;
  background: repeating-linear-gradient(45deg, var(--grid) 0 6px, transparent 6px 12px);
}
#objects:empty::before { content: "The objects of your game appear here, each with a picture and its own chat."; }
#assets:empty::before { content: "Add models and textures, and order them in folders. Then tell the agent to use them."; }

.section-help { position: relative; display: inline-flex; }
.help-button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: help; }
.help-button:hover { background: var(--hover); color: var(--text); }
.help-tooltip {
  position: absolute; z-index: 5; top: calc(100% + 6px); right: -8px; width: 232px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-3px);
  transition: opacity .12s, transform .12s, visibility .12s; pointer-events: none;
}
.section-help:hover .help-tooltip, .help-button:focus-visible + .help-tooltip { opacity: 1; visibility: visible; transform: none; }
.section-help.is-dismissed .help-tooltip { opacity: 0; visibility: hidden; }

/* ---------- object / asset cards: small HUD rows ---------- */
.cards, .asset-tree { display: flex; flex-direction: column; gap: 5px; }
.card {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--raised);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card:hover { background: var(--hover); border-color: var(--border-strong); }
.card.is-open {
  background: var(--tint); border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--glow-2);
}
/* the lit rail that marks the open object */
.card.is-open::before {
  content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.thumb {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 8px;
  border: 1px solid var(--border); background: var(--input); color: var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
button.thumb { padding: 0; cursor: zoom-in; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
button.thumb:hover { border-color: var(--accent); box-shadow: var(--glow-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-text { min-width: 0; line-height: 1.3; }
.card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 3px; }
.card-actions .btn { height: 27px; padding: 0 10px; font-size: 12px; background: transparent; border-color: var(--border); color: var(--text-2); box-shadow: none; }
.card-actions .btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.card-actions .btn-icon { width: 27px; padding: 0; border-color: transparent; color: var(--muted); }
.card-actions .btn-icon:hover { border-color: transparent; background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
/* an asset's buttons sit OVER its text while the pointer is on the card, so four of them never
   squeeze the name out of a narrow panel */
.card.is-asset { grid-template-columns: 40px minmax(0, 1fr); }
.card.is-asset .card-actions {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding-left: 18px;
  background: linear-gradient(90deg, transparent, var(--hover) 18px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease);
}
.card.is-asset:hover .card-actions, .card.is-asset:focus-within .card-actions { pointer-events: auto; }
.card.is-asset:hover .card-actions, .card.is-asset:focus-within .card-actions { opacity: 1; }
@media (hover: none) { .card.is-asset { grid-template-rows: auto auto; } .card.is-asset .card-actions { position: static; transform: none; grid-column: 1 / -1; padding: 0; background: none; opacity: 1; pointer-events: auto; } }
.card[draggable="true"] { cursor: grab; }
.card.is-dragging { opacity: .4; }

.folder { border-radius: var(--radius-sm); }
.folder.is-drop, .asset-tree.is-drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.folder-head { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 6px; border-radius: var(--radius-sm); }
.folder-head:hover { background: var(--raised); }
.folder-head .btn { opacity: 0; }
.folder-head:hover .btn, .folder-head:focus-within .btn { opacity: 1; }
@media (hover: none) { .folder-head .btn { opacity: 1; } }
.folder-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 2px; border: 0; border-radius: 6px;
                 background: none; cursor: pointer; text-align: left; }
.folder-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-name::before { content: ""; display: inline-block; width: 14px; height: 11px; margin-right: 7px; vertical-align: -1px;
                       background: var(--warn); opacity: .9; clip-path: polygon(0 0, 42% 0, 52% 18%, 100% 18%, 100% 100%, 0 100%); }
.folder-body { display: flex; flex-direction: column; gap: 3px; margin-left: 13px; padding: 2px 0 4px 8px; border-left: 1px solid var(--border); }
.folder.is-collapsed .folder-body { display: none; }
.folder-empty { padding: 6px 8px; color: var(--muted); font-size: 12px; }

/* the hidden game that takes the object pictures: it must stay INSIDE the viewport, or the
   browser stops running its frames; invisible and unreachable instead */
.snap-frame { position: fixed; right: 0; bottom: 0; width: 960px; height: 540px; border: 0; opacity: 0; pointer-events: none; z-index: -1; }   /* 16:9 - the cover is taken here */
.view-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--stage); }

/* ---------- dialogs ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); background: var(--sheen), var(--surface); color: var(--text);
  box-shadow: var(--shadow); animation: rise 220ms var(--ease);
}
.dialog-wide { width: min(780px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(4, 7, 12, .66); backdrop-filter: blur(4px); animation: fade 200ms var(--ease); }.dialog h2 { font-size: 17px; font-weight: 700; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-hint { margin: 6px 0 14px; color: var(--muted); font-size: 13px; }
.dialog-text { margin: 0 0 18px; color: var(--text-2); }
.dialog-rows { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
/* the gear's rows: a label with its story on the left, the number on the right */
.param-row { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 12px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--raised); cursor: pointer; }
.param-row:hover { border-color: var(--border-strong); }
.param-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.param-text b { font-size: 13px; font-weight: 600; color: var(--text); }
.param-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.param-row input[type="number"] { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 13px; text-align: right; }
.param-row input[type="checkbox"] { justify-self: end; width: 18px; height: 18px; accent-color: var(--accent); }
.btn-gear { font-size: 15px; }
.folder-nested { margin-left: 10px; border-left: 2px solid var(--border); padding-left: 8px; }
.folder-nested > .folder-head .folder-name { font-size: 12px; color: var(--text-2); }
.param-row-text { grid-template-columns: minmax(0, 1fr) 190px; }
.param-row input[type="text"] { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 13px; }
.card.is-game { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.dialog-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; padding: 9px; border-radius: var(--radius-sm);
              border: 1px solid var(--border); background: var(--raised); }
.dialog-row .thumb { width: 56px; height: 56px; }
.dialog-row label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-row input, .dialog-field select, .dialog-field input {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.dialog-row input:focus-visible, .dialog-field select:focus-visible, .dialog-field input:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.dialog-field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
/* a private / public choice: two radio rows, the meaning of each spelled out */
.dialog-choice { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 12px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.dialog-choice legend { padding: 0 6px; font-weight: 600; color: var(--text); }
.dialog-choice label { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline; padding: 6px 4px; cursor: pointer; border-radius: 8px; }
.dialog-choice label:hover { background: var(--raised); }
.dialog-choice label b { color: var(--text); font-weight: 600; }
.dialog-choice input { margin: 0; accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.view-stage { height: min(58vh, 480px); display: grid; place-items: center; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border);
              background: var(--stage); color: #8f9bb0; }
.view-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.view-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* nothing is drawn over the stage: the engine draws its own 3D floor grid under the object */
.view-stage { isolation: isolate; }
/* ---------- motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bob { 50% { transform: translateY(-5px) scale(1.03); } }
@keyframes hop { 50% { transform: translateY(-7px); opacity: .6; } }
@keyframes sweep { 0% { background-position: -60% 0; } 100% { background-position: 160% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) { .layout { grid-template-columns: 332px minmax(0, 1fr) 288px; } }
@media (max-width: 960px) {
  html, body { height: auto; }
  .brand-label, .topbar .badge { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { order: -1; }
  .chat, .side { border: 0; border-top: 1px solid var(--border); }
  .stage, .graph-view { flex: none; margin: 12px; }
  .stage { aspect-ratio: 16 / 10; }
  .graph-view { height: 78dvh; }
  .layout.is-graph { grid-template-columns: minmax(0, 1fr); }
  .layout.is-graph .side { display: flex; }
  .chat { height: 72dvh; }
  .side { overflow: visible; }
  .suggestions { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .toolbar-actions .btn { padding: 0 8px; }
}

/* a compact settings dialog: a name, the choice, one short hint */
.dialog-compact { width: min(400px, calc(100vw - 32px)); }
.dialog-compact h2 { margin-bottom: 6px; }
.setting { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.setting-name { font-size: 13px; font-weight: 600; color: var(--text); }
.setting-hint { font-size: 12px; color: var(--muted); }
.setting-row { display: grid; grid-template-columns: auto 1fr auto; column-gap: 12px; align-items: center; cursor: pointer; }
.setting-row .setting-hint { grid-column: 1 / 3; margin-top: -4px; }
.setting-row .switch { grid-column: 3; grid-row: 1 / 3; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-item { height: 32px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease); }
.seg-item:hover { border-color: var(--border-strong); color: var(--text); }
.seg-item.is-on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur) var(--ease); margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--dur) var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
/* the agent's question as a select box (ready-made objects of the assets list, or a new one) */
.ask-select { display: flex; gap: 8px; align-items: center; width: 100%; }
.ask-select-box { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; }
.ask-select-box:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* touch: every tappable thing of a question and of the model viewer is at least 44 px (measured at 390 px, sprint 3) */
@media (pointer: coarse), (max-width: 900px) {
  .ask-select-box { min-height: 44px; font-size: 16px; }
  .ask-select .btn, .ask .ask-send { height: auto; min-height: 44px; min-width: 64px; }
  .ask-option { min-height: 44px; }
  .view-head-actions .btn { height: auto; min-height: 44px; min-width: 64px; }
  .view-modes { gap: 6px !important; }
  .view-modes button { min-height: 44px; min-width: 64px; padding: 0 14px !important; }
}
