/* ==========================================================================
   Dataspace Copilot — design tokens taken from onboarding-dashboard-ai
   (Telekom / DIH design system: TeleNeo, magenta #E20074, light chrome)
   ========================================================================== */

@font-face { font-family: 'TeleNeoWeb'; font-weight: 400; font-style: normal; src: url('/fonts/TeleNeoWeb-Regular.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'TeleNeoWeb'; font-weight: 500; font-style: normal; src: url('/fonts/TeleNeoWeb-Medium.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'TeleNeoWeb'; font-weight: 700; font-style: normal; src: url('/fonts/TeleNeoWeb-Bold.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'TeleNeoWeb'; font-weight: 800; font-style: normal; src: url('/fonts/TeleNeoWeb-ExtraBold.woff2') format('woff2'); font-display: swap; }

:root {
  --background: oklch(0.975 0.002 300);
  --foreground: oklch(0.22 0.01 300);
  --card: oklch(1 0 0);
  --primary: oklch(0.591 0.2246 355.9);          /* Telekom Magenta #E20074 */
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.96 0.005 300);
  --muted: oklch(0.96 0.004 300);
  --muted-foreground: oklch(0.48 0.01 300);
  --accent: oklch(0.955 0.015 355);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.91 0.005 300);
  --ring: oklch(0.591 0.2246 355.9);
  --success: oklch(0.65 0.18 145);
  --warning: oklch(0.75 0.15 85);
  --info: oklch(0.55 0.12 240);
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --shadow-sm: 0 1px 2px 0 oklch(0.22 0.01 300 / 0.05);
  --shadow-md: 0 4px 12px -2px oklch(0.22 0.01 300 / 0.08), 0 2px 4px -2px oklch(0.22 0.01 300 / 0.04);
  --font-sans: 'TeleNeoWeb', 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; border-color: var(--border); }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

/* ---------- Layout ------------------------------------------------------ */

.app { display: grid; grid-template-columns: 16rem 1fr; height: 100vh; }

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1rem 1rem; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-foreground);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.01em; line-height: 1.2; }
.brand-sub { font-size: 0.6875rem; color: var(--muted-foreground); }

.sidebar-section { padding: 0.5rem 1rem; }
.sidebar-label {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-foreground); padding: 0.75rem 0.25rem 0.5rem;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-lg);
  font-size: 0.875rem; font-weight: 500; color: oklch(0.3 0.01 300 / 0.85);
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  font-family: inherit; transition: background-color .15s, color .15s;
}
.nav-item:hover { background: var(--secondary); color: var(--foreground); }
.nav-item svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }
.nav-item .nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot { margin-top: auto; padding: 1rem; border-top: 1px solid var(--border); }
.foot-links { display: flex; flex-wrap: wrap; gap: 0.375rem; font-size: 11px; color: var(--muted-foreground); }
.foot-links a { color: inherit; text-decoration: none; }
.foot-links a:hover { color: var(--foreground); }
.foot-copy { margin: 0.25rem 0 0; font-size: 11px; color: var(--muted-foreground); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 2rem; border-bottom: 1px solid var(--border); background: var(--card);
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
.topbar p { margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--muted-foreground); }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Primitives -------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500;
  white-space: nowrap; width: fit-content;
}
.badge svg { width: 0.75rem; height: 0.75rem; }
.badge-primary { background: var(--primary); color: var(--primary-foreground); }
.badge-soft { background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary); }
.badge-secondary { background: var(--secondary); color: var(--foreground); }
.badge-outline { border-color: var(--border); color: var(--muted-foreground); background: var(--card); }
.badge-success { background: color-mix(in oklab, var(--success) 15%, transparent); color: color-mix(in oklab, var(--success) 80%, black); }
.badge-warning { background: color-mix(in oklab, var(--warning) 22%, transparent); color: oklch(0.45 0.12 70); }
.badge-danger  { background: color-mix(in oklab, var(--destructive) 14%, transparent); color: var(--destructive); }
.badge-info    { background: color-mix(in oklab, var(--info) 14%, transparent); color: var(--info); }
.badge-mono { font-family: var(--font-mono); font-size: 0.6875rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.25rem; padding: 0 0.875rem; border-radius: var(--radius-lg);
  font-family: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 1rem; height: 1rem; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 90%, black); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--secondary); color: var(--foreground); }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--secondary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { width: 2.25rem; padding: 0; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}

