/* ─── Webspinner Studio — v0.2.6 ─────────────────────────────────────
   Persistent canvas (splash → stage with chat panel + ambient).
   Modals overlay the canvas with semi-transparent backdrop, never
   hide it. Chat panel is the user's lifeline — always visible. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #000;
  --bg-void: #020c1a;
  --cyan: #00e5ff;
  --cyan-soft: rgba(0, 229, 255, 0.65);
  --cyan-dim: rgba(0, 229, 255, 0.3);
  --cyan-ghost: rgba(0, 229, 255, 0.12);
  --gold: #ffd44f;
  --ice: #c8eeff;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Apple Garamond", serif;
  --mono: "Courier New", ui-monospace, monospace;
  --beat: 800ms;
  --chat-width: clamp(320px, 30vw, 460px);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--cyan);
  font-family: var(--mono);
  overflow: hidden;
  user-select: none;
  cursor: default;
}

.layer {
  position: fixed; inset: 0;
  transition: opacity var(--beat) ease-in-out;
}
[hidden] { display: none !important; }

/* ─── SPLASH ─────────────────────────────────────────────────────── */

#splash {
  z-index: 90;
  background: radial-gradient(ellipse at 50% 50%, var(--bg-void) 0%, #000 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 40px;
}
body[data-state="boot"] #splash,
body[data-state="splash"] #splash { opacity: 1; }
body[data-state="splash-fading"] #splash {
  opacity: 0; pointer-events: none;
  transition: opacity 700ms ease-in-out;
}

.splash-bg-particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 22%, rgba(0,229,255,0.35) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 78% 84%, rgba(0,229,255,0.25) 50%, transparent 50%),
    radial-gradient(1px 1px at 88% 18%, rgba(0,229,255,0.4) 50%, transparent 50%),
    radial-gradient(2px 2px at 18% 82%, rgba(0,229,255,0.2) 50%, transparent 50%),
    radial-gradient(1px 1px at 92% 56%, rgba(0,229,255,0.35) 50%, transparent 50%);
  background-size: 600px 600px, 800px 800px, 500px 500px, 700px 700px, 900px 900px;
  animation: drift 80s linear infinite;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.splash-frame {
  position: relative;
  z-index: 2;
  width: min(72vw, 1100px);
  aspect-ratio: 1672 / 941;
  max-height: 76vh;
  border: 1px solid rgba(0, 229, 255, 0.18);
  border-radius: 4px;
  box-shadow:
    0 0 80px rgba(0, 229, 255, 0.12),
    0 0 200px rgba(0, 229, 255, 0.06),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.splash-image, .splash-image picture, .splash-image img {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.splash-progress-shroud {
  position: absolute;
  left: 28%;
  right: 28%;
  bottom: 11.4%;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 229, 255, 0.25);
  transition: opacity 500ms ease-out;
}
.splash-progress-shroud::before {
  content: "";
  position: absolute; inset: 0;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.85), rgba(123, 47, 255, 0.85));
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.6);
  transition: width 220ms ease-out;
}
body[data-progress-done="true"] .splash-progress-shroud { opacity: 0; }

#splash { cursor: default; }
body[data-progress-done="true"] #splash { cursor: pointer; }
/* CTA is positioned absolutely so it's visible regardless of viewport
   size or how tall .splash-frame ends up (76vh max can push a flex
   sibling below the fold on short windows). Sits centered, near the
   bottom of the viewport, glowing. */
.splash-cta {
  position: absolute;
  bottom: 5vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}
.splash-cta-text {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-transform: uppercase;
  text-shadow:
    0 0 12px rgba(0, 229, 255, 0.95),
    0 0 28px rgba(0, 229, 255, 0.55);
  background: rgba(0, 0, 0, 0.55);
  padding: 10px 28px;
  border-radius: 2px;
  border: 1px solid var(--cyan-soft);
  animation: cta-pulse 1.4s ease-in-out infinite;
}
@keyframes cta-pulse {
  0%, 100% {
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.25), inset 0 0 12px rgba(0, 229, 255, 0.05);
    color: var(--cyan-soft);
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
    border-color: rgba(0, 229, 255, 0.35);
  }
  50% {
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.85), inset 0 0 22px rgba(0, 229, 255, 0.18);
    color: #fff;
    text-shadow: 0 0 16px rgba(0, 229, 255, 1), 0 0 36px rgba(0, 229, 255, 0.7);
    border-color: rgba(0, 229, 255, 0.95);
  }
}

