/* SIG — deep tide / brass premium shell (2026)
   Fraunces (display) + Outfit (UI), seafoam tide + warm brass, wine Adult.
   Open composition, soft glass chrome — not a dashboard. Phone + desktop. */

:root {
  /* Surfaces — coherent elevation (never pure black on black) */
  --bg0: #04080a;
  --bg1: #071015;
  --bg2: #0c171c;
  --panel: #0d181e;
  --raised: #13242e;
  --overlay: #0f1f28;
  --line: #2a4a54;
  --line-soft: rgba(36, 64, 74, 0.45);
  --line-bright: rgba(99, 220, 190, 0.24);

  /* Ink */
  --text: #f1f8f5;
  --muted: #9bb5b0;
  --muted2: #6a8384;

  /* Tide (seafoam) — accent for CTAs, focus, Homegrown */
  --ice: #63dcbe;
  --ice-bright: #8ee5d0;
  --ice-dim: #408f7b;
  --ice-glow: rgba(99, 220, 190, 0.16);
  --ice-wash: rgba(99, 220, 190, 0.07);
  --user: #85e3cc;

  /* Brass — Agent mode accent */
  --amber: #dca85e;
  --amber-bright: #f0c684;
  --amber-dim: rgba(220, 168, 94, 0.26);
  --amber-wash: rgba(220, 168, 94, 0.09);

  /* Adult — wine + gold */
  --adult: #e2637f;
  --adult-bright: #f2879e;
  --adult-dim: rgba(226, 99, 127, 0.32);
  --adult-wash: rgba(226, 99, 127, 0.1);
  --gold: #e6c07d;

  --danger: #e8897a;
  --ok: #7dcea0;

  /* Shape + rhythm */
  --radius-sm: 11px;
  --radius: 15px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 999px;
  --space: 8px;

  /* Motion — subtle presence only */
  --t-fast: 160ms ease;
  --t-med: 260ms cubic-bezier(0.22, 0.82, 0.2, 1);
  --t-slow: 420ms cubic-bezier(0.22, 0.82, 0.2, 1);

  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Outfit", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --font-mono: "Cascadia Code", ui-monospace, "SF Mono", Consolas, monospace;

  --shadow: 0 22px 56px rgba(0, 0, 0, 0.52);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.3);
  --shadow-float: 0 14px 40px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-ring: 0 0 0 3px var(--ice-glow);
  --glass: rgba(10, 20, 24, 0.72);
}

/* Global utility — anything tagged .hidden must never render.
   (Stop button, agent badge, force-generate buttons, etc. rely on this.) */
.hidden {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.52;
  letter-spacing: 0.008em;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Atmosphere: deep tide + brass warmth + soft vignette (not purple glow spam) */
body {
  background:
    radial-gradient(920px 540px at 8% -8%, rgba(99, 220, 190, 0.14), transparent 58%),
    radial-gradient(700px 480px at 96% 0%, rgba(220, 168, 94, 0.07), transparent 52%),
    radial-gradient(880px 620px at 50% 112%, rgba(46, 156, 129, 0.1), transparent 58%),
    radial-gradient(120% 80% at 50% 50%, transparent 42%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(168deg, #04080a 0%, #071015 46%, #050a0d 100%);
}

/* Soft vignette layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 8, 10, 0.35) 0%, transparent 18%, transparent 82%, rgba(4, 8, 10, 0.28) 100%),
    linear-gradient(180deg, rgba(4, 8, 10, 0.2) 0%, transparent 12%, transparent 88%, rgba(4, 8, 10, 0.45) 100%);
}

/* Film grain (pointer-transparent) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Accessible focus everywhere, no default outline noise */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ice-dim);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Themed slim scrollbars (all scroll regions) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 220, 190, 0.18) transparent;
}
*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(99, 220, 190, 0.14);
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 220, 190, 0.26);
}

#app {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ————————————————— Sidebar ————————————————— */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(99, 220, 190, 0.08);
  background:
    linear-gradient(180deg, rgba(12, 24, 28, 0.55) 0%, rgba(6, 12, 14, 0.35) 100%),
    radial-gradient(140% 70% at 0% 0%, rgba(99, 220, 190, 0.1), transparent 58%),
    radial-gradient(100% 50% at 100% 100%, rgba(220, 168, 94, 0.05), transparent 52%),
    linear-gradient(180deg, #071015 0%, #04080a 100%);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  padding: 0;
  gap: 0;
  animation: sidebar-settle 0.45s var(--t-med) both;
}

@keyframes sidebar-settle {
  from {
    opacity: 0.6;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.side-top {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 12px;
  flex-shrink: 0;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 4px;
}

.side-brand .brand-mark {
  width: 34px;
  height: 34px;
  aspect-ratio: 1 / 1;
  flex: 0 0 34px;
  object-fit: contain;
  object-position: center;
  display: block;
  border-radius: 10px;
  filter: drop-shadow(0 6px 18px rgba(99, 220, 190, 0.32));
  -webkit-user-drag: none;
  user-select: none;
}

.side-brand .brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.side-brand .mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.18em;
  line-height: 1;
  color: var(--text);
}

.side-brand .tag {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted2);
}