.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; flex-shrink: 0; }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger  { background: var(--destructive); }
.dot-muted   { background: var(--muted-foreground); }
.dot-live { box-shadow: 0 0 0 0 color-mix(in oklab, var(--success) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.muted { color: var(--muted-foreground); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.chat { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-inner { max-width: 60rem; margin: 0 auto; padding: 2rem 2rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; }

.msg { display: flex; gap: 0.875rem; }
.msg-avatar {
  width: 2rem; height: 2rem; border-radius: var(--radius-md); flex-shrink: 0;
  display: grid; place-items: center;
}
.msg-avatar svg { width: 1rem; height: 1rem; }
.msg-user .msg-avatar { background: var(--secondary); color: var(--muted-foreground); }
.msg-assistant .msg-avatar { background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary); }
.msg-body { flex: 1; min-width: 0; padding-top: 0.1875rem; }
.msg-role { font-size: 0.75rem; font-weight: 700; color: var(--muted-foreground); margin-bottom: 0.25rem; letter-spacing: 0.01em; }
.msg-text > *:first-child { margin-top: 0; }
.msg-text > *:last-child { margin-bottom: 0; }
.msg-text p { margin: 0 0 0.625rem; }
.msg-text ul, .msg-text ol { margin: 0 0 0.625rem; padding-left: 1.25rem; }
.msg-text li { margin-bottom: 0.1875rem; }
.msg-text code { font-family: var(--font-mono); font-size: 0.8125em; background: var(--secondary); padding: 0.0625rem 0.3125rem; border-radius: var(--radius-sm); }
.msg-text strong { font-weight: 700; }
.msg-user .msg-text { color: var(--foreground); font-weight: 500; }

/* Tool-Schritt */
.tool-step {
  display: flex; align-items: center; gap: 0.625rem;
  font-size: 0.8125rem; color: var(--muted-foreground);
  padding: 0.375rem 0.75rem; border: 1px solid var(--border);
  border-radius: 999px; background: var(--card); width: fit-content; max-width: 100%;
}
.tool-step svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.tool-step .ms { font-family: var(--font-mono); font-size: 0.6875rem; opacity: .7; }
.tool-step.is-error { border-color: color-mix(in oklab, var(--destructive) 35%, var(--border)); color: var(--destructive); }
.spinner {
  width: 0.875rem; height: 0.875rem; border-radius: 999px; flex-shrink: 0;
  border: 2px solid color-mix(in oklab, var(--primary) 25%, transparent);
  border-top-color: var(--primary); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing { display: inline-flex; gap: 0.25rem; align-items: center; height: 1.25rem; }
.typing span { width: 0.375rem; height: 0.375rem; border-radius: 999px; background: var(--muted-foreground); opacity: .4; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.35 } 30% { transform: translateY(-3px); opacity:.9 } }

/* ---------- Generative-UI-Bloecke -------------------------------------- */

.block { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); overflow: hidden; }
.block-head {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
}
.block-head .icon-tile {
  width: 1.75rem; height: 1.75rem; border-radius: var(--radius-sm);
  display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in oklab, var(--primary) 9%, transparent); color: var(--primary);
}
.block-head .icon-tile svg { width: 1rem; height: 1rem; }
.block-title { font-weight: 700; font-size: 0.875rem; letter-spacing: -0.01em; }
.block-meta { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.block-body { padding: 1rem; }
.block-body.flush { padding: 0; }

/* Tabelle */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.tbl th {
  text-align: left; font-weight: 700; font-size: 0.6875rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted-foreground);
  padding: 0.625rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 0.6875rem 1rem; border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in oklab, var(--secondary) 55%, transparent); }
.tbl .cell-strong { font-weight: 500; color: var(--foreground); }
.tbl .cell-sub { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 0.0625rem; }
.tbl-scroll { overflow-x: auto; }

/* Grid / Cards */
.grid { display: grid; gap: 0.75rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }

.mini-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.875rem; background: var(--card); }
.mini-card-head { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.mini-card-title { font-weight: 700; font-size: 0.875rem; line-height: 1.3; }
.mini-card-desc { font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.125rem; }

/* Policy-Regeln */
.rule { border-left: 3px solid var(--border); padding: 0.375rem 0 0.375rem 0.75rem; margin-bottom: 0.5rem; }
.rule:last-child { margin-bottom: 0; }
.rule-permission  { border-left-color: var(--success); }
.rule-prohibition { border-left-color: var(--destructive); }
.rule-obligation  { border-left-color: var(--warning); }
.rule-head { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.375rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: var(--font-mono); font-size: 0.6875rem;
  background: var(--secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.0625rem 0.375rem; color: var(--foreground);
}
.chip-op { color: var(--muted-foreground); }
.rule-empty { font-size: 0.8125rem; color: var(--muted-foreground); font-style: italic; }

/* Statusboard / Timeline */
.state-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1rem; border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.state-row:last-child { border-bottom: 0; }
.state-row .state-main { flex: 1; min-width: 0; }
.state-err { font-size: 0.75rem; color: var(--destructive); margin-top: 0.125rem; }

.flow { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.flow-step {
  font-size: 0.6875rem; font-weight: 500; padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm); background: var(--secondary); color: var(--muted-foreground);
  border: 1px solid transparent;
}
.flow-step.done { background: color-mix(in oklab, var(--success) 14%, transparent); color: color-mix(in oklab, var(--success) 80%, black); }
.flow-step.current { background: var(--primary); color: var(--primary-foreground); }
.flow-step.failed { background: color-mix(in oklab, var(--destructive) 13%, transparent); color: var(--destructive); }
.flow-sep { color: var(--border); font-size: 0.6875rem; }

/* Key/Value */
.kv { display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: 0.375rem 1rem; font-size: 0.8125rem; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; word-break: break-word; }

/* Raw JSON */
.raw { border-top: 1px solid var(--border); }
.raw summary {
  cursor: pointer; list-style: none; padding: 0.5rem 1rem;
  font-size: 0.75rem; color: var(--muted-foreground);
  display: flex; align-items: center; gap: 0.375rem; user-select: none;
}
.raw summary::-webkit-details-marker { display: none; }
.raw summary:hover { color: var(--foreground); }
.raw summary svg { width: 0.75rem; height: 0.75rem; transition: transform .15s; }
.raw[open] summary svg { transform: rotate(180deg); }
.raw pre {
  margin: 0; padding: 0.75rem 1rem; background: oklch(0.98 0.002 300);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.6875rem; line-height: 1.5;
  max-height: 22rem; overflow: auto; color: oklch(0.35 0.01 300);
}

/* Health */
.health-row { display: flex; align-items: center; gap: 0.625rem; font-size: 0.8125rem; padding: 0.375rem 0; }

/* ---------- Empty state ------------------------------------------------- */

.empty { max-width: 46rem; margin: 0 auto; padding: 3.5rem 2rem 2rem; text-align: center; }
.empty-mark {
  width: 3.5rem; height: 3.5rem; margin: 0 auto 1.25rem; border-radius: var(--radius-xl);
  background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary);
  display: grid; place-items: center;
}
.empty-mark svg { width: 1.75rem; height: 1.75rem; }
.empty h2 { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.empty p { margin: 0 auto 1.75rem; color: var(--muted-foreground); max-width: 34rem; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.625rem; text-align: left; }
.suggestion {
  display: flex; align-items: flex-start; gap: 0.625rem;
  padding: 0.75rem 0.875rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card); cursor: pointer; font-family: inherit; font-size: 0.8125rem;
  color: var(--foreground); text-align: left; transition: border-color .15s, box-shadow .15s, background .15s;
}
.suggestion:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-md); }
.suggestion svg { width: 1rem; height: 1rem; color: var(--primary); flex-shrink: 0; margin-top: 0.0625rem; }

