:root {
  color-scheme: dark;
  --bg: #060713;
  --bg-2: #0b0d1e;
  --panel: rgba(18, 21, 38, 0.72);
  --panel-strong: rgba(27, 31, 56, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f6ff;
  --muted: #9aa3c9;
  --faint: rgba(255, 255, 255, 0.045);
  --hot: #ff4fd8;
  --cyan: #4de8ff;
  --violet: #8e6cff;
  --green: #7bffaf;
  --danger: #ff6c88;
  --grad-primary: linear-gradient(135deg, var(--cyan), var(--violet));
  --grad-talk: linear-gradient(135deg, var(--hot), var(--violet));
  --grad-accent: linear-gradient(90deg, var(--cyan), var(--hot));
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --shadow-1: 0 18px 50px rgba(0, 0, 0, 0.32);
  --shadow-2: 0 30px 90px rgba(0, 0, 0, 0.42);
  --ring: 0 0 0 3px rgba(77, 232, 255, 0.28);
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --t-fast: 140ms var(--ease);
  --t-med: 240ms var(--ease);
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

::selection { background: rgba(77, 232, 255, 0.32); color: #fff; }

:focus-visible { outline: none; box-shadow: var(--ring); }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border: 3px solid transparent; background-clip: padding-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: padding-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(77, 232, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 78% 12%, rgba(255, 79, 216, 0.18), transparent 30rem),
    linear-gradient(145deg, #050611 0%, #0d1020 48%, #050712 100%);
}

button, input, select, textarea { font: inherit; }

code { color: var(--green); }

.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(20px) saturate(1.2);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.78rem;
}

h1, h2, p { margin-top: 0; }

h1 {
  max-width: 720px;
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 5.7rem);
  line-height: 0.88;
  letter-spacing: -0.08em;
}

h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; }
h2 { margin-bottom: 16px; }

.subcopy {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.auth-card {
  width: min(320px, 100%);
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-card small,
.mcp-panel p { color: var(--muted); line-height: 1.45; }

.key-health {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.88rem;
  line-height: 1.4;
}

.key-health.healthy { color: var(--green); border-color: rgba(141, 255, 180, 0.28); }
.key-health.warning { color: var(--danger); border-color: rgba(255, 108, 136, 0.28); }

.pill {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(141, 255, 180, 0.14);
  color: var(--green);
  font-size: 0.78rem;
}

.pill.danger { background: rgba(255, 108, 136, 0.14); color: var(--danger); }

.stage {
  position: relative;
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(250px, 0.7fr) minmax(340px, 1fr);
  align-items: center;
  gap: 28px;
  margin: 24px 0;
  padding: 64px 28px 92px;
  overflow: hidden;
}

.stage-topbar {
  position: absolute;
  top: 18px;
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 2;
}

.workspace-mode {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.84rem;
}

.orb {
  position: relative;
  width: min(54vw, 330px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  transition: transform 450ms ease;
}

.orb.docked { transform: translateX(-42%); }
.stage.generating .adaptive-workspace { transform: scale(0.98); opacity: 0.82; }
.stage.generating .media-dock { transform: translateX(0); }

.orb-core,
.orb-ring {
  position: absolute;
  border-radius: 50%;
}

.orb {
  --level: 0;
}

.orb-core {
  inset: 20%;
  background:
    radial-gradient(circle at 42% 35%, white, rgba(255, 255, 255, 0.2) 18%, transparent 26%),
    conic-gradient(from 110deg, var(--cyan), var(--violet), var(--hot), var(--cyan));
  filter: blur(0.2px);
  transform: scale(calc(0.9 + var(--level) * 0.2));
  box-shadow:
    0 0 calc(40px + var(--level) * 70px) rgba(77, 232, 255, calc(0.32 + var(--level) * 0.5)),
    inset 0 0 36px rgba(255, 255, 255, 0.22);
  transition: transform 70ms linear, box-shadow 70ms linear;
}

/* Reactive halo that blooms with audio level */
.orb::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(77, 232, 255, calc(var(--level) * 0.5)), transparent 62%);
  transform: scale(calc(1 + var(--level) * 0.7));
  opacity: calc(0.25 + var(--level) * 0.75);
  transition: transform 80ms linear, opacity 80ms linear;
}

.orb-ring {
  inset: 4%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  animation: breathe 3s ease-in-out infinite;
}

.orb.listening .orb-ring { animation-duration: 0.8s; border-color: var(--cyan); }
.orb.speaking .orb-ring { animation-duration: 0.55s; border-color: var(--hot); }
.orb.speaking::after { background: radial-gradient(circle, rgba(255, 79, 216, calc(var(--level) * 0.55)), transparent 62%); }

@keyframes breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.45; }
  50% { transform: scale(1.08); opacity: 0.95; }
}

.controls {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.realtime-status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.realtime-status.ready { color: var(--green); }
.realtime-status.warning { color: var(--danger); }
.realtime-status.live { color: var(--cyan); }

.adaptive-workspace {
  min-height: 300px;
  max-height: 520px;
  overflow: auto;
  align-self: stretch;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025)), rgba(0, 0, 0, 0.16);
}

.empty-workspace {
  min-height: 268px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-workspace span {
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
}

.empty-workspace strong {
  max-width: 420px;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.workspace-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: rgba(8, 10, 21, 0.62);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  animation: msgIn 260ms var(--ease);
}

.workspace-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }

.workspace-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.workspace-card h3 { margin: 0; font-size: 1.05rem; }
.workspace-card .meta { color: var(--muted); font-size: 0.82rem; }
.workspace-card p { color: var(--muted); line-height: 1.5; }

.chart-wrap { display: grid; gap: 12px; }
.workspace-svg-chart { width: 100%; height: 150px; overflow: visible; border-radius: 16px; background: rgba(255, 255, 255, 0.035); }
.workspace-svg-chart polyline { fill: none; stroke: var(--cyan); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 10px rgba(77, 232, 255, 0.45)); }
.workspace-svg-chart path { stroke: rgba(255, 255, 255, 0.12); stroke-width: 1; }
.chart-bars { display: grid; gap: 10px; }
.chart-row { display: grid; grid-template-columns: 110px 1fr 52px; align-items: center; gap: 10px; }
.chart-label, .chart-value { color: var(--muted); font-size: 0.86rem; }
.chart-track { height: 12px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.chart-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--hot)); box-shadow: 0 0 14px rgba(77, 232, 255, 0.35); transition: width 760ms var(--ease); transition-delay: var(--delay, 0ms); }
.chart-row { transition: background var(--t-fast); border-radius: 8px; }
.chart-row:hover { background: rgba(255, 255, 255, 0.05); }
.workspace-svg-chart .chart-grid line { stroke: rgba(255, 255, 255, 0.08); stroke-width: 0.5; }
.workspace-svg-chart .chart-area { fill: rgba(77, 232, 255, 0.1); stroke: none; }

.table-scroll { max-height: 360px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 14px; }
.workspace-table { width: 100%; border-collapse: collapse; overflow: hidden; }
.workspace-table th, .workspace-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.workspace-table th { position: sticky; top: 0; z-index: 1; color: var(--text); background: #161a2e; }
.workspace-table td { color: var(--muted); }
.workspace-table tr:last-child td { border-bottom: 0; }

.checklist { display: grid; gap: 6px; padding: 0; margin: 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 11px; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 12px; transition: background var(--t-fast); }
.checklist li:hover { background: rgba(255, 255, 255, 0.045); }
.checklist li.complete { color: var(--text); }
.checklist li.complete > span:last-child { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.3); }
.check { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; border: 1.5px solid var(--line-strong); color: #061018; flex: 0 0 auto; font-size: 0.74rem; font-weight: 800; transition: background var(--t-fast), border-color var(--t-fast); }
.checklist li.complete .check { background: var(--green); border-color: transparent; box-shadow: 0 0 14px rgba(123, 255, 175, 0.35); }
.checklist-wrap { display: grid; gap: 12px; }
.checklist-progress { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.checklist-count { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.checklist-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.checklist-fill { display: block; height: 100%; border-radius: inherit; background: var(--grad-accent); transition: width 500ms var(--ease); }
.artifact-remove { margin-top: 12px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast); }
.artifact-remove:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.4); background: rgba(255, 108, 136, 0.08); }
.source-form { display: grid; gap: 12px; }
.source-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.source-preview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

