/* NexSwap Studio (the badge designer). Landing-site look (nexswap-landing/styles.css): near-black ground, Inter Tight, JetBrains
   Mono for small labels, the purple-pink-amber gradient on the main action. Layout (chosen 13 Nov from mock-ups):
   the badge is the hero, screens in a rail on the right, the chat floats at the bottom of the canvas; on phones the
   chat is a bottom sheet. 48 px targets, no spinners. Tokens first. */
:root {
  --bg: #09080c; --bg-2: #111017; --bg-3: #17151f; --bg-4: #211e2b; --bg-5: #2a2636;
  --ink: #f4f2f8; --ink-2: #aaa5b9; --ink-3: #6f6a7c;
  --line: rgba(255, 255, 255, 0.07); --line-2: rgba(255, 255, 255, 0.13); --line-3: rgba(255, 255, 255, 0.22);
  --purple: #9b3dff; --pink: #ff5ea8; --amber: #ffc56b;
  --grad: linear-gradient(100deg, #9b3dff 0%, #ff5ea8 55%, #ffc56b 100%);
  --purple-soft: #9b3dff1f; --on-grad: #140b1c;
  --ok: #3ddc84; --err: #ff6b6b; --warn: #ffc857; --info: #6ad1ff;
  --ok-soft: #3ddc8418; --err-soft: #ff6b6b18; --warn-soft: #ffc8571a;
  --bezel-1: #25222d; --bezel-2: #121016; --bezel-edge: #39334a; --screen-black: #000000;
  --text-xs: 12px; --text-sm: 14px; --text-md: 15px; --text-base: 16px; --text-lg: 18px;
  --font-sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --radius: 18px; --radius-sm: 12px; --radius-pill: 999px; --tap: 48px;
  --shadow: 0 24px 70px #000d; --glow: 0 0 18px #9b3dff77;
  --dur: 160ms; --ease: cubic-bezier(.2, .7, .1, 1); --top-h: 64px; --rail-w: 212px; --sheet-h: 220px;
}
@media (prefers-reduced-motion: reduce) { :root { --dur: 0ms; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 400 var(--text-base)/1.55 var(--font-sans); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
button { font-family: inherit; }
kbd { font: 400 11px var(--font-mono); color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; margin-left: auto; }
svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.topbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: var(--s-2); height: var(--top-h);
  padding: 0 var(--s-5); border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 16px; height: 16px; border-radius: 5px; background: var(--grad); box-shadow: var(--glow); flex: none; }
.brand-name { font-weight: 600; }
.sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 var(--s-2); }
.top-actions { display: flex; align-items: center; gap: var(--s-1); }
.eyebrow { font: 500 11px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: var(--text-sm); margin: var(--s-2) 0 0; }
.grow { flex: 1; min-width: 0; }

/* menu (⋯) */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: 6px; border-radius: 14px; background: var(--bg-3);
  border: 1px solid var(--line-2); box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 9; }
.menu button { display: flex; align-items: center; gap: var(--s-3); min-height: 42px; padding: 0 var(--s-3); border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); font-size: var(--text-sm); text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--bg-4); }

/* buttons */
.btn { min-height: var(--tap); padding: 0 var(--s-5); border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--ink); font: 500 var(--text-md) var(--font-sans); cursor: pointer;
  transition: background var(--dur), border-color var(--dur); white-space: nowrap; }
.btn:hover { border-color: var(--line-3); }
.btn-sm { min-height: 40px; padding: 0 var(--s-4); font-size: var(--text-sm); }
/* main action: as the landing site's .btn, a near-white pill with dark text and a pink glow on hover (the gradient is
   only for text and progress there, never a button fill) */
.btn-primary { background: var(--ink); border: 0; color: #0b0a0f; font-weight: 600; border-radius: var(--radius-pill);
  transition: transform var(--dur), box-shadow var(--dur); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 40px -8px rgba(255, 94, 168, .55); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--bg-3); border-color: transparent; }
.btn-block { width: 100%; }
.btn:disabled, .icon-btn:disabled, .tool:disabled, .send:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer; font-size: 20px; line-height: 1; flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--bg-3); color: var(--ink); }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 10px; border-radius: var(--radius-pill);
  font: 500 10px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; border: 1px solid; white-space: nowrap; }