@keyframes drift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  to   { background-position: 600px 0, -800px 400px, 250px -250px, -350px -350px, 450px 450px; }
}

/* ─── STAGE — persistent canvas (chat + action area) ─────────────── */

#stage {
  z-index: 80;
  background: radial-gradient(ellipse at 50% 60%, var(--bg-void) 0%, #000 75%);
  display: grid;
  grid-template-columns: var(--chat-width) 1fr;
  opacity: 0;
}
/* Once splash starts fading, stage is visible and stays visible. */
body[data-state="splash-fading"] #stage,
body[data-state="void"] #stage,
body[data-state="signin"] #stage,
body[data-state="welcome"] #stage,
body[data-state="legal"] #stage,
body[data-state="pact"] #stage,
body[data-state="breath"] #stage,
body[data-state="prelaunch"] #stage,
body[data-state="ready"] #stage,
body[data-state="error"] #stage { opacity: 1; }

.void-particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(0,229,255,0.4) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 60% 70%, rgba(0,229,255,0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 80% 20%, rgba(0,229,255,0.5) 50%, transparent 50%),
    radial-gradient(2px 2px at 35% 80%, rgba(0,229,255,0.25) 50%, transparent 50%),
    radial-gradient(1px 1px at 90% 60%, rgba(0,229,255,0.45) 50%, transparent 50%);
  background-size: 600px 600px, 800px 800px, 500px 500px, 700px 700px, 900px 900px;
  animation: drift 80s linear infinite;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

/* ─── CHAT PANEL (left, always visible) ──────────────────────────── */

.chat-panel {
  position: relative;
  z-index: 2;
  height: 100%;
  border-right: 1px solid rgba(0, 229, 255, 0.22);
  background: linear-gradient(180deg, rgba(2, 12, 26, 0.85) 0%, rgba(0, 0, 0, 0.92) 100%);
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  overflow: hidden;
}
.chat-panel-head {
  flex-shrink: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.16);
  margin-bottom: 22px;
}
.chat-panel-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.7);
}
.chat-panel-sub {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 4px;
  color: var(--cyan-dim);
  margin-top: 4px;
}

/* ─── CHAT LOG (scrollback of all utterances) ────────────────────── */

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scroll-behavior: smooth;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.18);
  border-radius: 3px;
}

/* Each utterance is its own block with breathing room between. */
.utterance {
  margin-bottom: 18px;
}
.utterance:last-child { margin-bottom: 4px; }

/* Weaver utterance — modest serif italic, ice color */
.utterance.weaver {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.65;
  color: var(--ice);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.18);
  white-space: pre-wrap;
  word-spacing: 0.04em;
  letter-spacing: 0.1px;
}

/* User utterance — monospace, cyan, prefixed with ▸ */
.utterance.user {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.4px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
  padding-left: 18px;
  position: relative;
}
.utterance.user::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--cyan-soft);
}

/* System utterance — small all-caps note, e.g. "signed in", "EULA accepted" */
.utterance.system {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--cyan-dim);
  border-left: 2px solid rgba(0, 229, 255, 0.25);
  padding-left: 10px;
}

.weaver-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 320ms ease-out, transform 320ms ease-out;
}
.weaver-word.lit {
  opacity: 1;
  transform: none;
}
.weaver-cursor {
  display: inline-block;
  width: 6px;
  height: 0.95em;
  vertical-align: -0.12em;
  background: var(--cyan);
  margin-left: 3px;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.85);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  to { visibility: hidden; }
}

/* ─── ACTION AREA (right, becomes the workflow surface post-Genesis) */

.action-area {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

/* ─── WORKFLOW SURFACE (Drawflow canvas + toolbar, post-Genesis) ── */

.workflow-surface {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 720ms ease-out, transform 720ms ease-out;
}
.workflow-surface:not([hidden]) {
  opacity: 1;
  transform: none;
}

.workflow-canvas {
  flex: 1 1 auto;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(0, 229, 255, 0.04) 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(0, 229, 255, 0.04) 40px),
    repeating-linear-gradient(90deg, transparent 0, transparent 39px, rgba(0, 229, 255, 0.04) 40px);
}