.mode-toggle {
  display: flex;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
}

.mode, .button {
  border: 0;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.mode { padding: 9px 15px; background: transparent; color: var(--muted); font-weight: 600; }
.mode:hover { color: var(--text); }
.mode.active { background: rgba(255, 255, 255, 0.14); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.mode.locked { cursor: not-allowed; opacity: 0.5; }
.mode.locked:not(.active):hover { color: var(--muted); }
.mode.locked.active { opacity: 1; }

.button {
  position: relative;
  padding: 11px 17px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-weight: 600;
  overflow: hidden;
}

.button:hover { background: rgba(255, 255, 255, 0.14); border-color: var(--line-strong); transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(0.98); }
.button.primary { background: var(--grad-primary); border-color: transparent; color: #070812; font-weight: 800; box-shadow: 0 8px 24px rgba(77, 232, 255, 0.22); }
.button.primary:hover { box-shadow: 0 12px 32px rgba(142, 108, 255, 0.34); }
.button.talk { background: var(--grad-talk); border-color: transparent; font-weight: 800; min-width: 150px; box-shadow: 0 8px 24px rgba(255, 79, 216, 0.24); }
.button.talk:hover { box-shadow: 0 12px 32px rgba(255, 79, 216, 0.36); }
.button.ghost { background: transparent; color: var(--muted); }
.button.ghost:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.button.small { padding: 7px 12px; font-size: 0.86rem; }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.media-dock {
  position: absolute;
  right: 34px;
  width: min(460px, 44%);
  transition: opacity 240ms ease, transform 240ms ease;
  z-index: 4;
}

.hidden { display: none !important; }

.generating-card {
  min-height: 260px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel-strong);
  overflow: hidden;
  transform-origin: center right;
  animation: cardArrive 360ms cubic-bezier(.2, .8, .2, 1);
}

.generation-visual {
  min-height: 190px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.image-visual {
  aspect-ratio: 1;
  background:
    linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.24), transparent),
    radial-gradient(circle at 30% 25%, rgba(77, 232, 255, 0.75), transparent 36%),
    radial-gradient(circle at 78% 70%, rgba(255, 79, 216, 0.72), transparent 38%),
    #15192c;
  background-size: 220% 100%, auto, auto, auto;
  animation: shimmer 1.4s linear infinite;
}

.video-visual {
  aspect-ratio: 16 / 9;
  min-height: 0;
  background:
    linear-gradient(90deg, rgba(77, 232, 255, 0.18), transparent, rgba(255, 79, 216, 0.18)),
    radial-gradient(circle at 22% 42%, rgba(255, 255, 255, 0.18), transparent 22%),
    linear-gradient(135deg, #11162b, #070812 58%, #201535);
}

.video-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.video-frame span {
  position: absolute;
  inset: auto -20% 18%;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  animation: scanline 2.4s ease-in-out infinite;
}

.video-frame span:nth-child(2) { bottom: 44%; animation-delay: 0.35s; }
.video-frame span:nth-child(3) { bottom: 70%; animation-delay: 0.7s; }

.play-glyph {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 40px rgba(77, 232, 255, 0.24);
}

.play-glyph::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 20px;
  border-left: 18px solid rgba(255, 255, 255, 0.74);
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
}

.music-visual {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(141, 255, 180, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(77, 232, 255, 0.12), rgba(255, 79, 216, 0.1)),
    #0b0e1c;
}

.music-visual svg {
  width: min(78%, 260px);
  overflow: visible;
}

.note {
  fill: none;
  stroke: var(--green);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 18px rgba(141, 255, 180, 0.42));
  animation: notePulse 1.25s ease-in-out infinite;
}

.wave {
  fill: none;
  stroke: rgba(77, 232, 255, 0.62);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 28 16;
  animation: dashFlow 1.3s linear infinite;
}

.wave-b { stroke: rgba(255, 79, 216, 0.55); animation-duration: 1.8s; }

.tts-visual {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0c1020, #101327 48%, #070812);
}

.tts-loader { width: min(86%, 330px); display: grid; gap: 18px; }
.typing-line { display: flex; align-items: center; gap: 3px; color: var(--text); font-size: 1.1rem; }
.typing-line span { color: transparent; position: relative; min-width: 150px; }
.typing-line span::before { content: "composing voice"; position: absolute; left: 0; color: var(--text); animation: typeWords 4s steps(1) infinite; }
.typing-line i { width: 2px; height: 1.25em; background: var(--cyan); animation: blink 0.8s steps(1) infinite; }
.word-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.word-cloud span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); animation: wordFloat 2.4s ease-in-out infinite; }
.word-cloud span:nth-child(2) { animation-delay: 0.2s; }
.word-cloud span:nth-child(3) { animation-delay: 0.4s; }
.word-cloud span:nth-child(4) { animation-delay: 0.6s; }
.morph-loader { width: 54px; height: 54px; justify-self: center; border: 2px solid rgba(255,255,255,0.12); border-top-color: var(--hot); border-radius: 18px; animation: morphSpin 1.2s ease-in-out infinite; }

.diffusion-grid {
  position: absolute;
  inset: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.diffusion-grid span {
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(77, 232, 255, 0.28), rgba(255, 79, 216, 0.22));
  filter: blur(0.1px);
  animation: diffuseTile 1.8s ease-in-out infinite;
}

.diffusion-grid span:nth-child(2n) { animation-delay: 0.2s; }
.diffusion-grid span:nth-child(3n) { animation-delay: 0.45s; }

@keyframes shimmer { to { background-position: -220% 0, 0 0, 0 0, 0 0; } }

@keyframes cardArrive { from { opacity: 0; transform: translateX(18px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes scanline { 0% { transform: translateX(-20%); opacity: 0; } 35% { opacity: 1; } 100% { transform: translateX(30%); opacity: 0; } }
@keyframes notePulse { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-5px) scale(1.04); } }
@keyframes dashFlow { to { stroke-dashoffset: -44; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes typeWords { 0% { content: "composing voice"; } 25% { content: "shaping tone"; } 50% { content: "finding cadence"; } 75% { content: "warming signal"; } }
@keyframes wordFloat { 0%, 100% { transform: translateY(0); opacity: 0.62; } 50% { transform: translateY(-6px); opacity: 1; } }
@keyframes morphSpin { 0% { transform: rotate(0); border-radius: 18px; } 50% { border-radius: 50%; } 100% { transform: rotate(360deg); border-radius: 18px; } }
@keyframes diffuseTile { 0%, 100% { opacity: 0.35; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.02); } }

.grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.bottom-grid { grid-template-columns: 1fr 420px; }

.settings, .transcript-panel, .gallery-panel, .mcp-panel { padding: 22px; }

.model-status {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

label { display: grid; gap: 7px; margin-bottom: 12px; color: var(--muted); font-size: 0.9rem; font-weight: 500; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.26);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
textarea { min-height: 82px; resize: vertical; }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--bg-2); color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: rgba(77, 232, 255, 0.7); box-shadow: var(--ring); background: rgba(0, 0, 0, 0.34); }
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.32); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.transcript {
  min-height: 355px;
  max-height: 520px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.message {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 18px;
  line-height: 1.45;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.07);
  animation: msgIn 220ms var(--ease);
}

