:root {
  color-scheme: light;
  --ink: #111827;
  --ink-soft: #475569;
  --ink-muted: #64748b;
  --primary: #0d3b4e;
  --primary-strong: #082f3f;
  --accent: #22a69a;
  --accent-soft: #eefaf8;
  --surface: #f2f6fa;
  --surface-strong: #e7edf3;
  --white: #ffffff;
  --border: #d8e1e9;
  --border-strong: #a8b5c2;
  --success: #16814a;
  --success-soft: #edf8f1;
  --warning: #b26a00;
  --warning-soft: #fff5df;
  --danger: #c63f42;
  --danger-soft: #fff0f0;
  --focus: #2684a5;
  --shadow-sm: 0 1px 2px rgb(17 24 39 / 0.07);
  --shadow-lg: 0 24px 64px rgb(17 24 39 / 0.16);
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --sidebar: 15rem;
  --header-mobile: 4rem;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  font-kerning: normal;
}

@supports (color: oklch(0.5 0.1 220)) {
  :root {
    --ink: oklch(0.205 0.025 253);
    --ink-soft: oklch(0.405 0.03 247);
    --ink-muted: oklch(0.54 0.025 247);
    --primary: oklch(0.35 0.075 220);
    --primary-strong: oklch(0.29 0.068 220);
    --accent: oklch(0.65 0.11 184);
    --accent-soft: oklch(0.96 0.025 188);
    --surface: oklch(0.975 0.009 245);
    --surface-strong: oklch(0.945 0.014 245);
    --white: oklch(1 0 0);
    --border: oklch(0.88 0.018 245);
    --border-strong: oklch(0.76 0.025 245);
    --success: oklch(0.51 0.14 151);
    --success-soft: oklch(0.96 0.035 151);
    --warning: oklch(0.62 0.15 70);
    --warning-soft: oklch(0.97 0.04 82);
    --danger: oklch(0.53 0.2 27);
    --danger-soft: oklch(0.97 0.025 27);
    --focus: oklch(0.62 0.15 220);
    --shadow-sm: 0 1px 2px oklch(0.2 0.02 250 / 0.07);
    --shadow-lg: 0 24px 64px oklch(0.2 0.025 245 / 0.16);
  }
}

* { box-sizing: border-box; }

html { min-width: 20rem; background: var(--white); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--white);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
a { color: inherit; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -0.015em; }
h3 { font-size: 1rem; line-height: 1.3; }
small { font-size: 0.8125rem; }
code { font-size: 0.8125rem; }