.workflow-toolbar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.55);
  border-top: 1px solid rgba(0, 229, 255, 0.18);
}
.workflow-btn {
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
  border: 1px solid var(--cyan-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
  transition: background 0.18s, color 0.18s;
}
.workflow-btn:hover {
  background: rgba(0, 229, 255, 0.18);
  color: #fff;
}
.workflow-btn-primary {
  background: rgba(0, 229, 255, 0.16);
  color: #fff;
  border-color: var(--cyan);
}
.workflow-btn-primary:hover {
  background: rgba(0, 229, 255, 0.32);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}

/* ─── DRAWFLOW STYLE OVERRIDES (Studio aesthetic) ──────────────── */

.drawflow {
  background: transparent !important;
  width: 100%;
  height: 100%;
}

/* Each node — base frame */
.drawflow .drawflow-node {
  background: rgba(2, 12, 26, 0.96) !important;
  border: 1px solid var(--cyan-soft) !important;
  border-radius: 4px !important;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.18), inset 0 0 20px rgba(0, 229, 255, 0.04) !important;
  color: var(--ice) !important;
  padding: 14px 18px !important;
  min-width: 160px;
  min-height: auto;
  font-family: var(--mono);
}

/* Node title */
.drawflow .drawflow-node .title-box {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ice);
  letter-spacing: 0.4px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.18);
  padding-bottom: 6px;
  margin-bottom: 4px;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}
.drawflow .drawflow-node .body {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan-dim);
  margin-top: 4px;
}

/* Node-kind tints (per docs/v0.3.0-workflow-surface.md visual styling) */
.drawflow .drawflow-node.trigger {
  border-color: var(--gold) !important;
  box-shadow: 0 0 30px rgba(255, 212, 79, 0.22), inset 0 0 20px rgba(255, 212, 79, 0.05) !important;
}
.drawflow .drawflow-node.trigger .title-box {
  color: var(--gold);
  border-bottom-color: rgba(255, 212, 79, 0.28);
  text-shadow: 0 0 10px rgba(255, 212, 79, 0.5);
}
.drawflow .drawflow-node.agent {
  border-color: var(--cyan-soft) !important;
}
.drawflow .drawflow-node.output {
  border-color: rgba(255, 255, 255, 0.55) !important;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.12), inset 0 0 20px rgba(0, 229, 255, 0.04) !important;
}

/* Sockets (input/output dots) */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
  background: var(--cyan) !important;
  box-shadow: 0 0 8px var(--cyan);
  border: none !important;
  width: 12px;
  height: 12px;
}
.drawflow .drawflow-node.trigger .output { background: var(--gold) !important; box-shadow: 0 0 8px var(--gold); }

/* Connection lines (SVG paths between sockets) */
.drawflow svg .connection .main-path {
  stroke: var(--cyan-soft) !important;
  stroke-width: 1.5;
  fill: none;
}
.drawflow svg .connection.selected .main-path {
  stroke: #fff !important;
  filter: drop-shadow(0 0 6px var(--cyan));
}

/* Selected node */
.drawflow .drawflow-node.selected {
  border-color: #fff !important;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.45), inset 0 0 20px rgba(0, 229, 255, 0.08) !important;
}