@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.message.user { justify-self: end; border-bottom-right-radius: 6px; background: rgba(77, 232, 255, 0.14); border-color: rgba(77, 232, 255, 0.22); }
.message.agent { justify-self: start; border-bottom-left-radius: 6px; background: rgba(255, 79, 216, 0.12); border-color: rgba(255, 79, 216, 0.2); }
.message.system { max-width: 100%; color: var(--muted); background: rgba(255, 255, 255, 0.035); font-size: 0.9rem; }
.message.tool {
  max-width: 100%;
  width: 100%;
  border: 1px solid rgba(77, 232, 255, 0.22);
  background: linear-gradient(135deg, rgba(77, 232, 255, 0.08), rgba(142, 108, 255, 0.08));
}

.tool-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--text);
  font-weight: 800;
}

.tool-status { color: var(--cyan); font-size: 0.82rem; }
.tool-status.queued { color: var(--muted); }
.tool-status.done { color: var(--green); }
.tool-status.error { color: var(--danger); }
.tool-detail { color: var(--muted); font-size: 0.92rem; }

.composer, .mcp-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.gallery-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}

.gallery-item:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-1); }

.gallery-item img,
.gallery-item video,
.gallery-item iframe,
.gallery-item audio { width: 100%; border-radius: 12px; }
.gallery-item iframe { height: 220px; border: 1px solid var(--line); background: white; }
.gallery-item p { margin: 8px 0; color: var(--muted); font-size: 0.88rem; }
.gallery-item a { color: var(--cyan); text-decoration: none; }
.gallery-item details { color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; }
.gallery-item summary { cursor: pointer; color: var(--text); }
.gallery-use {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.gallery-use:hover { border-color: rgba(77, 232, 255, 0.5); }

.terminal-visual {
  background: #05070d;
  color: #b8ffd2;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  padding: 16px;
}

.terminal-output { display: grid; align-content: start; gap: 6px; min-height: 100%; }
.terminal-output p { margin: 0; color: #b8ffd2; font-size: 0.86rem; line-height: 1.45; }
.terminal-cursor { width: 9px; height: 18px; background: var(--green); animation: blink 0.8s steps(1) infinite; }

.mcp-list { display: grid; gap: 10px; }
.mcp-entry { padding: 10px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }

@media (max-width: 900px) {
  .hero, .grid, .bottom-grid { grid-template-columns: 1fr; display: grid; }
  .stage { grid-template-columns: 1fr; min-height: 720px; align-content: start; padding-top: 76px; }
  .media-dock { position: static; width: calc(100% - 28px); margin: 18px auto 0; }
  .orb.docked { transform: translateY(-8%); }
  .controls { width: calc(100% - 28px); }
  .composer, .mcp-form { flex-direction: column; }
}

/* Minimal production app shell overrides */
body { overflow: hidden; }

.app-shell {
  width: min(1440px, calc(100% - 24px));
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 12px 0;
}

.app-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(290px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 22px;
  background: rgba(8, 10, 18, 0.72);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fff, var(--cyan) 24%, var(--violet) 58%, transparent 72%);
  box-shadow: 0 0 26px rgba(77, 232, 255, 0.48);
}

.brand strong { display: block; font-family: var(--font-display); font-size: 1.06rem; letter-spacing: -0.02em; }
.brand span { display: block; color: var(--muted); font-size: 0.82rem; }

.app-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.nav-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}

.nav-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.nav-button.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.account-strip {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.balance-pill {
  position: relative;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text);
  border: 1px solid rgba(141, 255, 180, 0.26);
  background: rgba(141, 255, 180, 0.1);
  font-size: 0.84rem;
  overflow: hidden;
}

.balance-pill::after,
.button.primary::after,
.orb-core::after {
  content: "";
  position: absolute;
  inset: -60% auto -60% -70%;
  width: 44%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.52), transparent);
  animation: glimmer 5.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glimmer {
  0%, 58%, 100% { translate: 0 0; opacity: 0; }
  68% { opacity: 0.85; }
  82% { translate: 520% 0; opacity: 0; }
}

.app-header .key-health {
  position: absolute;
  right: 12px;
  top: calc(100% + 8px);
  max-width: 380px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-header:hover .key-health,
.app-header:focus-within .key-health {
  opacity: 1;
  transform: translateY(0);
}

.stage.panel {
  min-height: 0;
  height: 100%;
  margin: 0;
  border-radius: 30px;
  grid-template-columns: minmax(240px, 0.62fr) minmax(360px, 1fr);
  padding: 58px 28px 82px;
  background:
    radial-gradient(circle at 24% 42%, rgba(77, 232, 255, 0.15), transparent 24rem),
    radial-gradient(circle at 74% 28%, rgba(255, 255, 255, 0.08), transparent 18rem),
    rgba(8, 10, 18, 0.64);
}

.stage-topbar { top: 16px; }

.workspace-mode {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
}

.adaptive-workspace {
  max-height: none;
  height: 100%;
  min-height: 0;
  background: rgba(255, 255, 255, 0.035);
  transition: transform 220ms ease, opacity 220ms ease, margin 220ms ease;
}

.orb { width: min(28vw, 300px); }
.orb-core { overflow: hidden; }

.stage.panel.generating {
  grid-template-columns: minmax(180px, 0.42fr) minmax(320px, 0.8fr);
}

.stage.panel.generating .adaptive-workspace {
  margin-right: min(480px, 46vw);
}

.stage.panel.generating .orb {
  width: min(22vw, 230px);
}

.stage.panel .media-dock {
  top: 50%;
  transform: translateY(-50%) translateX(14px);
}

.stage.panel.generating .media-dock {
  transform: translateY(-50%) translateX(0);
}

.stage.panel .generating-card.video-loader {
  width: min(520px, 100%);
}

.stage.panel .generating-card.music-loader,
.stage.panel .generating-card.tts-loader {
  min-height: 300px;
}

.controls {
  bottom: 42px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 8, 18, 0.76);
  backdrop-filter: blur(18px);
}

.realtime-status { bottom: 16px; }