/* ---------- Composer ---------------------------------------------------- */

.composer-wrap { border-top: 1px solid var(--border); background: var(--card); padding: 1rem 2rem 1.25rem; }
.composer { max-width: 60rem; margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 0.5rem 0.5rem 0.5rem 0.875rem; background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 18%, transparent); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  font-family: inherit; font-size: 0.9375rem; line-height: 1.5; color: var(--foreground);
  max-height: 9rem; padding: 0.375rem 0; min-height: 1.5rem;
}
.composer textarea::placeholder { color: var(--muted-foreground); }
.composer-hint { display: flex; align-items: center; gap: 0.375rem; justify-content: center; margin-top: 0.625rem; font-size: 0.6875rem; color: var(--muted-foreground); }
.composer-hint svg { width: 0.75rem; height: 0.75rem; }

.banner {
  display: flex; align-items: center; gap: 0.5rem; margin: 0 auto 0.75rem; max-width: 60rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-lg); font-size: 0.8125rem;
  background: color-mix(in oklab, var(--warning) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent); color: oklch(0.42 0.11 70);
}
.banner svg { width: 1rem; height: 1rem; flex-shrink: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chat-inner, .composer-wrap { padding-left: 1rem; padding-right: 1rem; }
  .topbar { padding: 0.875rem 1rem; }
}

/* ---------- Sidebar: connection cards ----------------------------------- */

.conn-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font-family: inherit; margin-bottom: 0.375rem;
  padding: 0.625rem 0.75rem; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--card);
  transition: border-color .15s, background .15s;
}
.conn-card:hover { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); background: color-mix(in oklab, var(--primary) 3%, var(--card)); }
.conn-row { display: flex; align-items: center; gap: 0.5rem; }
.conn-mode { font-size: 0.8125rem; font-weight: 700; color: var(--foreground); }
.conn-detail { font-size: 0.6875rem; color: var(--muted-foreground); margin-top: 0.125rem; font-family: var(--font-mono); }

.readonly-note {
  display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.75rem;
  font-size: 0.6875rem; line-height: 1.4; color: var(--muted-foreground);
}
.readonly-note svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; margin-top: 0.0625rem; color: var(--primary); }

/* ---------- Dialog ------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: oklch(0.22 0.01 300 / 0.45); padding: 1.5rem;
  animation: fade .15s ease-out;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.dialog {
  width: min(46rem, 100%); max-height: min(88vh, 52rem);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: 0 24px 48px -12px oklch(0.22 0.01 300 / 0.25);
  animation: rise .18s cubic-bezier(.16,1,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99) } to { opacity: 1; transform: none } }
.dialog-head { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem 1.5rem 1rem; }
.dialog-head h2 { margin: 0; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.015em; }
.dialog-head p { margin: 0.25rem 0 0; font-size: 0.8125rem; color: var(--muted-foreground); max-width: 34rem; }
.dialog-head .btn { margin-left: auto; flex-shrink: 0; }
.dialog-body { padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; }
.dialog-foot {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
}
.dialog-foot-actions { margin-left: auto; display: flex; gap: 0.5rem; }

.tabs { display: flex; gap: 0.25rem; padding: 0 1.5rem; border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: none; cursor: pointer; font-family: inherit;
  font-size: 0.875rem; font-weight: 500; color: var(--muted-foreground);
  padding: 0.625rem 0.75rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--foreground); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Form --------------------------------------------------------- */

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; font-size: 0.8125rem; font-weight: 700;
  margin-bottom: 0.375rem; color: var(--foreground);
}
.label-opt { font-weight: 400; color: var(--muted-foreground); font-size: 0.75rem; }
.field input[type=text], .field input[type=url], .field input[type=password], .field input[type=number], .field select {
  width: 100%; height: 2.25rem; padding: 0 0.625rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  font-family: inherit; font-size: 0.875rem; color: var(--foreground);
  background: var(--card); outline: 0; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 18%, transparent); }