.btn-new {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 13px 15px;
  font: 600 13.5px/1 var(--font-ui);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  color: #04130e;
  background: linear-gradient(135deg, var(--ice-bright) 0%, var(--ice) 48%, var(--ice-dim) 100%);
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(99, 220, 190, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: filter var(--t-fast), box-shadow var(--t-med), transform var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-new-plus {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(4, 19, 14, 0.14);
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
}

.btn-new-label {
  letter-spacing: 0.03em;
}

.btn-new:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 28px rgba(99, 220, 190, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.btn-new:active {
  filter: brightness(0.96);
  transform: translateY(0);
}

.side-section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 0;
}

.side-section-label {
  font: 700 10px/1 var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-section-hint {
  font: 500 10px/1 var(--font-ui);
  color: var(--muted2);
  letter-spacing: 0.02em;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 12px 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 220, 190, 0.22) transparent;
}

.chat-search-wrap {
  flex-shrink: 0;
  padding: 0 12px 8px;
}

.chat-search {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(99, 220, 190, 0.16);
  border-radius: 10px;
  background: rgba(8, 14, 16, 0.72);
  color: var(--text);
  font: 500 12.5px/1.2 var(--font-ui);
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.chat-search::placeholder {
  color: var(--muted2);
}

.chat-search:focus {
  border-color: rgba(99, 220, 190, 0.42);
  box-shadow: 0 0 0 3px rgba(99, 220, 190, 0.1);
}

.chat-list-empty {
  margin: 8px 2px;
  padding: 24px 16px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px dashed rgba(99, 220, 190, 0.2);
  background: rgba(99, 220, 190, 0.035);
  color: var(--muted2);
  font-size: 12.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-list-empty strong {
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
}

.side-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(99, 220, 190, 0.07);
  background: linear-gradient(180deg, rgba(8, 16, 20, 0), rgba(4, 8, 10, 0.92));
  flex-shrink: 0;
}

.side-foot {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 9px;
  border-radius: 15px;
  border: 1px solid rgba(99, 220, 190, 0.12);
  background: rgba(13, 26, 32, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  min-width: 0;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.account-chip:hover {
  border-color: rgba(99, 220, 190, 0.22);
  background: rgba(16, 32, 38, 0.88);
}

.account-chip[hidden] {
  display: none !important;
}

.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  font: 700 11px/1 var(--font-ui);
  letter-spacing: 0.04em;
  color: #04130e;
  background: linear-gradient(145deg, var(--ice-bright), var(--ice-dim));
}

.account-meta {
  min-width: 0;
  flex: 1;
}

.account-name {
  font: 600 12.5px/1.2 var(--font-ui);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-email {
  margin-top: 2px;
  font: 400 10.5px/1.2 var(--font-ui);
  color: var(--muted2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-signout {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 8px;
  font: 600 10px/1 var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}

.account-signout:hover {
  color: var(--text);
  border-color: var(--ice-dim);
}

.ghost {
  flex: 1;
  appearance: none;
  border: 1px solid rgba(42, 70, 80, 0.65);
  background: rgba(13, 24, 29, 0.45);
  color: var(--muted);
  border-radius: 11px;
  padding: 11px;
  font: 500 12.5px/1 var(--font-ui);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast),
    transform var(--t-fast);
}

.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(99, 220, 190, 0.38);
  background: var(--ice-wash);
}

.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ————————————————— Main column ————————————————— */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  padding: 14px 20px 14px;
  gap: 12px;
}

.topbar {
  display: none;
}

.hero-brand {
  display: none;
}

/* Mode banner — compact brass chip */
.homegrown-banner {
  margin: 0;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--amber-dim);
  background: linear-gradient(90deg, rgba(42, 31, 15, 0.82), rgba(13, 22, 26, 0.55));
  color: #ecd7ab;
  font-size: 12.5px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(240, 198, 132, 0.08);
}

.homegrown-banner.hidden {
  display: none;
}

.homegrown-banner strong {
  color: var(--amber-bright);
  font-weight: 700;
  margin-right: 4px;
}

.homegrown-banner em {
  font-style: normal;
  color: var(--ice-bright);
  font-weight: 600;
}

/* ————————————————— Chat rows ————————————————— */
.chat-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: 13px;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}

.chat-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 2.5px;
  border-radius: 3px;
  background: var(--ice);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.chat-row:hover {
  background: rgba(99, 220, 190, 0.055);
}

.chat-row.active {
  background: rgba(99, 220, 190, 0.1);
  border-color: rgba(99, 220, 190, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.chat-row.active::before {
  opacity: 1;
}

.chat-row-main {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 12px 8px 12px 14px;
  cursor: pointer;
  border-radius: 13px;
  font: inherit;
}

.chat-row .title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row .meta {
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted2);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chat-row .brain-tag {
  flex: 0 0 auto;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 9px;
  color: #04130e;
  background: linear-gradient(135deg, var(--ice-bright), var(--ice));
  border-radius: 999px;
  padding: 3px 7px;
  line-height: 1;
}

.chat-row.brain-agent .brain-tag {
  color: #1a1206;
  background: linear-gradient(135deg, var(--amber-bright), var(--amber));
}

.chat-row .meta-sep {
  opacity: 0.45;
}

.chat-row .meta-date {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row.brain-agent::before {
  background: var(--amber);
}

.chat-row.brain-agent.active {
  background: rgba(220, 168, 94, 0.1);
  border-color: rgba(220, 168, 94, 0.24);
}

.chat-row.busy .title::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.55);
  animation: agent-pulse 1.4s ease-out infinite;
  vertical-align: middle;
}

.chat-row.brain-agent.busy .title::after {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(220, 168, 94, 0.55);
}

@keyframes agent-pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(99, 220, 190, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 220, 190, 0); }
}

.mode-chip.brain-homegrown {
  border-color: rgba(99, 220, 190, 0.35);
  color: var(--ice-bright);
}

.mode-chip.brain-studio {
  border-color: rgba(99, 220, 190, 0.42);
  color: var(--ice-bright);
  background: linear-gradient(
    90deg,
    rgba(12, 36, 32, 0.92),
    rgba(10, 20, 24, 0.95)
  );
}

.mode-chip.brain-agent {
  border-color: rgba(220, 168, 94, 0.4);
  color: var(--amber-bright);
  background: linear-gradient(90deg, rgba(42, 28, 12, 0.9), rgba(20, 16, 12, 0.9));
}

.chat-row-actions {
  display: flex;
  flex-shrink: 0;
  align-items: stretch;
  gap: 0;
  margin: 3px 3px 3px 0;
}

.chat-more {
  appearance: none;
  flex-shrink: 0;
  width: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted2);
  font: 700 13px/1 var(--font-ui);
  letter-spacing: 1px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}

.chat-row:hover .chat-more,
.chat-row.active .chat-more,
.chat-more:focus,
.chat-more[aria-expanded="true"] {
  opacity: 1;
}

.chat-more:hover {
  background: rgba(99, 220, 190, 0.14);
  color: var(--ice);
}

.chat-ctx-menu {
  position: fixed;
  z-index: 900;
  min-width: 152px;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(165deg, #101d23, #0a1216);
  box-shadow: var(--shadow);
  animation: pop-in 0.16s ease both;
}

.chat-ctx-item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 500 13px/1.3 var(--font-ui);
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.chat-ctx-item:hover {
  background: var(--ice-wash);
}

.chat-ctx-item.danger {
  color: var(--danger);
}

.chat-ctx-item.danger:hover {
  background: rgba(232, 137, 122, 0.14);
}

/* ————————————————— Transcript ————————————————— */
.transcript-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(99, 220, 190, 0.08);
  background:
    linear-gradient(180deg, rgba(10, 20, 24, 0.55), rgba(5, 10, 12, 0.72));
  box-shadow: none;
  overflow: hidden;
  position: relative;
}

.transcript-shell.is-empty {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}

.transcript-shell.is-empty::before {
  opacity: 0.7;
}

.transcript-shell.is-empty .thread-status:not(.thinking) {
  border-top-color: transparent;
  background: transparent;
}

.transcript-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(780px 280px at 50% -20%, rgba(99, 220, 190, 0.08), transparent 64%),
    radial-gradient(520px 220px at 90% 100%, rgba(220, 168, 94, 0.04), transparent 60%);
  z-index: 0;
}

/* Adult wine atmosphere when mode chip is Adult (CSS-only via :has) */
.main:has(#modeChip.adult) .transcript-shell::before {
  background:
    radial-gradient(780px 280px at 50% -20%, rgba(226, 99, 127, 0.1), transparent 64%),
    radial-gradient(520px 220px at 90% 100%, rgba(230, 192, 125, 0.05), transparent 60%);
}

.main:has(#modeChip.adult) .composer {
  border-color: rgba(226, 99, 127, 0.28);
}

.main:has(#modeChip.adult) .composer:focus-within {
  border-color: rgba(226, 99, 127, 0.48);
  box-shadow:
    0 0 0 3px rgba(226, 99, 127, 0.14),
    0 12px 34px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.main:has(#modeChip.brain-agent) .transcript-shell::before {
  background:
    radial-gradient(780px 280px at 50% -20%, rgba(220, 168, 94, 0.09), transparent 64%),
    radial-gradient(520px 220px at 10% 100%, rgba(99, 220, 190, 0.04), transparent 60%);
}

.transcript {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 1;
  overscroll-behavior: contain;
}

/* Status footer under the transcript */
.thread-status {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 16px;
  border-top: 1px solid rgba(99, 220, 190, 0.06);
  background: rgba(4, 10, 12, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-height: 40px;
  transition: background var(--t-med), border-color var(--t-med);
}

.thread-status.thinking {
  border-top-color: rgba(99, 220, 190, 0.28);
  background: linear-gradient(
    90deg,
    rgba(12, 36, 32, 0.88) 0%,
    rgba(8, 18, 21, 0.82) 55%,
    rgba(8, 18, 21, 0.82) 100%
  );
}

.thread-status.thinking #status {
  color: var(--ice-bright);
}

.thread-status.thinking #status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.5);
  animation: pulse 1.25s ease infinite;
  vertical-align: middle;
}

