/*
 * Oji surface system
 * ------------------
 * Shared refinement layer for Chat, Zenuwstelsel, Agentstroom and
 * Instellingen. This file is intentionally loaded after each surface's
 * functional stylesheet: the older files retain state-specific mechanics,
 * while this layer owns the cross-surface visual language and responsive shell.
 *
 * Atlas rules carried here: flat colour blocks, filled geometry, warm natural
 * pigments, visible structure, restrained motion, no gradients and no glossy
 * shadows. All controls retain a clear keyboard focus state.
 */

:root {
  color-scheme: light;

  --atlas-petrol: #153937;
  --atlas-petrol-2: #102b29;
  --atlas-teal: #1f4e4a;
  --atlas-teal-2: #29605b;
  --atlas-ochre: #e6a24a;
  --atlas-ochre-2: #c7873a;
  --atlas-sand: #f2d6a2;
  --atlas-sand-mute: #c9b385;
  --atlas-sage: #7fa39a;
  --atlas-sage-2: #6a8c84;
  --atlas-coral: #d97a5b;
  --atlas-terracotta: #a63d2f;
  --atlas-burnt: #c65a2e;
  --atlas-clay: #8c4a2f;

  --canvas: #ead8b4;
  --canvas-strong: #e6c98f;
  --surface: #f8edd8;
  --surface-raised: #f2d6a2;
  --surface-quiet: #efe0c2;
  --ink: #153937;
  --ink-muted: #4f6c67;
  --line: rgba(21, 57, 55, 0.18);
  --line-strong: rgba(21, 57, 55, 0.34);
  --error-surface: #efd0bd;

  /*
   * Compatibility names consumed by the surface-specific stylesheets. This
   * loaded-last layer is authoritative while body[data-surface] is present;
   * duplicate legacy :root tokens can be consolidated in a later CSS-only pass.
   */
  --bg: var(--canvas);
  --bg-elev: var(--surface);
  --bg-raised: var(--surface-raised);
  --bg-input: #fcf5e7;
  --fg: var(--ink);
  --fg-muted: var(--ink-muted);
  --accent: var(--atlas-ochre-2);
  --accent-hov: var(--atlas-burnt);
  --accent-fade: rgba(199, 135, 58, 0.17);
  --user-bg: var(--atlas-teal);
  --oji-bg: var(--surface);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --warning: var(--atlas-coral);
  --error: var(--atlas-terracotta);
  --error-fg: #75281e;
  --at-cap: var(--atlas-burnt);
  --focus-ring: var(--atlas-burnt);
  --secondary: var(--atlas-sage-2);
  --secondary-hov: var(--atlas-teal-2);
  --branch-glow: transparent;

  --font-ui: Inter, Avenir, "Avenir Next", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-headline: "Playfair Display", Iowan Old Style, Baskerville, Georgia,
    "Times New Roman", serif;
  --font-mono: "SFMono-Regular", "SF Mono", ui-monospace, Menlo, Consolas,
    monospace;

  /* Shared rhythm intentionally replaces the near-identical legacy radii. */
  --radius-sm: 5px;
  --radius-md: 9px;
  --radius-lg: 15px;
  --radius-xl: 24px;
  --content-wide: 1240px;
  --content-reading: 920px;

  /* Atlas deliberately avoids glossy depth effects; these override legacy values. */
  --shadow-1: none;
  --shadow-2: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #102b29;
    --canvas-strong: #153937;
    --surface: #153937;
    --surface-raised: #1f4e4a;
    --surface-quiet: #183f3c;
    --ink: #f2d6a2;
    --ink-muted: #c9b385;
    --line: rgba(242, 214, 162, 0.14);
    --line-strong: rgba(242, 214, 162, 0.3);
    --error-surface: #3f302b;
    --bg-input: #183f3c;
    --accent: #e6a24a;
    --accent-hov: #f0b867;
    --accent-fade: rgba(230, 162, 74, 0.17);
    --user-bg: #29605b;
    --oji-bg: #153937;
    --error-fg: #f1c2b2;
    --focus-ring: #e6a24a;
    --secondary: #7fa39a;
    --secondary-hov: #91b3aa;
  }

}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body[data-surface] {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
}