.field input::placeholder { color: color-mix(in oklab, var(--muted-foreground) 75%, transparent); }
.hint { margin: 0.375rem 0 0; font-size: 0.75rem; color: var(--muted-foreground); line-height: 1.45; }
.hint code { font-family: var(--font-mono); font-size: 0.9em; background: var(--secondary); padding: 0 0.25rem; border-radius: var(--radius-sm); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.field-row .field-narrow { max-width: 9rem; }
.field-narrow { max-width: 12rem; }
.input-with-action { display: flex; gap: 0.5rem; }
.input-with-action input { flex: 1; }
.btn-sm { height: 1.875rem; padding: 0 0.625rem; font-size: 0.8125rem; }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.5rem; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-box {
  display: flex; flex-direction: column; gap: 0.25rem; height: 100%;
  padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.mode-option:hover .mode-box { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); }
.mode-option input:checked + .mode-box {
  border-color: var(--primary); background: color-mix(in oklab, var(--primary) 5%, transparent);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.mode-icon { color: var(--primary); }
.mode-icon svg { width: 1.125rem; height: 1.125rem; }
.mode-title { font-size: 0.8125rem; font-weight: 700; }
.mode-desc { font-size: 0.75rem; color: var(--muted-foreground); line-height: 1.4; }

.mode-fields { display: none; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.mode-fields.is-active { display: block; }

.callout {
  display: flex; gap: 0.625rem; padding: 0.875rem;
  border-radius: var(--radius-lg); font-size: 0.8125rem; line-height: 1.5;
  background: color-mix(in oklab, var(--primary) 6%, transparent);
  border: 1px solid color-mix(in oklab, var(--primary) 22%, transparent);
}
.callout svg { width: 1.125rem; height: 1.125rem; color: var(--primary); flex-shrink: 0; }

.partner-row { display: grid; grid-template-columns: 1fr 1fr 1.6fr auto; gap: 0.375rem; margin-bottom: 0.375rem; }
.partner-row input { height: 2rem !important; font-size: 0.8125rem !important; }

.test-row {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.test-result { font-size: 0.8125rem; display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.test-result svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.test-result.ok { color: color-mix(in oklab, var(--success) 80%, black); }
.test-result.fail { color: var(--destructive); }
.test-result.pending { color: var(--muted-foreground); }

.mode-grid { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.mode-box-top { display: flex; align-items: center; gap: 0.5rem; }
.mode-box-top .badge { margin-left: auto; }

.advanced { margin-top: 1rem; }
.advanced > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: inline-flex; align-items: center; gap: 0.375rem;
  font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground);
  padding: 0.25rem 0;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary:hover { color: var(--foreground); }
.advanced > summary svg { width: 0.75rem; height: 0.75rem; transition: transform .15s; }
.advanced[open] > summary svg { transform: rotate(180deg); }
.mode-option-inline { display: block; margin-top: 0.5rem; }
.mode-box-inline { flex-direction: row; align-items: flex-start; gap: 0.625rem; }
.mode-box-inline .mode-title, .mode-box-inline .mode-desc { display: block; }
.flow-step.current-done { background: var(--success); color: white; }
.state-row .flow { flex-shrink: 0; justify-content: flex-end; }

/* ---------- Participant identity (name + BPN on demand) ----------------- */

.party { display: inline-flex; align-items: center; gap: 0.25rem; max-width: 100%; }
.idchip {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 1.125rem; height: 1.125rem; padding: 0; border: 0; cursor: pointer;
  border-radius: var(--radius-sm); background: transparent; color: var(--muted-foreground);
  position: relative; font-family: inherit; transition: background .15s, color .15s;
}
.idchip svg { width: 0.75rem; height: 0.75rem; }
.idchip:hover { background: var(--secondary); color: var(--primary); }
.idchip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 0.375rem); left: 50%; transform: translateX(-50%);
  background: oklch(0.24 0.01 300); color: white; font-family: var(--font-mono);
  font-size: 0.6875rem; line-height: 1.4; white-space: nowrap;
  padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 20;
}
.idchip:hover::after, .idchip:focus-visible::after { opacity: 1; }
.idchip.copied { color: var(--success); }

.field-directory { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; margin-bottom: 0.375rem; }
.check input { width: 1rem; height: 1rem; accent-color: var(--primary); cursor: pointer; }
.party { align-items: flex-start; }
.party .mono { word-break: break-all; }
.party .idchip { margin-top: 0.0625rem; }

/* ---------- Markdown produced by marked (scoped to assistant prose) ------ */

.msg-text h1, .msg-text h2, .msg-text h3, .msg-text h4, .msg-text h5, .msg-text h6 {
  font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.01em;
  margin: 0.875rem 0 0.375rem;
}
.msg-text h1:first-child, .msg-text h2:first-child, .msg-text h3:first-child, .msg-text h4:first-child { margin-top: 0; }
.msg-text hr { border: 0; border-top: 1px solid var(--border); margin: 0.875rem 0; }
.msg-text blockquote {
  margin: 0 0 0.625rem; padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 3px solid var(--border); color: var(--muted-foreground);
}
.msg-text pre {
  margin: 0 0 0.625rem; padding: 0.75rem; overflow-x: auto;
  background: oklch(0.98 0.002 300); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.5;
}
.msg-text pre code { background: none; padding: 0; font-size: inherit; }
.msg-text del, .msg-text s { color: var(--muted-foreground); }
.msg-text a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.msg-text a:hover { text-decoration-thickness: 2px; }
.msg-text table {
  width: 100%; border-collapse: collapse; font-size: 0.8125rem;
  margin: 0 0 0.625rem; display: block; overflow-x: auto;
}
.msg-text thead { background: color-mix(in oklab, var(--secondary) 60%, transparent); }
.msg-text th, .msg-text td {
  text-align: left; padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border); vertical-align: top;
}
.msg-text th {
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; color: var(--muted-foreground); white-space: nowrap;
}
.msg-text li > input[type=checkbox] { margin-right: 0.375rem; accent-color: var(--primary); }
.msg-text li::marker { color: var(--muted-foreground); }

/* ---------- Sidebar: conversations -------------------------------------- */

.sidebar-chats { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.sidebar-label .btn-sm { width: 1.5rem; height: 1.5rem; }
.sidebar-label .btn-sm svg { width: 0.875rem; height: 0.875rem; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.chat-item {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.4375rem 0.5rem 0.4375rem 0.75rem; border-radius: var(--radius-lg);
  cursor: pointer; transition: background-color .15s;
}
.chat-item:hover { background: var(--secondary); }
.chat-item:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.chat-item.is-active { background: color-mix(in oklab, var(--primary) 8%, transparent); }
.chat-item.is-active .chat-item-title { color: var(--primary); font-weight: 700; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-title { font-size: 0.8125rem; font-weight: 500; line-height: 1.3; }
.chat-item-meta { font-size: 0.6875rem; color: var(--muted-foreground); }
.chat-item-del {
  flex-shrink: 0; width: 1.25rem; height: 1.25rem; padding: 0; border: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted-foreground); opacity: 0; transition: opacity .12s, color .12s;
}
.chat-item-del svg { width: 0.75rem; height: 0.75rem; }
.chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:hover { color: var(--destructive); background: var(--card); }

/* ---------- Floating demo notice ---------------------------------------- */

.demo-notice {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 40;
  display: flex; align-items: flex-start; gap: 0.75rem;
  max-width: 24rem; padding: 1rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: 0 12px 28px -8px oklch(0.22 0.01 300 / 0.18);
  animation: rise .2s cubic-bezier(.16,1,.3,1);
}
.demo-notice[hidden] { display: none; }
.demo-notice:hover { box-shadow: 0 16px 36px -8px oklch(0.22 0.01 300 / 0.22); }
.demo-notice-icon {
  width: 2rem; height: 2rem; border-radius: var(--radius-md); flex-shrink: 0;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary);
}
.demo-notice-icon svg { width: 1rem; height: 1rem; }
.demo-notice-body { flex: 1; min-width: 0; }
.demo-notice-title { margin: 0 0 0.125rem; font-size: 0.875rem; font-weight: 700; }
.demo-notice-text { margin: 0; font-size: 0.75rem; line-height: 1.5; color: var(--muted-foreground); }
.demo-notice-text a { color: var(--primary); font-weight: 500; text-decoration: none; }
.demo-notice-text a:hover { text-decoration: underline; }
.demo-notice-close {
  flex-shrink: 0; margin: -0.25rem -0.25rem 0 0; padding: 0.25rem;
  border: 0; background: none; cursor: pointer; color: var(--muted-foreground);
  display: grid; place-items: center; border-radius: var(--radius-sm);
}
.demo-notice-close svg { width: 1rem; height: 1rem; }
.demo-notice-close:hover { color: var(--foreground); background: var(--secondary); }

@media (max-width: 640px) {
  .demo-notice { left: 1rem; right: 1rem; max-width: none; }
}

/* ---------- Bounded panels: caps, folding, stats, filtering -------------- */

/* The one rule that bounds every component at once. */
.block[data-cap] .is-extra { display: none; }
.is-filtered-out { display: none !important; }

.block-head { position: relative; }
.block-fold {
  flex-shrink: 0; width: 1.5rem; height: 1.5rem; margin-left: 0.25rem; padding: 0;
  border: 0; background: none; cursor: pointer; color: var(--muted-foreground);
  display: grid; place-items: center; border-radius: var(--radius-sm);
  transition: transform .15s, color .15s, background .15s;
}
.block-fold svg { width: 0.875rem; height: 0.875rem; }
.block-fold:hover { color: var(--foreground); background: var(--secondary); }
.block.is-folded .block-fold { transform: rotate(-90deg); }
.block.is-folded .block-body,
.block.is-folded .block-note,
.block.is-folded .block-more,
.block.is-folded .filter-bar,
.block.is-folded .raw { display: none; }
.block.is-focus .block-fold { display: none; }

.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1px; background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  display: flex; flex-direction: column; gap: 0.0625rem;
  padding: 0.75rem 1rem; background: var(--card);
  border: 0; text-align: left; font-family: inherit;
}
button.stat { cursor: pointer; transition: background .15s; }
button.stat:hover { background: color-mix(in oklab, var(--primary) 5%, var(--card)); }
.stat-label {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-foreground);
}
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-sub { font-size: 0.6875rem; color: var(--muted-foreground); }
.stat.tone-success .stat-value { color: color-mix(in oklab, var(--success) 80%, black); }
.stat.tone-danger  .stat-value { color: var(--destructive); }
.stat.tone-warning .stat-value { color: oklch(0.5 0.13 70); }
.stat.tone-primary .stat-value { color: var(--primary); }

.block-note {
  margin: 0; padding: 0.5rem 1rem 0; font-size: 0.75rem; color: var(--muted-foreground);
}

.filter-bar {
  display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap;
  padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
}
.filter-icon { display: grid; place-items: center; color: var(--muted-foreground); }
.filter-icon svg { width: 0.875rem; height: 0.875rem; }
.filter-input {
  flex: 1; min-width: 7rem; height: 1.75rem; padding: 0 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.8125rem; background: var(--card); color: var(--foreground); outline: 0;
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 15%, transparent); }
.filter-input::-webkit-search-cancel-button { cursor: pointer; }
.facet {
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-family: inherit; font-size: 0.6875rem; font-weight: 500;
  padding: 0.1875rem 0.5rem; border-radius: 999px; color: var(--muted-foreground);
  transition: background .15s, color .15s, border-color .15s;
}
.facet:hover { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); color: var(--foreground); }
.facet.is-on { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.filter-count { font-size: 0.6875rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.tbl .no-match td { color: var(--muted-foreground); font-style: italic; }

.block-more { padding: 0.5rem 1rem; border-top: 1px solid var(--border); }
.block-more[hidden] { display: none; }
.block-more button {
  border: 0; background: none; cursor: pointer; font-family: inherit;
  font-size: 0.75rem; font-weight: 500; color: var(--primary); padding: 0.125rem 0;
}
.block-more button:hover { text-decoration: underline; }

.block-actions {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  padding: 0.625rem 1rem; border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--secondary) 40%, transparent);
}
.chip-action {
  display: inline-flex; align-items: center; gap: 0.375rem;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-family: inherit; font-size: 0.75rem; font-weight: 500; color: var(--foreground);
  padding: 0.3125rem 0.625rem; border-radius: var(--radius-lg);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.chip-action svg { width: 0.8125rem; height: 0.8125rem; color: var(--primary); }
.chip-action:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-sm); }
.chip-action.is-primary { background: color-mix(in oklab, var(--primary) 8%, var(--card)); border-color: color-mix(in oklab, var(--primary) 30%, var(--border)); }
body.is-busy .chip-action, body.is-busy button.stat { pointer-events: none; opacity: .5; }