.thread-status.boot #status {
  color: var(--muted2);
  font-size: 11.5px;
  letter-spacing: 0.05em;
}

.thread-status.idle #status {
  opacity: 0;
}

.main.no-chat .thread-status {
  display: none;
}

/* ————————————————— Messages ————————————————— */
.msg {
  max-width: min(680px, 92%);
  animation: fade-up 0.24s ease both;
}

.msg.you {
  align-self: flex-end;
}

.msg.sig,
.msg.system {
  align-self: flex-start;
}

.msg .role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--muted2);
}

.msg.you .role {
  text-align: right;
  color: var(--user);
}

.msg.sig .role {
  color: var(--ice);
}

.msg .bubble {
  padding: 15px 19px;
  border-radius: 20px;
  line-height: 1.64;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid transparent;
  font-size: 15px;
  letter-spacing: 0.004em;
  box-shadow: none;
}

.msg.you .bubble {
  background: linear-gradient(155deg, #1d564c 0%, #154038 52%, #11322d 100%);
  border-color: rgba(139, 227, 203, 0.22);
  color: #f2fcf8;
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 26px rgba(12, 40, 34, 0.32);
}

.msg.sig .bubble {
  background: linear-gradient(155deg, rgba(22, 40, 48, 0.92) 0%, rgba(14, 26, 32, 0.94) 55%, rgba(10, 18, 22, 0.96) 100%);
  border-color: rgba(99, 220, 190, 0.12);
  color: var(--text);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.msg.system .bubble {
  background: rgba(11, 20, 24, 0.75);
  border-color: rgba(99, 220, 190, 0.08);
  color: var(--muted);
  font-size: 13.5px;
  box-shadow: none;
}

.msg.pending .bubble {
  color: var(--muted);
  font-style: normal;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: linear-gradient(
    135deg,
    rgba(18, 48, 44, 0.96) 0%,
    rgba(10, 22, 26, 0.97) 55%,
    rgba(12, 24, 28, 0.94) 100%
  );
  border-color: rgba(99, 220, 190, 0.38);
  box-shadow:
    inset 0 0 0 1px rgba(99, 220, 190, 0.06),
    0 0 0 1px rgba(99, 220, 190, 0.08);
  letter-spacing: 0.01em;
  min-width: min(100%, 280px);
}

.msg.pending .agent-live {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 1.2em;
  width: 100%;
}

.msg.pending .agent-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.5);
  animation: agent-live-pulse 1.35s ease-out infinite;
  flex: 0 0 auto;
  margin-top: 1.15em;
}

.msg.pending .agent-live-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.msg.pending .agent-live-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ice);
  opacity: 0.85;
  line-height: 1.2;
}

.msg.pending .agent-live-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 12.5em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 14%, #000 100%);
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 14%,
    #000 100%
  );
}

.msg.pending .agent-live-line {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg.pending .agent-live-text {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  opacity: 1;
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
  /* No enter animation — live polls update this node often; animating
     each change made the Agent queued line blink/flash. */
}

@keyframes agent-live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.45);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(99, 220, 190, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 220, 190, 0);
    transform: scale(1);
  }
}

@keyframes agent-live-fade {
  from {
    opacity: 0.4;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Generated media — intentional frames */
.msg .bubble img,
.msg .bubble .gen-img {
  display: block;
  max-width: min(100%, 560px);
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-top: 0;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.msg .bubble .gen-video {
  display: block;
  max-width: min(100%, 560px);
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #080d0f;
}

.msg .bubble .gen-figure {
  margin: 12px 0 2px;
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(99, 220, 190, 0.18);
  background: linear-gradient(160deg, rgba(14, 26, 32, 0.95), rgba(6, 10, 12, 0.98));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  animation: rise 0.35s ease both;
}

.img-missing {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
}

.img-path {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted2);
  font-family: var(--font-mono);
  word-break: break-all;
}

.img-missing-card {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(99, 220, 190, 0.14);
  background: rgba(8, 14, 16, 0.55);
}

.img-missing-card .img-missing {
  margin-top: 0;
  color: var(--muted);
}

.gen-img-hit {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.gen-actions,
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.gen-action,
.msg-copy {
  appearance: none;
  border: 1px solid rgba(99, 220, 190, 0.28);
  border-radius: 8px;
  background: rgba(99, 220, 190, 0.08);
  color: var(--ice);
  padding: 7px 11px;
  font: 600 11.5px/1 var(--font-ui);
  cursor: pointer;
  min-height: 32px;
}

.gen-action:hover,
.msg-copy:hover {
  border-color: rgba(99, 220, 190, 0.55);
  background: rgba(99, 220, 190, 0.14);
}

.msg-copy.is-copied,
.gen-action.is-copied {
  color: #04130e;
  background: var(--ice);
  border-color: transparent;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 8, 0.88);
  backdrop-filter: blur(8px);
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox img {
  max-width: min(960px, 100%);
  max-height: min(90vh, 100%);
  border-radius: 12px;
  border: 1px solid rgba(99, 220, 190, 0.22);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  object-fit: contain;
  background: #0a1216;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(99, 220, 190, 0.28);
  background: rgba(10, 18, 22, 0.9);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  border-color: rgba(99, 220, 190, 0.55);
  color: var(--ice);
}

.mode-card.mode-preferred {
  border-color: rgba(99, 220, 190, 0.55);
  box-shadow: 0 0 0 3px rgba(99, 220, 190, 0.12), 0 10px 24px rgba(0, 0, 0, 0.28);
}

/* ————————————————— Empty states ————————————————— */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 28px 20px;
  max-width: 360px;
}

.empty-state p,
.empty-state h2 {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.main.no-chat {
  /* Welcome screen only — hide the composer until a chat exists. */
}

.main.no-chat .composer-wrap,
.main.no-chat .thread-status,
.main.no-chat .topbar,
.main.no-chat .homegrown-banner {
  display: none !important;
}

.main.no-chat .transcript {
  justify-content: center;
}

.main.no-chat .transcript-shell {
  flex: 1 1 auto;
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}

.main.no-chat .transcript-shell::before {
  display: none;
}

.empty-state--welcome {
  position: relative;
  max-width: 380px;
  padding: 48px 22px;
  animation: fade-up 0.5s var(--t-med) both;
}

.empty-state--welcome::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  width: 320px;
  height: 320px;
  margin-left: -160px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(99, 220, 190, 0.16) 0%,
    rgba(99, 220, 190, 0.04) 40%,
    transparent 68%
  );
  pointer-events: none;
  z-index: 0;
  animation: empty-glow 5.5s ease-in-out infinite;
}

@keyframes empty-glow {
  0%,
  100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

.empty-state--welcome > * {
  position: relative;
  z-index: 1;
}

.empty-state--welcome .empty-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  display: block;
  border-radius: 14px;
  filter: drop-shadow(0 10px 28px rgba(99, 220, 190, 0.35));
  animation: brand-settle 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.empty-state--welcome .empty-eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted2);
}

