:root {
  --bg: #0b1016;
  --bg-alt: #111823;
  --panel: rgba(16, 22, 31, 0.92);
  --panel-strong: #161d28;
  --panel-soft: #101722;
  --ink: #e7edf7;
  --muted: #8e9aae;
  --accent: #10a37f;
  --accent-soft: rgba(16, 163, 127, 0.16);
  --accent-warm: #8fb4ff;
  --border: rgba(148, 163, 184, 0.16);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.34);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --stage-line: rgba(255, 255, 255, 0.1);
  --speech-glow: 0.28;
  --speech-bloom: 0.14;
  --halo-x-shift: 0%;
  --halo-y-shift: 0%;
  --look-x-shift: 0%;
  --look-y-shift: 0%;
  --siri-angle: 0deg;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(16, 163, 127, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(93, 129, 255, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg), var(--bg-alt));
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI Variable Text", sans-serif;
}

body {
  padding: 16px;
}

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

.page-shell {
  display: grid;
  grid-template-columns: minmax(132px, 156px) minmax(0, 1fr);
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100vh - 32px);
}

.control-rail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  overflow: visible;
}

.conversation-stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.brain-stage {
  position: relative;
  min-height: clamp(280px, 34vh, 400px);
  overflow: hidden;
  border: 1px solid rgba(143, 180, 255, 0.14);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 18%, rgba(141, 99, 255, 0.18), transparent 28%),
    radial-gradient(circle at 76% 18%, rgba(91, 216, 255, 0.12), transparent 26%),
    radial-gradient(circle at 50% 56%, rgba(255, 255, 255, 0.04), transparent 16%),
    linear-gradient(180deg, rgba(8, 12, 18, 0.98), rgba(10, 14, 21, 0.96));
  box-shadow: var(--shadow);
  isolation: isolate;
}

.brain-stage-backdrop,
.brain-stage-grid,
.brain-aura {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.brain-stage-backdrop {
  background:
    radial-gradient(circle at 50% 54%, rgba(255, 255, 255, 0.04), transparent 18%),
    radial-gradient(circle at 28% 48%, rgba(91, 216, 255, 0.08), transparent 30%),
    radial-gradient(circle at 72% 46%, rgba(141, 99, 255, 0.1), transparent 30%);
  filter: saturate(124%);
}

.brain-stage-grid {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 11.111%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.014) 0, rgba(255, 255, 255, 0.014) 1px, transparent 1px, transparent 11.111%);
  opacity: 0.08;
}

.brain-stage-copy,
.brain-stage-panel {
  position: absolute;
  z-index: 3;
}

.brain-stage-copy {
  top: clamp(20px, 2.6vw, 30px);
  left: clamp(20px, 2.8vw, 32px);
  display: grid;
  gap: 10px;
  max-width: min(390px, 46%);
}

.brain-stage-kicker,
.brain-stage-panel-label {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #b8d7ff;
  font-weight: 700;
}

.brain-stage-copy h2 {
  margin: 0;
  font-size: clamp(1.7rem, 2.9vw, 2.8rem);
  line-height: 0.96;
}

.brain-stage-copy p,
.brain-stage-panel p {
  margin: 0;
  color: #c2cfdd;
  line-height: 1.46;
  max-width: 30ch;
}

.brain-stage-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.brain-stage-panel {
  left: clamp(20px, 2.8vw, 32px);
  bottom: clamp(20px, 2.8vw, 28px);
  width: min(320px, calc(100% - 40px));
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--stage-line);
  border-radius: 18px;
  background: rgba(8, 12, 18, 0.34);
  backdrop-filter: blur(20px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
}

.brain-stage-panel strong {
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: #f1f6ff;
}

.brain-stage-panel p {
  font-size: 0.86rem;
  color: #adc0d9;
}

.brain-aura {
  inset: auto 50% -10%;
  width: min(92vmin, 920px);
  height: min(92vmin, 920px);
  transform: translateX(-50%);
  border-radius: 50%;
  mix-blend-mode: screen;
}