.rows > .state-row:first-child { border-top: 0; }

/* Answer above work, regardless of the order events arrive in. */
.msg-answer:empty { display: none; }
.msg-answer > *:last-child { margin-bottom: 0; }
.msg-work:empty { display: none; }
.msg-work { display: flex; flex-direction: column; gap: 0.625rem; }
.msg-answer + .msg-work { margin-top: 0.75rem; }

.md-cut { color: var(--muted-foreground); font-size: 0.75rem; font-style: italic; }
p.md-h { font-weight: 700; margin: 0.5rem 0 0.25rem; }

.dialog-foot .foot-left { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.check-sm { font-size: 0.75rem; font-weight: 400; color: var(--muted-foreground); margin: 0 0 0 0.25rem; }
.check-sm input { width: 0.875rem; height: 0.875rem; }
.group-row { display: flex; align-items: flex-start; gap: 0.75rem; }
.group-count {
  flex-shrink: 0; min-width: 2rem; text-align: center;
  font-size: 1.125rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--primary); line-height: 1.4;
}
.group-count.tone-danger { color: var(--destructive); }
.group-count.tone-warning { color: oklch(0.5 0.13 70); }
.group-title { font-size: 0.875rem; font-weight: 500; line-height: 1.35; }
.group-detail { margin: 0.5rem 0 0 2.75rem; }
.offer-cell + .offer-cell { margin-top: 0.375rem; padding-top: 0.375rem; border-top: 1px solid var(--border); }