.pill-info { color: var(--info); border-color: #6ad1ff66; } .pill-ok { color: var(--ok); border-color: #3ddc8466; }
.pill-warn { color: var(--warn); border-color: #ffc85766; } .pill-err { color: var(--err); border-color: #ff6b6b66; }
.pill-accent { color: #c99bff; border-color: #9b3dff88; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-5); }
.card-title { font-size: var(--text-lg); font-weight: 600; margin: var(--s-1) 0 var(--s-2); }
.row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.row.gap { gap: var(--s-3); margin-top: var(--s-5); }

/* ------------------------------------------------------------------ start */
.start { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 0 var(--s-4) var(--s-7);
  background: radial-gradient(1100px 560px at 50% -5%, #9b3dff2a, transparent 70%), var(--bg); }
.start-hero { width: 100%; max-width: 720px; display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: clamp(48px, 12vh, 120px); }
.start h1 { font-size: clamp(36px, 6vw, 60px); font-weight: 700; letter-spacing: -.03em; line-height: 1.04; text-align: center; }
.start h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.start-sub { margin: 0; color: var(--ink-2); font-size: var(--text-lg); text-align: center; max-width: 560px; }
.bigbox { width: 100%; margin-top: var(--s-4); border-radius: 24px; background: var(--bg-2); border: 1px solid var(--line-2);
  padding: 18px 18px 12px; box-shadow: var(--shadow), 0 0 0 5px #9b3dff12; display: flex; flex-direction: column; gap: var(--s-2); }
.bigbox:focus-within { border-color: #9b3dff88; }
.bigbox textarea { width: 100%; min-height: 64px; max-height: 200px; border: 0; background: transparent; color: var(--ink); resize: none;
  font: 400 var(--text-lg)/1.5 var(--font-sans); padding: 2px 4px; }
.bigbox textarea:focus { outline: none; }
.bigbox textarea::placeholder { color: var(--ink-3); }
.bigbox .bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); }
.bigbox .send { width: 44px; height: 44px; }
.start-starters { justify-content: center; }
.start-below { width: 100%; max-width: 1080px; margin-top: clamp(64px, 14vh, 140px); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.start-gallery { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.style-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 10px; cursor: pointer; text-align: left; color: var(--ink);
  font: 500 var(--text-md) var(--font-sans); transition: border-color var(--dur), transform .2s var(--ease); }
.style-card:hover, .style-card:focus-visible { border-color: var(--line-3); transform: translateY(-3px); }
.style-card img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 10px; display: block; background: var(--screen-black); }
.style-card span { display: block; padding: 12px 4px 4px; }

/* ------------------------------------------------------------------ editor: canvas | rail, chat floating at the bottom */
.editor { flex: none; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); grid-template-rows: minmax(0, 1fr); height: calc(100vh - var(--top-h)); min-height: 520px;
  background: radial-gradient(900px 520px at 44% 34%, #9b3dff12, transparent 70%), var(--bg); }
.canvas { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: var(--s-6) var(--s-6) var(--s-5); gap: var(--s-5); }
.stage-wrap { flex: 1; min-height: 160px; width: 100%; container-type: size; display: grid; place-items: center; }
.stage { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--s-3); width: 100%; }
/* above the badge: what the designer is doing right now (kept the same height when idle, so the badge never moves) */
.status-row { width: 100%; height: 32px; display: flex; align-items: center; justify-content: center; flex: none; }
.under { display: none; align-items: center; gap: var(--s-5); flex-wrap: wrap; justify-content: center; }
.pager { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-2); font-size: var(--text-sm); }
.pager .icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); }
.pager b { color: var(--ink); font-weight: 500; }
.status { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 9px; background: currentColor; }
.status-ok::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.status-warn { color: var(--warn); } .status-accent { color: #d2a8ff; } .status-info { color: var(--info); }
.caption { color: var(--ink-3); font-size: 12px; margin: 0; text-align: center; }

/* the badge device */
/* the real V2 badge (nexswap-landing assets/v2.glb, rendered face-on as on the landing page, with the lid's window
   redrawn as on a real tag: a rounded rectangle holding the whole panel) */
.device { position: relative; width: min(720px, 94cqw, calc((100cqh - 8px - 44px) * 1.6624));   /* 44: the status row + gap */ aspect-ratio: 1305 / 785; filter: drop-shadow(0 30px 50px #000c); }
.device .frame { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.device .engrave { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font: 500 11px var(--font-mono); letter-spacing: .06em; color: var(--warn); text-transform: uppercase; }
/* the screen: the 2.8" panel's active area (57.6 x 43.2 mm) in the lid's rounded-rectangle window, as on a real V2
   tag (photo, 13 Nov); the thin black panel edge around it is part of v2-frame.png */
.screen { position: absolute; left: 23.48%; top: 16.925%; width: 53.04%; height: 66.277%; background: var(--screen-black); overflow: hidden; border-radius: 3px; }
/* working: the badge stays visible under a light veil with a moving sheen; what's happening now, and for how long,
   is the .busy-card in the status row above the badge (no frozen "Updating...", nothing written on the tag) */
.device .busy { position: absolute; inset: 0; background: #09080c40; overflow: hidden; pointer-events: none; }
.device .busy::before { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, #ffffff1f 50%, transparent 65%);
  transform: translateX(-100%); animation: sheen 1.6s ease-in-out infinite; }
@keyframes sheen { to { transform: translateX(100%); } }
.busy-card { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: #111017e6; border: 1px solid var(--line-2); font: 500 12px var(--font-sans); color: var(--ink); white-space: nowrap; max-width: min(560px, 100%); }
.busy-msg { overflow: hidden; text-overflow: ellipsis; }
.busy-time { font: 500 11px var(--font-mono); color: var(--ink-3); }
.busy-dot { width: 8px; height: 8px; border-radius: 9px; background: var(--grad); flex: none; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .35; transform: scale(.8); } to { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .device .busy::before, .busy-dot { animation: none; } }
/* previews are drawn at 3x (tools/canvas_hd.py): let the browser scale them smoothly */
.screen img { display: block; width: 100%; height: 100%; }
.screen.selecting { cursor: crosshair; }
.screen .sel-box { position: absolute; border: 2px solid var(--pink); border-radius: 4px; box-shadow: 0 0 0 9999px #00000066; pointer-events: none; }
.stage.comparing { flex-direction: column; gap: var(--s-3); }
.compare-bar { display: flex; align-items: center; justify-content: center; gap: var(--s-3); color: var(--ink-2); font-size: var(--text-sm); }
.compare-pair { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); align-items: center; }
.compare-pair .device { width: 100%; }
.compare-pair .tag { display: block; text-align: center; margin-bottom: var(--s-2); }

/* screens rail */
.rail { border-left: 1px solid var(--line); background: var(--bg); padding: var(--s-5) 28px; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: var(--s-4); }
/* the screens fill the column: one per row, two once it's wide enough (drag the column's left edge) */
.filmstrip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; align-content: start; }
/* the column's left edge: a 10 px grab strip over the border (the editor grid is position: relative) */
.rail-resizer { position: absolute; top: 0; bottom: 0; right: calc(var(--rail-w) - 5px); width: 10px; cursor: col-resize; z-index: 3; touch-action: none; }
.rail-resizer::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background var(--dur); }
.rail-resizer:hover::after, .rail-resizer:focus-visible::after, body.resizing .rail-resizer::after { background: var(--purple); }
.rail-resizer:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
.film { display: flex; flex-direction: column; gap: 7px; border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--ink-3); font: 400 12px var(--font-sans); text-align: left; }
.film img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 8px; outline: 1px solid var(--line); background: var(--screen-black); display: block; transition: outline-color var(--dur); }
.film:hover img { outline-color: var(--line-3); }
.film[aria-selected="true"] { color: var(--ink); }
.film[aria-selected="true"] img { outline: 2px solid var(--purple); outline-offset: 2px; }

/* ------------------------------------------------------------------ the floating chat */
.chatdock { width: 100%; display: flex; justify-content: center; flex: none; }
.chatbox { width: min(680px, 100%); max-height: min(60vh, calc(100vh - var(--top-h) - 220px)); display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-3);
  border-radius: 24px; background: rgba(17, 16, 23, .96); backdrop-filter: blur(16px); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.convo-head { flex: none; display: none; justify-content: space-between; align-items: center; padding: 0 0 0 var(--s-2); }
.chatbox.open .convo-head { display: flex; }
.icon-plain { width: 36px; height: 36px; }
.handle { border: 0; background: none; padding: 6px 0 2px; cursor: pointer; display: grid; place-items: center; }
.handle i { width: 40px; height: 5px; border-radius: 9px; background: var(--line-3); display: block; }

.latest { flex: none; display: flex; gap: var(--s-3); align-items: flex-start; padding: 4px 6px 0; min-height: 26px; }
.chatbox.open .latest { display: none; }
.latest .av { width: 22px; height: 22px; border-radius: 7px; background: var(--grad); flex: none; margin-top: 1px; }
.latest .body { flex: 1; min-width: 0; font-size: var(--text-md); }
.latest .body p { margin: 0; }
.latest .expand { flex: none; width: 32px; height: 32px; margin: -4px -4px 0 0; border: 0; border-radius: 10px; background: none; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; }
.latest .expand:hover { background: var(--bg-4); }
.latest .expand:hover { color: var(--ink); }
.latest .expand svg { width: 18px; height: 18px; }
.latest .err { color: var(--err); }

/* chat log: plain text for the designer, a soft bubble for the organiser */
.log { list-style: none; margin: 0; padding: var(--s-2) var(--s-3) var(--s-2); flex: 1; min-height: 0; overflow-y: auto; display: none; flex-direction: column; gap: 22px; scrollbar-width: thin; }
.chatbox.open .log { display: flex; }
.msg { max-width: 100%; font-size: var(--text-md); line-height: 1.6; }
.msg p { margin: 0; }
.msg-you { align-self: flex-end; max-width: 82%; padding: 10px 16px; border-radius: 18px; background: var(--bg-4); }
.msg-bot { align-self: stretch; }
.msg-wide { align-self: stretch; }
.msg-err { padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm); background: var(--err-soft); border: 1px solid #ff6b6b55; }
.msg-sys { align-self: center; color: var(--ink-3); font-size: 13px; }
.msg .said { word-break: break-word; }
.msg .q { font-weight: 600; font-size: var(--text-base); }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-2); }
.edit-chip { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 32px; padding: 0 var(--s-3); border-radius: var(--radius-pill);
  background: var(--bg-5); border: 1px solid var(--line-2); color: var(--ink); font: 500 13px var(--font-sans); cursor: pointer; }
.edit-chip.from-text::before { content: "AI read"; font: 500 10px var(--font-mono); color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.edit-chip .edit { font: 500 10px var(--font-mono); color: #c99bff; letter-spacing: .06em; text-transform: uppercase; }
.target-tag { display: block; font: 500 10px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.vhead { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; }
.vhead .vname { font-weight: 500; }
.vthumb { width: 100%; max-width: 220px; aspect-ratio: 4 / 3; height: auto; border-radius: 8px; outline: 1px solid var(--line-2); margin-top: var(--s-2); display: block; background: var(--screen-black); cursor: pointer; }
.stages { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: 2px; font-size: 13px; color: var(--ink-3); }
.stages li { display: flex; gap: var(--s-2); align-items: baseline; }
.stages li::before { content: "✓"; color: var(--ok); width: 1em; flex: none; }
.stages li.warn::before { content: "!"; color: var(--warn); }
.stages li.error::before { content: "×"; color: var(--err); }
.stages li.active { color: var(--ink); }
.stages li.active::before { content: "›"; color: #c99bff; }
details.how { margin-top: 6px; }
details.how summary { cursor: pointer; color: var(--ink-3); font-size: 13px; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.how summary::-webkit-details-marker { display: none; }
details.how summary::before { content: "✓"; color: var(--ok); }
details.how summary::after { content: "⌄"; }
.working { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-2); font-size: var(--text-sm); }
.working .bar { flex: 1; max-width: 160px; height: 3px; border-radius: 2px; background: var(--bg-5); overflow: hidden; position: relative; }
.working .bar::after { content: ""; position: absolute; inset: 0; width: 30%; background: var(--grad); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .working .bar::after { animation: none; width: 100%; opacity: .5; } }

/* variants (shown in the chat box) */
.variants { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); margin-top: var(--s-3); }
.variant { display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--ink); text-align: left; cursor: pointer; font: 500 12px var(--font-sans); transition: border-color var(--dur); }
.variant:hover, .variant:focus-visible { border-color: var(--pink); }
.variant img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--screen-black); }
.variant .use { font: 500 10px var(--font-mono); color: var(--pink); letter-spacing: .06em; text-transform: uppercase; }
.variant-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-3); }