:focus { outline: none; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; }
::selection { color: var(--ink); background: #b6e4df; background: oklch(0.86 0.08 187); }

.skip-link {
  position: fixed;
  z-index: 100;
  top: var(--space-md);
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--white);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.app-shell[data-authenticated="false"] { visibility: hidden; }
.sidebar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--space-md);
  color: #f4f8fa;
  color: oklch(0.97 0.01 220);
  background: var(--primary-strong);
}
.brand { display: flex; align-items: center; gap: var(--space-sm); color: inherit; text-decoration: none; min-height: 2.75rem; }
.brand-mark { position: relative; width: 1.75rem; height: 2rem; flex: 0 0 auto; border-left: 0.25rem solid var(--accent); }
.brand-mark::before { content: ""; position: absolute; top: 0; left: -0.25rem; width: 0.25rem; height: 54%; background: var(--white); }
.brand-mark span { position: absolute; top: 0; left: 0.35rem; width: 0.0625rem; height: 100%; background: rgb(255 255 255 / 0.35); background: oklch(1 0 0 / 0.35); }
.brand-mark.large { width: 2.25rem; height: 2.75rem; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 0.9375rem; line-height: 1.2; }
.brand-copy small { color: #b9ced7; color: oklch(0.8 0.025 220); }

.primary-nav { display: grid; gap: var(--space-xs); margin-top: var(--space-2xl); }
.primary-nav a, .nav-button {
  position: relative;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-sm);
  border: 0;
  border-radius: var(--radius-sm);
  color: #c7d7de;
  color: oklch(0.84 0.02 220);
  background: transparent;
  text-decoration: none;
  font-size: 0.9375rem;
  text-align: left;
}
.primary-nav a::before { content: ""; position: absolute; inset-block: 0.5rem; left: -1rem; width: 0.1875rem; background: transparent; border-radius: 0 1rem 1rem 0; }
.primary-nav a:hover, .nav-button:hover { color: var(--white); background: rgb(255 255 255 / 0.07); background: oklch(1 0 0 / 0.07); }
.primary-nav a[aria-current="page"] { color: var(--white); background: rgb(255 255 255 / 0.11); background: oklch(1 0 0 / 0.11); }
.primary-nav a[aria-current="page"]::before { background: var(--accent); }
.nav-count { margin-left: auto; min-width: 1.375rem; padding: 0.0625rem 0.375rem; text-align: center; border-radius: 2rem; color: var(--primary-strong); background: var(--accent); font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sidebar-footer { display: grid; gap: var(--space-md); margin-top: auto; }
.nav-button { width: 100%; }
.environment { display: flex; align-items: center; gap: var(--space-xs); padding-inline: var(--space-sm); color: #9ab3bd; color: oklch(0.72 0.025 220); font-size: 0.75rem; }
.environment span:first-child { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0.1875rem rgb(34 166 154 / 0.15); box-shadow: 0 0 0 0.1875rem oklch(0.65 0.11 184 / 0.15); }

.mobile-header, .mobile-nav { display: none; }
.main-content { min-width: 0; min-height: 100vh; background: var(--white); }
#page { min-height: 100vh; }

.page-shell { min-height: 100vh; display: flex; flex-direction: column; }
.page-header { min-height: 6.5rem; padding: var(--space-lg) var(--space-xl); display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-lg); border-bottom: 1px solid var(--border); }
.page-heading { display: grid; gap: var(--space-xs); }
.page-heading p { color: var(--ink-soft); max-width: 65ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); justify-content: flex-end; }
.eyebrow { color: var(--ink-muted); font-size: 0.75rem; line-height: 1.3; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.625rem var(--space-md);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--white);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.button:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--primary); color: var(--white); background: var(--primary); }
.button.primary:hover { border-color: var(--primary-strong); color: var(--white); background: var(--primary-strong); }
.button.danger { border-color: #dc8a8d; border-color: oklch(0.75 0.1 27); color: var(--danger); background: var(--white); }
.button.danger:hover { background: var(--danger-soft); }
.button.quiet { border-color: transparent; box-shadow: none; background: transparent; }
.button.full-width { width: 100%; }
.button.small { min-height: 2.25rem; padding: 0.375rem 0.75rem; }
.icon-button { width: 2.75rem; height: 2.75rem; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; }
.icon-button:hover { color: var(--primary); background: var(--surface-strong); }

.toolbar { min-height: 4.5rem; padding: var(--space-sm) var(--space-xl); display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); border-bottom: 1px solid var(--border); }
.bulk-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); margin-left: auto; }
.bulk-count { color: var(--ink-soft); font-size: 0.8125rem; font-weight: 650; white-space: nowrap; }
.search-field { position: relative; min-width: min(22rem, 100%); flex: 1; }
.search-field svg { position: absolute; top: 50%; left: var(--space-sm); transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.search-field input { padding-left: 2.5rem; }
.filter-label { display: flex; align-items: center; gap: var(--space-xs); color: var(--ink-soft); font-size: 0.875rem; }
.filter-label select { min-width: 9rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 0.6875rem 0.75rem;
  min-height: 2.75rem;
}
input[type="checkbox"] { width: 1.125rem; min-width: 1.125rem; height: 1.125rem; min-height: 1.125rem; padding: 0; accent-color: var(--accent); }
textarea { min-height: 8rem; resize: vertical; line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 0.1875rem rgb(38 132 165 / 0.16); box-shadow: 0 0 0 0.1875rem oklch(0.62 0.15 220 / 0.16); }
label { font-size: 0.875rem; font-weight: 650; }
.field { display: grid; gap: var(--space-xs); }
.field-help { color: var(--ink-muted); font-size: 0.8125rem; }
.form-error { color: var(--danger); font-size: 0.875rem; }

.content { padding: var(--space-xl); }
.empty-state { min-height: 20rem; display: grid; place-items: center; text-align: center; padding: var(--space-2xl); }
.empty-state > div { display: grid; justify-items: center; gap: var(--space-sm); max-width: 32rem; }
.empty-state svg { width: 2rem; height: 2rem; color: var(--primary); }
.empty-state p { color: var(--ink-soft); }
.empty-state .button { margin-top: var(--space-sm); }

.loading-list { padding: var(--space-md) var(--space-xl); }
.skeleton-row { height: 4rem; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, transparent, #edf2f7, transparent); background: linear-gradient(90deg, transparent, oklch(0.96 0.01 245), transparent); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { padding: 0.75rem var(--space-md); color: var(--ink-soft); background: var(--surface); text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.025em; white-space: nowrap; }
.data-table td { padding: 0.875rem var(--space-md); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { position: relative; }
.data-table tbody tr:hover { background: var(--surface); }
.data-table tbody tr.selected { background: var(--accent-soft); box-shadow: inset 0.1875rem 0 var(--accent); }
.data-table .primary-cell { min-width: 15rem; font-weight: 650; }
.data-table .wrap-cell { min-width: 18rem; max-width: 30rem; }
.data-table .actions-cell { text-align: right; white-space: nowrap; }
.numeric { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }

.status { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--ink-soft); font-size: 0.8125rem; font-weight: 650; white-space: nowrap; }
.status::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ink-muted); }
.status.pending::before, .status.processing::before, .status.queued::before, .status.draft::before { background: var(--warning); }
.status.completed::before, .status.approved::before, .status.published::before { background: var(--success); }
.status.failed::before, .status.rejected::before, .status.error::before { background: var(--danger); }
.status.private::before { background: var(--primary); }
.badge { display: inline-flex; align-items: center; min-height: 1.75rem; padding: 0.1875rem 0.5rem; border-radius: 2rem; color: var(--primary); background: var(--surface-strong); font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.badge.warning { color: #7c4800; color: oklch(0.44 0.12 64); background: var(--warning-soft); }
.badge.success { color: #146b3d; color: oklch(0.38 0.11 151); background: var(--success-soft); }
.badge.private { color: var(--primary); background: var(--accent-soft); }

.split-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(26rem, 0.9fr) minmax(34rem, 1.1fr); }
.master-pane { min-width: 0; border-right: 1px solid var(--border); }
.detail-pane { min-width: 0; background: var(--surface); }
.detail-header { min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border); background: var(--white); }
.detail-body { position: relative; display: grid; gap: var(--space-xl); padding: var(--space-xl) var(--space-xl) 6.5rem; }
.detail-body::before { content: ""; position: absolute; top: var(--space-xl); bottom: 6rem; left: 1rem; width: 0.125rem; background: var(--accent); }
.detail-section { display: grid; gap: var(--space-sm); padding-left: var(--space-md); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); }
.detail-footer { position: sticky; bottom: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); padding: var(--space-md) var(--space-xl); border-top: 1px solid var(--border); background: rgb(255 255 255 / 0.96); background: oklch(1 0 0 / 0.96); backdrop-filter: blur(0.5rem); }
.detail-footer .actions { display: flex; gap: var(--space-sm); }
.evidence-list { display: grid; gap: var(--space-sm); }
.evidence-item { padding: var(--space-md); border-left: 0.1875rem solid var(--accent); background: var(--white); box-shadow: var(--shadow-sm); }
.evidence-item header { display: flex; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-xs); color: var(--ink-soft); font-size: 0.75rem; }
.evidence-item p { white-space: pre-wrap; overflow-wrap: anywhere; }
.confidence { display: inline-flex; gap: 0.25rem; }
.confidence i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--border-strong); }
.confidence i.filled { background: var(--success); }