/* ---------- Human-in-the-loop confirmation card ------------------------- */

.block-confirm { border-color: color-mix(in oklab, var(--primary) 35%, var(--border)); }
.block-confirm .block-head { background: color-mix(in oklab, var(--primary) 5%, transparent); }
.block-confirm.is-destructive { border-color: color-mix(in oklab, var(--destructive) 40%, var(--border)); }
.block-confirm.is-destructive .block-head { background: color-mix(in oklab, var(--destructive) 6%, transparent); }
.block-confirm.is-destructive .icon-tile { background: color-mix(in oklab, var(--destructive) 12%, transparent); color: var(--destructive); }
.block-confirm.is-done { border-color: color-mix(in oklab, var(--success) 40%, var(--border)); opacity: .92; }
.block-confirm.is-cancelled { opacity: .6; }
.block-confirm.is-cancelled .wf-input { pointer-events: none; }

.confirm-summary { margin: 0 0 0.5rem; font-size: 0.875rem; }
.confirm-impact {
  display: flex; align-items: flex-start; gap: 0.5rem; margin: 0 0 0.75rem;
  padding: 0.5rem 0.625rem; border-radius: var(--radius-lg); font-size: 0.75rem; line-height: 1.5;
  background: color-mix(in oklab, var(--warning) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--warning) 30%, transparent); color: oklch(0.42 0.11 70);
}
.confirm-impact svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; margin-top: 0.125rem; }
.confirm-endpoint { margin-left: auto; font-size: 0.6875rem; color: var(--muted-foreground); }