/* composer */
.composer { display: flex; flex-direction: column; gap: var(--s-3); overflow-y: auto; min-height: 0; flex: none; max-height: 52vh; padding: 2px; }
.chatbox.open .composer { max-height: 36vh; }
.composer .q { font-weight: 600; font-size: var(--text-base); margin: 0 4px; }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); margin: 0 4px; }
.step-head .q { margin: 0; }
.progress { display: flex; gap: 3px; }
.progress { flex: none; }
.progress span { width: 10px; height: 4px; border-radius: 2px; background: var(--bg-5); }
.progress span.done { background: var(--purple); }
.progress span.now { background: var(--pink); }
.progress span.jump { cursor: pointer; box-shadow: 0 0 0 4px transparent; }   /* an answered question: tap to go back */
.progress span.jump:hover { background: #c99bff; }
/* after the questions: the answers so far, tap one to change it */
.answers-row { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.answers-row::-webkit-scrollbar { display: none; }
.answers-row .group-label { margin: 0 4px 0 4px; flex: none; }
.answers-row .edit-chip { flex: none; white-space: nowrap; }
.edit-chip .k { font: 500 10px var(--font-mono); color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.group-label { font: 500 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 4px var(--s-2); }
.chip-set { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 38px; padding: 0 var(--s-4); border-radius: var(--radius-pill); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--ink); font: 500 var(--text-sm) var(--font-sans); cursor: pointer; transition: background var(--dur), border-color var(--dur);
  display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.chip:hover { border-color: var(--line-3); }
.chip[aria-pressed="true"] { background: var(--purple-soft); border-color: var(--purple); }
.chip-decide { border-style: dashed; color: var(--ink-2); }
.chip-decide[aria-pressed="true"] { color: var(--ink); }
.chip-suggest { background: var(--bg-2); }
.chip-suggest:hover { border-color: var(--purple); }
.suggest-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.swatch { display: inline-flex; }
.swatch i { width: 10px; height: 16px; display: block; }
.swatch i:first-child { border-radius: 4px 0 0 4px; } .swatch i:last-child { border-radius: 0 4px 4px 0; }
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: 136px; gap: var(--s-2); overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.gal { display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--ink); font: 500 12px var(--font-sans); cursor: pointer; text-align: left; }
.gal img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--screen-black); }
.gal[aria-pressed="true"] { border-color: var(--pink); box-shadow: 0 0 0 3px #ff5ea826; }
.input-row { display: flex; gap: var(--s-2); align-items: flex-end; min-height: 56px; padding: 8px 8px 8px 16px; border-radius: 18px;
  background: var(--bg-3); border: 1px solid var(--line-2); transition: border-color var(--dur); }
.input-row:focus-within { border-color: #9b3dff88; }
.input { flex: 1; width: 100%; min-height: 40px; max-height: 160px; padding: 9px 0; border: 0; background: transparent;
  color: var(--ink); font: 400 var(--text-md)/1.45 var(--font-sans); resize: none; }
.input:focus { outline: none; }
.input::placeholder { color: var(--ink-3); }
.send { width: 40px; height: 40px; border-radius: var(--radius-pill); border: 0; background: var(--ink); color: #0b0a0f; transition: box-shadow var(--dur); display: grid; place-items: center; cursor: pointer; flex: none; }
.send svg { stroke-width: 2.4; }
.label { display: block; font-weight: 500; font-size: var(--text-sm); margin: 0 4px var(--s-1); }
.sub-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: space-between; align-items: center; }
.counter { font: 400 11px var(--font-mono); color: var(--ink-3); margin-right: 4px; }
.target-chip { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 32px; padding: 0 4px 0 var(--s-3); border-radius: var(--radius-pill);
  background: #ff5ea81f; border: 1px solid #ff5ea888; font: 500 var(--text-sm) var(--font-sans); align-self: flex-start; }
.target-chip button { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 18px; width: 28px; height: 28px; }
.file { font: 400 var(--text-sm) var(--font-sans); color: var(--ink-2); }
.logo-thumb { max-width: 80px; max-height: 80px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-4); }

/* ------------------------------------------------------------------ history drawer, submissions, modal, toast */
.drawer { position: fixed; top: var(--top-h); right: 0; bottom: 0; width: min(400px, 100vw); z-index: 8; background: var(--bg-2); border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow); padding: var(--s-5); overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.versions { list-style: none; padding: 0; margin: var(--s-5) 0 0; display: flex; flex-direction: column; gap: var(--s-3); }
.ver { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-3); padding: var(--s-3); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-3); }
.ver.current { border-color: #9b3dff88; background: #9b3dff12; }
.ver img { width: 96px; height: 72px; border-radius: 6px; background: var(--screen-black); }
.ver .vtitle { font-weight: 500; font-size: var(--text-sm); overflow-wrap: anywhere; }
.ver .vmeta { color: var(--ink-3); font-size: 12px; }
.ver .row { margin-top: var(--s-2); }
.ver .btn-sm { min-height: 32px; padding: 0 var(--s-3); }
.ver input { width: 100%; min-height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-4); color: var(--ink); padding: 0 var(--s-2); font: inherit; }
.pane-subs { flex: 1; display: flex; justify-content: center; padding: var(--s-7) var(--s-4); }
.subs-inner { width: 100%; max-width: 640px; }
.subs { list-style: none; padding: 0; margin: var(--s-5) 0; display: flex; flex-direction: column; gap: var(--s-3); }
.sub { display: flex; gap: var(--s-4); align-items: center; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); }
.sub img { width: 112px; height: auto; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--screen-black); }
.sub .meta { flex: 1; min-width: 0; }
.sub .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub .folder { font: 400 11px var(--font-mono); color: var(--ink-3); word-break: break-all; }
.empty { color: var(--ink-3); }
.modal-backdrop { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; padding: var(--s-4); z-index: 10; }
.modal { max-width: 480px; box-shadow: var(--shadow); }
.modal .vthumb { max-width: 100%; }
.mono { font-family: var(--font-mono); font-size: 12px; word-break: break-all; color: var(--ink-3); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-4); font-size: var(--text-sm); }
.keys kbd { margin: 0; justify-self: start; }
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { max-width: 520px; position: fixed; right: calc(var(--rail-w) + 24px); top: calc(var(--top-h) + 16px); z-index: 12; background: var(--bg-4); border: 1px solid var(--line-2);
  border-radius: var(--radius-pill); padding: 6px 8px 6px 18px; box-shadow: var(--shadow); font-size: var(--text-sm); display: flex; gap: var(--s-3); align-items: center; }