.empty-state--welcome .empty-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 52px);
  font-weight: 650;
  letter-spacing: 0.08em;
  line-height: 1.02;
  color: var(--text);
  animation: brand-settle 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.empty-state--welcome .empty-sub {
  margin: 0 0 34px;
  font-size: 15.5px;
  color: var(--muted);
  line-height: 1.55;
}

.empty-state--welcome .empty-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-state--welcome .btn-new {
  min-width: 188px;
  padding: 15px 26px;
  border-radius: var(--radius);
}

.empty-state--welcome .empty-secondary {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted2);
  font: 500 13px/1 var(--font-ui);
  cursor: pointer;
  padding: 11px 14px;
  border-radius: 8px;
  transition: color var(--t-fast), background var(--t-fast);
}

.empty-state--welcome .empty-secondary:hover {
  color: var(--ice);
  background: var(--ice-wash);
}

.empty-state--thread {
  max-width: 300px;
  padding: 40px 18px;
}

.empty-state--thread .empty-eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ice-dim);
}

.empty-state--thread .empty-thread-lead {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state--thread p {
  font-size: 14px;
  color: var(--muted2);
}

/* ————————————————— Composer ————————————————— */
.composer-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 56px;
  z-index: 30;
  position: relative;
  background: linear-gradient(
    180deg,
    rgba(5, 9, 11, 0) 0%,
    rgba(5, 9, 11, 0.85) 35%,
    var(--bg0) 100%
  );
  padding-top: 2px;
}

#status {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--t-fast);
}

#status.error {
  color: var(--danger);
}

#status.ok {
  color: var(--ok);
}

/* Mode chip — pill, mode-aware tint */
.mode-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(14, 26, 32, 0.95);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  font: 600 11px/1 var(--font-ui);
  letter-spacing: 0.04em;
  cursor: pointer;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast),
    box-shadow var(--t-fast);
  flex-shrink: 0;
}

/* Stop / agent badge must never peek through when idle */
.mode-chip.hidden,
#btnCancelJob.hidden,
#btnCancelJob[hidden],
.agent-badge.hidden,
.agent-badge[hidden] {
  display: none !important;
}

#btnCancelJob.stop-live {
  border-color: rgba(226, 99, 127, 0.55);
  color: #efb9c5;
  background: linear-gradient(
    90deg,
    rgba(50, 18, 27, 0.92),
    rgba(20, 12, 16, 0.95)
  );
}

.mode-chip:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(99, 220, 190, 0.4);
  background: var(--ice-wash);
  box-shadow: var(--shadow-ring);
}

.mode-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mode-chip.adult {
  border-color: var(--adult-dim);
  color: #efb9c5;
  background: linear-gradient(90deg, rgba(50, 18, 27, 0.9), rgba(20, 12, 16, 0.9));
}

.mode-chip.adult:hover:not(:disabled) {
  border-color: rgba(226, 99, 127, 0.55);
  color: var(--adult-bright);
  background: var(--adult-wash);
  box-shadow: 0 0 0 3px rgba(226, 99, 127, 0.14);
}

/* Attach / generate chips above the composer */
.attach-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 0 2px;
}

.attach-bar.hidden {
  display: none;
}

.attach-stage-grid {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.attach-dropzone {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.attach-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.attach-tools:not(:has(.attach-btn:not(.hidden))) {
  display: none;
}

.attach-btn {
  flex: 0 0 auto;
  padding: 9px 14px;
  font-size: 12px;
  border-radius: var(--radius-pill);
  min-height: 34px;
}

.attach-btn-kicker {
  display: inline;
}

.attach-btn-sub {
  display: none;
}

.attach-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.generate-btn {
  border-color: var(--amber-dim) !important;
  color: #f2ddac !important;
  background: rgba(42, 31, 15, 0.35) !important;
}

.generate-btn:hover:not(:disabled) {
  border-color: rgba(220, 168, 94, 0.5) !important;
  background: var(--amber-wash) !important;
  color: #ffe9b8 !important;
}

.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(11, 20, 24, 0.95);
  animation: pop-in 0.18s ease both;
}

.attach-thumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.attach-preview.hidden {
  display: none;
}

.attach-preview img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--radius-pill);
  background: var(--raised);
}

.attach-preview img.hidden {
  display: none;
}

.attach-preview span {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-clear {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  transition: color var(--t-fast), background var(--t-fast);
}

.attach-clear:hover {
  color: var(--danger);
  background: rgba(232, 137, 122, 0.12);
}

/* Chat attach — compact single strip, not a studio stage */
.main.chat-attach .attach-bar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.main.chat-attach .attach-stage-grid {
  flex: 1 1 auto;
  gap: 8px;
  align-items: center;
}

.main.chat-attach .attach-dropzone {
  flex: 0 0 auto;
}

.main.chat-attach .attach-dropzone:has(.attach-preview:not(.hidden)) .attach-btn {
  display: none;
}

.main.chat-attach .attach-tools {
  flex: 0 0 auto;
  margin-left: auto;
}

.main.chat-attach:not(.has-refs) .attach-tools {
  opacity: 0.78;
}

.main.chat-attach .attach-preview {
  max-width: 200px;
}

/* Studio banner — bold purpose header */
.studio-banner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 8px;
  animation: fade-up 0.28s ease both;
  border-bottom: 1px solid rgba(99, 220, 190, 0.14);
  margin-bottom: 4px;
}

.main.studio-media .studio-banner {
  margin: 0 22px 0;
  padding: 2px 2px 12px;
}

.studio-banner.hidden {
  display: none;
}

.studio-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.studio-eyebrow {
  font: 700 10px/1.2 var(--font-ui);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ice);
}

.studio-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--text);
}

.studio-lead {
  margin: 0;
  font: 500 13.5px/1.4 var(--font-ui);
  color: var(--muted);
  max-width: 42ch;
}

.studio-steps {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  flex-shrink: 0;
}

.studio-steps li {
  font: 700 10px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
  padding: 8px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(99, 220, 190, 0.12);
  background: rgba(8, 16, 20, 0.65);
}

.studio-steps li:first-child {
  color: var(--ice-bright);
  border-color: rgba(99, 220, 190, 0.35);
  background: var(--ice-wash);
}

/* ————————————————— Image / Video studio composition ————————————————— */
.main.studio-media {
  gap: 0;
  padding: 12px 0 0;
}

.main.studio-media .homegrown-banner {
  display: none !important;
}

.main.studio-media .topbar {
  margin-bottom: 8px;
}

/* Canvas well — unmistakably not a chat transcript */
.main.studio-media .transcript-shell {
  flex: 1 1 auto;
  margin: 0 16px 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid rgba(99, 220, 190, 0.14);
  border-bottom: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(99, 220, 190, 0.07), transparent 55%),
    linear-gradient(180deg, #071012 0%, #04080a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.main.studio-media .transcript-shell.is-empty {
  border-style: dashed;
  border-width: 2px;
  border-bottom-width: 0;
  border-color: rgba(99, 220, 190, 0.22);
  background:
    radial-gradient(ellipse 70% 55% at 50% 40%, rgba(99, 220, 190, 0.05), transparent 60%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 11px,
      rgba(99, 220, 190, 0.025) 11px,
      rgba(99, 220, 190, 0.025) 12px
    ),
    #050a0c;
}

