:root {
  color-scheme: dark;
  --canvas: #090c0b;
  --surface-1: #0e1311;
  --surface-2: #131a17;
  --surface-3: #18211d;
  --surface-raised: #1d2722;
  --line: #27332e;
  --line-strong: #39483f;
  --ink: #edf2ee;
  --ink-soft: #b7c2bb;
  --ink-muted: #7f8d85;
  --accent: #d8b56c;
  --accent-strong: #f0cf86;
  --accent-ink: #201a0d;
  --good: #70c99c;
  --good-deep: #173a2a;
  --warn: #e6b76b;
  --warn-deep: #3b2b13;
  --bad: #ef8d84;
  --bad-deep: #411d1c;
  --info: #7bb8ca;
  --info-deep: #17323a;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow: 0 24px 70px rgb(0 0 0 / 42%);
  --topbar-height: 66px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow: hidden;
  background:
    radial-gradient(circle at 67% -20%, rgb(50 72 61 / 22%), transparent 36rem),
    var(--canvas);
  color: var(--ink);
}

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

button {
  border: 0;
}

button:not(:disabled),
label,
summary {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: #0b100e;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(216 181 108 / 14%);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

::selection {
  background: rgb(216 181 108 / 28%);
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-strong);
  color: var(--accent-ink);
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  height: var(--topbar-height);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(12 17 15 / 92%);
  backdrop-filter: blur(16px);
}

.brand-block,
.brand-line,
.topbar-actions,
.topbar-status,
.summary-item,
.panel-heading,
.rail-heading,
.section-heading-row,
.composer-footer,
.governance-actions,
.message-meta,
.evidence-row,
.tool-heading,
.thread-button-meta {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 11px;
  min-width: 0;
}

.brand-line {
  gap: 10px;
}

.brand-line h1 {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 19px;
  letter-spacing: 0.05em;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.35;
  text-transform: uppercase;
}

.surface-label {
  color: var(--ink-muted);
  font-size: 12px;
}

.topbar-status {
  justify-content: center;
  gap: 16px;
}

.summary-item {
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.signal {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
  box-shadow: 0 0 0 3px rgb(127 141 133 / 12%);
}

.signal-good {
  background: var(--good);
  box-shadow: 0 0 0 3px rgb(112 201 156 / 12%);
}

.signal-warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgb(230 183 107 / 12%);
}

.signal-bad {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgb(239 141 132 / 12%);
}

.topbar-actions {
  justify-content: flex-end;
  gap: 8px;
}

.quiet-button,
.icon-button,
.text-button,
.danger-button,
.primary-button,
.send-button,
.new-thread-button {
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.quiet-button {
  padding: 7px 10px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
}

.quiet-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
}

.icon-button:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 252px minmax(420px, 1fr) 354px;
  height: calc(100vh - var(--topbar-height));
}

.thread-rail,
.governance-panel,
.conversation {
  min-height: 0;
}

.thread-rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface-1);
}