.tabs { display: flex; align-items: center; gap: var(--space-lg); min-height: 3rem; padding: 0 var(--space-xl); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { position: relative; min-height: 3rem; padding: 0; border: 0; color: var(--ink-soft); background: transparent; font-size: 0.875rem; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); font-weight: 700; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 0.1875rem; background: var(--accent); }

.inspector-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 24rem; }
.inspector { min-width: 0; overflow: hidden; border-left: 1px solid var(--border); background: var(--surface); }
.inspector-inner { position: sticky; top: 0; display: grid; gap: var(--space-lg); padding: var(--space-lg); }
.inspector-title { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); }
.inspector-title > div { min-width: 0; }
.inspector-title h2 { overflow-wrap: anywhere; }
.metadata-list { display: grid; gap: var(--space-sm); }
.metadata-row { display: flex; justify-content: space-between; gap: var(--space-md); padding-bottom: var(--space-sm); border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.metadata-row dt { flex: 0 0 auto; color: var(--ink-muted); }
.metadata-row dd { min-width: 0; margin: 0; text-align: right; overflow-wrap: anywhere; }
.message-list { max-height: 22rem; overflow-y: auto; display: grid; gap: var(--space-sm); padding-right: var(--space-xs); }
.message { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--space-sm); }
.avatar { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--surface-strong); font-size: 0.6875rem; font-weight: 700; }
.message-content { padding: var(--space-sm); border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md); background: var(--white); font-size: 0.875rem; overflow-wrap: anywhere; }
.message.assistant .message-content { border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md); background: var(--accent-soft); }
.message-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2xs) var(--space-sm); margin-bottom: var(--space-2xs); color: var(--ink-muted); font-size: 0.6875rem; }
.privacy-note { display: flex; gap: var(--space-sm); padding: var(--space-sm); color: var(--primary); background: var(--accent-soft); font-size: 0.8125rem; }