/* ------------------------------------------------------------------ phones: badge on top, chat as a bottom sheet */
.only-sm { display: none !important; }
@media (max-width: 899px) {
  :root { --top-h: 60px; }
  .only-sm { display: grid !important; }
  .hide-sm { display: none !important; }
  .topbar { padding: 0 var(--s-2) 0 var(--s-4); gap: 2px; }
  .brand-name { display: none; }
  .btn-primary#btn-submit { padding: 0 var(--s-4); border-radius: var(--radius-pill); }
  .start-hero { padding-top: 40px; }
  .start-sub { font-size: var(--text-base); }
  .start-gallery { grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
  .style-card { padding: 6px; font-size: 13px; }
  .style-card span { padding: 8px 2px 2px; }
  .editor { display: flex; flex-direction: column; flex: 1; height: auto; min-height: calc(100vh - var(--top-h)); padding-bottom: calc(var(--sheet-h) + 16px); }
  .canvas { order: 1; padding: var(--s-5) var(--s-5) 0; gap: var(--s-4); flex: none; }
  .stage-wrap { flex: none; min-height: 0; container-type: inline-size; }
  .device { width: 100%; }  /* phones: the whole badge, edge to edge inside the page margins */
  .compare-pair { grid-template-columns: 1fr; gap: var(--s-3); }
  .rail, .rail-resizer { display: none; }
  .under { display: flex; }
  .chatdock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; }
  .chatbox { width: 100%; max-height: 86vh; border-radius: 26px 26px 0 0; border-bottom: 0; padding: 4px var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); box-shadow: 0 -24px 60px #000c; }
  .chatbox.open { height: 86vh; }
  .composer { max-height: 46vh; }
  .composer > .hint, .composer > .q + .hint { display: none; }
  .composer .chip-set, .composer .sub-actions .row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .composer .chip-set .chip, .composer .sub-actions .btn { flex: none; }
  .composer .counter, .latest details.how { display: none; }
  .composer { gap: var(--s-2); }
  .latest .body { font-size: var(--text-sm); }
  .composer .gallery { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 40%; overflow-x: auto; }
  .variants { grid-template-columns: repeat(2, 1fr); }
  .drawer { top: 0; z-index: 11; }
  .toast { top: calc(var(--top-h) + 8px); right: 16px; left: 16px; }
  kbd { display: none; }
}

