/* Aura Labs — shared styling for the hub and the editor. Dark, neon, glitch-leaning. */
:root {
  --bg: #0a0a12; --panel: #14141f; --panel-2: #1b1b29; --line: #2a2a3d;
  --ink: #e8e8f0; --muted: #8a8aa3; --accent: #00e5ff; --accent-2: #ff007a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* non-blocking render indicator — a thin sliding bar across the very top */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
}
.progress.on { opacity: 1; animation: progress-slide 0.9s linear infinite; }
@keyframes progress-slide { 0% { background-position: -40% 0; } 100% { background-position: 140% 0; } }
h1 { font-size: 1.25rem; margin: 0; letter-spacing: 0.5px; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ── top bar ── */
.bar {
  display: flex; align-items: center; gap: 18px; padding: 12px 18px;
  background: linear-gradient(180deg, #12121d, #0d0d16); border-bottom: 1px solid var(--line);
}
.bar .back { color: var(--muted); font-size: 0.85rem; }
.bar-title { flex: 1; }
.bar-title p { margin: 2px 0 0; font-size: 0.82rem; }
.status { font-size: 0.8rem; color: var(--accent); min-width: 120px; text-align: right; }
.live-chip {
  margin-left: auto;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  max-width: min(42vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-chip[data-rec="1"] {
  color: #ff6b8a;
  border-color: color-mix(in srgb, #ff6b8a 55%, transparent);
}
.vcam-status {
  font-size: 0.78rem;
  opacity: 0.75;
  cursor: default;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vcam-status[title]:not([title=""]) { cursor: pointer; text-decoration: underline dotted; }
.btn.live-on { border-color: var(--accent); color: var(--accent); }

/* ── buttons / inputs ── */
.btn, .icon, select {
  font: inherit; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.accent { background: linear-gradient(135deg, var(--accent), #0098b3); color: #00121a; border: 0; font-weight: 600; }
.btn.ghost { background: transparent; }
.icon { padding: 4px 8px; line-height: 1; }
select { padding: 7px 10px; }

/* ── editor layout ── */
.editor { display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .group { display: inline-flex; gap: 6px; align-items: center; }
.gen-color { width: 30px; height: 34px; padding: 0; border: 1px solid var(--line); background: none; border-radius: 6px; cursor: pointer; }
.gen-dim { width: 62px; }
.export-px-hint { font-size: 0.72rem; white-space: nowrap; align-self: center; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.export-size-group { flex-wrap: wrap; }
.gen-x { color: var(--muted); font-size: 0.85rem; }
.toolbar .spacer { flex: 1; }
.staff-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.staff-account[hidden] { display: none; }
.staff-account .muted { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staff-admin-add {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 10px;
  align-items: end;
  padding: 0 4px 12px;
}
.staff-table select { min-width: 110px; }
/* export controls flow inline in the toolbar on desktop (the wrapper is transparent); on mobile they
   collapse into the "Export ▾" sheet (see the media query). */
.export-group { display: contents; }
#btn-export-menu { display: none; }

/* ── vector (SVG) trace options — right side drawer ── */
.vec-wrap { display: inline-flex; gap: 6px; align-items: center; }
.vec-drawer-backdrop {
  position: fixed; inset: 0; z-index: 69;
  background: rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.vec-drawer-backdrop.open {
  opacity: 1; pointer-events: auto;
}
.vec-drawer-backdrop[hidden] { display: none; }
.vec-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: 300px;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0,0,0,0.45);
  display: flex; flex-direction: column; gap: 0;
  transform: translateX(100%); transition: transform 0.22s ease;
  padding: 0;
}
.vec-panel.open { transform: translateX(0); }
.vec-panel[hidden] { display: none; }
.vec-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.vec-drawer-head h2 { margin: 0; }
.vec-drawer-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0;
}
.vec-row, .vec-slide { display: grid; align-items: center; gap: 8px; }
.vec-row { grid-template-columns: 72px 1fr; }
.vec-slide { grid-template-columns: 72px 1fr 28px; }
.vec-row label, .vec-slide label { font-size: 0.78rem; color: var(--muted); }
.vec-row select { width: 100%; padding: 5px 8px; font-size: 0.82rem; }
.vec-slide input[type=range] { width: 100%; accent-color: var(--accent); }
.vec-val { font-size: 0.78rem; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.vec-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.vec-actions .btn { padding: 6px 12px; }
.vec-result { font-size: 0.74rem; line-height: 1.2; margin: 6px 0 0; }
.vec-hint { font-size: 0.72rem; margin: 4px 0 0; line-height: 1.25; }

/* ── AI assist popover ── */
.ai-wrap { position: relative; }
.ai-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; width: 300px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55); display: flex; flex-direction: column; gap: 8px;
}
.ai-panel[hidden] { display: none; }
.ai-label { font-size: 0.78rem; color: var(--muted); }
.ai-input {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; resize: vertical; min-height: 54px;
}
.ai-input:focus { outline: none; border-color: var(--accent); }
.ai-actions { display: flex; align-items: center; gap: 10px; }
.ai-msg { font-size: 0.74rem; flex: 1; line-height: 1.25; }

/* trace preview shown over the canvas */
.vec-preview {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  background: #fff; border-radius: var(--radius); z-index: 5;
}
.vec-preview[hidden], .vec-preview-close[hidden] { display: none; }
.vec-preview-close {
  position: absolute; top: 8px; right: 8px; z-index: 6; width: 28px; height: 28px; line-height: 1;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  cursor: pointer; font-size: 18px;
}
/* ── account popover (top-right of the header) ── */
.account { position: relative; margin-left: auto; }  /* keep it pinned right (status span removed) */
#account-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.acct-ico { display: none; }   /* desktop shows the text label; mobile swaps to this icon */

/* ── transient status toast (replaces the old header status text) ── */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 200;
  transform: translate(-50%, 12px); max-width: min(90vw, 460px); padding: 9px 16px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.55); font-size: 0.85rem; text-align: center; line-height: 1.3;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Publish lens modal (WKWebView-safe — no window.prompt) */
.modal {
  position: fixed; inset: 0; z-index: 210;
  display: grid; place-items: center;
  background: color-mix(in srgb, #000 55%, transparent);
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
  overflow: auto;
  align-content: center;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
}
.modal-card-tall {
  width: min(560px, 100%);
  max-height: min(92vh, 900px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-card-head {
  flex: 0 0 auto;
  padding: 18px 18px 0;
}
.modal-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 18px 12px;
  -webkit-overflow-scrolling: touch;
}
.modal-card h2,
.modal-card-head h2 {
  margin: 0 0 6px; text-transform: none; letter-spacing: 0;
  font-size: 1.05rem; color: var(--ink);
}
.modal-field {
  display: flex; flex-direction: column; gap: 6px;
  margin: 12px 0; font-size: 0.85rem; color: var(--muted);
}
.modal-field input {
  font: inherit; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.modal-check {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 10px 0 4px; font-size: 0.88rem; color: var(--ink); cursor: pointer;
}
.modal-check input { margin-top: 3px; }
.modal-geo-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 8px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.modal-geo-map-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 4px;
}
.modal-geo-place {
  grid-column: 1 / -1;
  margin: 0 0 4px;
}
.modal-geo-fields .modal-field:last-child { grid-column: 1 / -1; }
.modal-geo-fields[hidden] { display: none !important; }
.modal-warn, .modal-error { font-size: 0.82rem; margin: 10px 0 0; }
.modal-warn { color: #ffcc66; }
.modal-error { color: #ff6b8a; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.catalog-modal { align-items: start; padding: 28px 18px; }
.catalog-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  padding: 20px 20px 16px;
}
.catalog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.catalog-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.catalog-search { margin: 12px 0 8px; }
.catalog-body { min-height: 180px; overflow: auto; }
.catalog-table-wrap { overflow: auto; max-height: min(56vh, 520px); border: 1px solid var(--line); border-radius: 8px; }
.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.catalog-table th, .catalog-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.catalog-table th {
  position: sticky; top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.catalog-table tbody tr:last-child td { border-bottom: 0; }
.catalog-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.catalog-title { font-weight: 600; }
.catalog-slug { color: var(--muted); font-size: 0.78rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.pill-member {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.catalog-empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 48px 16px;
}
.catalog-empty .btn { margin-top: 8px; }
.catalog-skel { display: grid; gap: 10px; padding: 8px 0; }
.catalog-skel-row {
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2));
  background-size: 200% 100%;
  animation: catalog-shimmer 1.2s ease-in-out infinite;
}
@keyframes catalog-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; width: 300px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.6); display: flex; flex-direction: column; gap: 10px; text-align: left;
}
.account-menu[hidden] { display: none; }
.acct-tabs { display: flex; gap: 6px; }
.acct-tab { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 7px; padding: 6px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.acct-tab.active { color: var(--ink); border-color: var(--accent); }
.acct-form { display: flex; flex-direction: column; gap: 8px; }
.acct-form[hidden] { display: none; }
.acct-form input {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; width: 100%; }
.acct-form input:focus { outline: none; border-color: var(--accent); }
.acct-note { font-size: 0.72rem; line-height: 1.35; margin: 2px 0 0; }
.acct-who { font-size: 0.85rem; color: var(--muted); }
.acct-who strong { color: var(--ink); }
.acct-recipes-head { display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 2px; }
.recipe-list { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.recipe-item { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 8px; }
.recipe-item .r-name { flex: 1; font-size: 0.82rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-item .r-name:hover { color: var(--accent); }
.recipe-item .r-del { color: var(--muted); cursor: pointer; background: none; border: 0; font-size: 15px; line-height: 1; padding: 2px 4px; }
.recipe-item .r-del:hover { color: var(--accent-2); }
.recipe-empty { font-size: 0.78rem; color: var(--muted); padding: 4px 2px; }
.acct-msg { font-size: 0.76rem; margin: 0; min-height: 1em; }
.acct-msg.err { color: var(--accent-2); }
.acct-msg.ok { color: var(--accent); }
.invite-code { font-family: ui-monospace, "SF Mono", monospace; background: var(--panel); border: 1px dashed var(--line);
  border-radius: 6px; padding: 5px 8px; user-select: all; word-break: break-all; font-size: 0.8rem; display: block; }
.account-menu .btn { width: 100%; }
.work { display: grid; grid-template-columns: 240px 1fr 280px; gap: 0; flex: 1; min-height: 0; }
.left, .right { padding: 16px; overflow-y: auto; }
.left { border-right: 1px solid var(--line); background: var(--panel); }
.right { border-left: 1px solid var(--line); background: var(--panel); }
.right-head { display: flex; align-items: center; justify-content: space-between; }
.preset-meta {
  margin: 4px 0 10px; padding: 10px 12px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 0.82rem;
}
.preset-meta .preset-story { margin: 0 0 6px; color: var(--ink); }
.preset-meta .preset-spine,
.preset-meta .preset-edition { margin: 0; font-size: 0.75rem; }
.preset-meta .preset-spine + .preset-edition { margin-top: 4px; }
.layer-name.spine-layer { color: var(--accent); }
.param.spine-param .param-label { color: var(--accent); }
.param.spine-param { outline: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 6px; padding: 2px 4px; margin: 0 -4px; }
.edition-seed-group #edition-seed { width: 72px; }

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip-thumb { width: 100%; aspect-ratio: 1; border-radius: 5px; display: block; }
.chip-name { font-size: 0.68rem; line-height: 1.15; text-align: center; color: var(--muted); word-break: break-word; }
.chip:hover .chip-name { color: var(--accent); }

/* ── stage / canvas ── */
.stage {
  display: flex; align-items: center; justify-content: center; padding: 22px;
  background:
    radial-gradient(circle at 50% 40%, #15151f, #0a0a12),
    repeating-linear-gradient(45deg, #0d0d16 0 12px, #0b0b14 12px 24px);
  min-height: 0;
}
.stage.drag { outline: 2px dashed var(--accent); outline-offset: -10px; }
.canvas-wrap { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
.canvas-wrap[hidden] { display: none; }
.canvas-wrap.masking { cursor: grab; }
.canvas-wrap.masking:active { cursor: grabbing; }
.canvas-wrap.drawing { cursor: crosshair; }
.canvas-stack { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
#canvas { display: block; max-width: 100%; max-height: 74vh; border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: var(--radius); }

/* stage HUD — fullscreen / live controls over the preview */
.stage-hud {
  position: absolute; top: 8px; right: 8px; z-index: 8;
  display: flex; align-items: center; gap: 6px; pointer-events: none;
}
.stage-hud .stage-hud-btn,
.stage-hud .fs-live-chip { pointer-events: auto; }
.stage-hud-btn {
  font-size: 0.72rem; padding: 5px 10px;
  background: rgba(18, 18, 28, 0.82); backdrop-filter: blur(6px);
}
.fs-live-chip {
  margin-left: 0; max-width: min(50vw, 320px);
  background: rgba(18, 18, 28, 0.82); backdrop-filter: blur(6px);
}
.fs-live-chip[hidden],
#btn-fs-record[hidden] { display: none; }

/* element fullscreen — cover the whole viewport (crop edges; do not change bitmap size) */
.canvas-wrap:fullscreen,
.canvas-wrap:-webkit-full-screen,
.canvas-wrap.is-stage-fs {
  width: 100%; height: 100%; max-width: none;
  display: flex; align-items: center; justify-content: center;
  background: #000; padding: 0; box-sizing: border-box;
  overflow: hidden;
}
/* WKWebView has no Fullscreen API — fixed overlay covers the webview */
.canvas-wrap.is-stage-fs {
  position: fixed;
  inset: 0;
  z-index: 10000;
}
html.stage-fs-active,
html.stage-fs-active body.editor {
  overflow: hidden;
}
.canvas-wrap:fullscreen .canvas-stack,
.canvas-wrap:-webkit-full-screen .canvas-stack,
.canvas-wrap.is-stage-fs .canvas-stack {
  position: relative;
  flex: 0 0 auto;
  max-width: none;
  max-height: none;
}
.canvas-wrap:fullscreen #canvas,
.canvas-wrap:-webkit-full-screen #canvas,
.canvas-wrap.is-stage-fs #canvas {
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}
.canvas-wrap:fullscreen #overlay,
.canvas-wrap:-webkit-full-screen #overlay,
.canvas-wrap.is-stage-fs #overlay {
  border-radius: 0;
}
.canvas-wrap:fullscreen .stage-hud,
.canvas-wrap:-webkit-full-screen .stage-hud,
.canvas-wrap.is-stage-fs .stage-hud {
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
}
.canvas-wrap:fullscreen .vec-preview-close,
.canvas-wrap:-webkit-full-screen .vec-preview-close,
.canvas-wrap.is-stage-fs .vec-preview-close {
  top: 8px;
  left: 8px;
  right: auto;
}

.empty {
  color: var(--muted); text-align: center;
  max-width: 360px; padding: 36px 28px; margin: 12px;
  border: 2px dashed var(--line); border-radius: 14px;
  cursor: pointer; user-select: none;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.empty:hover, .empty:focus-visible {
  border-color: var(--accent); color: var(--ink);
  background: rgba(0, 229, 255, 0.04); outline: none;
}
.empty[hidden] { display: none; }
.empty strong { color: var(--ink); }

/* ── layer cards ── */
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.layer { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.layer.off { opacity: 0.5; }
.layer.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mask-hint { font-size: 0.72rem; margin: 4px 0 0; }
.layer-head { display: flex; align-items: center; gap: 8px; }
.layer-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.layer-tools { display: inline-flex; gap: 2px; }
.param { display: grid; grid-template-columns: 70px 1fr 34px; align-items: center; gap: 8px; margin-top: 8px; }
.param-label { font-size: 0.78rem; color: var(--muted); }
.param-val { font-size: 0.78rem; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.param input[type=range] { width: 100%; accent-color: var(--accent); }
.param input[type=color] { width: 100%; height: 26px; padding: 0; border: 1px solid var(--line); background: none; border-radius: 6px; }
.param select { grid-column: 2 / 4; }

/* per-layer mix (opacity + blend) */
.param.mix { display: flex; align-items: center; gap: 8px; }
.param.mix .param-label { flex: 0 0 32px; }
.opacity-ctl { flex: 1; display: flex; align-items: center; gap: 6px; }
.opacity-ctl input[type=range] { flex: 1; accent-color: var(--accent); }
.param.mix select { flex: 0 0 96px; padding: 5px 6px; font-size: 0.8rem; }

/* disabled toolbar buttons (undo/redo) */
.icon:disabled, .btn:disabled { opacity: 0.35; cursor: default; }
.icon:disabled:hover, .btn:disabled:hover { border-color: var(--line); color: var(--ink); }

/* ── hub ── */
.hub-main { max-width: 920px; margin: 0 auto; padding: 36px 22px 64px; }
.lede { font-size: 1.15rem; color: var(--ink); margin: 0 0 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; color: var(--ink); transition: transform 0.1s, border-color 0.1s; }
.card:hover { transform: translateY(-3px); text-decoration: none; }
.card h2 { color: var(--ink); font-size: 1.2rem; text-transform: none; letter-spacing: 0; margin-bottom: 8px; }
.card p { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }
.card .go { color: var(--accent); font-weight: 600; }
.card.glitch:hover { border-color: var(--accent-2); }
.card.glitch .go { color: var(--accent-2); }
.card.chroma:hover { border-color: #00e5ff; }
.card.mirror:hover { border-color: #b388ff; }
.card.mirror .go { color: #b388ff; }
.hub .small { margin-top: 28px; }

/* ── mobile Effects/Layers tab bar (only shown in the mobile layout) ── */
.mobile-tabs { display: none; }
.mtab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-size: 0.92rem; padding: 12px; cursor: pointer; }
.mtab.active { color: var(--ink); border-bottom-color: var(--accent); }

@media (max-width: 820px) {
  /* fill the viewport so the canvas + active panel get real space (dvh handles the URL bar) */
  .editor { height: 100dvh; }

  /* compact header — ‹Labs + live status + account is enough; the title block is redundant here */
  .bar { gap: 10px; padding: 8px 12px; }
  .bar-title { display: none; }
  .bar .back { white-space: nowrap; flex: 0 0 auto; }
  .status { min-width: 0; flex: 1 1 auto; font-size: 0.78rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* account button becomes a person icon (accent when signed in); text label is desktop-only */
  #account-btn { flex: 0 0 auto; padding: 9px 11px; min-height: 40px; }
  #account-btn .acct-ico { display: block; }
  #account-btn #acct-label { display: none; }
  #account-btn.authed { color: var(--accent); border-color: var(--accent); }

  /* toolbar: one swipeable row instead of wrapping into a wall */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding: 8px 12px; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > *, .toolbar .group { flex: 0 0 auto; }
  .toolbar .spacer { display: none; }
  .toolbar .btn, .toolbar select, .toolbar .icon { min-height: 40px; } /* bigger tap targets */

  /* "Export ▾" pinned to the right edge of the scrolling toolbar — always one tap, no swiping.
     Flush to the right (no gap) with an opaque bg + left fade so scrolled controls don't peek past it. */
  #btn-export-menu { display: inline-flex; align-items: center; position: sticky; right: 0; z-index: 3;
    flex: 0 0 auto; background: var(--panel-2);
    box-shadow: -14px 0 14px -6px var(--bg), 12px 0 0 12px var(--panel-2); }
  .export-group { display: none; }
  .export-group.open {
    display: flex; flex-direction: column; gap: 8px; position: fixed; top: 60px; left: 8px; right: 8px; z-index: 66;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
    box-shadow: 0 14px 44px rgba(0,0,0,0.6); max-height: calc(100dvh - 76px); overflow-y: auto;
  }
  .export-group.open > *, .export-group.open .btn, .export-group.open select { width: 100%; }
  .export-group.open .vec-wrap { display: flex; gap: 8px; position: static; flex-wrap: wrap; }
  .export-group.open #btn-svg, .export-group.open #btn-pdf { flex: 1; }
  .export-group.open #btn-vec-opts { width: auto; flex: 0 0 auto; }

  /* work area is a vertical stack: canvas, tab bar, then the active panel */
  .work { display: flex; flex-direction: column; min-height: 0; }
  .stage { order: 0; flex: 0 0 auto; padding: 10px; }
  #canvas { max-height: 40vh; }
  .mobile-tabs { display: flex; order: 1; border-bottom: 1px solid var(--line); background: var(--panel); }
  .left, .right { order: 2; flex: 1 1 auto; min-height: 0; border: 0; border-top: 1px solid var(--line); }
  .right { display: none; }
  body.mtab-layers .left { display: none; }
  body.mtab-layers .right { display: block; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }

  /* account / AI stay as floating sheets; vec-panel is a full-height drawer */
  .account-menu, .ai-panel {
    position: fixed; top: 60px; left: 8px; right: 8px; bottom: auto; width: auto; z-index: 82;
    max-height: calc(100dvh - 76px); overflow-y: auto;
  }
  .vec-panel {
    width: min(100vw, 360px); z-index: 83;
  }
  .vec-drawer-backdrop { z-index: 82; }
}
