@import url("https://fonts.googleapis.com/css2?family=Host+Grotesk:wght@400;500;600;700&family=Martian+Mono:wght@400;500;600&display=swap");

:root {
  color-scheme: light;
  --navy: #05375e;
  --navy-dark: #032c4e;
  --blue: #1870c9;
  --logo-blue: #1e74bb;
  --cyan: #00c4e8;
  --teal: #6cdcd8;
  --dark-teal: #027b92;
  --surface: #f4fbff;
  --surface-blue: #e9f1fb;
  --panel: #fbfdff;
  --panel-strong: #dfeef9;
  --text: #2b3c6a;
  --muted: #456187;
  --line: #b9d4ea;
  --warning: #bc7a00;
  --danger: #b23b34;
  --ok: #16836f;
  --shadow-soft: 0 24px 70px rgba(5, 55, 94, 0.11);
  --shadow-tight: 0 10px 28px rgba(5, 55, 94, 0.09);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  font-family: "Host Grotesk", "Aptos", "Segoe UI", sans-serif;
}

@supports (color: oklch(50% 0 0)) {
  :root {
    --navy: oklch(32% 0.086 247);
    --navy-dark: oklch(26% 0.078 247);
    --blue: oklch(54% 0.17 253);
    --logo-blue: oklch(55% 0.151 249);
    --cyan: oklch(75% 0.14 216);
    --teal: oklch(84% 0.106 190);
    --dark-teal: oklch(50% 0.109 211);
    --surface: oklch(97% 0.012 238);
    --surface-blue: oklch(94% 0.035 248);
    --panel: oklch(99% 0.008 238);
    --panel-strong: oklch(92% 0.041 235);
    --text: oklch(34% 0.067 254);
    --muted: oklch(52% 0.055 251);
    --line: oklch(86% 0.033 242);
    --warning: oklch(68% 0.146 72);
    --danger: oklch(58% 0.19 28);
    --ok: oklch(63% 0.119 169);
    --shadow-soft: 0 24px 70px color-mix(in oklch, var(--navy) 11%, transparent);
    --shadow-tight: 0 10px 28px color-mix(in oklch, var(--navy) 9%, transparent);
  }
}

@supports not (color: color-mix(in oklch, #000 50%, #fff 50%)) {
  body,
  .topbar {
    background: var(--surface-blue);
  }

  .chat-heading,
  .audit-header,
  .examples,
  .composer,
  .profile-preview,
  .policy-strip,
  .tab-panel,
  .message,
  textarea,
  input {
    background: var(--panel);
  }

  .example-card,
  .profile-preview div,
  .policy-strip div,
  .timeline-node,
  .rule-row,
  .source-row,
  .envelope-section,
  .decision-list li,
  .tag,
  .tab-button {
    background: var(--surface-blue);
  }

  .run-button {
    color: #f4fbff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--surface);
  background:
    linear-gradient(140deg, color-mix(in oklch, var(--surface-blue) 82%, transparent), transparent 42%),
    var(--surface);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--cyan) 55%, transparent);
  outline-offset: 2px;
}

a {
  color: var(--blue);
}

.shell {
  width: 100%;
  overflow-x: hidden;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: var(--space-sm) clamp(var(--space-md), 3vw, var(--space-xl));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: color-mix(in oklch, var(--surface-blue) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--navy-dark);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0;
}

.brand img {
  width: 92px;
  height: auto;
  display: block;
}

.topbar-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--panel) 90%, var(--surface-blue));
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.status-pill-strong {
  color: var(--navy);
  border-color: color-mix(in oklch, var(--teal) 70%, var(--line));
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: var(--space-md);
  width: 100%;
  margin: 0 auto;
  padding: clamp(var(--space-sm), 1.6vw, var(--space-lg));
  overflow-x: hidden;
}

.chat-pane,
.audit-pane {
  min-width: 0;
  min-height: calc(100dvh - 104px);
  display: flex;
  flex-direction: column;
}

.chat-heading,
.audit-header,
.examples,
.composer,
.profile-preview,
.policy-strip,
.tab-panel,
.message {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--panel) 96%, var(--surface-blue));
  box-shadow: var(--shadow-tight);
}

.chat-heading {
  padding: var(--space-md);
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(260px, 0.72fr);
  gap: var(--space-md);
  align-items: end;
}

.chat-heading h1,
.audit-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.38rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.chat-heading p,
.audit-header p,
.message p {
  margin: 0;
}