.brain-aura--outer {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, calc(0.06 + var(--speech-glow) * 0.08)) 0%, rgba(255, 255, 255, 0) 18%),
    repeating-conic-gradient(from var(--siri-angle), rgba(91, 216, 255, calc(0.18 + var(--speech-bloom) * 0.18)) 0deg 7deg, rgba(91, 216, 255, 0) 7deg 22deg, rgba(141, 99, 255, calc(0.16 + var(--speech-bloom) * 0.16)) 22deg 30deg, rgba(141, 99, 255, 0) 30deg 56deg);
  filter: blur(calc(24px + var(--speech-bloom) * 16px));
  opacity: calc(0.38 + var(--speech-glow) * 0.3);
}

.brain-aura--inner {
  background:
    radial-gradient(circle at calc(50% + var(--halo-x-shift)) calc(50% + var(--halo-y-shift)), rgba(91, 216, 255, calc(0.22 + var(--speech-glow) * 0.22)) 0%, rgba(91, 216, 255, 0) 32%),
    radial-gradient(circle at 50% 56%, rgba(141, 99, 255, calc(0.2 + var(--speech-bloom) * 0.2)) 0%, rgba(141, 99, 255, 0) 36%);
  filter: blur(calc(42px + var(--speech-bloom) * 20px));
  opacity: calc(0.42 + var(--speech-glow) * 0.24);
}

.brain-aura--beam {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, calc(0.06 + var(--speech-glow) * 0.06)) 0%, rgba(255, 255, 255, 0) 18%),
    linear-gradient(146deg, rgba(91, 216, 255, calc(0.16 + var(--speech-bloom) * 0.2)) 12%, rgba(91, 216, 255, 0) 34%),
    linear-gradient(214deg, rgba(141, 99, 255, calc(0.14 + var(--speech-bloom) * 0.18)) 10%, rgba(141, 99, 255, 0) 32%),
    repeating-conic-gradient(from var(--siri-angle) at 50% 50%, rgba(86, 239, 197, calc(0.12 + var(--speech-bloom) * 0.12)) 0deg 4deg, rgba(86, 239, 197, 0) 4deg 18deg, rgba(91, 216, 255, calc(0.16 + var(--speech-bloom) * 0.16)) 18deg 24deg, rgba(91, 216, 255, 0) 24deg 38deg);
  filter: blur(calc(12px + var(--speech-bloom) * 10px));
  opacity: calc(0.28 + var(--speech-bloom) * 0.18);
}

.assistant-face--stage {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.assistant-avatar-frame--stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.assistant-avatar-frame--stage::before,
.assistant-avatar-frame--stage::after,
.assistant-siri-glow--stage,
.assistant-siri-glow--stage::before,
.assistant-siri-glow--stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.assistant-avatar-frame--stage::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 16%),
    linear-gradient(150deg, rgba(91, 216, 255, calc(0.1 + var(--speech-glow) * 0.14)) 10%, rgba(91, 216, 255, 0) 30%),
    linear-gradient(210deg, rgba(141, 99, 255, calc(0.08 + var(--speech-bloom) * 0.14)) 10%, rgba(141, 99, 255, 0) 30%);
  mix-blend-mode: screen;
  opacity: calc(0.2 + var(--speech-glow) * 0.14);
}

.assistant-avatar-frame--stage::after {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0) 0 16%, rgba(255, 255, 255, calc(0.02 + var(--speech-glow) * 0.04)) 16% 17.2%, rgba(255, 255, 255, 0) 17.2% 33%),
    radial-gradient(circle at calc(50% + var(--halo-x-shift)) calc(44% + var(--halo-y-shift)), rgba(255, 255, 255, calc(0.08 + var(--speech-glow) * 0.08)) 0%, rgba(255, 255, 255, 0) 16%);
  mix-blend-mode: screen;
  opacity: calc(0.08 + var(--speech-bloom) * 0.12);
}

.assistant-siri-glow--stage {
  background:
    radial-gradient(circle at calc(50% + var(--halo-x-shift)) calc(48% + var(--halo-y-shift)), rgba(91, 216, 255, calc(0.16 + var(--speech-glow) * 0.18)) 0%, rgba(91, 216, 255, 0) 24%),
    radial-gradient(circle at 50% 54%, rgba(141, 99, 255, calc(0.14 + var(--speech-bloom) * 0.14)) 0%, rgba(141, 99, 255, 0) 36%);
  filter: blur(calc(18px + var(--speech-bloom) * 12px));
  opacity: calc(0.28 + var(--speech-glow) * 0.2);
}