.chat-archive { display: grid; grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr); min-height: calc(100vh - 10rem); }
.chat-list-pane { min-width: 0; border-right: 1px solid var(--border); background: var(--white); }
.chat-file-rows { display: grid; }
.chat-file-row { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-sm); align-items: center; padding: var(--space-md); border: 0; border-bottom: 1px solid var(--border); color: var(--ink); background: var(--white); text-align: left; }
.chat-file-row:hover { background: var(--surface); }
.chat-file-row.selected { background: var(--accent-soft); box-shadow: inset 0.1875rem 0 0 var(--accent); }
.chat-file-icon { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--primary); background: var(--surface-strong); border-radius: var(--radius-sm); }
.chat-file-icon svg { width: 1rem; height: 1rem; }
.chat-file-copy { min-width: 0; display: grid; gap: 0.1875rem; }
.chat-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; }
.chat-file-copy small { color: var(--ink-muted); font-size: 0.6875rem; }
.chat-viewer { min-width: 0; display: grid; align-content: start; gap: var(--space-md); padding: var(--space-lg) var(--space-xl); background: var(--surface); overflow: hidden; }
.chat-viewer-header { display: flex; justify-content: space-between; gap: var(--space-md); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); background: var(--white); }
.chat-viewer-header h2 { overflow-wrap: anywhere; }
.chat-viewer-header .chat-back { display: none; }
.chat-viewer-actions { display: flex; align-items: flex-start; gap: var(--space-sm); }
.danger-text { color: var(--danger); }
.chat-viewer-toolbar { display: flex; align-items: center; gap: var(--space-md); }
.chat-viewer-toolbar .search-field { flex: 1; }
.archive-notice { display: flex; gap: var(--space-sm); padding: var(--space-sm); color: var(--primary); background: var(--accent-soft); font-size: 0.8125rem; }
.archive-messages { display: grid; gap: var(--space-sm); max-height: calc(100vh - 21rem); overflow-y: auto; padding-right: var(--space-xs); }
.archive-messages .message-content { max-width: 65ch; }
.archive-end { margin: 0; color: var(--ink-muted); font-size: 0.8125rem; text-align: center; }
.archive-empty { padding: var(--space-xl); text-align: center; }

.knowledge-layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; min-height: 30rem; }
.topic-panel { padding: var(--space-lg); border-left: 1px solid var(--border); background: var(--surface); }
.topic-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-md); }
.topic-list { display: grid; gap: var(--space-xs); }
.topic-item { padding: var(--space-sm); border-left: 0.125rem solid var(--border-strong); }
.topic-item strong { display: block; font-size: 0.875rem; }
.topic-item p { margin-top: var(--space-2xs); color: var(--ink-muted); font-size: 0.75rem; }

.insights-list { display: grid; }
.insight-row { display: grid; grid-template-columns: minmax(12rem, 1fr) 6rem 9rem 9rem; gap: var(--space-lg); align-items: center; padding: var(--space-md) 0; border-bottom: 1px solid var(--border); }
.insight-row.header { padding-top: 0; color: var(--ink-muted); font-size: 0.75rem; font-weight: 700; }
.insight-question { font-weight: 650; }
.confidence-bar { height: 0.375rem; margin-top: var(--space-xs); background: var(--surface-strong); }
.confidence-bar span { display: block; height: 100%; background: var(--accent); }