/* start screen: nothing to undo or submit yet */
.is-start #btn-undo, .is-start #btn-redo, .is-start #btn-submit { display: none; }
@media (max-width: 899px) { .is-start .brand-name { display: inline; } }

/* quieter: no scroll bars on the chat or the page (phones overlay their own) */
.composer, .shell, .start { scrollbar-width: none; }
.composer::-webkit-scrollbar, .start::-webkit-scrollbar, html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
html, body { scrollbar-width: none; }
.vhead .vname { color: var(--ink-2); font-size: var(--text-sm); }
@media (max-width: 899px) {
  /* the badge sits in the middle of the space above the sheet, not stuck to the top */
  .editor { justify-content: center; }
  /* layout options: one sideways row, so the sheet stays short and the badge stays visible */
  .variants { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 42%; overflow-x: auto; scrollbar-width: none; }
  .variants::-webkit-scrollbar { display: none; }
}

/* scroll cues: a soft fade on any edge that has more beyond it (classes set by edgeFades() in app.js), and a thin
   scroll bar on the conversation */
.log { scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
.log::-webkit-scrollbar { width: 6px; } .log::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 6px; }
.fade-y { --ft: 0px; --fb: 0px; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%); }
.fade-y.more-up { --ft: 36px; } .fade-y.more-down { --fb: 36px; }
.fade-x { --fl: 0px; --fr: 0px; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%); }
.fade-x.more-left { --fl: 40px; } .fade-x.more-right { --fr: 56px; }