body[data-surface]::before {
  /* The functional surface stylesheet supplies the existing grain image. */
  opacity: 0.42;
}

body[data-surface] *,
body[data-surface] *::before,
body[data-surface] *::after {
  box-shadow: none;
}

body[data-surface] button,
body[data-surface] input,
body[data-surface] select,
body[data-surface] textarea {
  font: inherit;
}

body[data-surface] button,
body[data-surface] a,
body[data-surface] input,
body[data-surface] select,
body[data-surface] textarea,
body[data-surface] [tabindex] {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.sr-only {
  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;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 300;
  padding: 0.65rem 0.9rem;
  background: var(--atlas-sand);
  color: var(--atlas-petrol);
  border: 2px solid var(--atlas-petrol);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}

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

body[data-surface] :focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   Shared header and navigation
   -------------------------------------------------------------------------- */

body[data-surface] > header {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: 72px;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 1.25rem;
  background: var(--atlas-petrol);
  border-bottom: 4px solid var(--atlas-ochre);
}

.brand {
  min-width: max-content;
  gap: 0.55rem;
}

.brand-name {
  color: var(--atlas-sand);
  font-family: var(--font-headline);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

.brand-sep {
  color: var(--atlas-sage);
}

.brand-sub {
  color: var(--atlas-sand-mute);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dot {
  position: relative;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  background: var(--atlas-ochre);
  clip-path: polygon(50% 0%, 63% 36%, 100% 50%, 63% 64%, 50% 100%, 37% 64%, 0% 50%, 37% 36%);
}

.header-right {
  min-width: 0;
  flex-wrap: nowrap;
  gap: 0.8rem;
}

.surface-nav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.15rem;
  padding: 0.25rem;
  background: var(--atlas-petrol-2);
  border: 1px solid rgba(242, 214, 162, 0.18);
  border-radius: var(--radius-md);
}

.surface-link {
  min-height: 38px;
  padding: 0.5rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--atlas-sand-mute);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.015em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 140ms ease, background-color 140ms ease;
}

.surface-link:hover {
  color: var(--atlas-sand);
  background: var(--atlas-teal);
}

.surface-link.is-current {
  color: var(--atlas-petrol);
  background: var(--atlas-ochre);
  font-weight: 800;
}

.account-wrap {
  position: relative;
  flex: 0 1 auto;
}

.account-chip {
  min-height: 42px;
  max-width: 230px;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  gap: 0.55rem;
  background: var(--atlas-teal);
  color: var(--atlas-sand);
  border: 1px solid rgba(242, 214, 162, 0.28);
  border-radius: 999px;
}

.account-chip:hover {
  border-color: var(--atlas-ochre);
  background: var(--atlas-teal-2);
}

.account-chip .avatar {
  width: 30px;
  height: 30px;
  background: var(--atlas-ochre);
  color: var(--atlas-petrol);
}

.account-chip .email-text,
.account-chip .caret {
  color: var(--atlas-sand-mute);
}

.account-menu {
  top: calc(100% + 0.25rem);
  right: 0;
  min-width: 250px;
  padding: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}

.account-menu .menu-section {
  color: var(--ink-muted);
}

.account-menu .menu-account-email {
  padding-top: 0;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  word-break: break-word;
}

.account-menu button {
  min-height: 42px;
  color: var(--ink);
  border-radius: var(--radius-md);
}

.account-menu button:hover {
  background: var(--surface-raised);
}

.account-menu hr {
  border-top-color: var(--line);
}

body[data-surface] > main {
  position: relative;
  z-index: 1;
  min-height: 0;
  background: var(--canvas);
}

/* --------------------------------------------------------------------------
   Sign-in and access states
   -------------------------------------------------------------------------- */

.signin-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: min(900px, calc(100% - 2rem));
  max-width: 900px;
  min-height: 480px;
  margin: clamp(1.5rem, 6vh, 5rem) auto;
  padding: clamp(2rem, 5vw, 4rem);
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(320px, 1.15fr);
  grid-template-rows: repeat(5, min-content);
  align-content: center;
  column-gap: clamp(2rem, 6vw, 5rem);
  text-align: left;
  background: var(--atlas-sand);
  color: var(--atlas-petrol);
  border: 1px solid rgba(21, 57, 55, 0.28);
  border-radius: 28px;
}

