:root {
  --bg: #fcfbf8;
  --surface: #ffffff;
  --panel: #f4f2ed;
  --line: #e2e0db;
  --line-strong: #c9cbd0;
  --ink: #141414;
  --muted: #5a5a60;
  --accent: #1f4e8c;
  --accent-soft: #e5ecf4;
  --danger: #8b3a3a;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --focus: 0 0 0 3px rgba(31, 78, 140, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 10;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.topbar-row,
.brand-lockup,
.status-strip,
.surface-line,
.mode-bar {
  display: flex;
  align-items: center;
}

.topbar-row {
  min-height: 58px;
  width: min(100%, 920px);
  margin-inline: auto;
}

.brand-lockup {
  gap: 10px;
}

.brand-lockup h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.context-meta,
.surface-state,
.rail-meta,
.status-dot,
.eyebrow,
.rail-label,
.mode-tab,
.surface-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.product-mark,
.context-meta,
.rail-meta,
.surface-state,
.surface-label,
.rail-label {
  color: var(--muted);
}

.status-strip {
  min-height: 40px;
  gap: 0;
  overflow-x: auto;
  width: min(100%, 920px);
  margin-inline: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
}

.status-strip::-webkit-scrollbar {
  display: none;
}

.status-item {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  flex: none;
  gap: 7px;
  min-height: 40px;
  padding: 10px 16px 9px 0;
  margin-right: 16px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.sidebar-trigger {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  margin: 4px 14px 4px 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
}

.sidebar-trigger:disabled {
  cursor: default;
  opacity: 0.78;
}

.status-item strong {
  max-width: 22ch;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  text-overflow: ellipsis;
}

.status-label,
.status-source,
.popover-note {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.status-source {
  color: var(--accent);
  font-size: 0.54rem;
}

.status-menu {
  position: relative;
  flex: none;
}

.status-menu summary {
  list-style: none;
  cursor: pointer;
}

.status-menu summary::-webkit-details-marker {
  display: none;
}

.status-chevron {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1;
}

.status-popover {
  position: fixed;
  top: 100px;
  left: 16px;
  right: auto;
  z-index: 20;
  display: grid;
  min-width: 150px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 4px 10px rgba(20, 20, 20, 0.08);
}

.popover-note {
  padding: 4px 7px 7px;
}

.menu-button {
  width: 100%;
  padding: 7px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
}

.menu-button:hover {
  background: var(--panel);
}

.agent-popover {
  min-width: 210px;
}

.agent-popover strong {
  padding: 3px 7px 7px;
  font-size: 0.75rem;
}

.agent-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0 7px 4px 23px;
  color: var(--muted);
  font-size: 0.7rem;
}

.context-pill {
  padding: 5px 8px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #c8d5e4;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: block;
}

.gear-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.gear-tab {
  flex: 0 0 auto;
  min-height: 31px;
  padding: 6px 12px 5px;
  color: var(--muted);
  text-align: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
}

.gear-tab:hover {
  color: var(--ink);
}

.gear-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.canvas-tabs {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  width: max-content;
  min-height: 32px;
  margin: 0 0 8px;
  padding: 0;
  background: transparent;
}

.gear-window {
  width: min(100%, 920px);
  min-height: calc(100vh - 150px);
  margin: 28px auto 0;
}

.gear-panels {
  min-height: calc(100vh - 204px);
}

.workspace-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  padding: 9px 0 8px;
  border-top: 1px solid var(--line);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.04em;
  text-transform: none;
}

.status-dot::before {
  width: 7px;
  height: 7px;
  content: "";
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.ok { color: #356b49; }
.status-dot.info { color: var(--accent); }
.status-dot.warn { color: var(--danger); }

.canvas {
  min-width: 0;
  min-height: calc(100vh - 58px);
  padding: 0 0 54px;
}

.gear-panel {
  width: 100%;
  min-height: calc(100vh - 204px);
  display: flex;
  flex-direction: column;
  padding: 44px clamp(24px, 6vw, 96px) 54px;
  margin: 0;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--surface);
}

.gear-panel[hidden] {
  display: none;
}

.canvas-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
}

.canvas-heading h2 {
  max-width: none;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.03;
  white-space: nowrap;
}

.lede {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.quiet-button,
.primary-button,
.send-button,
.mode-tab {
  cursor: pointer;
}

.quiet-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 7px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.quiet-button {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
}

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

.primary-button,
.send-button {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.primary-button:hover,
.send-button:hover {
  background: #173d6d;
}

.auth-gate {
  max-width: 460px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.auth-gate h3 {
  margin: 0;
  font-size: 1rem;
}

.auth-gate p {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.helper-text,
.error-text {
  font-size: 0.78rem;
  line-height: 1.5;
}

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

.conversation {
  flex: 1;
  min-height: 220px;
  padding: 8px 0 24px;
}

.msg {
  max-width: 68ch;
  margin: 0 0 22px;
}

.msg .hd {
  margin-bottom: 6px;
}

.msg .who {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.msg.human .who,
.msg.human .text {
  color: var(--ink);
}

.msg.vera .who {
  color: var(--accent);
}

.msg.vera .who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg.vera .who::before {
  width: 4px;
  height: 4px;
  content: "";
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
}

.msg.vera .text {
  border-left-color: #9eb3cf;
  color: var(--ink);
}

.msg .text {
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.msg.system .text { color: var(--muted); }
.msg.degraded .text { color: var(--danger); }

.reasoning {
  margin: 12px 0 0 16px;
  color: var(--muted);
  font-size: 0.78rem;
}

.reasoning summary {
  cursor: pointer;
}

.reasoning pre {
  max-width: 100%;
  overflow: auto;
  padding: 10px;
  background: var(--panel);
  white-space: pre-wrap;
}

.composer-wrap {
  margin-top: auto;
}

.composer-actions {
  display: none;
}

.composer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 31px;
  margin-bottom: 3px;
}

.session-flag {
  min-height: 22px;
  padding: 3px 8px;
  color: #a65d55;
  background: #fff5f2;
  border: 1px solid #e8c8c2;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
}

.session-flag:hover {
  color: #8f443d;
  background: #ffefeb;
  border-color: #dba9a1;
}

.session-flag:disabled {
  cursor: default;
  opacity: 0.9;
}

.voice-button {
  display: inline-grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.voice-button:hover {
  color: var(--ink);
  background: var(--panel);
}

.mode-bar {
  justify-content: space-between;
  min-height: 34px;
}

.mode-tabs {
  display: flex;
  gap: 4px;
}

.mode-tab {
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
}

.mode-tab:hover,
.mode-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--line);
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.composer.disabled {
  background: #fbfaf7;
}

.composer input {
  min-width: 0;
  flex: 1;
  padding: 10px 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.send-button {
  display: inline-grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border-radius: 6px;
}

.work-surface,
.build-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.surface-line {
  gap: 14px;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.surface-line:last-of-type {
  border-bottom: 0;
}

.surface-label {
  width: 90px;
  flex: none;
}

.surface-line strong {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.surface-note {
  margin: 0;
  padding: 16px 18px 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.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: 760px) {
  .topbar {
    padding: 16px;
  }

  .topbar-row {
    min-height: 36px;
    width: 100%;
  }

  .status-strip {
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    padding-bottom: 4px;
  }

  .status-item {
    min-height: 32px;
    padding: 7px 10px 6px 0;
    margin-right: 10px;
  }

  .status-item strong {
    max-width: 18ch;
    font-size: 0.7rem;
  }

  .sidebar-trigger {
    margin-right: 10px;
  }

  .status-label,
  .status-source,
  .popover-note {
    font-size: 0.54rem;
  }

  .gear-window {
    width: 100%;
    margin-top: 12px;
  }

  .canvas-tabs {
    width: max-content;
    margin-bottom: 10px;
  }

  .gear-tabs {
    flex: none;
  }

  .gear-tab {
    flex: 0 0 auto;
    min-height: 31px;
    padding: 6px 8px 5px;
  }

  .tab-status {
    display: none;
  }

  .gear-panel {
    min-height: calc(100vh - 170px);
    padding: 30px 16px 34px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .canvas-heading {
    display: block;
    margin-bottom: 28px;
  }

  .canvas-heading h2 {
    max-width: none;
    font-size: clamp(2rem, 9vw, 2.25rem);
  }

  .lede {
    font-size: 0.86rem;
  }

  .conversation {
    min-height: 260px;
  }

  .msg {
    max-width: 100%;
    margin-bottom: 18px;
  }

  .msg .text {
    padding-left: 12px;
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .composer-header {
    width: 100%;
  }

  .session-flag {
    min-height: 22px;
    padding-inline: 6px;
    font-size: 0.56rem;
  }

  .composer {
    gap: 4px;
    padding: 6px;
  }

  .composer input {
    padding: 9px 6px;
    font-size: 0.88rem;
  }

  .surface-line {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 13px 16px;
  }

  .surface-label {
    width: 100%;
  }

  .surface-line strong {
    flex-basis: calc(100% - 140px);
  }
}

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