.main.studio-media .transcript-shell::before {
  background:
    radial-gradient(720px 280px at 50% -8%, rgba(99, 220, 190, 0.1), transparent 62%);
  opacity: 1;
}

.main.studio-media .transcript {
  padding: 22px 22px 18px;
  gap: 16px;
  align-items: center;
}

.main.studio-media .thread-status {
  padding: 6px 16px;
  min-height: 34px;
  border-top-color: rgba(99, 220, 190, 0.08);
  background: rgba(4, 10, 12, 0.55);
}

.main.studio-media .thread-status #status {
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* Workbench dock — attach + prompt own the bottom */
.main.studio-media .composer-wrap {
  flex: 0 0 auto;
  gap: 14px;
  margin: 0;
  padding: 18px 22px max(16px, env(safe-area-inset-bottom, 0px));
  border-radius: 0;
  border-top: 1px solid rgba(99, 220, 190, 0.22);
  background:
    linear-gradient(180deg, rgba(14, 28, 32, 0.98) 0%, rgba(6, 12, 14, 1) 100%);
  box-shadow:
    0 -24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  z-index: 40;
}

/* Single upload control — studio stage */
.main.studio-media .attach-bar {
  padding: 0;
  gap: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.main.studio-media .attach-bar::before {
  content: "Reference";
  display: block;
  font: 700 10px/1.2 var(--font-ui);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ice);
  margin-bottom: 2px;
}

.main.studio-video .attach-bar::before {
  content: "Source frame";
}

.main.studio-media .attach-stage-grid {
  display: block;
}

.main.studio-media .attach-dropzone {
  position: relative;
  min-height: 96px;
  border-radius: var(--radius-lg);
  border: 2px dashed rgba(99, 220, 190, 0.28);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(99, 220, 190, 0.08), transparent 55%),
    rgba(6, 14, 16, 0.9);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast),
    box-shadow var(--t-fast);
  overflow: hidden;
}

.main.studio-media .attach-dropzone:hover,
.main.studio-media .attach-dropzone.is-dragover {
  border-color: rgba(99, 220, 190, 0.5);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(99, 220, 190, 0.14), transparent 55%),
    rgba(8, 18, 22, 0.95);
  box-shadow: 0 0 0 3px rgba(99, 220, 190, 0.1);
}

.main.studio-media .attach-dropzone:has(.attach-preview:not(.hidden)) {
  border-style: solid;
  border-color: rgba(99, 220, 190, 0.38);
  background: rgba(8, 18, 22, 0.95);
}

.main.studio-media .attach-dropzone .attach-btn {
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;
  margin: 0;
  padding: 18px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-weight: 600;
}

.main.studio-media .attach-dropzone .attach-btn:hover:not(:disabled) {
  background: transparent;
  box-shadow: none;
  color: var(--ice-bright);
}

.main.studio-media .attach-btn-kicker {
  display: block;
  font: 700 14px/1.2 var(--font-ui);
  letter-spacing: 0.04em;
}

.main.studio-media .attach-btn-sub {
  display: block;
  font: 500 12px/1.3 var(--font-ui);
  color: var(--muted2);
  letter-spacing: 0.02em;
}

.main.studio-media .attach-dropzone:has(.attach-preview:not(.hidden)) .attach-btn {
  display: none;
}

.main.studio-media .attach-preview {
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 12px;
  animation: pop-in 0.22s ease both;
}

.main.studio-media .attach-preview img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid rgba(99, 220, 190, 0.28);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.main.studio-media .attach-preview span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  max-width: none;
  flex: 1 1 auto;
  white-space: normal;
}

.main.studio-media .attach-tools {
  display: none;
}

/* Prompt + Generate — hero of the studio */
.main.studio-media .composer {
  padding: 16px 16px 16px 24px;
  border-radius: 20px;
  border-color: rgba(99, 220, 190, 0.4);
  background:
    linear-gradient(180deg, rgba(32, 56, 60, 0.98), rgba(10, 18, 22, 1)),
    radial-gradient(120% 80% at 0% 0%, rgba(99, 220, 190, 0.14), transparent 55%);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(99, 220, 190, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.main.studio-media .composer:focus-within {
  border-color: rgba(99, 220, 190, 0.65);
  box-shadow:
    0 0 0 4px var(--ice-glow),
    0 18px 44px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.main.studio-media #input {
  min-height: 64px;
  max-height: 180px;
  font-size: 16px;
  padding: 14px 4px;
}

.main.studio-media #send {
  min-width: 128px;
  min-height: 58px;
  padding: 16px 26px;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  box-shadow: 0 8px 28px rgba(99, 220, 190, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Canvas-first transcript: media dominates, chat chrome recedes */
.main.studio-media .msg {
  max-width: min(740px, 96%);
  width: 100%;
}

.main.studio-media .msg .role {
  display: none;
}

.main.studio-media .msg.you {
  max-width: min(520px, 88%);
  align-self: center;
}

.main.studio-media .msg.you .bubble {
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 12px;
  background: rgba(14, 36, 34, 0.75);
  border-color: rgba(99, 220, 190, 0.16);
  box-shadow: none;
  color: var(--muted);
  text-align: center;
}

.main.studio-media .msg.sig:not(.has-media):not(.pending) .bubble {
  padding: 10px 14px;
  font-size: 13px;
  background: rgba(10, 18, 22, 0.55);
  border-color: rgba(99, 220, 190, 0.08);
  box-shadow: none;
  color: var(--muted);
}

.main.studio-media .msg.has-media {
  max-width: min(760px, 98%);
}

.main.studio-media .msg.has-media .bubble {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  white-space: normal;
}

.main.studio-media .msg.has-media .media-caption {
  display: block;
  padding: 6px 4px 10px;
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.35;
  text-align: center;
}

.main.studio-media .msg.has-media .bubble > :not(.gen-figure):not(.img-missing):not(.img-path):not(.img-missing-card):not(.media-caption):not(.gen-actions):not(.msg-actions) {
  display: block;
  padding: 6px 4px 10px;
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.35;
  text-align: center;
}

.main.studio-media .msg.has-media .gen-figure {
  margin: 0;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(99, 220, 190, 0.28);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(99, 220, 190, 0.08);
  max-width: min(100%, 720px);
  overflow: hidden;
}

.main.studio-media .msg.has-media .gen-img,
.main.studio-media .msg.has-media .gen-video {
  max-width: 100%;
  width: 100%;
  border-radius: 0;
  box-shadow: none;
}

.main.studio-media .empty-state--studio {
  position: relative;
  margin: auto;
  text-align: center;
  padding: 48px 28px 56px;
  max-width: 420px;
  animation: fade-up 0.36s ease both;
}

.main.studio-media .studio-canvas-frame {
  width: min(220px, 55vw);
  aspect-ratio: 4 / 3;
  margin: 0 auto 22px;
  border-radius: 18px;
  border: 2px dashed rgba(99, 220, 190, 0.32);
  background:
    linear-gradient(145deg, rgba(99, 220, 190, 0.06), transparent 50%),
    rgba(6, 12, 14, 0.6);
  box-shadow: inset 0 0 40px rgba(99, 220, 190, 0.04);
  position: relative;
}

.main.studio-media .studio-canvas-frame::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 10px;
  border: 1px solid rgba(99, 220, 190, 0.14);
  background: rgba(99, 220, 190, 0.03);
}

.main.studio-media .empty-state--studio .empty-eyebrow {
  color: var(--ice);
  margin-bottom: 10px;
  letter-spacing: 0.18em;
}

.main.studio-media .empty-state--studio .empty-thread-lead {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.5vw, 30px);
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.2;
}

.main.studio-media .empty-state--studio .empty-studio-hint {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted2);
  line-height: 1.5;
}