.auth-screen { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(20rem, 32rem) minmax(24rem, 1fr); background: var(--white); }
.auth-screen[hidden] { display: none; }
.auth-panel { align-self: center; width: 100%; max-width: 28rem; margin-inline: auto; padding: var(--space-xl); }
.auth-heading { display: flex; align-items: center; gap: var(--space-md); }
.auth-heading .eyebrow { margin-bottom: var(--space-2xs); }
.auth-intro { margin: var(--space-lg) 0 var(--space-xl); color: var(--ink-soft); max-width: 45ch; }
.auth-panel form { display: grid; gap: var(--space-sm); }
.password-field { position: relative; }
.password-field input { padding-right: 3.25rem; }
.password-field .icon-button { position: absolute; right: 0; top: 0; }
.auth-config { margin-top: var(--space-xl); color: var(--ink-muted); font-size: 0.75rem; }
.auth-context { position: relative; display: grid; align-content: center; gap: var(--space-xl); padding: 10vw; overflow: hidden; color: #e8f0f3; color: oklch(0.94 0.015 220); background: var(--primary-strong); }
.auth-context::after { content: ""; position: absolute; right: -12rem; bottom: -10rem; width: 32rem; height: 32rem; border: 1px solid rgb(255 255 255 / 0.1); border: 1px solid oklch(1 0 0 / 0.1); border-radius: 50%; }
.auth-context > p { position: relative; max-width: 30ch; font-size: 1.5rem; line-height: 1.35; }
.auth-context ol { position: relative; display: grid; gap: var(--space-lg); margin: 0; padding: 0; list-style: none; }
.auth-context li { display: grid; grid-template-columns: 2.5rem 1fr; gap: var(--space-md); align-items: center; }
.auth-context li span { color: var(--accent); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.auth-context li strong { font-size: 0.9375rem; }
.context-line { position: absolute; top: 0; left: 10vw; width: 0.25rem; height: 28%; background: var(--accent); }

.editor-dialog { width: min(42rem, calc(100vw - 2rem)); max-height: min(48rem, calc(100vh - 2rem)); padding: 0; border: 0; border-radius: var(--radius-md); color: var(--ink); background: var(--white); box-shadow: var(--shadow-lg); overflow: hidden; }
.editor-dialog::backdrop { background: rgb(9 20 29 / 0.5); background: oklch(0.12 0.025 240 / 0.5); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); padding: var(--space-lg); border-bottom: 1px solid var(--border); }
.dialog-header p { margin-top: var(--space-xs); color: var(--ink-soft); font-size: 0.875rem; }
.dialog-body { display: grid; gap: var(--space-md); padding: var(--space-lg); overflow-y: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border); background: var(--surface); }