.rail-heading,
.panel-heading {
  justify-content: space-between;
  min-height: 70px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.rail-heading h2,
.panel-heading h2,
.conversation-header h2 {
  margin: 3px 0 0;
  font-size: 15px;
  font-weight: 650;
}

.new-thread-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 12px;
  padding: 10px 11px;
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.new-thread-button:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.new-thread-button span:first-child {
  color: var(--accent);
  font-size: 17px;
}

.thread-list-wrap {
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 14px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.list-state {
  padding: 15px 10px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.thread-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.thread-list li + li {
  margin-top: 3px;
}

.thread-button {
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.thread-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.thread-button[aria-current="true"] {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--ink);
}

.thread-button[aria-current="true"]::before {
  position: absolute;
  width: 2px;
  height: 28px;
  margin: -4px 0 0 -11px;
  background: var(--accent);
  content: "";
}

.thread-button-title,
.thread-button-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-button-title {
  font-size: 13px;
  font-weight: 650;
}

.thread-button-preview {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 11px;
}

.thread-button-meta {
  justify-content: space-between;
  margin-top: 7px;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rail-footer {
  padding: 13px 16px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}

.rail-footer strong,
.owner-mark {
  display: block;
}

.owner-mark {
  margin-bottom: 3px;
  color: var(--ink-muted);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.conversation {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgb(255 255 255 / 1.2%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 1.2%) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgb(9 12 11 / 92%);
}

.thread-context {
  min-width: 0;
}

.thread-context h2 {
  max-width: 48ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-switch[hidden] {
  display: none !important;
}

.mode-switch {
  display: flex;
  padding: 3px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}

.mode-switch label {
  position: relative;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch span {
  display: block;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 2px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

.mode-switch input:checked + span {
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
}

.mode-switch input[value="execution"]:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
}

.mode-switch input:focus-visible + span {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.conversation-notice {
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--warn-deep);
  color: #f4d6a4;
  font-size: 12px;
  line-height: 1.45;
}

.conversation-notice.notice-error {
  background: var(--bad-deep);
  color: #ffd0cb;
}

.message-stream {
  min-height: 0;
  overflow-y: auto;
  padding: 28px clamp(18px, 5vw, 68px) 36px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.empty-state {
  width: min(600px, 100%);
  margin: clamp(40px, 12vh, 130px) auto 0;
  color: var(--ink-soft);
}

.empty-monogram {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
}

.empty-state h2 {
  max-width: 530px;
  margin: 9px 0 12px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 400;
  line-height: 1.15;
}

.empty-state > p:last-child {
  max-width: 570px;
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

.message-group {
  width: min(830px, 100%);
  margin: 0 auto;
}

.message-group + .message-group {
  margin-top: 26px;
}

.message {
  position: relative;
}

.message + .message {
  margin-top: 10px;
}

.message-role {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.message-user {
  width: min(690px, 90%);
  margin-left: auto;
}

.message-user .message-role {
  text-align: right;
}

.message-body {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.66;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-user .message-body {
  border-color: #4a4534;
  background: #252217;
}

.message-assistant .message-body {
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: rgb(19 26 23 / 92%);
}

.message-pending .message-body {
  color: var(--ink-muted);
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes pulse-dot {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.message-meta {
  flex-wrap: wrap;
  gap: 7px 12px;
  margin-top: 9px;
  color: var(--ink-muted);
  font-size: 10px;
}

.meta-chip,
.evidence-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.evidence-row {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.evidence-chip.evidence-good {
  border-color: #315c46;
  color: var(--good);
}

.evidence-chip.evidence-warn {
  border-color: #5a4625;
  color: var(--warn);
}

.evidence-chip.evidence-bad {
  border-color: #653330;
  color: var(--bad);
}

.message-error .message-body {
  border-color: #653330;
  border-left-color: var(--bad);
  background: var(--bad-deep);
  color: #ffd3cf;
}

.composer {
  margin: 0 clamp(18px, 5vw, 68px) 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgb(14 19 17 / 96%);
  box-shadow: 0 13px 36px rgb(0 0 0 / 28%);
}

.composer:focus-within {
  border-color: #6e6347;
  box-shadow: 0 0 0 3px rgb(216 181 108 / 8%), 0 13px 36px rgb(0 0 0 / 28%);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 62px;
  max-height: 220px;
  field-sizing: content;
  resize: vertical;
  padding: 16px 16px 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1.5;
}

.composer textarea:focus {
  box-shadow: none;
}

.attachment-composer {
  padding: 0 10px 7px;
  border-top: 1px solid transparent;
}

.attachment-composer.is-dragging {
  border-top-color: var(--accent);
  background: rgb(216 181 108 / 8%);
}

.attachment-prompt {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--ink-muted);
  font-size: 10px;
}

.attachment-button,
.attachment-remove {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.attachment-button {
  padding: 5px 8px;
}

.attachment-button:hover:not(:disabled),
.attachment-remove:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.attachment-list,
.message-attachments {
  padding: 0;
  margin: 7px 0 0;
  list-style: none;
}

.attachment-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--ink-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  overflow-wrap: anywhere;
}

.attachment-edit-hint {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
  line-height: 1.45;
}

.attachment-file-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.attachment-file-name {
  overflow-wrap: anywhere;
}

.attachment-file-states {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.attachment-state-chip,
.message-attachment-state {
  display: inline-flex;
  width: fit-content;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 8px;
  line-height: 1.25;
}

.attachment-state-good { color: var(--good); border-color: rgb(91 189 130 / 40%); }
.attachment-state-warn { color: var(--warn); border-color: rgb(216 181 108 / 45%); }
.attachment-state-info { color: var(--ink-muted); }

.attachment-list li + li {
  margin-top: 4px;
}

.attachment-remove {
  flex: none;
  padding: 3px 6px;
}

.attachment-status {
  min-height: 0;
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
}

.attachment-status:empty {
  display: none;
}

.attachment-status.attachment-error {
  color: var(--bad);
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.message-attachments li {
  display: grid;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid #4a4534;
  border-radius: var(--radius-sm);
  background: #1b1a14;
  color: var(--ink-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.revised-files {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgb(91 189 130 / 35%);
  border-radius: var(--radius-sm);
  background: rgb(91 189 130 / 7%);
}

.revised-files-heading {
  margin: 0 0 5px;
  color: var(--good);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.revised-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.revised-file-link {
  display: inline-flex;
  padding: 6px 8px;
  border: 1px solid var(--good);
  border-radius: var(--radius-sm);
  color: var(--good);
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.revised-file-link:hover,
.revised-file-link:focus-visible {
  background: rgb(91 189 130 / 12%);
}

.composer-footer {
  justify-content: space-between;
  gap: 12px;
  padding: 8px 9px 9px 14px;
}

.composer-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 10px;
}

.mode-indicator {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.send-button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px 8px 13px;
  border-color: var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 750;
}

.send-button:hover:not(:disabled),
.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.governance-panel {
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface-1);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.panel-close {
  display: none;
}

.panel-section {
  padding: 17px 16px 19px;
  border-bottom: 1px solid var(--line);
}

.section-heading-row {
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 13px;
}

.section-heading-row h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-heading-row p {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 11px;
  line-height: 1.45;
}

.text-button {
  padding: 2px 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-size: 10px;
}

.text-button:hover:not(:disabled) {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 0;
  margin: 0;
}

.status-card {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.status-card-wide {
  grid-column: 1 / -1;
}

.status-card dt {
  margin-bottom: 7px;
  color: var(--ink-muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-card dd {
  min-width: 0;
  margin: 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 19px;
  padding: 2px 6px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-good {
  border-color: #315c46;
  background: var(--good-deep);
  color: var(--good);
}

.status-warn {
  border-color: #604a26;
  background: var(--warn-deep);
  color: var(--warn);
}

.status-bad {
  border-color: #653330;
  background: var(--bad-deep);
  color: var(--bad);
}

.status-info {
  border-color: #2b5765;
  background: var(--info-deep);
  color: var(--info);
}

.state-detail {
  margin: 11px 0 0;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.governance-form,
.login-form {
  display: grid;
  gap: 8px;
}

.governance-form > label:not(.approval-check),
.login-form label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.governance-form input[type="text"],
.governance-form textarea,
.login-form input {
  width: 100%;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.governance-form textarea {
  resize: vertical;
}

.existing-admission {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.existing-admission > summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
}

.existing-admission-form {
  margin-top: 12px;
}

.approval-check {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 9px;
  align-items: start;
  margin: 5px 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.5;
}

.approval-check input {
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.governance-actions {
  gap: 8px;
  margin-top: 2px;
}

.primary-button,
.danger-button {
  min-height: 35px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 750;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.danger-button {
  border-color: #613532;
  background: transparent;
  color: var(--bad);
}

.danger-button:hover:not(:disabled) {
  background: var(--bad-deep);
}

.form-message {
  min-height: 16px;
  margin: 9px 0 0;
  color: var(--ink-muted);
  font-size: 10px;
  line-height: 1.5;
}

.form-message.message-good {
  color: var(--good);
}

.form-message.message-error {
  color: var(--bad);
}

.tool-timeline {
  padding: 0 0 0 15px;
  margin: 0;
  list-style: none;
}

.tool-event {
  position: relative;
  padding: 0 0 16px 17px;
  border-left: 1px solid var(--line-strong);
}

.tool-event:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.tool-event::before {
  position: absolute;
  top: 3px;
  left: -4px;
  width: 7px;
  height: 7px;
  border: 1px solid var(--surface-1);
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 2px var(--good-deep);
  content: "";
}

.tool-event.tool-error::before {
  background: var(--bad);
  box-shadow: 0 0 0 2px var(--bad-deep);
}

.tool-heading {
  justify-content: space-between;
  gap: 9px;
}

.tool-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-duration {
  flex: none;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.tool-meta {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
}

.tool-details {
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
}

.tool-details summary {
  padding: 6px 8px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tool-payload {
  padding: 8px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tool-error .tool-payload {
  color: #ffc2bd;
}

.scrim {
  position: fixed;
  z-index: 50;
  inset: var(--topbar-height) 0 0;
  background: rgb(0 0 0 / 58%);
  backdrop-filter: blur(2px);
}

.login-dialog {
  width: min(420px, calc(100vw - 30px));
  padding: 27px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.login-dialog::backdrop {
  background: rgb(4 7 6 / 86%);
  backdrop-filter: blur(8px);
}

.login-lockup {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
}

.login-dialog h2 {
  margin: 7px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 400;
}

.login-dialog > p:not(.eyebrow):not(.security-note) {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.login-form {
  gap: 10px;
}

.login-form input {
  min-height: 43px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.login-message {
  margin: 0;
}

.login-button {
  width: 100%;
  min-height: 43px;
  margin-top: 2px;
}

.security-note {
  padding-top: 16px;
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 10px;
  line-height: 1.55;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: 0 10px 28px rgb(0 0 0 / 34%);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in 150ms ease-out;
}

.toast.toast-error {
  border-left-color: var(--bad);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-conversation-actions,
.mobile-current-mode {
  display: none;
}

.mobile-only,
#governanceDrawerButton {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 238px minmax(0, 1fr);
  }

  .governance-panel {
    position: fixed;
    z-index: 70;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: min(380px, 92vw);
    box-shadow: -20px 0 50px rgb(0 0 0 / 38%);
    transform: translateX(105%);
    transition: transform 170ms ease-out;
  }

  .governance-panel.is-open {
    transform: translateX(0);
  }

  .panel-close,
  #governanceDrawerButton {
    display: inline-grid;
  }
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-status {
    display: none;
  }
}

@media (max-width: 800px) {
  :root {
    --topbar-height: 60px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    height: var(--topbar-height);
    padding: 0 10px;
  }

  .brand-block .eyebrow,
  .surface-label,
  .topbar-status {
    display: none;
  }

  .brand-line h1 {
    font-size: 16px;
  }

  .mobile-only {
    display: inline-grid;
  }

  .workspace {
    display: block;
    height: calc(100vh - var(--topbar-height));
  }

  .thread-rail {
    position: fixed;
    z-index: 70;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: min(300px, 88vw);
    box-shadow: 20px 0 50px rgb(0 0 0 / 38%);
    transform: translateX(-105%);
    transition: transform 170ms ease-out;
  }

  .thread-rail.is-open {
    transform: translateX(0);
  }

  .conversation {
    height: 100%;
  }

  .conversation-header {
    min-height: 64px;
    padding: 10px 14px;
  }

  .mode-switch span {
    min-width: 64px;
    padding: 6px 7px;
    font-size: 10px;
  }

  .message-stream {
    padding: 22px 14px 28px;
  }

  .empty-state {
    margin-top: 54px;
  }

  .empty-state h2 {
    font-size: 28px;
  }

  .composer {
    margin: 0 10px 10px;
  }

  .composer-context span:last-child {
    display: none;
  }
}

@media (max-width: 480px) {
  .quiet-button {
    padding-inline: 8px;
  }

  #logoutButton {
    font-size: 0;
  }

  #logoutButton::after {
    font-size: 14px;
    content: "⌁";
  }

  .conversation-header {
    align-items: flex-end;
  }

  .thread-context .section-kicker {
    display: none;
  }

  .thread-context h2 {
    max-width: 25vw;
    margin: 0;
  }

  .mode-switch span {
    min-width: 58px;
  }

  .message-user {
    width: 94%;
  }

  .composer-footer {
    padding-left: 10px;
  }

  .login-dialog {
    padding: 22px;
  }
}

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

/* Conversation-first shell. Threads and governance remain complete, but neither
   takes permanent width away from the active conversation. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --topbar-core-height: 66px;
  --topbar-height: calc(var(--topbar-core-height) + var(--safe-top));
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.app-shell {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-height);
  padding: var(--safe-top) max(18px, var(--safe-right)) 0 max(18px, var(--safe-left));
}

.workspace {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  height: calc(100vh - var(--topbar-height));
  height: calc(var(--app-viewport-height, 100dvh) - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
}

.conversation {
  grid-template-rows: auto auto minmax(0, 1fr) max-content;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.conversation-header,
.thread-context,
.message-stream,
.message-group,
.message,
.message-body,
.composer,
.composer-footer,
.composer-context,
.attachment-composer,
.attachment-list,
.attachment-list li {
  min-width: 0;
  max-width: 100%;
}

.conversation-header {
  grid-row: 1;
  gap: 16px;
}

.conversation-notice {
  grid-row: 2;
}

.message-stream {
  grid-row: 3;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: max(clamp(18px, 5vw, 68px), var(--safe-right));
  padding-left: max(clamp(18px, 5vw, 68px), var(--safe-left));
  overscroll-behavior: contain;
}

.composer {
  grid-row: 4;
  display: flex;
  flex-direction: column;
  max-height: min(48dvh, 440px);
  margin-right: max(clamp(12px, 5vw, 68px), var(--safe-right));
  margin-bottom: max(12px, var(--safe-bottom));
  margin-left: max(clamp(12px, 5vw, 68px), var(--safe-left));
  overflow: hidden;
}

.composer textarea {
  flex: none;
  min-height: 48px;
  max-height: min(28dvh, 220px);
  resize: none;
  field-sizing: fixed;
  overflow-x: hidden;
}

.attachment-composer {
  flex: 0 1 auto;
  max-height: min(18dvh, 160px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.attachment-list {
  max-height: 112px;
  overflow-x: hidden;
  overflow-y: auto;
}

.composer-footer {
  position: relative;
  z-index: 1;
  flex: none;
  min-height: 50px;
  background: rgb(14 19 17 / 98%);
}

.send-button {
  flex: none;
  min-width: 82px;
  min-height: 40px;
  justify-content: center;
}

.mobile-only,
#governanceDrawerButton,
.panel-close {
  display: inline-grid;
}

.thread-rail,
.governance-panel {
  position: fixed;
  z-index: 70;
  top: var(--topbar-height);
  bottom: 0;
  max-width: calc(100vw - 24px);
  visibility: hidden;
  pointer-events: none;
  transition: transform 170ms ease-out, visibility 0s linear 170ms;
  overscroll-behavior: contain;
}

.thread-rail {
  left: 0;
  width: min(340px, calc(100vw - 24px));
  border-right: 1px solid var(--line-strong);
  box-shadow: 20px 0 50px rgb(0 0 0 / 38%);
  transform: translateX(-105%);
}

.governance-panel {
  right: 0;
  width: min(420px, calc(100vw - 24px));
  border-left: 1px solid var(--line-strong);
  box-shadow: -20px 0 50px rgb(0 0 0 / 38%);
  transform: translateX(105%);
}

.thread-rail.is-open,
.governance-panel.is-open {
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 0s;
}

.rail-footer {
  padding-bottom: max(13px, var(--safe-bottom));
}

.governance-panel .panel-section:last-child {
  padding-bottom: max(19px, var(--safe-bottom));
}

.scrim {
  inset: var(--topbar-height) 0 0;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
}

.scrim[hidden] {
  display: none;
}

.toast-region {
  right: max(18px, var(--safe-right));
  bottom: max(18px, var(--safe-bottom));
  max-width: calc(100vw - max(36px, var(--safe-left)) - max(36px, var(--safe-right)));
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-status {
    display: none;
  }
}

@media (max-width: 800px) {
  :root {
    --topbar-core-height: 60px;
    --topbar-height: calc(var(--topbar-core-height) + var(--safe-top));
  }

  .topbar {
    height: var(--topbar-height);
    padding: var(--safe-top) max(10px, var(--safe-right)) 0 max(10px, var(--safe-left));
  }

  .workspace {
    height: calc(var(--app-viewport-height, 100dvh) - var(--topbar-height));
  }

  .conversation-header {
    min-height: 60px;
    padding: 9px max(12px, var(--safe-right)) 9px max(12px, var(--safe-left));
  }

  .thread-context {
    flex: 1 1 auto;
  }

  .thread-context h2 {
    max-width: min(46vw, 36ch);
  }

  .mode-switch {
    flex: none;
  }

  .mode-switch span {
    min-width: 58px;
    padding: 6px;
  }

  .message-stream {
    padding: 18px max(12px, var(--safe-right)) 24px max(12px, var(--safe-left));
  }

  .empty-state {
    margin-top: 34px;
  }

  .composer {
    max-height: min(52dvh, 410px);
    margin-right: max(8px, var(--safe-right));
    margin-bottom: max(8px, var(--safe-bottom));
    margin-left: max(8px, var(--safe-left));
  }

  .composer textarea {
    padding: 12px 12px 6px;
  }

  .composer-footer {
    min-height: 48px;
    padding: 6px 7px 7px 11px;
  }

  .composer-context span:last-child,
  .attachment-prompt > span {
    display: none;
  }

  .send-button {
    min-width: 76px;
    min-height: 40px;
  }

  .toast-region {
    top: calc(var(--topbar-height) + 10px);
    right: max(10px, var(--safe-right));
    bottom: auto;
    left: max(10px, var(--safe-left));
    width: auto;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .topbar-actions {
    gap: 4px;
  }

  .quiet-button {
    padding-inline: 7px;
  }

  .conversation-header {
    align-items: center;
    gap: 8px;
  }

  .thread-context h2 {
    max-width: 42vw;
  }

  .mode-switch span {
    min-width: 54px;
    padding-inline: 4px;
    font-size: 9px;
  }

  .message-user {
    width: 94%;
  }

  .composer-footer {
    padding-left: 10px;
  }

  .login-dialog {
    width: calc(100vw - max(24px, var(--safe-left)) - max(24px, var(--safe-right)));
  }
}

/* Additive desktop restoration. Keep the safe-area and mobile drawer work above,
   while returning the previously built thread rail and governance/tool surface
   to their permanent desktop positions. */
@media (min-width: 801px) {
  .workspace {
    position: relative;
    display: grid;
    grid-template-columns:
      clamp(210px, 18vw, 252px)
      minmax(0, 1fr)
      clamp(290px, 25vw, 354px);
    width: 100%;
    max-width: 100%;
    height: calc(var(--app-viewport-height, 100dvh) - var(--topbar-height));
    min-height: 0;
    overflow: hidden;
  }

  .thread-rail,
  .thread-rail.is-open,
  .governance-panel,
  .governance-panel.is-open {
    position: relative;
    z-index: auto;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: auto;
    max-width: none;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
    box-shadow: none;
  }

  .thread-rail {
    grid-column: 1;
    border-right: 1px solid var(--line);
  }

  .conversation {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    height: 100%;
  }

  .governance-panel {
    grid-column: 3;
    border-left: 1px solid var(--line);
  }

  .mobile-only,
  #governanceDrawerButton,
  .panel-close {
    display: none !important;
  }

  .scrim {
    display: none !important;
  }
}

/* Additive owner-brain switch and one-sightline machine proof. */

/* Operator GEE glass house. Every moving state is driven by a newly observed
   source event; the visual never runs a perpetual fake heartbeat. */
.operator-gee-open {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  white-space: nowrap;
}

.gee-live-dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 50%;
  background: var(--muted, #737c77);
  box-shadow: 0 0 0 3px rgba(115, 124, 119, 0.13);
  flex: 0 0 auto;
}

.gee-live-dot.is-live,
.gee-connection-chip.is-live .gee-live-dot {
  background: #83e6b7;
  box-shadow: 0 0 0 3px rgba(131, 230, 183, 0.12), 0 0 18px rgba(131, 230, 183, 0.45);
}

.gee-live-dot.is-attention,
.gee-connection-chip.is-attention .gee-live-dot {
  background: #e7bd69;
  box-shadow: 0 0 0 3px rgba(231, 189, 105, 0.12);
}

.gee-live-dot.is-offline,
.gee-connection-chip.is-offline .gee-live-dot {
  background: #ef7a74;
  box-shadow: 0 0 0 3px rgba(239, 122, 116, 0.12);
}

.operator-gee-dialog {
  width: min(1480px, calc(100vw - 32px));
  height: min(920px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  color: #e7f0eb;
  background: #07100d;
  border: 1px solid rgba(143, 214, 181, 0.26);
  border-radius: 24px;
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.operator-gee-dialog::backdrop {
  background: rgba(2, 6, 5, 0.82);
  backdrop-filter: blur(10px);
}

.operator-gee-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 10% -10%, rgba(68, 161, 119, 0.16), transparent 34%),
    radial-gradient(circle at 95% 8%, rgba(221, 178, 91, 0.09), transparent 28%),
    linear-gradient(rgba(107, 177, 145, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(107, 177, 145, 0.035) 1px, transparent 1px),
    #07100d;
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
}

.operator-gee-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid rgba(143, 214, 181, 0.19);
  background: rgba(8, 19, 15, 0.92);
}

.operator-gee-header h2 {
  margin: 0.12rem 0 0.2rem;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  font-weight: 500;
}

.operator-gee-header p:last-child {
  margin: 0;
  color: #9eaaa4;
  max-width: 70ch;
}

.operator-gee-header-actions {
  display: flex;
  align-items: center;
  gap: 0.72rem;
}

.gee-connection-chip,
.glass-status {
  display: inline-flex;
  align-items: center;
  gap: 0.46rem;
  min-height: 1.8rem;
  padding: 0.3rem 0.62rem;
  border: 1px solid rgba(158, 170, 164, 0.24);
  border-radius: 999px;
  color: #aab5b0;
  background: rgba(14, 27, 22, 0.82);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.67rem;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.glass-status.is-good,
.gee-connection-chip.is-live {
  color: #a7efca;
  border-color: rgba(131, 230, 183, 0.38);
  background: rgba(39, 107, 76, 0.18);
}

.glass-status.is-warn,
.gee-connection-chip.is-attention {
  color: #f0ce88;
  border-color: rgba(231, 189, 105, 0.4);
  background: rgba(115, 81, 24, 0.18);
}

.glass-status.is-bad,
.gee-connection-chip.is-offline {
  color: #f3a09b;
  border-color: rgba(239, 122, 116, 0.4);
  background: rgba(111, 43, 39, 0.2);
}

.operator-gee-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(0.85rem, 2vw, 1.45rem);
  scrollbar-color: rgba(131, 230, 183, 0.35) transparent;
}

.operator-gee-scroll > *,
.brain-beat-copy,
.glasshouse-heading-row,
.glasshouse-heading-row > div {
  min-width: 0;
  max-width: 100%;
}

.brain-beat-stage,
.glass-panel {
  border: 1px solid rgba(143, 214, 181, 0.17);
  background: linear-gradient(145deg, rgba(16, 32, 25, 0.9), rgba(9, 19, 15, 0.93));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.brain-beat-stage {
  min-height: 245px;
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(320px, 1.45fr);
  align-items: center;
  gap: clamp(1rem, 3vw, 2.4rem);
  margin-bottom: 1rem;
  padding: clamp(1.15rem, 3vw, 2.1rem);
  border-radius: 22px;
  overflow: hidden;
  position: relative;
}

.brain-beat-stage::after {
  content: '';
  position: absolute;
  inset: auto -20% -75% 20%;
  height: 250px;
  background: radial-gradient(ellipse, rgba(131, 230, 183, 0.11), transparent 68%);
  pointer-events: none;
}

.brain-beat-visual {
  width: min(220px, 64vw);
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  margin: auto;
}

.brain-beat-orbit,
.brain-beat-core {
  position: absolute;
  border-radius: 50%;
}

.brain-beat-orbit {
  inset: 8%;
  border: 1px solid rgba(131, 230, 183, 0.24);
  box-shadow: inset 0 0 42px rgba(131, 230, 183, 0.035);
}

.brain-beat-orbit.orbit-two {
  inset: 22%;
  border-color: rgba(231, 189, 105, 0.2);
}

.brain-beat-core {
  width: 36%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #07100d;
  background: linear-gradient(135deg, #b5f1d4, #6ac49c);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2rem, 5vw, 3.6rem);
  box-shadow: 0 0 0 10px rgba(131, 230, 183, 0.055), 0 0 55px rgba(131, 230, 183, 0.2);
}

.brain-beat-visual.beat-observed .orbit-one {
  animation: observed-beat 900ms cubic-bezier(0.2, 0.75, 0.25, 1) 1;
}

.brain-beat-visual.beat-observed .orbit-two {
  animation: observed-beat 900ms 110ms cubic-bezier(0.2, 0.75, 0.25, 1) 1;
}

.brain-beat-visual.is-stale .brain-beat-core {
  background: linear-gradient(135deg, #d6b36e, #8d6d35);
  box-shadow: 0 0 0 10px rgba(231, 189, 105, 0.05);
}

.brain-beat-visual.is-offline .brain-beat-core {
  background: linear-gradient(135deg, #d98983, #8f4640);
  box-shadow: 0 0 0 10px rgba(239, 122, 116, 0.05);
}

@keyframes observed-beat {
  0% { transform: scale(0.88); opacity: 0.35; }
  48% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0.78; }
}

.glasshouse-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.glasshouse-heading-row h3,
.heartbeat-card h4 {
  margin: 0.15rem 0 0;
}

.brain-beat-now,
.machine-now-line {
  color: #edf6f1;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.18rem, 2.4vw, 1.75rem);
  line-height: 1.35;
  margin: 1rem 0;
}

.brain-beat-facts,
.chamber-facts,
.heartbeat-card dl {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.brain-beat-facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.brain-beat-facts div,
.chamber-facts div,
.heartbeat-card dl div {
  min-width: 0;
}

.brain-beat-facts dt,
.chamber-facts dt,
.heartbeat-card dt {
  color: #74847c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.63rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.brain-beat-facts dd,
.chamber-facts dd,
.heartbeat-card dd {
  margin: 0.18rem 0 0;
  color: #cedbd4;
  overflow-wrap: anywhere;
}

.brain-beat-boundary,
.glass-footnote {
  color: #7e9087;
  font-size: 0.78rem;
  line-height: 1.5;
}

.brain-beat-boundary {
  margin: 1rem 0 0;
  max-width: 78ch;
}

.glass-panel {
  border-radius: 18px;
  padding: clamp(1rem, 2.3vw, 1.35rem);
}

.loop-panel,
.closed-loop-panel,
.robert-code-panel,
.machine-flow-panel,
.activity-panel {
  margin-bottom: 1rem;
}

.closed-loop-panel {
  background:
    radial-gradient(circle at 100% 0%, rgba(132, 223, 181, 0.08), transparent 36%),
    linear-gradient(145deg, rgba(12, 29, 22, 0.94), rgba(7, 18, 14, 0.97));
}

.closed-loop-now {
  margin: 0.9rem 0;
  color: #dce9e2;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.02rem;
  line-height: 1.45;
}

.closed-loop-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(143, 214, 181, 0.13);
  border-radius: 13px;
}

.closed-loop-facts div {
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border-left: 1px solid rgba(143, 214, 181, 0.12);
  border-top: 1px solid rgba(143, 214, 181, 0.12);
}

.closed-loop-facts div:nth-child(-n + 4) { border-top: 0; }
.closed-loop-facts div:nth-child(4n + 1) { border-left: 0; }

.closed-loop-facts dt {
  color: #74847c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.61rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.closed-loop-facts dd {
  margin: 0.25rem 0 0;
  color: #d4e0da;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.closed-loop-phases {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
}

.closed-loop-phases li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(126, 144, 135, 0.2);
  border-radius: 9px;
  color: #96a69e;
  background: rgba(4, 13, 9, 0.38);
  font-size: 0.68rem;
}

.closed-loop-phases li.is-good { border-color: rgba(132, 223, 181, 0.36); color: #b9e8d0; }
.closed-loop-phases li.is-bad { border-color: rgba(239, 122, 116, 0.38); color: #f3aaa5; }
.closed-loop-phases li.is-warn { border-color: rgba(231, 189, 105, 0.34); color: #e9cb8f; }
.closed-loop-phases span { color: inherit; opacity: 0.82; }

.robert-code-panel {
  background:
    radial-gradient(circle at 95% 0%, rgba(231, 189, 105, 0.08), transparent 32%),
    linear-gradient(145deg, rgba(16, 32, 25, 0.94), rgba(9, 19, 15, 0.96));
}

.robert-code-manifest {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  gap: 0.85rem;
  margin-top: 1rem;
}

.robert-code-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid rgba(143, 214, 181, 0.13);
  border-radius: 13px;
  overflow: hidden;
}

.robert-code-facts div {
  min-width: 0;
  padding: 0.72rem 0.78rem;
  border-left: 1px solid rgba(143, 214, 181, 0.12);
}

.robert-code-facts div:first-child { border-left: 0; }

.robert-code-facts dt,
.robert-code-boundary span,
.robert-code-trace-heading > div > span {
  color: #74847c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.61rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.robert-code-facts dd {
  margin: 0.28rem 0 0;
  color: #d4e0da;
  overflow-wrap: anywhere;
}

.robert-code-facts code,
.robert-code-trace-heading strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.robert-code-boundary {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(231, 189, 105, 0.2);
  border-radius: 13px;
  background: rgba(89, 63, 19, 0.1);
}

.robert-code-boundary p {
  margin: 0.42rem 0 0;
  color: #c9d5ce;
  font-size: 0.78rem;
  line-height: 1.5;
}

.robert-code-trace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 1rem;
}

.robert-code-trace-heading > div {
  min-width: 0;
  display: grid;
  gap: 0.28rem;
}

.robert-code-trace-heading strong {
  color: #dce9e2;
  overflow-wrap: anywhere;
}

.loop-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 1.4rem 0 0.8rem;
  padding: 0;
  list-style: none;
}

.loop-track li {
  min-width: 0;
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.45rem;
  padding: 0 0.45rem;
  text-align: center;
  color: #718178;
}

.loop-track li:not(:last-child)::after {
  content: '';
  position: absolute;
  z-index: 0;
  top: 1.05rem;
  left: calc(50% + 1.2rem);
  width: calc(100% - 2.4rem);
  height: 1px;
  background: rgba(126, 144, 135, 0.25);
}

.loop-node {
  width: 2.1rem;
  height: 2.1rem;
  z-index: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(126, 144, 135, 0.3);
  border-radius: 50%;
  background: #0a1511;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.65rem;
}

.loop-track li.is-recorded {
  color: #dceae3;
}

.loop-track li.is-recorded .loop-node {
  color: #07100d;
  border-color: #84dfb5;
  background: #84dfb5;
  box-shadow: 0 0 18px rgba(132, 223, 181, 0.2);
}

.loop-track li.is-recorded:not(:last-child)::after {
  background: linear-gradient(90deg, rgba(132, 223, 181, 0.75), rgba(132, 223, 181, 0.18));
}

.loop-track li.is-warn {
  color: #d5bd89;
}

.loop-track li.is-warn .loop-node {
  color: #f0ce88;
  border-color: rgba(231, 189, 105, 0.55);
  background: rgba(115, 81, 24, 0.22);
}

.loop-track li.is-failed {
  color: #f0aaa5;
}

.loop-track li.is-failed .loop-node {
  color: #f3a09b;
  border-color: rgba(239, 122, 116, 0.58);
  background: rgba(111, 43, 39, 0.24);
}

.loop-track strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.loop-track small {
  width: 100%;
  color: #718178;
  font-size: 0.7rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glasshouse-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.heartbeat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.heartbeat-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid rgba(143, 214, 181, 0.13);
  border-radius: 14px;
  background: rgba(4, 13, 9, 0.47);
}

.heartbeat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.heartbeat-wave {
  width: 2.2rem;
  height: 0.72rem;
  opacity: 0.42;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='14' viewBox='0 0 46 14'%3E%3Cpath d='M1 7h8l3-5 5 10 4-8 4 6 3-3h17' fill='none' stroke='%2383e6b7' stroke-width='1.5'/%3E%3C/svg%3E");
}

.heartbeat-card.is-moving .heartbeat-wave {
  opacity: 1;
}

.heartbeat-card h4 {
  margin-top: 0.85rem;
  font-size: 1rem;
}

.heartbeat-card > p {
  min-height: 2.6em;
  color: #87978f;
  font-size: 0.75rem;
  line-height: 1.4;
}

.heartbeat-card dl {
  grid-template-columns: 0.7fr 1fr 1.3fr;
}

.heartbeat-card dd {
  font-size: 0.76rem;
}

.execution-chamber {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chamber-core {
  min-height: 145px;
  position: relative;
  display: grid;
  place-content: center;
  gap: 0.4rem;
  text-align: center;
}

.chamber-ring {
  width: 110px;
  height: 110px;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(126, 144, 135, 0.25);
  border-radius: 50%;
  box-shadow: inset 0 0 30px rgba(126, 144, 135, 0.05);
}

.execution-chamber.is-active .chamber-ring {
  border-color: rgba(131, 230, 183, 0.55);
  box-shadow: inset 0 0 30px rgba(131, 230, 183, 0.08), 0 0 30px rgba(131, 230, 183, 0.08);
}

.execution-chamber.is-expired .chamber-ring {
  border-color: rgba(239, 122, 116, 0.55);
}

.chamber-core strong,
.chamber-core span {
  position: relative;
  z-index: 1;
}

.chamber-core span {
  color: #83938b;
  font-size: 0.78rem;
}

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

.machine-now-line {
  margin: 1rem 0 1.1rem;
}

.metric-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid rgba(143, 214, 181, 0.13);
  border-radius: 13px;
  overflow: hidden;
}

.metric-ribbon > div {
  min-width: 0;
  padding: 0.75rem;
  background: rgba(4, 13, 9, 0.46);
}

.metric-ribbon > div + div {
  border-left: 1px solid rgba(143, 214, 181, 0.12);
}

.metric-ribbon span,
.chain-head span {
  display: block;
  color: #718178;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.61rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-ribbon strong {
  display: block;
  margin-top: 0.25rem;
  font-size: clamp(1rem, 2vw, 1.35rem);
}

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

.gate-rail,
.evidence-receipts,
.machine-activity {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.gate-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.gate-rail li {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  padding: 0.58rem;
  border: 1px solid rgba(126, 144, 135, 0.16);
  border-radius: 10px;
  background: rgba(4, 13, 9, 0.38);
}

.gate-rail .gate-number {
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #8fa097;
  background: rgba(126, 144, 135, 0.09);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
}

.gate-rail li.is-good .gate-number {
  color: #07100d;
  background: #83e6b7;
}

.gate-rail li.is-warn .gate-number {
  color: #f0ce88;
  background: rgba(115, 81, 24, 0.3);
}

.gate-rail li.is-bad .gate-number {
  color: #f3a09b;
  background: rgba(111, 43, 39, 0.34);
}

.gate-rail strong,
.gate-rail small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-rail strong { font-size: 0.73rem; }
.gate-rail small { margin-top: 0.13rem; color: #718178; font-size: 0.61rem; }

.source-health {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.9rem;
}

.source-health span {
  padding: 0.28rem 0.46rem;
  border: 1px solid rgba(126, 144, 135, 0.2);
  border-radius: 7px;
  color: #93a199;
  font-size: 0.65rem;
}

.source-health span.is-bad { color: #f3a09b; border-color: rgba(239, 122, 116, 0.3); }
.source-health span.is-warn { color: #f0ce88; border-color: rgba(231, 189, 105, 0.3); }

.chain-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 0.62rem;
  border: 1px solid rgba(143, 214, 181, 0.13);
  border-radius: 10px;
  background: rgba(4, 13, 9, 0.38);
}

.chain-head code {
  overflow: hidden;
  color: #a9b9b0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-receipts,
.machine-activity {
  display: grid;
  gap: 0.55rem;
}

.evidence-receipts li,
.machine-activity li {
  min-width: 0;
  padding: 0.64rem 0.7rem;
  border-left: 2px solid rgba(131, 230, 183, 0.4);
  background: rgba(4, 13, 9, 0.38);
}

.evidence-receipts strong,
.machine-activity strong {
  display: block;
  color: #d6e3dc;
  font-size: 0.78rem;
}

.evidence-receipts span,
.machine-activity span {
  display: block;
  margin-top: 0.22rem;
  color: #77877f;
  font-size: 0.68rem;
  line-height: 1.4;
}

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

.machine-activity li.is-bad { border-left-color: #ef7a74; }
.machine-activity li.is-warn { border-left-color: #e7bd69; }

.operator-gee-error {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(239, 122, 116, 0.4);
  border-radius: 12px;
  color: #f3a09b;
  background: rgba(54, 19, 17, 0.95);
}

@media (max-width: 980px) {
  .glasshouse-two-column,
  .glasshouse-lower-grid {
    grid-template-columns: 1fr;
  }

  .brain-beat-stage {
    grid-template-columns: minmax(160px, 0.55fr) minmax(280px, 1.45fr);
  }

  .robert-code-manifest {
    grid-template-columns: 1fr;
  }

  .robert-code-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .robert-code-facts div:nth-child(4) {
    border-left: 0;
    border-top: 1px solid rgba(143, 214, 181, 0.12);
  }

  .robert-code-facts div:nth-child(5) {
    border-top: 1px solid rgba(143, 214, 181, 0.12);
  }
}

@media (max-width: 800px) {
  .operator-gee-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .operator-gee-header {
    align-items: flex-start;
    padding: calc(0.9rem + env(safe-area-inset-top)) 0.9rem 0.9rem;
  }

  .operator-gee-header p:last-child {
    display: none;
  }

  .operator-gee-header-actions {
    gap: 0.38rem;
  }

  .gee-connection-chip {
    padding-inline: 0.48rem;
  }

  .brain-beat-stage {
    grid-template-columns: 1fr;
    min-height: 0;
    max-width: 100%;
    padding: 1rem;
  }

  .glasshouse-heading-row {
    flex-wrap: wrap;
  }

  .glasshouse-heading-row .glass-status {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .brain-beat-visual {
    width: min(168px, 46vw);
  }

  .brain-beat-facts,
  .heartbeat-card dl {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .loop-track {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .loop-track li {
    grid-template-columns: auto minmax(65px, 0.35fr) minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    text-align: left;
    padding: 0;
  }

  .loop-track li:not(:last-child)::after {
    top: calc(2.1rem + 2px);
    left: calc(1.05rem - 0.5px);
    width: 1px;
    height: calc(100% + 0.55rem - 2px);
  }

  .loop-track small {
    white-space: normal;
  }

  .robert-code-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .closed-loop-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .closed-loop-facts div:nth-child(-n + 4) { border-top: 1px solid rgba(143, 214, 181, 0.12); }
  .closed-loop-facts div:nth-child(-n + 2) { border-top: 0; }
  .closed-loop-facts div { border-left: 1px solid rgba(143, 214, 181, 0.12); }
  .closed-loop-facts div:nth-child(odd) { border-left: 0; }

  .robert-code-facts div,
  .robert-code-facts div:nth-child(4),
  .robert-code-facts div:nth-child(5) {
    border-top: 1px solid rgba(143, 214, 181, 0.12);
  }

  .robert-code-facts div:nth-child(-n + 2) { border-top: 0; }
  .robert-code-facts div:nth-child(odd) { border-left: 0; }

  .robert-code-trace-heading {
    align-items: flex-start;
  }

  .heartbeat-grid,
  .machine-activity {
    grid-template-columns: 1fr;
  }

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

  .metric-ribbon > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid rgba(143, 214, 181, 0.12);
  }

  .metric-ribbon > div:nth-child(4) {
    border-top: 1px solid rgba(143, 214, 181, 0.12);
  }

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

  .topbar-actions .operator-gee-open span:last-child {
    display: none;
  }

  .topbar-actions .operator-gee-open {
    min-width: 2.45rem;
    justify-content: center;
  }
}

@media (max-width: 390px) {
  .operator-gee-scroll { padding: 0.65rem; }
  .brain-beat-facts { grid-template-columns: 1fr; }
  .heartbeat-card dl { grid-template-columns: 1fr 1fr; }
  .heartbeat-card dl div:last-child { grid-column: 1 / -1; }
  .gate-rail { grid-template-columns: 1fr; }
  .chamber-facts { grid-template-columns: 1fr; }
  .operator-gee-header .section-kicker { max-width: 20ch; }
  .robert-code-facts { grid-template-columns: 1fr; }
  .closed-loop-facts { grid-template-columns: 1fr; }
  .closed-loop-facts div,
  .closed-loop-facts div:nth-child(-n + 2) { border-top: 1px solid rgba(143, 214, 181, 0.12); border-left: 0; }
  .closed-loop-facts div:first-child { border-top: 0; }
  .robert-code-facts div,
  .robert-code-facts div:nth-child(-n + 2) { border-top: 1px solid rgba(143, 214, 181, 0.12); border-left: 0; }
  .robert-code-facts div:first-child { border-top: 0; }
  .robert-code-trace-heading { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .brain-beat-visual.beat-observed .orbit-one,
  .brain-beat-visual.beat-observed .orbit-two {
    animation: none;
  }
}

/* TASK-2267 · Discovery Copilot. This is an additive owner surface: questions
   stay separate from the conversation until Robert explicitly uses them. */
.discovery-open {
  gap: 7px;
}

.discovery-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border: 1px solid rgb(221 184 98 / 34%);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgb(221 184 98 / 8%);
  font: 750 10px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
}

.discovery-open.has-discovery .discovery-count {
  border-color: rgb(221 184 98 / 68%);
  color: #f1d68b;
  background: rgb(221 184 98 / 16%);
  box-shadow: 0 0 18px rgb(221 184 98 / 15%);
}

.discovery-dialog {
  width: min(880px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(var(--app-viewport-height, 100dvh) - 32px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(156 226 191 / 28%);
  border-radius: 22px;
  color: var(--ink);
  background: #09130f;
  box-shadow: 0 28px 90px rgb(0 0 0 / 70%);
}

.discovery-dialog::backdrop {
  background: rgb(2 7 5 / 78%);
  backdrop-filter: blur(7px);
}

.discovery-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  background:
    radial-gradient(circle at 94% 0%, rgb(90 201 151 / 10%), transparent 34%),
    linear-gradient(180deg, #0c1914 0%, #08100d 100%);
}

.discovery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgb(156 226 191 / 18%);
}

.discovery-header h2 {
  margin: 3px 0 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 500;
}

.discovery-header p:last-child {
  max-width: 68ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.discovery-header-actions,
.discovery-actions,
.discovery-card-top,
.discovery-meta {
  display: flex;
  align-items: center;
}

.discovery-header-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.discovery-status {
  min-height: 42px;
  margin: 0;
  padding: 12px 24px;
  border-bottom: 1px solid rgb(156 226 191 / 12%);
  color: var(--ink-soft);
  font-size: 12px;
}

.discovery-status.is-good { color: var(--good); }
.discovery-status.is-error { color: var(--bad); }
.discovery-status.is-loading { color: var(--warn); }

.discovery-list {
  min-height: 0;
  padding: 18px 24px 28px;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.discovery-card {
  padding: 18px;
  border: 1px solid rgb(156 226 191 / 20%);
  border-radius: 17px;
  background: rgb(14 31 24 / 86%);
}

.discovery-card + .discovery-card { margin-top: 14px; }
.discovery-card.is-selected { border-color: rgb(221 184 98 / 48%); }
.discovery-card.is-adopted { border-color: rgb(112 201 156 / 50%); }
.discovery-card.is-rejected,
.discovery-card.is-superseded { opacity: .68; }

.discovery-card-top {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.discovery-number,
.discovery-state {
  color: var(--good);
  font: 750 10px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.discovery-state {
  padding: 5px 8px;
  border: 1px solid rgb(156 226 191 / 22%);
  border-radius: 999px;
}

.discovery-question {
  display: block;
  width: 100%;
  min-height: 112px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid rgb(156 226 191 / 24%);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: rgb(3 12 8 / 58%);
  font: 500 15px/1.55 system-ui, sans-serif;
}

.discovery-question:focus {
  border-color: rgb(156 226 191 / 70%);
  box-shadow: 0 0 0 3px rgb(112 201 156 / 10%);
}

.discovery-why {
  margin: 11px 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.discovery-meta {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.discovery-meta strong,
.discovery-meta span {
  font: 700 9px/1.2 ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: .045em;
}

.discovery-meta strong { margin-right: 3px; color: var(--ink-soft); text-transform: uppercase; }
.discovery-meta span {
  max-width: min(100%, 300px);
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid rgb(156 226 191 / 16%);
  border-radius: 999px;
  color: var(--good);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discovery-actions {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.discovery-action {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgb(156 226 191 / 25%);
  border-radius: 10px;
  color: var(--ink);
  background: rgb(13 34 25 / 86%);
  font: 700 11px/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.discovery-action:hover { border-color: rgb(156 226 191 / 58%); }
.discovery-action.is-primary { color: #07110d; border-color: #9ce2bf; background: #9ce2bf; }
.discovery-action.is-quiet { color: var(--ink-soft); background: transparent; }
.discovery-action:disabled { opacity: .48; cursor: wait; }

.discovery-gee-question {
  margin: 12px 0 15px;
  color: var(--ink);
  font: 500 clamp(14px, 1.5vw, 18px)/1.5 Georgia, "Times New Roman", serif;
}

.discovery-gee-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.discovery-gee-facts div {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgb(156 226 191 / 14%);
  border-radius: 10px;
  background: rgb(3 12 8 / 35%);
}

.discovery-gee-facts dt {
  color: var(--ink-soft);
  font: 700 9px/1.2 ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.discovery-gee-facts dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
}

@media (max-width: 800px) {
  .discovery-dialog {
    width: 100vw;
    height: var(--app-viewport-height, 100dvh);
    margin: 0;
    border-width: 0;
    border-radius: 0;
  }

  .discovery-shell {
    padding-top: var(--safe-top);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
  }

  .discovery-header {
    gap: 10px;
    padding: 15px 14px 12px;
  }

  .discovery-header p:last-child { display: none; }
  .discovery-header h2 { font-size: 25px; }
  .discovery-status { padding: 10px 14px; }
  .discovery-list { padding: 12px 12px 24px; }
  .discovery-card { padding: 14px; border-radius: 14px; }
  .discovery-question { min-height: 132px; font-size: 16px; }
  .discovery-action { flex: 1 1 calc(50% - 8px); min-height: 46px; }
  .discovery-header-actions .quiet-button,
  .discovery-header-actions .icon-button { min-width: 44px; min-height: 44px; }
  .discovery-gee-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-actions .discovery-open > span:first-child { display: none; }
  .topbar-actions .discovery-open { min-width: 42px; padding-inline: 8px; }
}

@media (max-width: 390px) {
  .discovery-header .quiet-button { padding-inline: 9px; }
  .discovery-action { flex-basis: 100%; }
}
.conversation-header {
  display: grid;
  grid-template-areas:
    "thread controls"
    "descriptor descriptor";
  grid-template-columns: minmax(0, 1fr) auto;
  row-gap: 7px;
}

.thread-context {
  grid-area: thread;
}

.conversation-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.brain-profile-descriptor {
  grid-area: descriptor;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  letter-spacing: .035em;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brain-switch {
  display: flex;
  flex: none;
  padding: 3px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}

.brain-switch label {
  position: relative;
}

.brain-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.brain-switch span {
  display: block;
  min-width: 64px;
  padding: 6px 8px;
  border-radius: 2px;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .045em;
  text-align: center;
}

.brain-switch input:checked + span {
  background: var(--surface-raised);
  color: var(--accent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
}

.brain-switch input:focus-visible + span {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.brain-switch[aria-busy="true"] {
  opacity: .62;
}

.provider-picker {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}

.provider-picker label {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.provider-picker label > span {
  padding-left: 3px;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 7px;
  font-weight: 750;
  letter-spacing: .065em;
  line-height: 1;
  text-transform: uppercase;
}

.provider-picker select {
  width: auto;
  max-width: 142px;
  min-width: 78px;
  min-height: 26px;
  padding: 3px 22px 3px 6px;
  border: 0;
  border-radius: 2px;
  background-color: var(--surface-raised);
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  font-weight: 750;
}

.provider-picker select:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

.provider-picker[aria-busy="true"],
.provider-picker.is-unavailable {
  opacity: .62;
}

body[data-brain-profile="QQ-002-DO-NATIVE"] .brain-profile-descriptor {
  color: var(--good);
}

.owner-proof .section-heading-row {
  align-items: flex-start;
}

.owner-proof .section-heading-row .section-kicker {
  margin-bottom: 5px;
}

.proof-stack {
  display: grid;
  gap: 8px;
}

.proof-group {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 1.5%);
}

.proof-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.proof-group-heading h4 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.brain-proof-badge {
  flex: none;
  padding: 3px 6px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .04em;
}

.proof-group .status-card {
  padding: 7px;
}

.proof-group .status-card dt {
  margin-bottom: 5px;
}

.proof-detail {
  margin: 7px 0 0;
  color: var(--ink-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 8px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.native-runtime-details {
  margin-top: 8px;
  border: 1px solid rgb(112 201 156 / 28%);
  border-radius: var(--radius-sm);
  background: rgb(112 201 156 / 5%);
}

.native-runtime-details summary {
  padding: 7px 9px;
  color: var(--good);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.native-runtime-payload {
  max-height: 240px;
  padding: 9px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid rgb(112 201 156 / 22%);
  color: var(--ink-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.status-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1180px) and (min-width: 801px) {
  .conversation-controls {
    gap: 6px;
  }

  .brain-switch span,
  .mode-switch span {
    min-width: 55px;
    padding-inline: 5px;
  }


  .provider-picker select {
    max-width: 110px;
    min-width: 66px;
  }
}

@media (max-width: 800px) {
  .conversation-header {
    min-height: 104px;
    grid-template-areas:
      "thread"
      "controls"
      "descriptor";
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    align-content: center;
  }

  .conversation-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }


  .provider-picker {
    order: 3;
    width: 100%;
  }

  .provider-picker label {
    flex: 1 1 0;
  }

  .provider-picker select {
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding-block: 8px;
    font-size: 11px;
  }

  .brain-profile-descriptor {
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .brain-switch span,
  .mode-switch span {
    min-width: 56px;
    padding: 6px 5px;
    font-size: 9px;
  }

  .thread-context h2 {
    max-width: 100%;
  }
}

@media (max-width: 390px) {
  .conversation-header {
    padding-inline: max(8px, var(--safe-left));
  }

  .conversation-controls {
    gap: 5px;
  }

  .brain-switch span,
  .mode-switch span {
    min-width: 50px;
    padding-inline: 3px;
  }

  .brain-profile-descriptor {
    font-size: 8px;
  }

  .status-grid-three {
    grid-template-columns: 1fr;
  }
}

/* Owner mobile stabilization: all existing controls remain available. */
.action-label-mobile,
.attachment-help-button {
  display: none;
}

.attachment-help-button {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 700;
}

.attachment-help-button:hover,
.attachment-help-button[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 800px) {
  .app-shell {
    position: fixed;
    top: var(--app-viewport-offset-top, 0px);
    right: 0;
    left: 0;
    height: var(--app-viewport-height, 100dvh);
  }

  .topbar {
    grid-template-columns: minmax(44px, 1fr) auto;
    gap: 6px;
    padding-right: max(7px, var(--safe-right));
    padding-left: max(7px, var(--safe-left));
  }

  .brand-block {
    gap: 5px;
    overflow: hidden;
  }

  .brand-block > div,
  .brand-line,
  .brand-line h1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(44px, auto));
    gap: 3px;
    min-width: 0;
  }

  .topbar-actions .quiet-button,
  .topbar-actions .discovery-open,
  .topbar-actions .operator-gee-open {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    padding: 4px 6px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
  }

  #governanceDrawerButton {
    display: inline-flex;
  }

  #logoutButton {
    font-size: 9px;
  }

  #logoutButton::after {
    content: none;
  }

  .topbar-actions .action-label-desktop,
  .topbar-actions .discovery-open > .action-label-desktop,
  .topbar-actions .operator-gee-open > .action-label-desktop {
    display: none;
  }

  .topbar-actions .action-label-mobile,
  .topbar-actions .discovery-open > .action-label-mobile,
  .topbar-actions .operator-gee-open > .action-label-mobile {
    display: inline;
  }

  .topbar-actions .discovery-count {
    min-width: 17px;
    padding-inline: 4px;
    font-size: 9px;
  }

  .topbar-actions .gee-live-dot {
    flex: none;
  }

  .conversation-header {
    min-height: 0;
    padding: 8px max(10px, var(--safe-right)) 8px max(10px, var(--safe-left));
    grid-template-areas:
      "thread"
      "controls";
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    align-content: start;
  }

  .thread-context h2 {
    max-width: 100%;
  }

  .conversation-controls {
    display: grid;
    width: 100%;
    grid-template-areas:
      "brain mode"
      "provider provider";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    align-items: stretch;
  }

  .brain-switch {
    grid-area: brain;
  }

  .mode-switch {
    grid-area: mode;
  }

  .brain-switch,
  .mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .brain-switch span,
  .mode-switch span {
    display: grid;
    min-width: 0;
    min-height: 44px;
    padding: 6px 4px;
    place-items: center;
    font-size: 9px;
  }

  .provider-picker {
    grid-area: provider;
    order: initial;
    width: 100%;
  }

  .provider-picker label {
    flex: 1 1 0;
  }

  .provider-picker select {
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding-block: 8px;
    font-size: 11px;
  }

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

  .composer {
    max-height: var(--composer-max-height, 410px);
  }

  .attachment-help-button {
    display: inline-flex;
    align-items: center;
  }

  .attachment-edit-hint,
  .attachment-prompt > #attachmentRules {
    display: none;
  }

  .attachment-composer.is-help-open .attachment-edit-hint {
    display: block;
  }

  .attachment-composer.is-help-open .attachment-prompt > #attachmentRules {
    display: inline;
    flex-basis: 100%;
    line-height: 1.45;
  }

  .attachment-button,
  .attachment-help-button {
    min-height: 36px;
    padding: 7px 9px;
  }

  .send-button {
    min-width: 70px;
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .brand-block > div {
    display: none;
  }

  .topbar {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .topbar-actions {
    grid-template-columns: repeat(4, minmax(44px, 1fr));
  }

  .topbar-actions .quiet-button,
  .topbar-actions .discovery-open,
  .topbar-actions .operator-gee-open {
    min-width: 44px;
    padding-inline: 3px;
  }
}

@media (max-width: 800px) {
  body.is-keyboard-open {
    --topbar-height: 0px;
  }

  body.is-keyboard-open .topbar {
    display: none;
  }

  body.is-keyboard-open .workspace {
    height: var(--app-viewport-height, 100dvh);
  }

  body.is-keyboard-open .conversation-header {
    min-height: 36px;
    padding-top: 5px;
    padding-bottom: 5px;
    grid-template-areas: "thread";
  }

  body.is-keyboard-open .thread-context .section-kicker,
  body.is-keyboard-open .conversation-controls,
  body.is-keyboard-open .brain-profile-descriptor {
    display: none;
  }

  body.is-keyboard-open .thread-context h2 {
    margin: 0;
    font-size: 14px;
    line-height: 26px;
  }

  body.is-keyboard-open .message-stream {
    padding-top: 8px;
    padding-bottom: 10px;
  }

  body.is-keyboard-open .composer {
    max-height: var(--composer-max-height, 148px);
    margin-right: max(4px, var(--safe-right));
    margin-bottom: max(4px, var(--safe-bottom));
    margin-left: max(4px, var(--safe-left));
  }

  body.is-keyboard-open .composer textarea {
    min-height: 48px;
    padding: 9px 10px 4px;
  }

  body.is-keyboard-open .attachment-composer {
    max-height: 74px;
    padding: 0 7px 4px;
  }

  body.is-keyboard-open .attachment-button,
  body.is-keyboard-open .attachment-help-button {
    min-height: 32px;
    padding: 5px 7px;
  }

  body.is-keyboard-open .attachment-edit-hint,
  body.is-keyboard-open .attachment-prompt > #attachmentRules {
    display: none;
  }

  body.is-keyboard-open .composer-footer {
    min-height: 44px;
    padding-block: 3px;
  }

  body.is-keyboard-open .send-button {
    min-height: 40px;
  }
}

/* Mobile repair: one-tap thread creation, optional settings, compact composer.
   The drawer scrim lives INSIDE app-shell, sharing the drawers' stacking context. */
@media (max-width: 800px) {
  .conversation-header,
  body.is-keyboard-open .conversation-header {
    grid-template-areas: "thread actions" "controls controls";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 8px;
    padding: 5px max(8px, var(--safe-right)) 5px max(8px, var(--safe-left));
    max-height: min(300px, 42dvh);
    overflow-y: auto;
  }

  .thread-context .section-kicker { display: none; }
  .thread-context h2 { margin: 0; font-size: 14px; }
  .mobile-current-mode { display: block; margin: 4px 0 0; font-size: 10px; color: var(--accent); }
  .topbar-actions #operatorGeeButton .action-label-mobile { display: inline; }
  .mobile-conversation-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .mobile-conversation-actions button {
    min-height: 44px;
    min-width: 44px;
  }
  #newThreadShortcut { font-size: 12px; white-space: nowrap; }
  #conversationSettingsButton[aria-expanded="true"] { color: var(--accent); background: var(--surface-raised); }
  .conversation-controls { display: none; }
  .conversation-controls.is-expanded,
  body.is-keyboard-open .conversation-controls.is-expanded { display: grid; margin-top: 6px; }
  .provider-picker select { font-size: 16px; }
  .brain-switch span, .mode-switch span { font-size: 11px; }

  .composer,
  body.is-keyboard-open .composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, auto);
    gap: 0;
  }
  .composer textarea { grid-column: 1 / -1; font-size: 16px; }
  .attachment-composer,
  body.is-keyboard-open .attachment-composer {
    grid-row: 2;
    grid-column: 1;
    max-height: 112px;
    padding: 0 4px 6px 8px;
  }
  .attachment-prompt { gap: 4px; }
  .attachment-button, .attachment-help-button,
  body.is-keyboard-open .attachment-button,
  body.is-keyboard-open .attachment-help-button {
    min-height: 44px;
    padding: 6px 8px;
    font-size: 11px;
  }
  .composer-footer,
  body.is-keyboard-open .composer-footer {
    grid-row: 2;
    grid-column: 2;
    align-self: end;
    min-height: 50px;
    padding: 0 6px 6px 3px;
  }
  .composer-context { display: none; }
  .send-button, body.is-keyboard-open .send-button { min-height: 44px; min-width: 64px; }
  .message-stream { padding: 12px max(10px, var(--safe-right)) 16px max(10px, var(--safe-left)); }
  .empty-state { margin-top: 14px; }
  .rail-close, .panel-close, .thread-button, .new-thread-button { min-height: 44px; }
  .thread-list-wrap { -webkit-overflow-scrolling: touch; }
  .scrim { backdrop-filter: none; }
}