.wf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.625rem; }
.wf { display: flex; flex-direction: column; gap: 0.25rem; }
.wf-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-foreground); }
.wf-input {
  height: 2rem; padding: 0 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.8125rem; background: var(--card); color: var(--foreground); outline: 0;
}
.wf-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 15%, transparent); }

.confirm-status { display: flex; align-items: center; gap: 0.375rem; margin-top: 0.75rem; font-size: 0.8125rem; }
.confirm-status svg { width: 0.875rem; height: 0.875rem; }
.confirm-status.is-ok { color: color-mix(in oklab, var(--success) 80%, black); }
.confirm-status.is-error { color: var(--destructive); }

/* ---------- Policy constraint editor ------------------------------------ */

.cx-editor { margin-top: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--border); }
.cx-head { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.cx-hint { font-size: 0.6875rem; color: var(--muted-foreground); }
.cx-row {
  display: grid; grid-template-columns: minmax(9rem, 1.2fr) auto minmax(6rem, 0.6fr) minmax(9rem, 1.4fr) auto;
  gap: 0.375rem; align-items: center; margin-bottom: 0.375rem;
}
.cx-row .cx-custom[hidden] { display: none; }
.cx-row .wf-input { height: 1.875rem; font-size: 0.75rem; }
.cx-key, .cx-op { font-family: var(--font-mono); }
.cx-val { font-family: var(--font-mono); }
.cx-del {
  width: 1.5rem; height: 1.5rem; padding: 0; border: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted-foreground);
}
.cx-del svg { width: 0.8125rem; height: 0.8125rem; }
.cx-del:hover { color: var(--destructive); background: color-mix(in oklab, var(--destructive) 8%, transparent); }
.cx-add { margin-top: 0.25rem; }
.cx-summary { margin: 0.625rem 0 0; font-size: 0.8125rem; color: var(--muted-foreground); }
.cx-summary.is-warning {
  color: var(--destructive); font-weight: 500;
  padding: 0.375rem 0.5rem; border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--destructive) 8%, transparent);
}

@media (max-width: 720px) {
  .cx-row { grid-template-columns: 1fr auto; }
}

/* ---------- Home screen dashboard --------------------------------------- */

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0.75rem; margin-bottom: 2rem; text-align: left; }
.hc { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow-sm); padding: 0.875rem 1rem 1rem; }
.hc-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.hc-icon { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: var(--radius-sm); background: color-mix(in oklab, var(--primary) 9%, transparent); color: var(--primary); flex-shrink: 0; }
.hc-icon svg { width: 1rem; height: 1rem; }
.hc-title { font-size: 0.875rem; font-weight: 700; letter-spacing: -0.01em; }
.hc-head .badge { margin-left: auto; }
.hc-refresh { width: 1.5rem; height: 1.5rem; padding: 0; border: 0; background: none; cursor: pointer; color: var(--muted-foreground); display: grid; place-items: center; border-radius: var(--radius-sm); }
.hc-refresh svg { width: 0.875rem; height: 0.875rem; }
.hc-refresh:hover { color: var(--foreground); background: var(--secondary); }
.hc-refresh.is-spinning svg { animation: spin .7s linear infinite; }
.hc-meta { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; font-size: 0.6875rem; color: var(--muted-foreground); margin-bottom: 0.75rem; min-width: 0; }
.hc-meta .mono { font-size: 0.6875rem; max-width: 100%; }
.hc-host { font-family: var(--font-mono); }
.hc-empty { margin: 0; font-size: 0.8125rem; color: var(--muted-foreground); display: flex; align-items: center; gap: 0.5rem; }
.hc-empty.is-bad { color: var(--destructive); }
.hc-empty + .chip-action { margin-top: 0.75rem; }
.hc-foot { margin: 0.75rem 0 0; font-size: 0.6875rem; color: var(--muted-foreground); display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.hc-model {
  height: 1.625rem; padding: 0 0.375rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.6875rem; background: var(--card); color: var(--foreground); cursor: pointer; max-width: 14rem;
}
.hc-model:focus { outline: 0; border-color: var(--primary); }

.hs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: 0.375rem; }
.hs { display: flex; flex-direction: column; gap: 0.0625rem; padding: 0.5rem 0.625rem; border-radius: var(--radius-lg); background: color-mix(in oklab, var(--secondary) 55%, transparent); border: 1px solid transparent; text-align: left; font-family: inherit; }
button.hs { cursor: pointer; transition: border-color .15s, background .15s; }
button.hs:hover { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); background: color-mix(in oklab, var(--primary) 6%, transparent); }
.hs-value { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hs-value.is-bad { color: var(--destructive); }
.hs-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-foreground); }

.sp { display: inline-flex; align-items: flex-end; gap: 1px; height: 14px; }
.sp-bar { width: 3px; border-radius: 1px; background: color-mix(in oklab, var(--primary) 55%, transparent); }