.drawer {
  position: fixed;
  top: 84px;
  right: max(12px, calc((100vw - min(1440px, calc(100vw - 24px))) / 2 + 12px));
  bottom: 12px;
  z-index: 30;
  width: min(430px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  padding: 18px;
  opacity: 0;
  transform: translateX(20px) scale(0.985);
  pointer-events: none;
  box-shadow: var(--shadow-2);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  overflow: hidden;
}

.drawer.active {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.drawer .transcript,
.drawer .gallery,
.drawer .mcp-list {
  flex: 1 1 0;      /* basis 0: take exactly the leftover height, don't size to content */
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}
/* Never stretch/compress gallery rows to "fit" — rows are content-height and the
   grid scrolls once it overflows, so top thumbnails stay proportioned. */
.drawer .gallery { align-content: start; grid-auto-rows: max-content; }
.drawer .panel-head { flex: 0 0 auto; }

.drawer.settings { overflow: auto; }
.drawer .composer { margin-top: auto; }
.panel-actions { display: flex; gap: 8px; }

@media (max-width: 920px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .app-header { grid-template-columns: 1fr; }
  .app-nav, .account-strip { justify-content: flex-start; flex-wrap: wrap; }
  .stage.panel, .stage.panel.generating { grid-template-columns: 1fr; min-height: 760px; height: auto; padding: 72px 14px 116px; }
  .stage.panel.generating .adaptive-workspace { margin-right: 0; opacity: 1; transform: none; }
  .orb { width: min(64vw, 280px); }
  .stage.panel.generating .orb { width: min(52vw, 220px); }
  .stage.panel .media-dock {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    margin: 0;
    transform: none;
    order: 2;
  }
  .stage.panel.generating .media-dock { transform: none; }
  .adaptive-workspace { order: 3; min-height: 260px; }
  .controls { bottom: 48px; max-width: calc(100% - 18px); }
  .mode-toggle { width: 100%; justify-content: center; }
  .drawer { top: 12px; left: 12px; right: 12px; bottom: 12px; width: auto; }
}

@media (max-width: 560px) {
  .app-shell { width: calc(100% - 12px); padding: 6px 0; gap: 8px; }
  .app-header { padding: 10px; border-radius: 18px; }
  .brand span { display: none; }
  .app-nav { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .account-strip .button { padding: 8px 10px; }
  .balance-pill, .pill { font-size: 0.76rem; }
  .stage.panel { border-radius: 22px; }
  .stage-topbar { left: 12px; right: 12px; }
  .workspace-card { padding: 12px; border-radius: 18px; }
  .chart-row { grid-template-columns: 82px 1fr 42px; }
  .generating-card { padding: 12px; border-radius: 20px; }
  .generation-visual { min-height: 160px; }
  .video-visual { min-height: 0; }
}

body[data-theme="paper"] {
  color-scheme: light;
  --text: #171923;
  --muted: #667085;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(20, 24, 40, 0.12);
  --line-strong: rgba(20, 24, 40, 0.22);
  --faint: rgba(20, 24, 40, 0.04);
  background: radial-gradient(circle at 20% 0%, rgba(77, 232, 255, 0.18), transparent 34rem), linear-gradient(145deg, #f7f7fb, #eef1f8);
}

body[data-theme="obsidian"] {
  --cyan: #b6f3ff;
  --hot: #d6b0ff;
  --violet: #7c5cff;
  background: radial-gradient(circle at 50% -10%, rgba(255,255,255,0.08), transparent 30rem), #030407;
}

body[data-theme="studio"] {
  --cyan: #ffd36e;
  --hot: #ff7a59;
  --violet: #9f7aea;
  background: radial-gradient(circle at 18% 12%, rgba(255, 211, 110, 0.18), transparent 28rem), radial-gradient(circle at 80% 20%, rgba(159, 122, 234, 0.16), transparent 30rem), #0b0b10;
}

body[data-layout="canvas"] .stage.panel { grid-template-columns: minmax(180px, 0.44fr) minmax(440px, 1.2fr); }
body[data-layout="canvas"] .orb { width: min(22vw, 240px); }
body[data-layout="compact"] .stage.panel { padding-top: 50px; padding-bottom: 76px; }
body[data-layout="compact"] .adaptive-workspace { padding: 10px; gap: 10px; }
body[data-layout="compact"] .workspace-card { padding: 12px; }

/* ============================================================
   Overhaul layer: drawers, gallery viewer, workspace artifacts
   ============================================================ */

/* Drawer scrim — click-outside / ESC closes; see openDrawer/closeDrawers */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(4, 5, 12, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
.drawer-scrim.active { opacity: 1; pointer-events: auto; }

.drawer.active { animation: drawerIn 240ms var(--ease); }
@keyframes drawerIn { from { opacity: 0; transform: translateX(26px) scale(0.97); } to { opacity: 1; transform: none; } }

/* Gallery card structure */
.gallery-item { display: flex; flex-direction: column; gap: 8px; }
.gallery-item > img, .gallery-item > video, .gallery-item > audio { width: 100%; border-radius: 12px; }
.gallery-caption { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; text-transform: capitalize; }
.gallery-actions { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.gallery-download { flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--cyan); text-decoration: none; font-size: 0.84rem; transition: border-color var(--t-fast), background var(--t-fast); }
.gallery-download:hover { border-color: rgba(77, 232, 255, 0.5); background: rgba(77, 232, 255, 0.08); }
.gallery-use { flex: 1; margin: 0; }

/* Project source/preview viewer (untrusted model HTML) */
.project-viewer { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, 0.3); }
.viewer-tabs { display: flex; align-items: center; gap: 6px; padding: 7px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.viewer-tab { border: 0; padding: 6px 11px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: color var(--t-fast), background var(--t-fast); }
.viewer-tab:hover { color: var(--text); }
.viewer-tab.active { color: var(--text); background: rgba(255, 255, 255, 0.12); }
.viewer-copy { margin-left: auto; border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.78rem; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast); }
.viewer-copy:hover { color: var(--text); border-color: var(--line-strong); }
.viewer-stage { height: 240px; overflow: auto; }
.viewer-stage .project-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.code-view { margin: 0; padding: 14px; height: 100%; overflow: auto; color: #c9d6ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.78rem; line-height: 1.55; white-space: pre; tab-size: 2; }
.code-view code { color: inherit; }

/* Workspace: card summary, metrics, code, note */
.card-summary { margin: -4px 0 14px; }
.note-body { display: grid; gap: 10px; }
.note-body p { margin: 0; color: var(--text); opacity: 0.92; line-height: 1.55; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.metric-tile { display: grid; gap: 3px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)); animation: msgIn 280ms var(--ease); }
.metric-tile strong { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; letter-spacing: -0.02em; }
.metric-label { color: var(--muted); font-size: 0.82rem; }
.metric-note { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }
.metric-note.up { color: var(--green); }
.metric-note.down { color: var(--danger); }

.code-block { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, 0.32); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.code-lang { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.12em; }
.code-copy { border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.78rem; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast); }
.code-copy:hover { color: var(--text); border-color: var(--line-strong); }
.code-block .code-view { max-height: 320px; }

/* Staggered entrance for workspace cards */
.adaptive-workspace > .workspace-card:nth-child(1) { animation-delay: 0ms; }
.adaptive-workspace > .workspace-card:nth-child(2) { animation-delay: 50ms; }
.adaptive-workspace > .workspace-card:nth-child(3) { animation-delay: 100ms; }
.adaptive-workspace > .workspace-card:nth-child(n+4) { animation-delay: 140ms; }

/* Markdown-rendered agent messages */
.message .md { display: grid; gap: 9px; }
.md-p { margin: 0; line-height: 1.55; }
.md-h { margin: 2px 0; font-size: 1.02rem; letter-spacing: -0.01em; }
.md-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.md-list li { line-height: 1.5; }
.md-code { padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.32); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.86em; }
.md a { color: var(--cyan); text-underline-offset: 2px; }
.md a:hover { text-decoration: underline; }
.message .code-block { margin: 2px 0; }
.message .code-block .code-view { max-height: 280px; }

/* Volume slider in settings */
input[type="range"] { appearance: none; -webkit-appearance: none; padding: 0; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); cursor: pointer; }
input[type="range"]:hover { background: rgba(255, 255, 255, 0.2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(77, 232, 255, 0.5); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(77, 232, 255, 0.5); cursor: pointer; }

#soundToggle { font-size: 1rem; line-height: 1; padding: 8px 10px; }

/* ---- Containment / bounding: stop wide content (code, long strings) from
   pushing cards past the viewport. Grid/flex children need min-width:0 to
   shrink, and scrollable code stays inside its card. ---- */
.adaptive-workspace { min-width: 0; }
.adaptive-workspace > * { min-width: 0; max-width: 100%; }
.workspace-card { min-width: 0; max-width: 100%; overflow: hidden; }
.workspace-card > * { min-width: 0; max-width: 100%; }
.code-block, .widget-view { min-width: 0; max-width: 100%; overflow: hidden; }
.code-view { max-width: 100%; overflow: auto; }
.message { min-width: 0; }
.message .md, .message .code-block, .message .code-view { max-width: 100%; }
.message, .md, .md-p, .card-summary, .note-body p, .workspace-card p, .tool-detail, .workspace-table td, .workspace-table th, .mcp-entry, .gallery-caption {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.transcript, .gallery, .mcp-list, .drawer { min-width: 0; }
.workspace-table { display: block; overflow-x: auto; }

/* Coder-generated live widget */
.widget-view { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, 0.3); }
.widget-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.widget-stage { height: 300px; overflow: auto; background: #0c1020; border-radius: 12px; }
.widget-stage .widget-frame { width: 100%; height: 100%; border: 0; background: #0c1020; display: block; color-scheme: dark; }
.widget-stage .code-view { height: 100%; max-height: none; }

/* Web-search "scanning" loader */
.search-visual { display: grid; place-items: center; background: linear-gradient(135deg, #0c1020, #101327 48%, #070812); }
.search-loader { position: relative; width: min(80%, 300px); height: 160px; }
.search-sources { position: absolute; inset: 22px 14px; display: grid; gap: 11px; align-content: center; }
.search-sources span { height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)); animation: srcPulse 1.8s ease-in-out infinite; }
.search-sources span:nth-child(1) { width: 100%; }
.search-sources span:nth-child(2) { width: 78%; animation-delay: 0.12s; }
.search-sources span:nth-child(3) { width: 62%; animation-delay: 0.24s; }
.search-sources span:nth-child(4) { width: 88%; animation-delay: 0.36s; }
.search-sources span:nth-child(5) { width: 70%; animation-delay: 0.48s; }
.search-lens { position: absolute; width: 56px; height: 56px; left: 2%; top: 16%; fill: none; stroke: var(--cyan); stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 0 12px rgba(77, 232, 255, 0.55)); animation: lensScan 2.8s ease-in-out infinite; }
.search-lens circle { fill: rgba(77, 232, 255, 0.08); }
@keyframes srcPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes lensScan { 0%, 100% { left: 2%; top: 14%; } 50% { left: 66%; top: 48%; } }

/* Gallery delete button */
.gallery-delete { flex: 0 0 auto; width: 34px; padding: 8px 0; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast); }
.gallery-delete:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.4); background: rgba(255, 108, 136, 0.08); }