.assistant-siri-glow--stage::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, calc(0.06 + var(--speech-glow) * 0.08)) 0%, rgba(255, 255, 255, 0) 18%),
    linear-gradient(146deg, rgba(86, 239, 197, calc(0.12 + var(--speech-bloom) * 0.16)) 12%, rgba(86, 239, 197, 0) 34%),
    linear-gradient(214deg, rgba(141, 99, 255, calc(0.12 + var(--speech-bloom) * 0.16)) 12%, rgba(141, 99, 255, 0) 34%);
  opacity: calc(0.34 + var(--speech-bloom) * 0.18);
}

.assistant-siri-glow--stage::after {
  background: repeating-conic-gradient(from var(--siri-angle) at 50% 50%, rgba(91, 216, 255, calc(0.12 + var(--speech-bloom) * 0.14)) 0deg 5deg, rgba(91, 216, 255, 0) 5deg 16deg, rgba(141, 99, 255, calc(0.12 + var(--speech-bloom) * 0.14)) 16deg 22deg, rgba(141, 99, 255, 0) 22deg 36deg, rgba(86, 239, 197, calc(0.12 + var(--speech-bloom) * 0.14)) 36deg 42deg, rgba(86, 239, 197, 0) 42deg 58deg);
  filter: blur(calc(8px + var(--speech-bloom) * 6px));
  opacity: calc(0.28 + var(--speech-bloom) * 0.2);
}

.assistant-avatar-canvas--stage {
  position: absolute;
  inset: 0;
}

.assistant-avatar-canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.assistant-avatar-fallback {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.6);
  border: 1px solid var(--stage-line);
  color: #d6e1f2;
  backdrop-filter: blur(14px);
}

.brand-card,
.command-card,
.voice-card,
.vision-card,
.inspector-card,
.chat-header,
.transcript,
.composer {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-card,
.command-card,
.voice-card,
.vision-card,
.inspector-card,
.chat-header,
.composer {
  padding: 16px;
}

.brand-card {
  display: grid;
  gap: 8px;
}

.brand-bar,
.brand-meta,
.chat-header,
.voice-card-header,
.backend-voice-block,
.message-meta,
.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.utility-stack {
  display: grid;
  gap: 12px;
}

.drawer-stack {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 600;
}

h1 {
  font-size: 1.18rem;
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.95rem;
}

.status-badge,
.mode-badge,
.message-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.72rem;
  line-height: 1;
}

.status-badge {
  background: var(--accent-soft);
  color: #8ff0d4;
  font-weight: 700;
}

.mode-badge {
  background: rgba(143, 180, 255, 0.14);
  color: #b4cbff;
  font-weight: 700;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tool-drawer {
  position: relative;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  overflow: visible;
}

.tool-drawer summary {
  list-style: none;
}

.tool-drawer summary::-webkit-details-marker {
  display: none;
}

.tool-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-drawer[open] .tool-toggle {
  border-color: rgba(16, 163, 127, 0.44);
  background: #18212d;
}

.mini-tool-icon {
  width: 16px;
  display: grid;
  gap: 4px;
}

.mini-tool-icon span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #dce6f4;
}

.mini-tool-icon span:nth-child(2) {
  width: 12px;
}

.mini-tool-icon span:nth-child(3) {
  width: 8px;
}

.tool-drawer .drawer-stack {
  position: absolute;
  top: 56px;
  left: 0;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--border);
  background: rgba(16, 22, 31, 0.98);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.chip-grid button,
.desktop-window-button,
#sendButton,
.ghost-action {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.chip-grid button:hover,
.desktop-window-button:hover,
#sendButton:hover,
.ghost-action:hover {
  transform: translateY(-1px);
  border-color: rgba(16, 163, 127, 0.44);
  background: #1a2431;
}

.ghost-action {
  padding: 8px 10px;
  font-size: 0.78rem;
}

.desktop-window-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.conversation-toolbar {
  justify-self: end;
}

.desktop-window-button--danger {
  border-color: rgba(255, 113, 113, 0.24);
  color: #ffb3b3;
}

#sendButton {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 16px;
  background: var(--accent);
  color: #04130e;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.send-glyph {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
}