.signin-wrap::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -2;
  width: 42%;
  background: var(--atlas-teal);
  clip-path: polygon(0 0, 84% 0, 100% 50%, 84% 100%, 0 100%);
}

.signin-wrap::after {
  content: "";
  position: absolute;
  left: 7%;
  bottom: -7rem;
  z-index: -1;
  width: 19rem;
  height: 19rem;
  border-radius: 50%;
  background: var(--atlas-ochre);
  opacity: 0.8;
}

.signin-medallion {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: center;
  justify-self: center;
  width: clamp(120px, 16vw, 180px);
  height: clamp(120px, 16vw, 180px);
  margin: 0;
  color: var(--atlas-ochre);
  filter: none;
}

.signin-kicker,
.signin-headline,
.signin-prose,
.signin-wrap > #g_id_signin,
.signin-wrap > .signin-error,
.signin-wrap > #native-auth-retry {
  grid-column: 2;
}

.signin-kicker,
.surface-eyebrow {
  margin: 0 0 0.55rem;
  color: var(--atlas-clay);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.signin-headline {
  margin: 0;
  color: var(--atlas-petrol);
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.signin-prose {
  max-width: 42ch;
  margin: 1rem 0 1.75rem;
  color: var(--atlas-teal);
  font-size: 1rem;
  line-height: 1.65;
}

.signin-prose strong {
  color: var(--atlas-petrol);
  font-weight: 750;
}

.signin-wrap > #g_id_signin {
  min-height: 44px;
}

.signin-error {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  color: #6f241b;
  background: #efd0bd;
  border: 1px solid var(--atlas-terracotta);
  border-radius: var(--radius-md);
}

.access-denied {
  width: min(580px, calc(100% - 2rem));
  max-width: 580px;
  margin: clamp(2rem, 8vh, 6rem) auto;
  padding: clamp(2rem, 5vw, 3.5rem);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 8px solid var(--atlas-terracotta);
  border-radius: var(--radius-xl);
}

.access-denied .medallion {
  color: var(--atlas-terracotta);
  filter: none;
}

.access-denied h2 {
  color: var(--ink);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

.access-denied p,
.access-denied .email-shown {
  color: var(--ink-muted);
}

.access-denied button,
#native-auth-retry {
  min-height: 44px;
  padding: 0.65rem 1rem;
  background: var(--atlas-teal);
  color: var(--atlas-sand);
  border: 1px solid var(--atlas-teal);
  border-radius: var(--radius-md);
  font-weight: 750;
}

.access-denied button:hover,
#native-auth-retry:hover {
  background: var(--atlas-teal-2);
}

/* --------------------------------------------------------------------------
   Shared authenticated-page framing
   -------------------------------------------------------------------------- */

.surface-intro,
.chat-context {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 8px solid var(--atlas-ochre);
  border-radius: var(--radius-xl);
}