.msg-usage { margin-top: 0.375rem; font-size: 0.6875rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* ---------- Sovereign AI ------------------------------------------------- */

.badge-sovereign {
  background: color-mix(in oklab, var(--success) 12%, transparent);
  color: color-mix(in oklab, var(--success) 78%, black);
  border-color: color-mix(in oklab, var(--success) 28%, transparent);
  font-size: 0.6875rem; cursor: help;
}
.msg-role { display: flex; align-items: center; gap: 0.5rem; }
.msg-role .badge { font-weight: 500; text-transform: none; letter-spacing: 0; }
.hc-head .badge-sovereign { margin-left: auto; }
.hc-head .badge-sovereign + .badge { margin-left: 0; }

.callout-sovereign { margin-bottom: 1.25rem; }
.callout-sovereign a { color: var(--primary); font-weight: 500; }
.callout-sovereign code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: color-mix(in oklab, var(--primary) 8%, transparent);
  padding: 0.0625rem 0.25rem; border-radius: var(--radius-sm);
}

/* ---------- Home strip (compact) ---------------------------------------- */

.home {
  text-align: left; margin: 0 auto 2rem; max-width: 46rem;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--card); box-shadow: var(--shadow-sm); overflow: hidden;
}
.home-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.625rem 0.875rem; }
.home-row + .home-row { border-top: 1px solid var(--border); }
.hr-icon { display: grid; place-items: center; width: 1.375rem; height: 1.375rem; border-radius: var(--radius-sm); background: color-mix(in oklab, var(--primary) 9%, transparent); color: var(--primary); flex-shrink: 0; }
.hr-icon svg { width: 0.8125rem; height: 0.8125rem; }
.hr-name { font-size: 0.8125rem; font-weight: 700; letter-spacing: -0.01em; }
.hr-muted { font-size: 0.6875rem; color: var(--muted-foreground); display: inline-flex; align-items: center; gap: 0.375rem; min-width: 0; max-width: 20rem; }
.hr-muted.is-bad { color: var(--destructive); max-width: none; }
.hr-tag { font-family: var(--font-mono); font-size: 0.625rem; color: var(--muted-foreground); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 0.25rem; }
.hr-refresh { width: 1.25rem; height: 1.25rem; padding: 0; border: 0; background: none; cursor: pointer; color: var(--muted-foreground); display: grid; place-items: center; border-radius: var(--radius-sm); }
.hr-refresh svg { width: 0.75rem; height: 0.75rem; }
.hr-refresh:hover { color: var(--foreground); background: var(--secondary); }
.hr-refresh.is-spinning svg { animation: spin .7s linear infinite; }
.hr-link { border: 0; background: none; cursor: pointer; font-family: inherit; font-size: 0.75rem; font-weight: 500; color: var(--primary); padding: 0; }
.hr-link:hover { text-decoration: underline; }

.ht-row { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; width: 100%; margin-top: 0.375rem; }
.ht {
  display: inline-flex; align-items: baseline; gap: 0.3125rem;
  padding: 0.1875rem 0.5rem; border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--secondary) 60%, transparent);
  border: 1px solid transparent; font-family: inherit;
}
button.ht { cursor: pointer; transition: border-color .15s, background .15s; }
button.ht:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); background: color-mix(in oklab, var(--primary) 7%, transparent); }
.ht-value { font-size: 0.875rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ht-value.is-bad { color: var(--destructive); }
.ht-label { font-size: 0.625rem; font-weight: 500; color: var(--muted-foreground); text-transform: lowercase; }
.sp { display: inline-flex; align-items: flex-end; gap: 1px; height: 12px; margin-left: 0.25rem; }
.sp-bar { width: 3px; border-radius: 1px; background: color-mix(in oklab, var(--primary) 55%, transparent); }

/* Model selector inside the composer */
.composer-model {
  flex-shrink: 0; height: 1.875rem; max-width: 10rem; padding: 0 0.375rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 0.6875rem;
  background: var(--card); color: var(--muted-foreground); cursor: pointer; align-self: flex-end; margin-bottom: 0.125rem;
}
.composer-model:hover { color: var(--foreground); }
.composer-model:focus { outline: 0; border-color: var(--primary); }
.composer-model[hidden] { display: none; }

/* ---------- Policies panel ---------------------------------------------- */

.pol-count { font-size: 1.125rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.pol-count.is-bad { color: var(--destructive); }
.tbl td:has(.pol-count) { text-align: right; width: 3rem; }
.pol-ids > summary {
  cursor: pointer; list-style: none; font-size: 0.75rem; color: var(--muted-foreground);
  padding: 0.125rem 0; user-select: none; white-space: nowrap;
}
.pol-ids > summary::-webkit-details-marker { display: none; }
.pol-ids > summary::before { content: '▸ '; }
.pol-ids[open] > summary::before { content: '▾ '; }
.pol-ids > summary:hover { color: var(--foreground); }
.pol-ids .chips { margin-top: 0.25rem; max-width: 16rem; }
.chip-prohibition { border-color: color-mix(in oklab, var(--destructive) 35%, var(--border)); color: var(--destructive); }
.chip-obligation { border-color: color-mix(in oklab, var(--warning) 45%, var(--border)); color: oklch(0.45 0.12 70); }
.cell-strong.is-bad { color: var(--destructive); }

/* Identifiers and dates must not break character-by-character in a table cell.
   The break-all rule exists for long URLs in key/value lists, not for columns. */
.tbl td .party .mono,
.tbl td .mono.cell-sub { word-break: normal; white-space: nowrap; }
.tbl td .party { flex-wrap: nowrap; }
.tbl th:first-child, .tbl td:first-child { white-space: nowrap; }
.tbl th:last-child, .tbl td:last-child { white-space: nowrap; }
.tbl td .chips { min-width: 11rem; }