.send-glyph::before,
.send-glyph::after {
  content: "";
  position: absolute;
}

.send-glyph::before {
  width: 10px;
  height: 2px;
  top: 6px;
  left: 1px;
  border-radius: 999px;
  background: #04130e;
}

.send-glyph::after {
  width: 7px;
  height: 7px;
  border-top: 2px solid #04130e;
  border-right: 2px solid #04130e;
  top: 2px;
  right: 1px;
  transform: rotate(45deg);
}

.voice-status-text,
.composer-hint {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-actions,
.vision-controls {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.voice-actions {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.backend-voice-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.backend-voice-copy {
  flex: 1 1 auto;
}

.backend-voice-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c6d2e3;
}

.voice-toggle,
.file-picker {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--ink);
  padding: 9px 12px;
}

.voice-toggle {
  white-space: nowrap;
}

.voice-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.file-picker {
  justify-content: space-between;
  cursor: pointer;
}

.file-picker input {
  max-width: 100%;
  color: var(--muted);
}

.inspector-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.command-card,
.voice-card,
.vision-card,
.inspector-card {
  padding: 14px;
  box-shadow: none;
}

.inspector-stack {
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
}

.inspector-pane {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: var(--radius-md);
  padding: 12px;
}

.inspector-pane summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.inspector-pane summary::-webkit-details-marker {
  display: none;
}

.inspector-pane[open] summary {
  margin-bottom: 10px;
  color: #dce5f2;
}

pre {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #c3cfdf;
}

.brain-activity-frame {
  width: 100%;
  min-height: 320px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(10, 16, 24, 0.92);
}

.memory-lab {
  display: grid;
  gap: 10px;
}

.memory-view {
  display: grid;
  gap: 10px;
}

.memory-view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.memory-tab {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
}

.memory-tab.is-active {
  border-color: rgba(16, 163, 127, 0.46);
  background: rgba(16, 163, 127, 0.16);
  color: var(--ink);
}

.memory-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(84px, 0.42fr);
  gap: 8px;
}

.memory-toolbar button {
  min-height: 36px;
}

#memorySearchInput,
#memoryTableSelect,
#memoryEditorValue,
#adminTokenInput,
.memory-editor input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--ink);
}

#memorySearchInput,
#memoryTableSelect,
#adminTokenInput,
.memory-editor input {
  min-height: 36px;
  padding: 8px 10px;
}

#memoryEditorValue {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.45;
}

.admin-panel {
  display: grid;
  gap: 10px;
}

.admin-token-row,
.admin-actions {
  display: grid;
  gap: 8px;
}

.admin-token-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-actions button,
.admin-token-row button {
  min-height: 34px;
}

#adminPanel {
  min-height: 156px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

.memory-inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.memory-inline-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.memory-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.memory-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.memory-count {
  min-height: 34px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(143, 180, 255, 0.08);
}

.memory-count span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.memory-count strong {
  font-size: 0.86rem;
  line-height: 1;
}

.memory-items {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.memory-item {
  width: 100%;
  min-height: 74px;
  display: grid;
  gap: 5px;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
}

.memory-item:hover,
.memory-item.is-selected {
  border-color: rgba(16, 163, 127, 0.46);
  background: #1a2431;
}

.memory-item.is-deprecated {
  opacity: 0.62;
}

.memory-item-title,
.memory-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.memory-item-title strong,
.memory-editor-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.memory-item p {
  margin: 0;
  color: #c3cfdf;
  font-size: 0.78rem;
  line-height: 1.36;
}

.memory-item-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
}

.memory-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.memory-hygiene {
  gap: 12px;
}

.memory-hygiene-toolbar,
.memory-hygiene-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memory-hygiene-toolbar strong,
.memory-hygiene-section > strong {
  font-size: 0.82rem;
}

.memory-hygiene-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.memory-health-pill {
  min-height: 34px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(16, 163, 127, 0.08);
}