.toast-region { position: fixed; z-index: 80; right: var(--space-lg); bottom: var(--space-lg); display: grid; gap: var(--space-sm); width: min(24rem, calc(100vw - 2rem)); }
.toast { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: var(--space-sm); padding: var(--space-md); border-left: 0.25rem solid var(--accent); border-radius: var(--radius-sm); background: var(--ink); color: var(--white); box-shadow: var(--shadow-lg); }
.toast.error { border-left-color: #e57373; border-left-color: oklch(0.72 0.18 27); }
.toast button { border: 0; color: inherit; background: transparent; }

@media (hover: hover) and (pointer: fine) {
  .data-table tbody tr[data-selectable="true"] { cursor: pointer; }
}

@media (max-width: 75rem) {
  :root { --sidebar: 5rem; }
  .sidebar { padding-inline: var(--space-sm); }
  .sidebar .brand { justify-content: center; }
  .brand-copy, .primary-nav a span:not(.nav-count), .nav-button span, .environment span:last-child { display: none; }
  .primary-nav a, .nav-button { justify-content: center; }
  .primary-nav a::before { left: -0.5rem; }
  .nav-count { position: absolute; top: 0.125rem; right: 0.125rem; }
  .split-workspace { grid-template-columns: minmax(23rem, 0.85fr) minmax(30rem, 1.15fr); }
}

@media (max-width: 62rem) {
  .split-workspace { display: block; }
  .split-workspace.has-selection .master-pane { display: none; }
  .detail-pane { min-height: calc(100vh - 6.5rem); }
  .inspector-layout { grid-template-columns: minmax(0, 1fr); }
  .inspector { border-top: 1px solid var(--border); border-left: 0; }
  .inspector-inner { position: static; }
  .knowledge-layout { grid-template-columns: minmax(0, 1fr); }
  .topic-panel { border-top: 1px solid var(--border); border-left: 0; }
  .chat-archive { grid-template-columns: minmax(18rem, 0.8fr) minmax(0, 1.2fr); }
}

@media (max-width: 47.99rem) {
  :root { --sidebar: 0rem; }
  .app-shell { display: block; padding-top: var(--header-mobile); padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .mobile-header { position: fixed; z-index: 20; inset: 0 0 auto; height: var(--header-mobile); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-md); color: var(--ink); background: rgb(255 255 255 / 0.96); background: oklch(1 0 0 / 0.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(0.5rem); }
  .mobile-header .brand-mark::before { background: var(--primary); }
  .mobile-nav { position: fixed; z-index: 20; inset: auto 0 0; min-height: calc(4.5rem + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: rgb(255 255 255 / 0.97); background: oklch(1 0 0 / 0.97); backdrop-filter: blur(0.5rem); }
  .mobile-nav a { position: relative; min-height: 4.5rem; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.1875rem; color: var(--ink-muted); text-decoration: none; font-size: 0.6875rem; }
  .mobile-nav a[aria-current="page"] { color: var(--primary); font-weight: 700; }
  .mobile-nav a[aria-current="page"]::before { content: ""; position: absolute; top: -1px; width: 2rem; height: 0.1875rem; background: var(--accent); }
  .main-content, #page, .page-shell { min-height: calc(100vh - var(--header-mobile) - 4.5rem); }
  .page-header { min-height: auto; padding: var(--space-lg) var(--space-md); align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .page-actions .button { flex: 1; }
  .toolbar { padding: var(--space-sm) var(--space-md); }
  .search-field { flex-basis: 100%; }
  .filter-label { flex: 1; }
  .filter-label select { min-width: 0; }
  .bulk-actions { width: 100%; margin-left: 0; }
  .bulk-actions .button { flex: 1; }
  .content { padding: var(--space-md); }
  .tabs { padding-inline: var(--space-md); gap: var(--space-lg); }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--border); }
  .data-table td { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-2xs) 0; border: 0; text-align: right; }
  .data-table td::before { content: attr(data-label); color: var(--ink-muted); font-size: 0.75rem; font-weight: 650; text-align: left; }
  .data-table .primary-cell { min-width: 0; display: block; margin-bottom: var(--space-xs); text-align: left; }
  .data-table .primary-cell::before { display: none; }
  .data-table .wrap-cell { min-width: 0; max-width: none; }
  .data-table .actions-cell { justify-content: flex-end; padding-top: var(--space-sm); }
  .data-table .actions-cell::before { display: none; }
  .detail-header { padding: var(--space-sm) var(--space-md); }
  .detail-body { padding: var(--space-lg) var(--space-md) var(--space-xl); }
  .detail-body::before { display: none; }
  .detail-section { padding-left: 0; }
  .detail-footer { position: static; align-items: stretch; flex-direction: column; padding: var(--space-md); }
  .detail-footer .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .inspector-inner { padding: var(--space-md); }
  .insights-list { gap: var(--space-sm); }
  .insight-row { grid-template-columns: 1fr 1fr; gap: var(--space-xs) var(--space-md); padding: var(--space-md); border: 1px solid var(--border); border-left: 0.1875rem solid var(--accent); }
  .insight-row.header { display: none; }
  .insight-question { grid-column: 1 / -1; }
  .topic-panel { padding: var(--space-md); }
  .chat-archive { display: block; min-height: calc(100vh - var(--header-mobile) - 4.5rem); }
  .chat-archive.has-selection .chat-list-pane { display: none; }
  .chat-viewer { min-height: calc(100vh - var(--header-mobile) - 4.5rem); padding: var(--space-md); }
  .chat-viewer-header { flex-direction: column; }
  .chat-viewer-header .chat-back { display: inline-flex; margin-bottom: var(--space-sm); }
  .chat-viewer-toolbar { align-items: stretch; flex-direction: column; }
  .archive-messages { max-height: none; }
  .auth-screen { grid-template-columns: 1fr; overflow-y: auto; }
  .auth-panel { align-self: start; margin-top: 8vh; padding: var(--space-lg); }
  .auth-context { display: none; }
  .toast-region { right: var(--space-md); bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .editor-dialog { width: 100vw; max-width: none; max-height: 100vh; height: 100vh; border-radius: 0; }
  .dialog-form { max-height: 100vh; height: 100%; }
}