.surface-intro h1,
.chat-context h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-headline);
  font-size: clamp(2rem, 4vw, 3.35rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.surface-intro > div > p:last-child {
  max-width: 64ch;
  margin: 0.7rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.surface-assurance {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.45rem 0.65rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-muted);
  background: var(--surface-quiet);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}

.surface-assurance > span {
  width: 9px;
  height: 9px;
  background: var(--atlas-sage-2);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.section-title {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
}

.error-strip,
.session-banner,
.flow-detail-status,
.qi-row-error {
  color: var(--error-fg);
  background: var(--error-surface);
  border-color: var(--atlas-terracotta);
}

/* --------------------------------------------------------------------------
   Chat
   -------------------------------------------------------------------------- */

body[data-surface="chat"] > main {
  padding: 0 clamp(0.75rem, 2.5vw, 2rem);
}

#chat-wrap {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 1.75rem) 0 0;
}

.chat-context {
  max-width: var(--content-reading);
  margin: 0 auto 0.75rem;
  padding-block: 1.1rem;
  align-items: center;
}

.chat-context h1 {
  font-size: clamp(1.55rem, 3vw, 2.15rem);
}

.chat-context .surface-eyebrow {
  margin-bottom: 0.25rem;
}

.messages {
  max-width: var(--content-reading);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  gap: 0.9rem;
  background: var(--surface-quiet);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  scrollbar-color: var(--line-strong) transparent;
}

.message {
  max-width: min(78%, 680px);
}

.message-bubble {
  padding: 0.8rem 1rem;
  border-radius: 14px;
  box-shadow: none;
}

.message.user .message-bubble {
  color: var(--atlas-sand);
  background: var(--atlas-teal);
  border: 1px solid var(--atlas-teal-2);
  border-radius: 14px 14px 4px 14px;
}

.message.oji .message-bubble {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--atlas-ochre);
  border-radius: 4px 14px 14px 14px;
}

.message-bubble a {
  color: var(--atlas-burnt);
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  /* Clay is intentionally earthy on sand, but it falls below AA on petrol. */
  .surface-eyebrow {
    color: var(--atlas-ochre);
  }

  .message-bubble a {
    color: var(--atlas-ochre);
  }
}

.message-error .message-bubble,
.message-retry .retry-text {
  color: var(--error-fg);
  background: var(--error-surface);
  border-color: var(--atlas-terracotta);
}

.cortex-badge,
.char-counter {
  color: var(--ink-muted);
  background: var(--surface);
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
}