/* Hide Drawflow's own zoom controls — we use trackpad pinch */
.drawflow .drawflow-delete { background: rgba(255, 80, 80, 0.85) !important; color: #fff !important; }

/* ─── SPINNER POPUP (atomic mini-app overlay) ───────────────────── */

.spinner-popup-host {
  position: fixed; inset: 0;
  z-index: 180;  /* below modal-host (200), above stage (80) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 280ms ease-out;
}
.spinner-popup-host.live { opacity: 1; }
.spinner-popup-host:not(.live) { pointer-events: none; }

.spinner-popup {
  background: rgba(2, 12, 26, 0.97);
  border: 1px solid var(--cyan-soft);
  border-radius: 6px;
  padding: 22px 26px 24px;
  width: clamp(420px, 64vw, 720px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  box-shadow: 0 0 80px rgba(0, 229, 255, 0.22), inset 0 0 30px rgba(0, 229, 255, 0.04);
  font-family: var(--mono);
  color: var(--ice);
  position: relative;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform 360ms ease-out, opacity 360ms ease-out;
}
.spinner-popup-host.live .spinner-popup { transform: none; opacity: 1; }

.spinner-head {
  position: relative;
  text-align: center;
  margin: 4px 0 16px;
}
.spinner-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ice);
}
.spinner-subtitle {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 5px;
  color: var(--cyan-dim);
  text-transform: uppercase;
  margin-top: 4px;
}
.spinner-close {
  position: absolute;
  top: -2px; right: 0;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan-soft);
  width: 28px; height: 28px;
  border-radius: 14px;
  font-size: 18px; line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.spinner-close:hover { background: rgba(0, 229, 255, 0.15); color: #fff; border-color: var(--cyan); }

/* Universal progress pills — same across all Spinners */
.spinner-pills {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.spinner-pill {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 2.5px;
  color: var(--cyan-dim);
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 11px;
  background: rgba(0, 229, 255, 0.02);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.spinner-pill.done {
  color: var(--cyan-soft);
  border-color: rgba(0, 229, 255, 0.4);
  background: rgba(0, 229, 255, 0.06);
}
.spinner-pill.active {
  color: #fff;
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.18);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.spinner-body { padding: 4px 0; }

.spinner-prose {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(200, 238, 255, 0.9);
  margin-bottom: 14px;
}

.spinner-textarea {
  width: 100%;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid var(--cyan-soft);
  border-radius: 4px;
  color: var(--ice);
  caret-color: var(--cyan);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  outline: 0;
  resize: vertical;
  margin-bottom: 14px;
}
.spinner-textarea:focus { border-color: #fff; box-shadow: 0 0 14px rgba(0, 229, 255, 0.4); }
.spinner-textarea::placeholder { color: rgba(200, 238, 255, 0.3); }

.spinner-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.spinner-row-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.spinner-primary-btn,
.spinner-secondary-btn,
.spinner-back-btn,
.spinner-discard-btn,
.spinner-refine-btn,
.spinner-skip-btn,
.spinner-file-btn {
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
  border: 1px solid var(--cyan-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 9px 18px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
  transition: background 0.15s, color 0.15s;
}
.spinner-primary-btn {
  background: rgba(0, 229, 255, 0.18);
  color: #fff;
  border-color: var(--cyan);
}
.spinner-primary-btn:hover { background: rgba(0, 229, 255, 0.35); box-shadow: 0 0 16px rgba(0, 229, 255, 0.4); }
.spinner-secondary-btn:hover, .spinner-back-btn:hover, .spinner-skip-btn:hover, .spinner-refine-btn:hover { background: rgba(0, 229, 255, 0.18); color: #fff; }
.spinner-discard-btn { color: rgba(255, 140, 66, 0.85); border-color: rgba(255, 140, 66, 0.55); }
.spinner-discard-btn:hover { background: rgba(255, 140, 66, 0.18); color: #fff; border-color: rgba(255, 140, 66, 0.85); }
.spinner-back-btn { letter-spacing: 2px; padding: 8px 12px; font-size: 10px; opacity: 0.85; }

.spinner-file-btn { display: inline-flex; align-items: center; }

.spinner-source-preview {
  margin-top: 14px;
  padding: 10px;
  background: rgba(0, 229, 255, 0.03);
  border: 1px solid rgba(0, 229, 255, 0.18);
  border-radius: 4px;
  text-align: center;
}
.spinner-source-preview img { max-width: 100%; max-height: 200px; border-radius: 3px; }
.spinner-source-meta {
  margin-top: 6px;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
  text-transform: uppercase;
}

.spinner-loading {
  height: 4px;
  background: rgba(0, 229, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
  position: relative;
}
.spinner-loading-bar {
  position: absolute;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: spinner-loading-slide 1.4s ease-in-out infinite;
}
@keyframes spinner-loading-slide {
  0% { left: -30%; }
  100% { left: 100%; }
}

.spinner-prompt-display {
  background: rgba(0, 229, 255, 0.04);
  border-left: 2px solid var(--cyan-soft);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  color: rgba(200, 238, 255, 0.85);
  margin: 12px 0;
  border-radius: 0 3px 3px 0;
}
.spinner-prompt-display strong { color: var(--cyan); font-weight: normal; letter-spacing: 1px; text-transform: uppercase; font-size: 9px; margin-right: 6px; }

.spinner-result {
  margin: 12px 0;
  text-align: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 4px;
}
.spinner-result img {
  max-width: 100%;
  max-height: 380px;
  border-radius: 3px;
  display: inline-block;
}

.spinner-asset-meta {
  background: rgba(0, 229, 255, 0.04);
  border-left: 2px solid var(--cyan);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--ice);
  margin: 12px 0;
  border-radius: 0 3px 3px 0;
}
.spinner-asset-meta div { margin-bottom: 4px; }
.spinner-asset-meta strong { color: var(--cyan); font-weight: normal; }

.spinner-key-note,
.spinner-error {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--cyan-dim);
  text-align: center;
  padding: 10px;
}
.spinner-error {
  color: rgba(255, 140, 66, 0.95);
  border: 1px solid rgba(255, 140, 66, 0.45);
  border-radius: 3px;
  background: rgba(255, 140, 66, 0.06);
}
.spinner-error strong { color: #fff; }
.spinner-error button { display: block; margin: 8px auto 0; }

/* Toolbar key-config button + dialog */
.workflow-btn-key {
  margin-left: auto;
  background: rgba(255, 212, 79, 0.08);
  color: var(--gold);
  border-color: rgba(255, 212, 79, 0.55);
  text-shadow: 0 0 6px rgba(255, 212, 79, 0.5);
}
.workflow-btn-key:hover { background: rgba(255, 212, 79, 0.22); color: #fff; }

/* Assets grid (in the assets popup) */
.spinner-asset-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  background: rgba(0, 229, 255, 0.04);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 4px;
  margin-bottom: 10px;
}
.spinner-asset-card img {
  width: 96px; height: 96px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid rgba(0, 229, 255, 0.25);
  flex-shrink: 0;
}
.spinner-asset-card-meta {
  flex: 1; min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ice);
}
.spinner-asset-card-meta strong { color: #fff; font-weight: normal; letter-spacing: 1.5px; }
.spinner-asset-card-prompt {
  font-family: var(--serif);
  font-style: italic;
  color: rgba(200, 238, 255, 0.7);
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}
.spinner-asset-card-id {
  margin-top: 6px;
  color: var(--cyan-dim);
  font-size: 9px;
  letter-spacing: 2px;
}

/* ─── SIGNED-IN PILL (top-right, persistent after auth) ──────────── */

.signed-in-pill {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(2, 12, 26, 0.85);
  border: 1px solid var(--cyan-soft);
  border-radius: 22px;
  padding: 8px 16px 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--ice);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.18);
}
.signed-in-pill:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: #fff;
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.35);
}
.signed-in-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan) 0%, rgba(0, 229, 255, 0.2) 70%);
  box-shadow: 0 0 10px var(--cyan);
  flex-shrink: 0;
}
.signed-in-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ice);
  letter-spacing: 0;
}
.signed-in-tier {
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--cyan-soft);
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid rgba(0, 229, 255, 0.3);
}
.signed-in-tier:empty { display: none; padding: 0; margin: 0; border: 0; }
.signed-in-action {
  font-size: 12px;
  color: var(--cyan-dim);
  margin-left: 4px;
}