/* Long-term memory panel */
.memory-block { display: grid; gap: 8px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.18); }
.memory-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.9rem; }
.memory-list { display: grid; gap: 6px; max-height: 180px; overflow: auto; }
.memory-empty { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.4; }
.memory-entry { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.memory-entry span { flex: 1; font-size: 0.86rem; overflow-wrap: anywhere; }
.memory-remove { flex: 0 0 auto; width: 24px; height: 24px; border: 0; border-radius: 7px; background: rgba(255, 255, 255, 0.06); color: var(--muted); cursor: pointer; transition: color var(--t-fast), background var(--t-fast); }
.memory-remove:hover { color: var(--danger); background: rgba(255, 108, 136, 0.12); }

@media (max-width: 560px) {
  .viewer-stage { height: 200px; }
  .metric-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Multi-tile generation dock (one tile per in-flight job)
   ============================================================ */
.gen-dock {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: min(78vh, 560px);
  overflow: auto;
}
.gen-dock[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.gen-dock[data-count="3"],
.gen-dock[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.gen-dock[data-count="3"] .gen-tile:first-child { grid-column: span 2; }

.gen-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-strong);
  overflow: hidden;
  animation: cardArrive 320ms var(--ease);
}
.gen-tile .generation-visual { min-height: 120px; }
.gen-dock[data-count="1"] .gen-tile .generation-visual { min-height: 190px; }
.gen-tile-tag {
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.gen-tile-status { margin: 0; color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.gen-tile.done { opacity: 0.7; }
.gen-tile.done .gen-tile-tag { background: rgba(123, 255, 175, 0.16); color: var(--green); }

/* Queued job: muted box with a glyph of what's coming */
.gen-tile.queued { opacity: 0.85; }
.queued-visual {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 10px, rgba(255, 255, 255, 0.06) 10px 20px),
    rgba(8, 10, 21, 0.6);
}
.queued-glyph svg {
  width: 56px;
  height: 56px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  animation: queuedPulse 1.8s ease-in-out infinite;
}
@keyframes queuedPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.85; } }

@media (max-width: 920px) {
  .gen-dock, .gen-dock[data-count] { grid-template-columns: 1fr; }
  .gen-dock[data-count] .gen-tile:first-child { grid-column: auto; }
}

/* Widget bar actions + saved-widgets drawer */
.widget-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-hint { color: var(--muted); font-size: 0.86rem; line-height: 1.45; margin: 4px 0 12px; }
.widget-list { display: grid; gap: 8px; min-height: 0; overflow: auto; }
.widget-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.widget-row-info { display: grid; gap: 2px; min-width: 0; flex: 1; }
.widget-row-info strong { font-size: 0.92rem; overflow-wrap: anywhere; }
.widget-row-info span { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.widget-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Adaptive workspace: real scrolling so multiple widgets coexist without overflow */
.adaptive-workspace { overflow-y: auto; overscroll-behavior: contain; }
.workspace-card.widget { overflow: hidden; }
.workspace-card.widget .widget-stage { height: clamp(240px, 42vh, 460px); resize: vertical; }

/* Config: section headers + feature toggles */
.config-section {
  margin: 18px 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--cyan);
}
.toggle-list { display: grid; gap: 8px; margin-bottom: 8px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
}
.toggle:hover { border-color: var(--line-strong); }
.toggle input { width: auto; flex: 0 0 auto; accent-color: var(--cyan); width: 18px; height: 18px; cursor: pointer; }
.toggle span { flex: 1; line-height: 1.35; }
.range-hint { margin: -6px 0 12px; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

/* Composer image attach strip */
.attach-strip { display: none; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attach-strip.active { display: flex; }
.attach-chip { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 7px;
  background: rgba(7, 8, 18, 0.78);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
}
.attach-remove:hover { background: var(--danger); }
#attachImage { font-size: 1rem; padding: 11px 13px; flex: 0 0 auto; }
.composer { align-items: stretch; }

/* Live camera preview (realtime) */
.camera-preview {
  position: absolute;
  left: 22px;
  bottom: 96px;
  width: min(200px, 36vw);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #000;
  box-shadow: var(--shadow-1);
  z-index: 5;
  transform: scaleX(-1);
}
#cameraToggle.active { color: var(--hot); border-color: rgba(255, 79, 216, 0.5); background: rgba(255, 79, 216, 0.1); }

/* Gallery lightbox overlay */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.active { display: flex; animation: msgIn 200ms var(--ease); }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(3, 4, 10, 0.82); backdrop-filter: blur(8px); }
.lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 12px;
  width: min(1100px, 100%);
  max-height: 92vh;
}
.lightbox-stage {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  max-height: 78vh;
}
.lightbox-stage img,
.lightbox-stage video {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.lightbox-stage audio { width: min(520px, 90%); }
.lightbox-text { color: var(--muted); padding: 40px; text-align: center; }
.lightbox-close { position: absolute; top: -6px; right: -6px; z-index: 2; }
.lightbox-close,
.lightbox-nav {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 10, 18, 0.7);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--line-strong); }
.lightbox-nav.prev { grid-column: 1; grid-row: 1; }
.lightbox-nav.next { grid-column: 3; grid-row: 1; }
.lightbox-meta { grid-column: 2; grid-row: 2; text-align: center; display: grid; gap: 8px; }
.lightbox-caption { margin: 0; color: var(--muted); font-size: 0.84rem; text-transform: capitalize; }
.lightbox-prompt { margin: 0; color: var(--text); font-size: 0.95rem; line-height: 1.5; overflow-wrap: anywhere; }
.lightbox-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lightbox-actions a { text-decoration: none; }
.danger-btn:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.45); background: rgba(255, 108, 136, 0.08); }
.gallery-openable { cursor: zoom-in; }