.main.studio-video .studio-eyebrow,
.main.studio-video .studio-steps li:first-child {
  color: var(--ok);
}

.main.studio-video .studio-steps li:first-child {
  border-color: rgba(125, 206, 160, 0.4);
  background: rgba(125, 206, 160, 0.1);
}

.main.studio-video .attach-dropzone {
  border-color: rgba(125, 206, 160, 0.28);
}

.main.studio-video .composer {
  border-color: rgba(125, 206, 160, 0.35);
}

/* The input shell */
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 11px 11px 11px 20px;
  border-radius: 28px;
  border: 1px solid rgba(99, 220, 190, 0.22);
  background:
    linear-gradient(180deg, rgba(24, 42, 48, 0.94), rgba(8, 16, 20, 0.97)),
    radial-gradient(120% 80% at 0% 0%, rgba(99, 220, 190, 0.07), transparent 55%);
  box-shadow:
    var(--shadow-float),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  transition: border-color var(--t-med), box-shadow var(--t-med), transform var(--t-fast);
}

.composer:focus-within {
  border-color: rgba(99, 220, 190, 0.48);
  box-shadow:
    0 0 0 3px var(--ice-glow),
    0 14px 36px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#input {
  width: 100%;
  min-height: 44px;
  max-height: 128px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  padding: 10px 4px;
}

#input::placeholder {
  color: var(--muted2);
}

#input:disabled {
  opacity: 0.55;
}

#send {
  appearance: none;
  border: 0;
  border-radius: var(--radius-pill);
  min-width: 86px;
  min-height: 44px;
  padding: 12px 20px;
  font: 700 12.5px/1 var(--font-ui);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #04130e;
  background: linear-gradient(135deg, var(--ice-bright), var(--ice) 45%, var(--ice-dim));
  cursor: pointer;
  box-shadow: 0 5px 18px var(--ice-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: filter var(--t-fast), opacity var(--t-fast), transform var(--t-fast),
    box-shadow var(--t-med);
}

#send:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 220, 190, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#send:active:not(:disabled) {
  transform: translateY(0);
}

#send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

/* ————————————————— Settings drawer ————————————————— */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 8, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med);
  z-index: 40;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 92vw);
  height: 100%;
  background:
    radial-gradient(120% 40% at 100% 0%, rgba(99, 220, 190, 0.08), transparent 55%),
    linear-gradient(180deg, #0c171c, #060c0f);
  border-left: 1px solid rgba(99, 220, 190, 0.1);
  padding: 28px 22px 28px;
  transform: translateX(104%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 50;
  overflow-y: auto;
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.4);
}

.drawer.open {
  transform: translateX(0);
}

.drawer h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

.drawer-lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-section:last-of-type {
  border-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ice);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  margin-bottom: 6px;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted2);
  font-size: 12px;
  line-height: 1.45;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font: 500 13.5px/1.3 var(--font-ui);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.field select {
  cursor: pointer;
}

.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.setting-toggle:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.setting-toggle span {
  min-width: 0;
}

.setting-toggle strong,
.setting-toggle small {
  display: block;
}

.setting-toggle strong {
  color: var(--text);
  font: 600 13px/1.35 var(--font-ui);
}

.setting-toggle small {
  margin-top: 3px;
  color: var(--muted2);
  font: 400 11.5px/1.4 var(--font-ui);
}

.setting-toggle input[type="checkbox"] {
  width: 40px;
  height: 23px;
  flex: 0 0 40px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--raised);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.setting-toggle input[type="checkbox"]::after {
  content: "";
  display: block;
  width: 17px;
  height: 17px;
  margin: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--t-med), background var(--t-fast);
}

.setting-toggle input[type="checkbox"]:checked {
  border-color: var(--ice-dim);
  background: var(--ice-glow);
}

.setting-toggle input[type="checkbox"]:checked::after {
  transform: translateX(17px);
  background: var(--ice);
}

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

.range-label output {
  color: var(--ice);
  font: 600 12px/1 var(--font-ui);
}

.field input[type="range"] {
  height: 32px;
  padding: 0;
  accent-color: var(--ice);
}

.voice-test {
  width: 100%;
  margin: -2px 0 14px;
}

.field select:disabled,
.field input:disabled,
.voice-test:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.field input:focus,
.field select:focus {
  border-color: var(--ice-dim);
  box-shadow: var(--shadow-ring);
}

.settings-advanced {
  margin: 4px 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(5, 11, 14, 0.55);
  padding: 0 12px 4px;
}

.settings-advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 4px;
  font: 600 13px/1.3 var(--font-ui);
  color: var(--muted);
  user-select: none;
  transition: color var(--t-fast);
}

.settings-advanced > summary:hover {
  color: var(--text);
}

.settings-advanced > summary::-webkit-details-marker {
  display: none;
}

.settings-advanced > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted2);
  transition: transform var(--t-fast);
}

.settings-advanced[open] > summary {
  color: var(--text);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 12px;
}

.settings-advanced[open] > summary::before {
  transform: rotate(90deg);
}

.settings-advanced .advanced-intro {
  margin: 0 0 12px;
}

.drawer-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, #070d10 28%);
}

.drawer-actions .btn-new {
  flex: 1;
}

/* ————————————————— Legacy context menu ————————————————— */
#ctx {
  position: fixed;
  z-index: 80;
  min-width: 160px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #101d23;
  box-shadow: var(--shadow);
  display: none;
}

#ctx.open {
  display: block;
}

#ctx button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font: 500 13px/1 var(--font-ui);
  cursor: pointer;
}

#ctx button:hover {
  background: rgba(232, 137, 122, 0.12);
  color: var(--danger);
}