/* ─── MODAL HOST (full-viewport overlay with semi-transparent backdrop) */

.modal-host {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  opacity: 0;
  transition: opacity 320ms ease-out;
  pointer-events: none;
}
.modal-host:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  z-index: 1;
  background: rgba(2, 12, 26, 0.96);
  border: 1px solid var(--cyan-soft);
  border-radius: 6px;
  padding: 32px 38px;
  width: clamp(360px, 56vw, 580px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  box-shadow:
    0 0 80px rgba(0, 229, 255, 0.22),
    inset 0 0 30px rgba(0, 229, 255, 0.04);
  font-family: var(--mono);
  text-align: left;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform 360ms ease-out, opacity 360ms ease-out;
}
.modal-host:not([hidden]) .modal-card {
  transform: none;
  opacity: 1;
}

.modal-card::-webkit-scrollbar { width: 6px; }
.modal-card::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.18);
  border-radius: 3px;
}

/* Modal content building blocks (reused across all rituals) */
.modal-head {
  text-align: center;
  margin-bottom: 20px;
}
.modal-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  font-weight: 400;
  color: var(--ice);
  margin-bottom: 6px;
}
.modal-subtitle {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--cyan-dim);
  text-transform: uppercase;
}
.modal-body {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.65;
  color: rgba(200, 238, 255, 0.88);
  margin-bottom: 22px;
}
.modal-body p { margin-bottom: 10px; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--cyan);
}
.modal-body a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgba(0, 229, 255, 0.4);
  text-underline-offset: 3px;
}
.modal-body a:hover { color: #fff; text-decoration-color: var(--cyan); }
.modal-body code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan-soft);
}