.send:hover:not(:disabled) { box-shadow: 0 8px 28px -6px rgba(255, 94, 168, .55); }

/* phones: every tap target at least 44 x 44 px (WCAG 2.5.5 / Apple HIG). Where the look should stay smaller, the hit
   area grows and negative margins give the space back, so the 390 px layout doesn't move. Checked by uicheck.mjs. */
@media (max-width: 899px) {
  .topbar .icon-btn { width: 44px; height: 44px; }
  .btn-sm { min-height: 44px; }
  .menu button { min-height: 44px; }
  /* the sheet's drag handle: same 40 x 5 bar, 44 px tall hit area; the sheet's top padding and the gap below give it
     most of the room */
  .chatbox { padding-top: 0; }
  .handle { min-height: 44px; padding: 0; margin-bottom: calc(-1 * var(--s-3)); }
  .pager .icon-btn { width: 44px; height: 44px; }
  .chip { min-height: 44px; }
  .send, .bigbox .send { width: 44px; height: 44px; }
  .input-row { padding-top: 6px; padding-bottom: 6px; }
  .icon-plain { width: 44px; height: 44px; }
  .latest .expand { width: 44px; height: 44px; margin: -10px -10px -10px 0; }
  .ver .btn-sm { min-height: 44px; }
  .ver input { min-height: 44px; }
  .target-chip button { width: 44px; height: 44px; margin: -6px -4px; }
}
@media (max-width: 899px) { .edit-chip { min-height: 44px; } }      /* the answers row: 44 px tap targets on phones */