/* ————————————————— Mode picker ————————————————— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 8, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med);
  z-index: 60;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mode-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%) scale(0.98);
  width: min(440px, 92vw);
  max-height: min(78vh, 620px);
  overflow-y: auto;
  padding: 26px 24px 20px;
  border-radius: 22px;
  border: 1px solid rgba(99, 220, 190, 0.12);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(99, 220, 190, 0.08), transparent 55%),
    linear-gradient(180deg, #0f1c22, #081014);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-med);
  z-index: 70;
}

.mode-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.mode-modal h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.005em;
}

.mode-modal .hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mode-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.mode-card {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(145deg, rgba(17, 31, 37, 0.95), rgba(9, 16, 20, 0.98));
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-med), transform var(--t-fast),
    background var(--t-fast);
}

.mode-card:hover {
  border-color: var(--ice-dim);
  box-shadow: var(--shadow-ring), 0 10px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.mode-card:active {
  transform: translateY(0);
}

.mode-card.kind-homegrown {
  border-color: var(--amber-dim);
  background:
    radial-gradient(130% 150% at 0% 0%, rgba(220, 168, 94, 0.1), transparent 55%),
    linear-gradient(145deg, rgba(20, 30, 30, 0.96), rgba(9, 16, 20, 0.98));
}

.mode-card.kind-homegrown:hover {
  border-color: rgba(220, 168, 94, 0.5);
  box-shadow: 0 0 0 3px rgba(220, 168, 94, 0.13), 0 10px 24px rgba(0, 0, 0, 0.3);
}

.mode-card.kind-homegrown .mode-kind {
  color: var(--amber-bright);
}

.mode-card.kind-agent {
  border-color: rgba(99, 220, 190, 0.38);
  background:
    radial-gradient(130% 150% at 100% 0%, rgba(99, 220, 190, 0.13), transparent 56%),
    linear-gradient(145deg, rgba(13, 31, 34, 0.98), rgba(7, 15, 19, 0.98));
}

.mode-card.kind-agent:hover {
  border-color: rgba(99, 220, 190, 0.62);
  box-shadow: 0 0 0 3px rgba(99, 220, 190, 0.12), 0 10px 24px rgba(0, 0, 0, 0.3);
}

.mode-card.kind-agent .mode-kind {
  color: var(--ice);
}

.agent-actions {
  margin-top: 10px;
}

.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(99, 220, 190, 0.4);
  border-radius: 999px;
  background: rgba(99, 220, 190, 0.1);
  color: var(--ice);
  font: 600 11px/1 var(--font-ui);
  white-space: nowrap;
}

.agent-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(99, 220, 190, 0.95);
  animation: pulse 1.4s ease-in-out infinite;
}

.agent-action {
  appearance: none;
  border: 1px solid rgba(99, 220, 190, 0.38);
  border-radius: 8px;
  background: rgba(99, 220, 190, 0.09);
  color: var(--ice);
  padding: 7px 11px;
  font: 600 11.5px/1 var(--font-ui);
  cursor: pointer;
}

.agent-action:hover {
  border-color: rgba(99, 220, 190, 0.62);
  background: rgba(99, 220, 190, 0.14);
}

.agent-action:disabled {
  opacity: 0.55;
  cursor: default;
}

.agent-confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(220, 168, 94, 0.28);
  border-radius: 9px;
  background: rgba(220, 168, 94, 0.07);
}

.agent-confirm strong,
.agent-confirm small {
  display: block;
}

.agent-confirm small {
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.agent-diff {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--raised);
}

.agent-diff summary {
  cursor: pointer;
  color: var(--ice);
  font: 600 12px/1.4 var(--font-ui);
}

.agent-diff-body {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font: 11px/1.45 ui-monospace, Consolas, monospace;
  color: var(--muted);
}

.agent-todos {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
  font: 12px/1.45 var(--font-ui);
}

.agent-todos ul {
  margin: 6px 0 0;
  padding-left: 1.1rem;
}

.agent-todos li {
  margin: 2px 0;
  color: var(--text);
}

.mode-card.kind-image {
  border-color: rgba(99, 220, 190, 0.28);
}

.mode-card.kind-image .mode-kind {
  color: var(--ice);
}

.mode-card.kind-video {
  border-color: rgba(125, 206, 160, 0.28);
}

.mode-card.kind-video .mode-kind {
  color: var(--ok);
}

/* Adult — wine velvet + gold, deliberately premium */
.mode-card.kind-adult {
  position: relative;
  border-color: var(--adult-dim);
  background:
    radial-gradient(130% 150% at 100% 0%, rgba(226, 99, 127, 0.17), transparent 55%),
    linear-gradient(150deg, #261019 0%, #160a10 60%, #100810 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 224, 0.07);
}

.mode-card.kind-adult:hover {
  border-color: rgba(226, 99, 127, 0.55);
  box-shadow: 0 0 0 3px rgba(226, 99, 127, 0.15), 0 10px 24px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 214, 224, 0.09);
}

.mode-card.kind-adult .mode-kind {
  color: var(--gold);
}

.mode-card.kind-adult .mode-kind::after {
  content: none;
  display: none;
}

.mode-card.kind-adult .mode-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: 0.01em;
}

.mode-card.kind-adult .mode-blurb {
  color: #cda6ae;
}

.mode-kind {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ice);
  margin-bottom: 5px;
}

.mode-name {
  display: block;
  font: 600 14.5px/1.35 var(--font-ui);
}

.mode-blurb {
  display: block;
  margin-top: 5px;
  font: 400 12px/1.45 var(--font-ui);
  color: var(--muted);
}

.mode-cancel {
  width: 100%;
  padding: 12px;
}

/* ————————————————— Busy pulse ————————————————— */
.busy-pulse {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ice);
  margin-right: 8px;
  box-shadow: 0 0 0 0 var(--ice-glow);
  animation: pulse 1.2s ease infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 220, 190, 0.5);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(99, 220, 190, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 220, 190, 0);
  }
}

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

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

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes brand-settle {
  from {
    opacity: 0;
    transform: translateY(10px);
    letter-spacing: 0.14em;
  }
  to {
    opacity: 1;
    transform: none;
    letter-spacing: 0.06em;
  }
}

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

  .empty-state--welcome::before {
    animation: none !important;
  }
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 228px 1fr;
  }
  .main {
    padding: 10px 14px 12px;
  }
}

/* ————————————————— Auth / unlock ————————————————— */
.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-backdrop {
  display: none;
}

.btn-menu {
  display: none;
}

.phone-topbar {
  display: none;
}

.auth-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 520px at 20% 10%, rgba(99, 220, 190, 0.14), transparent 55%),
    radial-gradient(700px 480px at 90% 80%, rgba(220, 168, 94, 0.07), transparent 50%),
    radial-gradient(120% 100% at 50% 50%, rgba(4, 8, 10, 0.72), rgba(2, 5, 7, 0.96)),
    #04080a;
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}

.auth-gate.open {
  display: flex;
  animation: fade-up 0.35s var(--t-med) both;
}

.auth-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 32px 26px 26px;
  border-radius: 24px;
  border: 1px solid rgba(99, 220, 190, 0.14);
  background:
    linear-gradient(165deg, rgba(16, 30, 36, 0.96), rgba(8, 16, 20, 0.98)),
    radial-gradient(120% 80% at 0% 0%, rgba(99, 220, 190, 0.08), transparent 55%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: pop-in 0.32s var(--t-med) both;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.auth-mark-img,
.auth-logo {
  width: 42px;
  height: 42px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 8px 22px rgba(99, 220, 190, 0.35));
}

.auth-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 0.12em;
  margin: 0;
  line-height: 1;
  color: var(--text);
  animation: brand-settle 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-lead {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 18px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 20px;
  border-radius: 14px;
  border: 1px solid rgba(99, 220, 190, 0.1);
  background: rgba(0, 0, 0, 0.22);
}

.auth-tab {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: 600 13.5px/1 var(--font-ui);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: linear-gradient(165deg, rgba(22, 42, 48, 0.98), rgba(14, 28, 34, 0.98));
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.auth-pane.hidden {
  display: none;
}

.auth-optional {
  font-weight: 400;
  opacity: 0.65;
  font-size: 11.5px;
}

.auth-card input[type="email"],
.auth-card input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  min-height: 52px;
  border-radius: 13px;
  border: 1px solid rgba(99, 220, 190, 0.12);
  background: rgba(5, 12, 15, 0.85);
  color: var(--text);
  font: 500 16px/1.3 var(--font-ui);
  letter-spacing: 0.01em;
  margin-bottom: 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.auth-card input[type="email"]:focus,
.auth-card input[type="password"]:focus {
  border-color: var(--ice-dim);
  box-shadow: var(--shadow-ring);
}

.auth-strength {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  margin: -8px 0 14px;
  overflow: hidden;
}

.auth-strength span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--danger);
  transition: width 0.25s ease, background 0.25s ease;
}