.chat-heading > p {
  max-width: 55ch;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow,
.section-label span,
.message-role,
.metric-label,
.field-label {
  margin: 0 0 var(--space-xs);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-label {
  display: block;
}

.examples {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm) var(--space-sm);
  max-height: 102px;
  overflow: auto;
  box-shadow: none;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xs);
}

.section-label small {
  color: var(--muted);
  font-size: 0.76rem;
}

.example-grid {
  display: flex;
  align-items: stretch;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-2xs);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklch, var(--blue) 45%, var(--line)) transparent;
}

.example-grid::-webkit-scrollbar {
  height: 6px;
}

.example-grid::-webkit-scrollbar-thumb {
  background: color-mix(in oklch, var(--blue) 45%, var(--line));
  border-radius: 99px;
}

.example-grid::-webkit-scrollbar-track {
  background: transparent;
}

.example-card {
  flex: 0 0 172px;
  min-height: 48px;
  padding: 7px 10px;
  display: grid;
  gap: 2px;
  border: 1px solid color-mix(in oklch, var(--blue) 22%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-blue) 40%, var(--panel));
  color: var(--text);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.example-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklch, var(--blue) 65%, var(--line));
  background: color-mix(in oklch, var(--surface-blue) 68%, var(--panel));
}

.example-card strong {
  color: var(--navy);
  font-size: 0.72rem;
  line-height: 1.14;
}

.example-card span {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-log {
  flex: 0 0 auto;
  min-height: 180px;
  max-height: 34dvh;
  overflow: auto;
  padding: var(--space-md) var(--space-xs) var(--space-md) 0;
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.message {
  width: min(94%, 820px);
  padding: var(--space-md);
  box-shadow: none;
  animation: enter 280ms ease both;
}

.message-user {
  margin-left: auto;
  background: var(--navy);
  color: color-mix(in oklch, var(--surface) 97%, var(--teal));
}

.message-user .message-role {
  color: var(--teal);
}

.message-agent {
  margin-right: auto;
  background: color-mix(in oklch, var(--panel) 98%, var(--surface-blue));
  border-color: color-mix(in oklch, var(--blue) 28%, var(--line));
}

.message-agent p {
  color: var(--navy-dark);
}

.message-agent strong {
  color: var(--navy);
}

.decision-list {
  display: grid;
  gap: var(--space-xs);
  margin: var(--space-sm) 0 0;
  padding: 0;
  list-style: none;
}

.decision-list li {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: color-mix(in oklch, var(--surface-blue) 36%, var(--panel));
}

.composer {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  box-shadow: var(--shadow-soft);
}

.input-block,
.fact-grid label {
  display: grid;
  gap: var(--space-xs);
}

.input-block span,
.fact-grid span {
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid color-mix(in oklch, var(--line) 80%, var(--blue));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--panel) 96%, var(--surface-blue));
  color: var(--navy-dark);
  outline: none;
}

textarea {
  min-height: 136px;
  padding: var(--space-md);
  resize: vertical;
  line-height: 1.45;
}

input {
  min-height: 44px;
  padding: 0 var(--space-sm);
}

textarea:focus,
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--cyan) 24%, transparent);
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.profile-preview {
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--space-sm);
  box-shadow: none;
}

.profile-preview div {
  min-width: 0;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-blue) 38%, var(--panel));
}

.profile-preview p {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.38;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  color: var(--muted);
  font-size: 0.88rem;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--blue);
}

.run-button,
.ghost-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.run-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-lg);
  background: var(--blue);
  color: color-mix(in oklch, var(--surface) 98%, var(--teal));
  box-shadow: 0 10px 28px color-mix(in oklch, var(--blue) 20%, transparent);
}

.run-button:hover:not(:disabled) {
  background: color-mix(in oklch, var(--blue) 82%, var(--navy));
}

.run-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}

.run-button.is-running .button-icon {
  animation: pulse 900ms ease infinite;
}

.audit-pane {
  align-self: start;
  position: sticky;
  top: 88px;
  height: calc(100dvh - 104px);
}

.audit-header {
  padding: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  box-shadow: none;
}

.ghost-button {
  padding: 0 var(--space-md);
  background: transparent;
  color: var(--blue);
  border-color: color-mix(in oklch, var(--blue) 35%, var(--line));
}

.ghost-button:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

.policy-strip {
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-sm);
  box-shadow: none;
}