@media (max-width: 560px) {
  .camera-preview { width: 130px; bottom: 104px; left: 12px; }
  .lightbox-panel { grid-template-columns: 1fr; }
  .lightbox-nav.prev, .lightbox-nav.next { position: absolute; top: 50%; transform: translateY(-50%); grid-row: 1; }
  .lightbox-nav.prev { left: 4px; grid-column: 1; }
  .lightbox-nav.next { right: 4px; grid-column: 1; }
  .lightbox-stage { grid-column: 1; }
  .lightbox-meta { grid-column: 1; }
}

/* ============================================================
   High-quality polish layer — refined depth, edges, and motion.
   Enhancements only; no structural/layout changes.
   ============================================================ */

/* Crisper panels: a hairline top highlight reads as real glass elevation */
.panel { border-color: rgba(255, 255, 255, 0.08); }
.app-header,
.stage.panel,
.drawer.panel {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 64px);
}

/* Cards: inset top-light + smoother, springier hover lift */
.workspace-card,
.gallery-item,
.gen-tile,
.widget-row,
.metric-tile {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.workspace-card,
.gallery-item {
  transition: transform 220ms var(--ease), border-color var(--t-fast), box-shadow 220ms var(--ease), background var(--t-fast);
}
.workspace-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Widget card reads like a real mini-app window with a titlebar */
.widget-view { box-shadow: var(--shadow-1); }
.widget-bar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015));
}
.widget-bar .code-lang { color: var(--text); opacity: 0.85; font-weight: 600; letter-spacing: 0; text-transform: none; }
.widget-actions .code-copy { border-color: var(--line); }
.widget-actions .code-copy:hover { color: var(--text); border-color: rgba(77, 232, 255, 0.45); background: rgba(77, 232, 255, 0.08); }

/* Nav + drawers: active state gets a gradient underglow */
.nav-button.active { background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06)); }
.drawer .panel-head { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.drawer .panel-head h2 { margin: 0; }

/* Inputs/selects: subtle inner depth, smoother focus */
input, select, textarea { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); }
input:focus, select:focus, textarea:focus { box-shadow: var(--ring), inset 0 1px 2px rgba(0, 0, 0, 0.25); }

/* Message bubbles: tighter, with a soft edge highlight */
.message { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.message.tool { box-shadow: inset 0 1px 0 rgba(77, 232, 255, 0.12); }

/* Generation tiles: cohesive titlebar tag + gentle entrance scale */
.gen-tile { box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.gen-tile-tag { background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)); }

/* Buttons: a touch more life on press/hover */
.button.primary, .button.talk { letter-spacing: 0.01em; }
.button.ghost.small:hover { color: var(--text); }