/* ---------- sign-in (v2 accounts) */
.account { display: flex; align-items: center; }
.acct-btn { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 36px; padding: 0 var(--s-3) 0 4px; border-radius: var(--radius-pill);
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.acct-btn:hover, .acct-btn:focus-visible { background: var(--bg-4); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; object-fit: cover;
  background: linear-gradient(135deg, #9b3dff, #ff5ea8); color: #fff; font: 600 11px var(--font-mono); }
.acct-menu { min-width: 260px; }
.acct-who { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.acct-who .hint { font-size: 12px; }
.send.locked { background: var(--bg-4); color: var(--ink); border: 1px solid var(--line-2); }
.send.locked svg { stroke-width: 2; }
.input-wrap { display: flex; flex-direction: column; gap: 4px; }
.lock-hint { margin: 0; font-size: 12px; color: var(--ink-2); }
.bigbox .bar .lock-hint { align-self: center; }
.start-privacy { max-width: 36rem; margin: var(--s-3) auto 0; text-align: center; font-size: 12px; }
.review-note { margin-top: 4px; font-size: var(--text-sm); color: var(--ink); }
.contact { user-select: all; }
@media (max-width: 899px) { .acct-name { display: none; } .acct-btn { padding: 0 4px; min-height: 44px; min-width: 44px; justify-content: center; } }