.policy-strip div {
  min-width: 0;
  padding: var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-blue) 50%, var(--panel));
}

.metric-label {
  display: block;
  margin-bottom: var(--space-2xs);
}

.policy-strip strong {
  display: block;
  overflow: hidden;
  color: var(--navy);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  margin-top: var(--space-sm);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
}

.tab-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--panel) 86%, var(--surface-blue));
  color: var(--muted);
  font-weight: 700;
}

.tab-button.active {
  background: var(--navy);
  color: color-mix(in oklch, var(--surface) 98%, var(--teal));
  border-color: var(--navy);
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  box-shadow: var(--shadow-soft);
}

.tab-panel.active {
  display: block;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.timeline {
  display: grid;
  gap: var(--space-sm);
}

.timeline-node,
.rule-row,
.source-row,
.envelope-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--panel) 92%, var(--surface-blue));
}

.timeline-node {
  padding: var(--space-md);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: var(--space-sm);
  animation: enter 260ms ease both;
}

.node-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--navy);
  background: color-mix(in oklch, var(--teal) 45%, var(--surface-blue));
}

.node-icon svg {
  width: 18px;
  height: 18px;
}

.node-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  color: var(--navy);
  font-weight: 700;
}

.node-time,
.node-detail,
.hash-value {
  font-family: "Martian Mono", "SFMono-Regular", Consolas, monospace;
}

.node-time {
  color: var(--muted);
  font-size: 0.7rem;
}

.node-detail {
  margin-top: var(--space-xs);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  word-break: break-word;
}

.rule-list,
.source-list,
.envelope-stack {
  display: grid;
  gap: var(--space-sm);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-xs);
  margin: var(--space-sm) 0;
}

.metric-grid div {
  min-width: 0;
  padding: var(--space-xs);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: color-mix(in oklch, var(--surface-blue) 44%, var(--panel));
}

.metric-grid strong {
  display: block;
  overflow: hidden;
  color: var(--navy);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-row,
.source-row,
.envelope-section {
  padding: var(--space-md);
}

.rule-head,
.source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
}

.rule-id,
.source-title {
  color: var(--navy);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.score {
  flex: 0 0 auto;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-xs);
  background: color-mix(in oklch, var(--teal) 55%, var(--surface-blue));
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 700;
}

.rule-text,
.source-url,
.envelope-section p,
.compact-list {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.48;
}

.rule-text {
  margin: var(--space-sm) 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 var(--space-xs);
  border-radius: var(--radius-xs);
  background: color-mix(in oklch, var(--surface-blue) 72%, var(--panel));
  color: var(--navy);
  font-size: 0.74rem;
  font-weight: 700;
}

.source-url {
  overflow-wrap: anywhere;
}

.source-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.source-actions a,
.copy-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid color-mix(in oklch, var(--blue) 38%, var(--line));
  border-radius: var(--radius-xs);
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  color: var(--blue);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}

.compact-list {
  margin: var(--space-xs) 0 0;
  padding-left: 1.1rem;
}

.hash-value {
  color: var(--navy-dark);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.toon-preview {
  max-height: 220px;
  margin: var(--space-sm) 0 0;
  overflow: auto;
  padding: var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: color-mix(in oklch, var(--navy) 4%, var(--panel));
  color: var(--navy-dark);
  font-family: "Martian Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: pre;
}

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

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

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

  .audit-pane {
    position: static;
    height: auto;
  }

  .tab-panel {
    max-height: 680px;
  }
}

@media (min-width: 1181px) {
  .audit-pane {
    margin-top: -60px;
  }
}

@media (max-width: 760px) {
  .topbar {
    width: 100%;
    overflow-x: hidden;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-status {
    justify-content: flex-start;
  }

  .chat-heading {
    grid-template-columns: 1fr;
  }

  .chat-heading,
  .composer,
  .examples,
  .message,
  .audit-header,
  .policy-strip,
  .tab-panel {
    width: 100%;
    min-width: 0;
  }

  .chat-heading > p {
    max-width: none;
  }

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

  .profile-preview {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .run-button {
    justify-content: center;
    width: 100%;
  }

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

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .workspace {
    padding: var(--space-sm);
  }

  .topbar {
    padding-inline: var(--space-md);
  }

  textarea,
  input {
    min-width: 0;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }

  .brand span {
    display: none;
  }

  .message {
    width: 100%;
  }

  .policy-strip,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