.memory-health-pill span,
.memory-hygiene-label {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.memory-health-pill strong {
  font-size: 0.86rem;
  line-height: 1;
}

.memory-hygiene-section,
.memory-hygiene-group {
  display: grid;
  gap: 8px;
}

.memory-hygiene-group {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(143, 180, 255, 0.06);
}

.memory-mini-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.memory-mini-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
  text-align: left;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
}

.memory-mini-copy:hover {
  border-color: rgba(16, 163, 127, 0.42);
}

.memory-mini-copy p {
  margin: 0;
  color: #c3cfdf;
  font-size: 0.76rem;
  line-height: 1.35;
}

.memory-mini-action {
  min-width: 84px;
}

.memory-editor {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(16, 163, 127, 0.24);
  border-radius: 14px;
  background: rgba(16, 163, 127, 0.08);
}

.memory-editor label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.memory-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.memory-editor-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.transcript {
  min-height: 0;
  overflow: auto;
  padding: 24px clamp(18px, 6vw, 80px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(11, 16, 23, 0.96), rgba(13, 19, 27, 0.96));
}

.message-card {
  width: min(100%, 820px);
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: rgba(20, 27, 37, 0.9);
}

.message-card.pending {
  width: fit-content;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(18, 24, 34, 0.96), rgba(20, 28, 39, 0.96));
  border-color: rgba(16, 163, 127, 0.18);
}

.message-card.assistant {
  margin-right: auto;
}

.message-card.user {
  margin-left: auto;
  background: rgba(27, 35, 47, 0.96);
  border-color: rgba(16, 163, 127, 0.22);
}

.message-card.system {
  margin: 0 auto;
  background: rgba(26, 32, 44, 0.9);
}

.message-role {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-tag {
  background: rgba(148, 163, 184, 0.12);
  color: #b9c5d8;
}

.message-meta[hidden],
.message-role[hidden],
.message-tag[hidden],
.tool-drawer:not([open]) .drawer-stack {
  display: none !important;
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.58;
  color: var(--ink);
}

.message-card.pending .message-body {
  color: #cdd7e5;
  line-height: 1;
}

.pending-shell {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.pending-label {
  font-size: 0.82rem;
  color: #b9c8db;
}

.pending-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(143, 180, 255, 0.08);
}

.pending-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #8ff0d4;
  opacity: 0.35;
  animation: pendingPulse 1.1s infinite ease-in-out;
}

.pending-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.pending-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pendingPulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(12, 17, 24, 0.98);
  border-radius: 22px;
}

.composer-actions {
  justify-content: flex-end;
  align-items: end;
}

.composer.is-busy #sendButton {
  opacity: 0.72;
}

#composerInput,
#visionPromptInput {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--ink);
}

#composerInput {
  min-height: 24px;
  max-height: 180px;
  resize: none;
  padding: 10px 6px 10px 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1.45;
}

#visionPromptInput {
  min-height: 76px;
  resize: vertical;
  padding: 12px 14px;
}

#visionPromptInput:focus {
  outline: none;
  border-color: rgba(16, 163, 127, 0.48);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

#composerInput:focus {
  outline: none;
  box-shadow: none;
}

#composerInput::placeholder {
  color: #8190a3;
}

.composer:focus-within {
  border-color: rgba(16, 163, 127, 0.48);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12), var(--shadow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  body {
    padding: 10px;
  }

  .page-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .control-rail,
  .conversation-stage {
    min-height: auto;
  }

  .voice-card-header,
  .backend-voice-block,
  .chat-header {
    flex-direction: column;
    align-items: stretch;
  }

  .brain-stage {
    min-height: 340px;
  }

  .brain-stage-copy {
    max-width: calc(100% - 32px);
    gap: 10px;
  }

  .brain-stage-panel {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
  }

  .voice-actions {
    grid-template-columns: 1fr;
  }

  .memory-toolbar,
  .memory-editor-actions,
  .memory-mini-item {
    grid-template-columns: 1fr;
  }

  .desktop-window-controls {
    width: 100%;
    justify-content: stretch;
  }

  .desktop-window-button {
    flex: 1 1 0;
  }

  .transcript {
    padding: 16px;
  }

  .composer {
    grid-template-columns: 1fr auto;
  }
}