.auth-strength.ok span {
  background: #d9a441;
}

.auth-strength.good span {
  background: #4fbf7a;
}

.auth-code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 14px;
}

.auth-code-row input {
  flex: 1;
  margin-bottom: 0;
}

.auth-send-code {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 14px;
  white-space: nowrap;
}

.auth-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}

.auth-card input[type="text"],
.auth-card input#authToken {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  min-height: 52px;
  border-radius: 13px;
  border: 1px solid rgba(99, 220, 190, 0.12);
  background: rgba(5, 12, 15, 0.85);
  color: var(--text);
  font: 500 16px/1.3 var(--font-ui);
  letter-spacing: 0.01em;
  margin-bottom: 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.auth-card input[type="text"]:focus,
.auth-card input#authToken:focus {
  border-color: var(--ice-dim);
  box-shadow: var(--shadow-ring);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  margin: 0 0 8px;
  user-select: none;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 220, 190, 0.08);
  background: rgba(99, 220, 190, 0.04);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.auth-remember:hover {
  border-color: rgba(99, 220, 190, 0.18);
  background: rgba(99, 220, 190, 0.07);
}

.auth-remember input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ice);
}

.auth-remember-hint {
  margin: 0 0 14px !important;
}

.auth-unlock {
  width: 100%;
  min-height: 48px;
  font-size: 15px !important;
  margin-top: 2px;
}

.auth-hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.auth-hint a {
  color: var(--ice);
}

.auth-hint code {
  font-size: 11.5px;
  word-break: break-all;
  font-family: var(--font-mono);
}

.auth-error {
  color: var(--danger);
  font-size: 13.5px;
  margin: 0 0 12px;
}

.auth-error.hidden {
  display: none;
}

/* ————————————————— Phone / narrow ————————————————— */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    height: 100%;
    height: 100dvh;
  }

  .chat-rename,
  .chat-del {
    opacity: 0.85;
    width: 34px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med);
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    box-shadow: 20px 0 48px rgba(0, 0, 0, 0.5);
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    animation: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .phone-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 2px 0 0;
    padding-top: max(2px, env(safe-area-inset-top));
  }

  .btn-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(99, 220, 190, 0.14);
    background: rgba(18, 34, 40, 0.9);
    color: var(--text);
    font-size: 17px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--t-fast), background var(--t-fast);
  }

  .btn-menu:active {
    background: var(--ice-wash);
    border-color: var(--line-bright);
  }

  /* Compact phone chrome — no big SIG hero */
  .phone-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    min-width: 0;
  }

  .phone-hero h1 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.05em;
    line-height: 1.15;
  }

  .phone-hero p {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: var(--muted2);
  }

  .main {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: 8px 12px 8px;
    gap: 8px;
    height: 100%;
    max-height: 100%;
  }

  .phone-topbar {
    grid-row: 1;
  }

  .homegrown-banner {
    grid-row: 2;
    padding: 6px 11px;
    font-size: 11.5px;
  }

  .transcript-shell {
    grid-row: 3;
    border-radius: var(--radius);
  }

  .transcript {
    padding: 16px 14px 12px;
    gap: 15px;
  }

  .msg {
    max-width: 88%;
  }

  .msg .bubble {
    padding: 11px 14px;
    font-size: 15px;
  }

  .composer-wrap {
    grid-row: 4;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }

  .composer {
    border-radius: 26px;
    padding: 9px 9px 9px 16px;
  }

  .composer textarea {
    font-size: 16px; /* prevents iOS zoom-on-focus */
    min-height: 44px;
  }

  .composer #send {
    min-height: 44px;
    min-width: 78px;
  }

  /* Comfortable tap targets for attach chips */
  .attach-btn {
    min-height: 40px;
    padding: 10px 15px;
  }

  .attach-preview {
    min-height: 40px;
  }

  .attach-preview span {
    max-width: 130px;
  }

  /* Studio — canvas + workbench on phone */
  .main.studio-media {
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }

  .main.studio-media .phone-topbar,
  .main.studio-media .homegrown-banner {
    margin-left: 12px;
    margin-right: 12px;
  }

  .main.studio-media .transcript-shell {
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0 8px 0;
  }

  .main.studio-media .studio-banner {
    padding: 2px 4px 8px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .main.studio-media .studio-title {
    font-size: 24px;
  }

  .main.studio-media .studio-lead {
    font-size: 12.5px;
  }

  .main.studio-media .studio-steps {
    width: 100%;
    justify-content: flex-start;
  }

  .main.studio-media .studio-steps li {
    padding: 7px 9px;
    font-size: 9px;
  }

  .main.studio-media .transcript {
    padding: 14px 12px 12px;
    gap: 12px;
  }

  .main.studio-media .composer-wrap {
    margin: 0;
    padding: 14px 12px max(12px, env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }

  .main.studio-media .attach-stage-grid {
    display: block;
  }

  .main.studio-media .attach-dropzone,
  .main.studio-media .attach-dropzone .attach-btn,
  .main.studio-media .attach-preview {
    min-height: 80px;
  }

  .main.studio-media .attach-preview img {
    width: 52px;
    height: 52px;
  }

  .main.studio-media .composer {
    padding: 12px 12px 12px 16px;
    border-radius: 18px;
  }

  .main.studio-media #input {
    min-height: 52px;
    font-size: 16px;
  }

  .main.studio-media #send {
    min-width: 104px;
    min-height: 52px;
  }

  .main.studio-media .empty-state--studio {
    padding: 28px 16px 36px;
  }

  .main.studio-media .studio-canvas-frame {
    width: min(180px, 50vw);
    margin-bottom: 16px;
  }

  .main.studio-media .empty-state--studio .empty-thread-lead {
    font-size: 22px;
  }

  .main.chat-attach .attach-tools {
    margin-left: 0;
    width: 100%;
  }

  /* Mode picker becomes a bottom sheet */
  .mode-modal {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: min(82dvh, 560px);
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding: 22px 18px max(18px, env(safe-area-inset-bottom));
    transform: translateY(8%);
  }

  .mode-modal.open {
    transform: translateY(0);
  }

  .mode-modal::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: -8px auto 14px;
    border-radius: var(--radius-pill);
    background: var(--line);
  }

  .drawer {
    width: min(100vw, 400px);
    padding-top: max(26px, env(safe-area-inset-top));
  }

  .gen-img,
  .gen-video {
    max-width: 100%;
  }

  .empty-state--welcome .empty-title {
    font-size: 34px;
  }

  .empty-state--welcome .empty-mark {
    width: 44px;
    height: 44px;
  }

  .auth-card {
    padding: 28px 20px 22px;
    border-radius: 20px;
  }
}

/* Extra-narrow phones (~390px and below) */
@media (max-width: 430px) {
  .main {
    padding: 5px 8px 5px;
  }

  .transcript {
    padding: 14px 12px 10px;
  }

  .msg {
    max-width: 92%;
  }

  .mode-chip {
    max-width: 150px;
  }

  .attach-bar {
    gap: 6px;
  }

  .attach-btn {
    padding: 10px 12px;
    font-size: 11.5px;
  }

  .empty-state--welcome {
    padding: 32px 12px;
  }
}