/* Gallery media: framed, consistent aspect, zoom affordance */
.gallery-item > img { aspect-ratio: 1; object-fit: cover; }
.gallery-item > video { background: #05070d; }
.gallery-openable { transition: filter var(--t-fast), transform var(--t-fast); }
.gallery-openable:hover { filter: brightness(1.06); }

/* Empty states: a hair more refined */
.empty-workspace strong { letter-spacing: -0.02em; }

/* Honor reduced-motion for the added transforms */
@media (prefers-reduced-motion: reduce) {
  .workspace-card:hover, .gallery-item:hover { transform: none; }
}

/* ============================================================
   Morphable SVG visualizer
   ============================================================ */
.orb-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  /* a quick pop when a tool fires (driven by --burst) */
  transform: scale(calc(1 + var(--burst, 0) * 0.07));
  transition: transform 70ms linear;
}
.orb-blob {
  transition: opacity 300ms ease;
  filter: url(#orbBlur) drop-shadow(0 0 calc(18px + var(--level) * 60px) rgba(142, 108, 255, calc(0.3 + var(--level) * 0.5)));
}
.orb-bars, .orb-rings, .orb-dots { transition: opacity 260ms ease; }
.orb-bars path { stroke: var(--cyan); stroke-width: 3.2; stroke-linecap: round; fill: none; filter: drop-shadow(0 0 6px rgba(77, 232, 255, 0.55)); }
.orb-rings circle { fill: none; stroke: var(--hot); stroke-width: 2; filter: drop-shadow(0 0 6px rgba(255, 79, 216, 0.5)); }
.orb-dots circle { fill: var(--cyan); filter: drop-shadow(0 0 7px rgba(77, 232, 255, 0.7)); }

/* Per-state accent tinting on the blob's glow */
.orb.user .orb-blob, .orb.listening .orb-blob { filter: url(#orbBlur) drop-shadow(0 0 calc(20px + var(--level) * 60px) rgba(77, 232, 255, calc(0.35 + var(--level) * 0.5))); }
.orb.speaking .orb-blob { filter: url(#orbBlur) drop-shadow(0 0 calc(22px + var(--level) * 70px) rgba(255, 79, 216, calc(0.4 + var(--level) * 0.5))); }
.orb.thinking .orb-dots circle { fill: var(--violet); }

.orb-label {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(7, 8, 18, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
}
.orb:not(.idle) .orb-label { opacity: 1; }
.orb.user .orb-label, .orb.listening .orb-label { color: var(--cyan); border-color: rgba(77, 232, 255, 0.4); }
.orb.speaking .orb-label { color: var(--hot); border-color: rgba(255, 79, 216, 0.4); }

@media (prefers-reduced-motion: reduce) {
  .orb-bars, .orb-rings, .orb-dots { opacity: 0 !important; }
}

/* ============================================================
   Workspace: reliable scroll + card reorder controls
   ============================================================ */
.adaptive-workspace { overflow-y: auto; min-height: 0; }
.card-meta-wrap { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.card-order { display: flex; gap: 3px; }
.order-btn {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.order-btn:hover { color: var(--text); border-color: rgba(77, 232, 255, 0.45); background: rgba(77, 232, 255, 0.08); }

/* ============================================================
   Gallery card actions — fixed, aligned, never out of place.
   Compact icon Download + Delete flank a flexible primary action.
   ============================================================ */
.gallery { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
.gallery-item { gap: 8px; }
.gallery-item details { margin: 0; }
.gallery-actions {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  margin-top: auto;
}
.gallery-actions > * { height: 34px; box-sizing: border-box; flex: 0 0 auto; }
.gallery-download {
  width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--cyan);
  font-size: 1.1rem;
  line-height: 1;
  text-decoration: none;
}
.gallery-download:hover { border-color: rgba(77, 232, 255, 0.5); background: rgba(77, 232, 255, 0.08); }
.gallery-use {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 32px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.gallery-use:hover { border-color: rgba(77, 232, 255, 0.5); background: rgba(77, 232, 255, 0.1); }
.gallery-delete {
  width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.gallery-delete:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.45); background: rgba(255, 108, 136, 0.1); }

/* ============================================================
   Canvas as a paged gallery — one artifact at a time, full height,
   internal scroll, prev/next cycling. Fixes tall/stacked cutoff.
   ============================================================ */
.adaptive-workspace.paged {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  align-content: stretch;
  overflow: hidden;
}
.ws-pager { display: flex; align-items: center; gap: 10px; }
.ws-page-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.ws-page-btn:hover:not(:disabled) { border-color: rgba(77, 232, 255, 0.45); background: rgba(77, 232, 255, 0.1); }
.ws-page-btn:disabled { opacity: 0.35; cursor: default; }
.ws-page-info { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ws-page-info strong { font-family: var(--font-display); font-size: 1.02rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-page-info span { flex: 0 0 auto; color: var(--muted); font-size: 0.82rem; }
.ws-dots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ws-dot { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.22); cursor: pointer; transition: background var(--t-fast), transform var(--t-fast); }
.ws-dot:hover { background: rgba(255, 255, 255, 0.42); }
.ws-dot.active { background: var(--cyan); transform: scale(1.35); box-shadow: 0 0 8px rgba(77, 232, 255, 0.6); }

.ws-viewport { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.ws-viewport .workspace-card { height: 100%; margin: 0; display: flex; flex-direction: column; }
.ws-viewport .workspace-card > header,
.ws-viewport .workspace-card > .card-summary,
.ws-viewport .workspace-card > .artifact-remove { flex: 0 0 auto; }
.ws-viewport .workspace-card > .artifact-remove { align-self: flex-start; }
/* The main body region grows to fill and scrolls inside the card. */
.ws-viewport .widget-view,
.ws-viewport .project-viewer,
.ws-viewport .source-form,
.ws-viewport .note-body,
.ws-viewport .code-block { flex: 1 1 auto; min-height: 0; }
.ws-viewport .widget-view,
.ws-viewport .project-viewer,
.ws-viewport .code-block { display: flex; flex-direction: column; }
.ws-viewport .workspace-card.widget .widget-stage,
.ws-viewport .project-viewer .viewer-stage,
.ws-viewport .code-block .code-view { flex: 1 1 auto; min-height: 160px; height: auto; max-height: none; resize: none; }
.ws-viewport .table-scroll { max-height: 100%; }

@media (max-width: 920px) {
  .ws-viewport .workspace-card.widget .widget-stage { min-height: 320px; }
}

/* ============================================================
   Gallery — clean, professional, media-forward cards.
   Authoritative redesign (new .g-* classes; supersedes old rules).
   ============================================================ */
.gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.gallery-item:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-1); }

.g-media {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #05070d;
}
/* contain (not cover) so images/videos show in full at their true aspect ratio —
   never cropped or stretched/squished to fill the box. */
.g-media img,
.g-media > video { width: 100%; height: 100%; object-fit: contain; display: block; }
.g-openable { cursor: zoom-in; transition: filter var(--t-fast); }
.g-openable:hover { filter: brightness(1.08); }
.g-play {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(7, 8, 18, 0.72);
  border: 1px solid var(--line-strong);
  color: #fff;
  font-size: 0.7rem;
  pointer-events: none;
}
.g-media.g-audio {
  aspect-ratio: auto;
  min-height: 92px;
  grid-auto-flow: row;
  gap: 8px;
  padding: 12px 10px;
  align-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(123, 255, 175, 0.14), transparent 60%), #0a0d18;
}
.g-media.g-audio .g-glyph { font-size: 1.7rem; color: var(--green); }
.g-media.g-audio audio { width: 100%; height: 32px; }
.g-media.g-code {
  cursor: pointer;
  background: linear-gradient(135deg, rgba(142, 108, 255, 0.2), rgba(77, 232, 255, 0.08)), #0a0d18;
}
.g-media.g-code .g-glyph {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1rem;
  color: #e6ecff;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  max-width: 86%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-info { display: flex; flex-direction: column; gap: 5px; padding: 10px 11px 0; min-width: 0; }
.g-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
.g-kind {
  flex: 0 1 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(77, 232, 255, 0.14);
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-model { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-prompt {
  margin: 0;
  color: var(--text);
  opacity: 0.86;
  font-size: 0.8rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.g-act { display: flex; gap: 6px; padding: 10px 11px 11px; margin-top: auto; }
.g-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.g-btn:hover { border-color: rgba(77, 232, 255, 0.45); background: rgba(77, 232, 255, 0.1); }
.g-del { color: var(--muted); }
.g-del:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.45); background: rgba(255, 108, 136, 0.1); }

/* ============================================================
   UI refresh: layout rebalance, poof glow, tidy cards, header.
   ============================================================ */

/* Rebalance the stage: slim presence column, much wider canvas. */
.stage.panel { grid-template-columns: minmax(186px, 0.34fr) minmax(440px, 1fr); padding: 52px 24px 84px; }
.stage.panel.generating { grid-template-columns: minmax(160px, 0.3fr) minmax(420px, 1fr); }
.orb { width: min(24vw, 248px); }
.stage.panel.generating .orb { width: min(20vw, 210px); }
body[data-layout="canvas"] .stage.panel { grid-template-columns: minmax(150px, 0.26fr) minmax(480px, 1.25fr); }

/* Tool-call poof glow */
.orb-poof { transition: opacity 150ms ease; pointer-events: none; }
.orb-poof circle { filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.25)); }

/* Header: remove (✕) in the card controls + collapsible build notes */
.order-remove:hover { color: var(--danger); border-color: rgba(255, 108, 136, 0.45); background: rgba(255, 108, 136, 0.1); }
.card-info { margin: -2px 0 12px; }
.card-info > summary { cursor: pointer; width: fit-content; display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.78rem; list-style: none; transition: color var(--t-fast), border-color var(--t-fast); }
.card-info > summary::-webkit-details-marker { display: none; }
.card-info > summary::before { content: "ⓘ"; opacity: 0.8; }
.card-info[open] > summary { color: var(--text); border-color: var(--line-strong); }
.card-info p { margin: 8px 2px 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.card-summary { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Cleaner workspace card chrome */
.workspace-card { border-radius: 18px; }
.workspace-card > header { align-items: flex-start; }
.workspace-card.widget .widget-view,
.ws-viewport .workspace-card.widget { box-shadow: none; }

/* Pollen pill never overflows the header */
.balance-pill { max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Premium control bar */
.controls { gap: 8px; padding: 7px; box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.06); }

/* ============================================================
   Switchable UI styles — minimal / refine (default) / classic / bolder
   ============================================================ */

/* CLASSIC — flatter, calmer, less neon */
body[data-uistyle="classic"] {
  --shadow-1: 0 8px 22px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 14px 38px rgba(0, 0, 0, 0.4);
}
body[data-uistyle="classic"] .app-header,
body[data-uistyle="classic"] .stage.panel,
body[data-uistyle="classic"] .drawer.panel { background-image: none; }
body[data-uistyle="classic"] .balance-pill::after,
body[data-uistyle="classic"] .button.primary::after { display: none; }
body[data-uistyle="classic"] .workspace-card,
body[data-uistyle="classic"] .gallery-item,
body[data-uistyle="classic"] .gen-tile,
body[data-uistyle="classic"] .metric-tile { box-shadow: none; }

/* MINIMAL — content-first, quiet surfaces, more breathing room */
body[data-uistyle="minimal"] {
  --line: rgba(255, 255, 255, 0.07);
  --panel: rgba(14, 16, 26, 0.6);
  background: linear-gradient(160deg, #07080f, #0a0c15 60%, #07080f);
}
body[data-uistyle="minimal"] .app-header,
body[data-uistyle="minimal"] .stage.panel,
body[data-uistyle="minimal"] .drawer.panel { background-image: none; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
body[data-uistyle="minimal"] .balance-pill::after,
body[data-uistyle="minimal"] .button.primary::after,
body[data-uistyle="minimal"] .orb-core::after { display: none; }
body[data-uistyle="minimal"] .button.primary,
body[data-uistyle="minimal"] .button.talk { background: rgba(255, 255, 255, 0.1); color: var(--text); box-shadow: none; }
body[data-uistyle="minimal"] .workspace-card,
body[data-uistyle="minimal"] .gallery-item,
body[data-uistyle="minimal"] .gen-tile,
body[data-uistyle="minimal"] .metric-tile { box-shadow: none; background: rgba(255, 255, 255, 0.025); }
body[data-uistyle="minimal"] .workspace-card:hover,
body[data-uistyle="minimal"] .gallery-item:hover { transform: none; box-shadow: none; }
body[data-uistyle="minimal"] .orb-bars path { stroke-width: 2.4; filter: none; }
body[data-uistyle="minimal"] .orb-rings circle { filter: none; }
body[data-uistyle="minimal"] .adaptive-workspace { background: rgba(255, 255, 255, 0.02); }
body[data-uistyle="minimal"] .stage.panel { padding-top: 60px; }

/* BOLDER — stronger hierarchy, richer depth, bigger focal point */
body[data-uistyle="bolder"] {
  --radius-lg: 32px;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.26);
}
body[data-uistyle="bolder"] .stage.panel {
  background:
    radial-gradient(circle at 22% 44%, rgba(77, 232, 255, 0.26), transparent 22rem),
    radial-gradient(circle at 78% 26%, rgba(255, 79, 216, 0.22), transparent 22rem),
    rgba(8, 10, 18, 0.7);
}
body[data-uistyle="bolder"] .orb { width: min(28vw, 290px); }
body[data-uistyle="bolder"] .brand strong { font-size: 1.18rem; }
body[data-uistyle="bolder"] .workspace-card,
body[data-uistyle="bolder"] .gallery-item { border-width: 1px; box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
body[data-uistyle="bolder"] .button.primary,
body[data-uistyle="bolder"] .button.talk { box-shadow: 0 14px 36px rgba(255, 79, 216, 0.4); }
body[data-uistyle="bolder"] .nav-button.active { box-shadow: inset 0 0 0 1px var(--line-strong), 0 6px 18px rgba(77, 232, 255, 0.2); }
body[data-uistyle="bolder"] .workspace-mode,
body[data-uistyle="bolder"] .ws-page-info strong { letter-spacing: -0.01em; }
body[data-uistyle="bolder"] .orb-blob { filter: url(#orbBlur) drop-shadow(0 0 calc(26px + var(--level) * 80px) rgba(142, 108, 255, calc(0.45 + var(--level) * 0.5))); }

/* ============================================================
   Mobile / touch layout — phones and small tablets (≤ 720px)
   Stage becomes a vertical flow; Start/Stop pin to the viewport
   bottom so they're always reachable instead of buried in a tall
   stage. Drawers go full-screen. Honors the iOS safe area.
   ============================================================ */
@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-y: auto; overflow-x: hidden; }
  .app-shell {
    width: 100%;
    margin: 0;
    padding: 8px 8px calc(140px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  /* Stacked header: brand row, account row (full width), scrollable nav row.
     One flat column avoids the cramped brand-vs-account squeeze. */
  .app-header {
    grid-template-columns: 1fr;
    grid-template-areas: "brand" "account" "nav";
    gap: 10px;
    padding: 10px 12px;
    border-radius: 18px;
  }
  .brand { grid-area: brand; }
  .app-nav { grid-area: nav; }
  .account-strip {
    grid-area: account;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .account-strip #connectByop { margin-left: auto; }
  .brand span { display: none; }
  .app-nav {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .app-nav::-webkit-scrollbar { display: none; }
  .nav-button { flex: 0 0 auto; padding: 9px 13px; }
  .account-strip .button { padding: 8px 12px; font-size: 0.84rem; }
  .account-strip #clearKey { font-size: 0.78rem; }
  .balance-pill, .pill { font-size: 0.76rem; padding: 7px 10px; }
  .balance-pill { max-width: 120px; }

  /* Stage: single-column vertical flow. Topbar is in-flow now, so the old
     56px top padding (which used to clear an absolute topbar) is gone. */
  .stage.panel,
  .stage.panel.generating {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    align-items: stretch;
    gap: 12px;
    min-height: auto;
    height: auto;
    padding: 14px 12px 18px;
    overflow: visible;
  }
  .stage-topbar {
    position: static;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 2px;
  }
  .workspace-mode { font-size: 0.78rem; }

  .orb,
  body[data-uistyle="bolder"] .orb { width: min(46vw, 190px); justify-self: center; margin: 4px auto 2px; }
  .stage.panel.generating .orb { width: min(40vw, 168px); }

  .media-dock { order: 1; }
  .adaptive-workspace {
    order: 2;
    width: 100%;
    max-height: none;
    min-height: 220px;
  }

  /* Pin transport controls to the bottom of the viewport, in a stable two-row
     bar: a full-width mode segment on top, action buttons below. Fixed height
     keeps the status line above it from overlapping. */
  .controls {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    transform: none;
    max-width: none;
    width: auto;
    z-index: 25;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    box-shadow: var(--shadow-2);
  }
  .mode-toggle { flex: 1 1 100%; justify-content: center; }
  .mode-toggle .mode { flex: 1 1 0; min-width: 0; padding: 9px 6px; font-size: 0.82rem; }
  .controls .button {
    flex: 1 1 0;
    min-width: 0;
    padding: 11px 8px;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .realtime-status {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(118px + env(safe-area-inset-bottom));
    transform: none;
    z-index: 25;
    pointer-events: none;
    padding: 5px 12px;
    border-radius: 999px;
    width: fit-content;
    margin: 0 auto;
    background: rgba(7, 8, 18, 0.82);
    backdrop-filter: blur(10px);
  }

  /* The drawers own the screen, so the floating transport must yield to them */
  body:has(.drawer.active) .controls,
  body:has(.drawer.active) .realtime-status { display: none; }

  /* Full-screen drawers using the dynamic viewport (no iOS URL-bar clipping) */
  .drawer {
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: auto;
    max-height: calc(100dvh - 16px);
    padding: 16px;
    border-radius: 20px;
  }
  .composer { flex-wrap: wrap; }
  .composer .composer-text { flex: 1 1 140px; }

  /* Comfortable touch targets across interactive bits */
  .button, .nav-button, .mode, .g-btn, .mkw-btn { min-height: 40px; }
}

@media (max-width: 420px) {
  .orb { width: min(52vw, 168px); }
  .controls { gap: 6px; padding: 7px; }
  .controls .button { padding: 10px 13px; font-size: 0.88rem; }
  .nav-button { padding: 8px 12px; font-size: 0.9rem; }
  .stage.panel, .stage.panel.generating { padding: 52px 10px 16px; }
}

/* Coarse-pointer (touch) devices: drop hover lifts that stick on tap */
@media (hover: none) {
  .workspace-card:hover,
  .gallery-item:hover { transform: none; }
}

/* ============================================================
   Inline chat — swaps the orb for a keyboard-first chat panel,
   toggled by the header "Chat" button. Mic-less users live here.
   ============================================================ */
.inline-chat {
  display: none;
  flex-direction: column;
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  min-height: 320px;
  max-height: 560px;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)), rgba(0, 0, 0, 0.18);
}
.inline-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.inline-chat-head span {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.inline-chat .inline-transcript {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}
.inline-chat .inline-transcript:empty::before {
  content: "Type below to chat — ask for an image, an edit, a widget, or anything.";
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.inline-chat .composer { margin-top: 0; }
.inline-chat .composer .composer-text { flex: 1 1 auto; min-width: 0; }
/* Header Chat toggle reuses .nav-button.active styling; add a subtle accent. */
#chatToggle.active { box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 1px rgba(77, 232, 255, 0.25); }

body[data-stageview="chat"] .orb { display: none; }
body[data-stageview="chat"] .inline-chat { display: flex; }
body[data-stageview="chat"] .stage.panel,
body[data-stageview="chat"] .stage.panel.generating {
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1fr);
}

@media (max-width: 720px) {
  .inline-chat { max-height: 56vh; min-height: 240px; }
  body[data-stageview="chat"] .inline-chat { order: 0; }
}

/* Desktop (Tauri) status block in Config */
.desktop-status { color: var(--muted); font-size: 0.86rem; line-height: 1.5; margin: 2px 0 10px; }
.desktop-controls { display: grid; gap: 10px; }
.desktop-controls.hidden { display: none; }

/* Desktop download button (web build only) */
#desktopDownload { display: inline-flex; align-items: center; gap: 6px; width: fit-content; margin: 2px 0 12px; text-decoration: none; }
#desktopDownload.hidden { display: none; }