.empty-state {
  width: min(100%, 560px);
  margin: auto;
  padding: clamp(2rem, 6vw, 4rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.empty-state .empty-headline {
  color: var(--ink);
  font-size: 1.4rem;
}

.empty-state .empty-prose {
  color: var(--ink-muted);
}

.composer {
  max-width: var(--content-reading);
  margin-top: 0.75rem;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.composer-input {
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}

.composer-input::placeholder {
  color: var(--ink-muted);
}

.composer-input:focus {
  border-color: var(--atlas-ochre-2);
  outline: 3px solid var(--accent-fade);
  outline-offset: 0;
  box-shadow: none;
}

.send-btn {
  width: 48px;
  height: 48px;
  color: var(--atlas-petrol);
  background: var(--atlas-ochre);
  border: 1px solid var(--atlas-ochre);
  border-radius: var(--radius-md);
}

.send-btn:hover {
  background: var(--atlas-ochre-2);
  border-color: var(--atlas-ochre-2);
}

.send-btn:disabled {
  color: var(--ink-muted);
  background: var(--surface-quiet);
  border-color: var(--line);
}

.prevchats-backdrop,
.flow-detail-backdrop {
  background: rgba(16, 43, 41, 0.72);
}

.prevchats-panel {
  width: min(430px, 94vw);
  color: var(--ink);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: none;
}

.prevchats-head,
.prevchats-item {
  border-color: var(--line);
}

.prevchats-title,
.prevchats-item-title,
.prevchats-close {
  color: var(--ink);
}

.prevchats-status,
.prevchats-item-meta {
  color: var(--ink-muted);
}

.prevchats-item {
  min-height: 58px;
  background: var(--surface-quiet);
  border-radius: var(--radius-md);
}

.prevchats-item:hover,
.prevchats-item.is-current {
  background: var(--surface-raised);
  border-color: var(--atlas-ochre-2);
}

/* --------------------------------------------------------------------------
   Zenuwstelsel
   -------------------------------------------------------------------------- */

.dashboard-wrap {
  max-width: var(--content-wide);
  padding: clamp(1rem, 3vw, 2rem);
  gap: 1.5rem;
}

.dashboard-grid {
  gap: 1.5rem;
}

@media (min-width: 980px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  }
}

.queue-section,
.recent-section {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}

.queue-head {
  align-items: center;
  min-height: 42px;
  padding-bottom: 0.8rem;
  border-color: var(--line-strong);
}

.queue-count,
.flow-count {
  color: var(--ink-muted);
  padding: 0.2rem 0.45rem;
  background: var(--surface-quiet);
  border-radius: var(--radius-sm);
}

.poll-status {
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
}

.queue-list {
  gap: 0.75rem;
}

.queue-item {
  padding: 1rem;
  gap: 0.65rem;
  color: var(--ink);
  background: var(--surface-quiet);
  border: 1px solid var(--line);
  border-left: 5px solid var(--atlas-sage-2);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.queue-item:hover {
  border-color: var(--line-strong);
  border-left-color: var(--atlas-ochre-2);
}

.recent-item {
  border-left-color: var(--atlas-ochre-2);
}

.qi-agent,
.qi-action-summary {
  color: var(--ink);
}

.qi-source,
.qi-time,
.qi-rationale,
.qi-brief,
.recent-note,
.recent-empty {
  color: var(--ink-muted);
}

.qi-rationale,
.qi-brief {
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.qi-brief-toggle,
.recent-artifact {
  color: var(--atlas-burnt);
  font-weight: 700;
}

.qi-actions,
.qi-edit-actions {
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.qi-btn {
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  font-weight: 750;
}

.qi-btn.is-approve,
.qi-btn.is-confirm,
.qi-btn.is-dispatch,
.qi-btn.is-complete {
  color: var(--atlas-sand);
  background: var(--atlas-teal);
  border-color: var(--atlas-teal);
}

.qi-btn.is-approve:hover,
.qi-btn.is-confirm:hover,
.qi-btn.is-dispatch:hover,
.qi-btn.is-complete:hover {
  background: var(--atlas-teal-2);
}

.qi-btn.is-edit,
.qi-btn.is-cancel {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.qi-btn.is-reject {
  color: var(--error-fg);
  background: transparent;
  border-color: currentColor;
}

.qi-btn.is-reject:hover {
  color: var(--surface);
  background: var(--error-fg);
  border-color: var(--error-fg);
}

.qi-confirm,
.qi-edit-form,
.qi-outcome-form {
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}

.qi-edit-input,
.qi-artifact-input {
  min-height: 44px;
  color: var(--ink);
  background: var(--bg-input);
  border-color: var(--line-strong);
}

.status-chip,
.qi-urgency {
  border-radius: var(--radius-sm);
}

.status-chip.st-approved {
  background: var(--atlas-ochre);
  color: var(--atlas-petrol);
}

.status-chip.st-dispatched,
.status-chip.st-in_progress {
  background: var(--atlas-sage);
  color: var(--atlas-petrol);
}

.status-chip.st-completed {
  background: var(--atlas-teal);
  color: var(--atlas-sand);
}

.status-chip.st-rejected {
  background: var(--atlas-terracotta);
  color: var(--atlas-sand);
}

/* --------------------------------------------------------------------------
   Agentstroom
   -------------------------------------------------------------------------- */

.flow-wrap {
  max-width: var(--content-wide);
  padding: clamp(1rem, 3vw, 2rem);
}

.flow-head {
  margin-top: 1.25rem;
  padding: 0 0 0.75rem;
  border-color: var(--line-strong);
}

.flow-controls {
  gap: 0.6rem;
}

.flow-toggle,
.resume-pill {
  min-height: 40px;
  border-radius: var(--radius-md);
}

.flow-toggle {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.resume-pill {
  color: var(--atlas-petrol);
  background: var(--atlas-ochre);
}

.flow-spotlight {
  padding: 1rem 1.2rem;
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-left: 6px solid var(--atlas-sage-2);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.flow-spotlight.is-live {
  background: var(--surface-raised);
  border-color: var(--atlas-ochre-2);
  border-left-color: var(--atlas-burnt);
  box-shadow: none;
}

.flow-spotlight.is-live .flow-spotlight-name,
.flow-spotlight-name {
  color: var(--ink);
  text-shadow: none;
}

.flow-spotlight.is-live .flow-spotlight-kicker {
  color: var(--atlas-clay);
}

.flow-legend {
  color: var(--ink-muted);
}

.flow-tree-shell {
  border: 2px solid var(--atlas-teal);
  border-radius: var(--radius-xl);
  box-shadow: none;
}

.flow-wrap.has-live-active .flow-tree-shell {
  border-color: var(--atlas-burnt);
  box-shadow: none;
}

.agent,
.agent-node {
  box-shadow: none !important;
  text-shadow: none !important;
}

.agent-node {
  color: var(--ink);
  background: var(--surface);
}

.agent-node.is-active {
  border-width: 3px;
  border-color: var(--atlas-burnt);
}

.flow-detail-panel {
  color: var(--ink);
  background: var(--surface);
  border-left: 4px solid var(--atlas-ochre);
  box-shadow: none;
}

.flow-detail-head,
.detail-stage,
.detail-query {
  border-color: var(--line);
}

.flow-detail-head h3,
.detail-stage-name,
.detail-query {
  color: var(--ink);
}

.flow-detail-close,
.detail-label,
.detail-meta,
.detail-summary,
.detail-list,
.detail-empty {
  color: var(--ink-muted);
}

.detail-query,
.detail-stage {
  background: var(--surface-quiet);
}

.detail-chip,
.wake-chip {
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Instellingen
   -------------------------------------------------------------------------- */

.settings-wrap {
  max-width: 1120px;
  padding: clamp(1rem, 3vw, 2rem);
}

.settings-head.surface-intro {
  margin-bottom: 1.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.settings-head h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-headline);
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.settings-lead {
  color: var(--ink-muted);
}

.settings-grid {
  gap: 1rem;
}

.settings-card {
  position: relative;
  min-height: 220px;
  padding: 1.25rem;
  gap: 0.75rem;
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-top: 5px solid var(--atlas-sage-2);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.settings-card:first-child {
  border-top-color: var(--atlas-ochre-2);
}

.settings-card.is-server {
  border-top-color: var(--atlas-teal-2);
}

.settings-card.is-stubbed {
  opacity: 1;
}

.settings-card-title,
.settings-server-label {
  color: var(--ink);
}

.settings-card-desc,
.settings-control,
.settings-stub-note {
  color: var(--ink-muted);
}

.settings-stub-note {
  align-self: flex-start;
  padding: 0.2rem 0.45rem;
  background: var(--surface-quiet);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.settings-readonly,
.settings-server-list li {
  color: var(--ink);
  background: var(--surface-quiet);
  border-color: var(--line);
}

.settings-control input[type="range"],
.settings-control select {
  color: var(--ink-muted);
  background: var(--bg-input);
  border-color: var(--line);
}

.settings-control input:disabled,
.settings-control select:disabled {
  opacity: 0.68;
}

.settings-server-badge {
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Responsive behavior
   -------------------------------------------------------------------------- */

@media (max-width: 980px) {
  body[data-surface] > header {
    gap: 0.75rem;
  }

  .brand-sub,
  .brand-sep {
    display: none;
  }

  .surface-link {
    padding-inline: 0.55rem;
    font-size: 0.72rem;
  }

  .account-chip .email-text {
    display: none;
  }

  .account-chip {
    padding-right: 0.45rem;
  }

  .signin-wrap {
    grid-template-columns: minmax(180px, 0.7fr) minmax(300px, 1.3fr);
    column-gap: 2rem;
  }
}

@media (max-width: 720px) {
  body[data-surface] {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body[data-surface] > header {
    min-height: 64px;
    padding: 0.6rem 0.85rem;
    padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
    border-bottom-width: 3px;
  }

  .header-right {
    margin-left: auto;
  }

  .surface-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.2rem;
    background: var(--atlas-petrol);
    border: 0;
    border-top: 3px solid var(--atlas-ochre);
    border-radius: 0;
  }

  .surface-link {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0.35rem 0.15rem;
    font-size: clamp(0.62rem, 2.6vw, 0.72rem);
    line-height: 1.15;
    white-space: normal;
    text-align: center;
  }

  .brand-name {
    font-size: 1.15rem;
  }

  .account-chip {
    min-height: 40px;
  }

  .signin-wrap {
    width: min(100% - 1rem, 560px);
    min-height: auto;
    margin: 0.5rem auto;
    padding: 2rem 1.25rem 2.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-radius: 20px;
  }

  .signin-wrap::before {
    inset: 0 0 auto;
    width: 100%;
    height: 42%;
    clip-path: polygon(0 0, 100% 0, 100% 74%, 50% 100%, 0 74%);
  }

  .signin-wrap::after {
    left: 50%;
    bottom: auto;
    top: -9rem;
    width: 17rem;
    height: 17rem;
    transform: translateX(-50%);
  }

  .signin-medallion {
    width: 104px;
    height: 104px;
    margin: 1.25rem 0 3.3rem;
  }

  .signin-kicker {
    margin-bottom: 0.4rem;
  }

  .signin-prose {
    margin-bottom: 1.25rem;
  }

  .surface-intro,
  .chat-context {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
    border-left-width: 5px;
  }

  .surface-assurance {
    align-self: flex-start;
  }

  body[data-surface="chat"] > main {
    padding-inline: 0.5rem;
  }

  #chat-wrap {
    padding-top: 0.5rem;
  }

  .chat-context {
    margin-bottom: 0.5rem;
  }

  .messages {
    padding: 0.85rem 0.65rem;
    border-radius: var(--radius-lg);
  }

  .message {
    max-width: 92%;
  }

  .composer {
    padding: 0.55rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .dashboard-wrap,
  .flow-wrap,
  .settings-wrap {
    padding: 0.75rem 0.5rem 1.25rem;
  }

  .queue-section,
  .recent-section {
    padding: 1rem;
  }

  .flow-head {
    align-items: flex-start;
  }

  .flow-controls {
    width: 100%;
    margin-left: 0;
  }

  .flow-toggle,
  .resume-pill {
    flex: 1;
    justify-content: center;
  }

  .settings-card {
    min-height: 0;
  }

  .flow-detail-panel,
  .prevchats-panel {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    height: auto;
  }
}

@media (max-width: 430px) {
  .brand {
    gap: 0.4rem;
  }

  .dot {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

  .account-chip .caret {
    display: none;
  }

  .account-chip {
    padding: 0.25rem;
    border-radius: 50%;
  }

  .account-chip .avatar {
    width: 30px;
    height: 30px;
  }

  .account-menu {
    position: fixed;
    top: calc(62px + env(safe-area-inset-top, 0px));
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
  }

  .signin-headline {
    font-size: 2rem;
  }

  .surface-intro h1,
  .settings-head h1 {
    font-size: 2rem;
  }

  .qi-actions,
  .qi-edit-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .qi-btn {
    width: 100%;
  }

  .flow-tree {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  body[data-surface] *,
  body[data-surface] *::before,
  body[data-surface] *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .dot,
  .surface-assurance > span,
  .settings-card-icon,
  .flow-spotlight-mark {
    forced-color-adjust: none;
  }

  .surface-link.is-current,
  .send-btn,
  .qi-btn,
  .access-denied button {
    border: 2px solid ButtonText;
  }
}