.modal-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
  padding: 12px 14px;
  background: rgba(0, 229, 255, 0.04);
  border-left: 2px solid rgba(0, 229, 255, 0.35);
}
.modal-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(200, 238, 255, 0.9);
  line-height: 1.4;
}
.modal-check input[type=checkbox] {
  margin-top: 1px;
  accent-color: var(--cyan);
  cursor: pointer;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.modal-input {
  width: 100%;
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid var(--cyan-soft);
  border-radius: 3px;
  color: var(--ice);
  caret-color: var(--cyan);
  font-family: var(--mono);
  font-size: 14px;
  padding: 12px 16px;
  outline: 0;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}
.modal-input::placeholder { color: rgba(200, 238, 255, 0.3); }
.modal-input:focus { border-color: #fff; box-shadow: 0 0 14px rgba(0, 229, 255, 0.45); }

.modal-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.modal-row .modal-input { margin-bottom: 0; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 4px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 229, 255, 0.10);
  color: var(--cyan);
  border: 1px solid var(--cyan-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  padding: 12px 26px;
  cursor: pointer;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
  transition: background 0.18s, color 0.18s;
  min-width: 180px;
}
.primary-button:hover { background: rgba(0, 229, 255, 0.22); color: #fff; }
.primary-button:disabled {
  background: rgba(0, 229, 255, 0.04);
  color: var(--cyan-dim);
  border-color: rgba(0, 229, 255, 0.15);
  cursor: not-allowed;
  text-shadow: none;
}
.primary-button.full { width: 100%; }
.primary-button-icon {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan) 0%, rgba(0, 229, 255, 0.2) 70%);
  display: inline-block;
}

.modal-footnote {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--cyan-dim);
  text-transform: uppercase;
  text-align: center;
}
.modal-error {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #ff8c42;
  text-align: center;
}
.modal-status {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan-soft);
  text-align: center;
}
.modal-status.ok { color: var(--cyan); }
.modal-status.error { color: #ff8c42; }

/* ─── BRAND MARK ─────────────────────────────────────────────────── */

.brand-mark {
  position: fixed;
  right: 18px; bottom: 14px;
  z-index: 100;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  color: rgba(0, 229, 255, 0.4);
  pointer-events: none;
}

/* ─── DEV BAR ────────────────────────────────────────────────────── */

body[data-dev="1"] .dev-bar { display: flex; }
.dev-bar {
  position: fixed; left: 12px; bottom: 12px;
  z-index: 200;
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--cyan-dim);
  padding: 6px 10px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--cyan-soft);
}
.dev-bar code { color: var(--cyan); }
.dev-bar button {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan-soft);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  padding: 3px 7px;
  cursor: pointer;
  text-transform: uppercase;
}
.dev-bar button:hover { background: var(--cyan-ghost); color: var(--cyan); }

/* ─── small-screen fallback ─────────────────────────────────────── */
@media (max-width: 720px) {
  #stage { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
  .chat-panel { border-right: 0; border-bottom: 1px solid rgba(0, 229, 255, 0.22); }
  .modal-card { width: calc(100vw - 40px); padding: 26px 22px; }
  .signed-in-pill { top: 12px; right: 12px; padding: 6px 12px 6px 10px; }
  .signed-in-name { font-size: 12px; }
}
