/* Avery Dennison R&D Knowledge Assistant — McKinsey-inspired light theme */
:root {
  --navy: #051C2C;
  --navy-2: #0B2D45;
  --blue: #2251FF;
  --blue-soft: #E9EEFF;
  --cyan: #00A9F4;
  --teal: #14B8A6;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --red: #C0262D;
  --green: #0F7B4F;
  --ink: #0B1F33;
  --text: #1F2A37;
  --muted: #5B6B7B;
  --faint: #8A97A5;
  --line: #E4E7EC;
  --line-2: #EEF0F3;
  --bg: #FFFFFF;
  --surface: #F7F8FA;
  --surface-2: #F1F3F6;
  --pfs: #2251FF;       /* structured source colour */
  --pfs-soft: #E9EEFF;
  --drive: #0E8A6A;     /* unstructured source colour */
  --drive-soft: #E3F5EF;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(5, 28, 44, .06), 0 8px 24px rgba(5, 28, 44, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); color: var(--ink); font-weight: 600; letter-spacing: -.01em; }
code, pre { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ------------------------------------------------ header */
.topbar {
  height: 60px; display: flex; align-items: center; gap: 28px; padding: 0 24px;
  border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none !important; }
.brand-mark { font: 800 13px/1 var(--sans); letter-spacing: .18em; color: var(--navy); }
.brand-sep { width: 1px; height: 22px; background: var(--line); }
.brand-name { font: 600 17px var(--serif); color: var(--navy); }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a {
  display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; text-decoration: none;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--navy); border-bottom-color: var(--blue); }
.topbar .spacer { flex: 1; }
.user-chip { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px; background: none; border: 1px solid var(--line);
  padding: 5px 10px 5px 5px; border-radius: 999px; color: var(--ink);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.role-badge.admin { background: #FDE8E8; color: var(--red); }
.role-badge.production { background: var(--amber-soft); color: var(--amber); }
.menu {
  position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  min-width: 280px; padding: 8px; border-radius: var(--radius); z-index: 50;
}
.menu h6 { margin: 6px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.menu a { display: flex; justify-content: space-between; padding: 8px; border-radius: 3px; color: var(--text); }
.menu a:hover { background: var(--surface); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius); font-weight: 500; text-decoration: none !important;
}
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.icon-btn {
  width: 32px; height: 32px; border: 0; background: none; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.on { color: var(--blue); background: var(--blue-soft); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }

/* ------------------------------------------------ chat layout */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr) 400px; height: calc(100vh - 60px); }
.app.no-evidence { grid-template-columns: 272px minmax(0, 1fr) 0; }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.sidebar-top { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sidebar-top .btn { justify-content: center; }
.sync-pill { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--amber); background: var(--amber-soft); border-radius: 999px; padding: 5px 10px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: none; animation: sync-blink 1.1s ease-in-out infinite; }
@keyframes sync-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.session-list { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.session-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 14px 8px 6px; }
.session {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 3px; color: var(--text);
  cursor: pointer; font-size: 13px;
}
.session:hover { background: #fff; }
.session.active { background: #fff; box-shadow: inset 2px 0 0 var(--blue); color: var(--ink); font-weight: 500; }
.session .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.session .acts { display: none; }
.session:hover .acts { display: flex; }
.session .acts button { border: 0; background: none; color: var(--faint); padding: 2px; }
.session .acts button:hover { color: var(--ink); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 16px; font-size: 12px; color: var(--muted); }
.source-toggle { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.switch { position: relative; width: 32px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #CBD2D9; border-radius: 999px; transition: .15s; }
.switch span:before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span:before { transform: translateX(14px); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.pfs { background: var(--pfs); }
.dot.drive { background: var(--drive); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread-inner { max-width: 860px; margin: 0 auto; padding: 28px 28px 40px; }

/* welcome */
.welcome h1 { font-size: 38px; line-height: 1.12; margin: 18px 0 8px; color: var(--navy); }
.welcome h1 em { font-style: normal; color: var(--blue); }
.welcome .lede { font-size: 16px; color: var(--muted); max-width: 640px; }
.kpis { display: flex; gap: 0; margin: 24px 0 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi { flex: 1; padding: 14px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi b { display: block; font: 600 26px var(--serif); color: var(--navy); }
.kpi span { font-size: 12px; color: var(--muted); }
.rec-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.rec-tab { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; color: var(--muted); }
.rec-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rec-card {
  text-align: left; border: 1px solid var(--line); background: #fff; padding: 14px 16px; border-radius: var(--radius);
  color: var(--ink); display: flex; flex-direction: column; gap: 10px; transition: .12s;
}
.rec-card:hover { border-color: var(--blue); box-shadow: var(--shadow); transform: translateY(-1px); }
.rec-card .src { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* messages */
.msg { margin-bottom: 30px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 14px 14px 2px 14px; max-width: 78%;
  white-space: pre-wrap;
}
.msg.assistant .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.msg.assistant .logo {
  width: 28px; height: 28px; background: var(--navy); color: #fff; font: 700 11px var(--sans); display: grid; place-items: center; border-radius: 3px;
}
.msg.assistant .name { font-weight: 600; color: var(--ink); }
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.step {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.step.run { color: var(--blue); background: var(--blue-soft); }
.step.run:before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--blue); border-top-color: transparent; animation: spin .8s linear infinite; }
.step.ok:before { content: "✓"; color: var(--green); font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer { color: var(--text); font-size: 14.5px; }
.answer h1, .answer h2, .answer h3 { font-size: 17px; margin: 18px 0 6px; }
.answer p { margin: 8px 0; }
.answer ul, .answer ol { padding-left: 22px; }
.answer li { margin: 3px 0; }
.answer table { border-collapse: collapse; margin: 12px 0; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.answer th { background: var(--surface); text-align: left; font-weight: 600; color: var(--ink); border-bottom: 2px solid var(--navy); }
.answer th, .answer td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.answer blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--blue); color: var(--muted); }
.answer code { background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 18px; padding: 0 5px; margin: 0 1px;
  font: 600 10.5px var(--sans); border-radius: 3px; vertical-align: 1px; cursor: pointer; border: 0;
}
.cite.P { background: var(--pfs-soft); color: var(--pfs); }
.cite.D { background: var(--drive-soft); color: var(--drive); }
.cite:hover { outline: 1px solid currentColor; }
.cursor:after { content: "▍"; color: var(--blue); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-tools { display: flex; align-items: center; gap: 2px; margin-top: 8px; color: var(--faint); }
.msg-tools .sep { flex: 1; }
.src-summary { font-size: 12px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.src-summary b { color: var(--ink); }
.warn { font-size: 12px; background: var(--amber-soft); color: var(--amber); padding: 6px 10px; border-radius: 3px; margin-top: 8px; }
.warn-link { border: 0; background: none; padding: 0; margin-left: 2px; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.suggestions { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.suggestions .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 2px; }
.sugg {
  text-align: left; border: 1px solid var(--line); background: #fff; padding: 8px 12px; border-radius: var(--radius);
  color: var(--ink); display: flex; gap: 8px; align-items: center;
}
.sugg:hover { border-color: var(--blue); color: var(--blue); }
.sugg svg { color: var(--blue); flex: none; }

/* composer */
.composer-wrap { padding: 0 28px 18px; }
.composer {
  max-width: 860px; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow);
  position: relative;
}
.composer:focus-within { border-color: var(--navy); }
.composer textarea {
  width: 100%; border: 0; resize: none; padding: 14px 16px 6px; font-size: 15px; max-height: 220px; outline: none; background: transparent;
}
.composer-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px 8px 10px; }
.composer-bar .grow { flex: 1; }
.send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; display: grid; place-items: center;
}
.send:disabled { background: #CBD2D9; cursor: not-allowed; }
.send.stop { background: var(--red); }
.mic.rec { color: #fff; background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(192, 38, 45, .45); } 70% { box-shadow: 0 0 0 10px rgba(192, 38, 45, 0); } 100% { box-shadow: 0 0 0 0 rgba(192, 38, 45, 0); } }
.interim { font-size: 12px; color: var(--muted); padding: 0 16px; min-height: 0; font-style: italic; }
.chips { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; background: #fff; font-size: 11.5px; color: var(--muted); }
.chip.on { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.autocomplete {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 20;
}
.autocomplete .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 8px 12px 2px; }
.autocomplete div.item { padding: 8px 12px; cursor: pointer; font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.autocomplete div.item.sel, .autocomplete div.item:hover { background: var(--surface); }
.autocomplete mark { background: none; color: var(--blue); font-weight: 600; }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 8px; }

/* ------------------------------------------------ evidence panel */
.evidence { border-left: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ev-head { padding: 16px 18px 0; }
.ev-head h3 { margin: 0 0 4px; font-size: 18px; }
.ev-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-top: 10px; }
.ev-tab { border: 0; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; font-size: 13px; }
.ev-tab.active { color: var(--navy); border-bottom-color: var(--blue); }
.ev-tab .n { font-size: 11px; background: var(--surface-2); padding: 0 6px; border-radius: 999px; margin-left: 4px; }
.ev-body { overflow-y: auto; flex: 1; padding: 14px 18px 30px; }
.ev-empty { color: var(--faint); text-align: center; margin-top: 40px; font-size: 13px; }
.ev-card { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; background: #fff; transition: box-shadow .2s; }
.ev-card.flash { box-shadow: 0 0 0 3px var(--blue-soft), var(--shadow); border-color: var(--blue); }
.ev-card .ev-top { display: flex; gap: 10px; padding: 10px 12px; align-items: flex-start; }
.ev-id { font: 700 11px var(--sans); padding: 2px 6px; border-radius: 3px; flex: none; }
.ev-id.P { background: var(--pfs-soft); color: var(--pfs); }
.ev-id.D { background: var(--drive-soft); color: var(--drive); }
.ev-card .ttl { font-weight: 600; color: var(--ink); font-size: 13px; line-height: 1.35; }
.ev-card .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ev-card .unused { font-size: 10.5px; color: var(--faint); border: 1px dashed var(--line); padding: 0 5px; border-radius: 3px; margin-left: 4px; }
.ev-card .body { padding: 0 12px 12px; }
.ev-card pre.sql { background: var(--navy); color: #DDE7FF; padding: 10px; border-radius: 3px; overflow-x: auto; white-space: pre-wrap; margin: 0 0 8px; max-height: 160px; }
.ev-card .tbl-wrap { max-height: 220px; overflow: auto; border: 1px solid var(--line-2); }
.ev-card table { border-collapse: collapse; font-size: 11.5px; width: 100%; }
.ev-card th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; }
.ev-card th, .ev-card td { padding: 4px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.ev-card .snippet { font-size: 12.5px; color: var(--text); background: var(--surface); padding: 8px 10px; border-left: 2px solid var(--drive); max-height: 150px; overflow: hidden; position: relative; }
.ev-card .snippet mark { background: #FFF3B0; color: inherit; padding: 0 1px; }
.ev-card .thumb { width: 64px; height: 84px; object-fit: cover; object-position: top; border: 1px solid var(--line); flex: none; background: var(--surface); cursor: zoom-in; }
.ev-card .row-actions { display: flex; gap: 6px; margin-top: 8px; }
.ev-card canvas { max-height: 220px; margin-top: 8px; }
.err { color: var(--red); font-size: 12px; }
.lineage { font-size: 12.5px; }
.lineage ol { list-style: none; padding: 0; margin: 0; position: relative; }
.lineage ol:before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.lineage li { position: relative; padding: 0 0 16px 34px; }
.lineage li .n { position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 50%; background: #fff; border: 1px solid var(--navy); color: var(--navy); font-weight: 700; font-size: 11px; display: grid; place-items: center; }
.lineage li b { color: var(--ink); }
.lineage .ms { color: var(--faint); font-size: 11px; margin-left: 4px; }
.lineage .kv { color: var(--muted); margin-top: 3px; }
.lineage .tag { display: inline-block; font-size: 11px; border: 1px solid var(--line); padding: 0 6px; border-radius: 3px; margin: 2px 2px 0 0; background: var(--surface); }
.bar-split { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 6px 0 2px; }
.bar-split .p { background: var(--pfs); }
.bar-split .d { background: var(--drive); }

/* ------------------------------------------------ modal viewer */
.modal { position: fixed; inset: 0; background: rgba(5, 28, 44, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-box { background: #fff; width: min(1180px, 100%); height: min(88vh, 900px); display: grid; grid-template-columns: 1fr 340px; border-radius: 6px; overflow: hidden; }
.modal-box iframe { width: 100%; height: 100%; border: 0; background: var(--surface-2); }
.modal-side { border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; }
.modal-side h3 { margin: 0 0 6px; font-size: 18px; }
.modal-close { position: absolute; top: 16px; right: 20px; color: #fff; background: none; border: 0; font-size: 28px; }
.share-box { background: #fff; width: min(420px, 100%); border-radius: 8px; padding: 20px; max-height: 85vh; overflow-y: auto; }
.share-form { display: flex; gap: 6px; }
.share-form input[type=email] { flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; min-width: 0; }
.share-form select { padding: 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 12.5px; }
.page-text { font-size: 12.5px; white-space: pre-wrap; background: var(--surface); padding: 10px; border-radius: 3px; max-height: 50vh; overflow: auto; }
.page-text mark { background: #FFF3B0; }

/* ------------------------------------------------ pages (documents / data / about / login) */
.page { max-width: 1240px; margin: 0 auto; padding: 32px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 34px; color: var(--navy); }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--blue); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; display: flex; flex-direction: column; overflow: hidden; cursor: pointer; transition: .12s; }
.doc-card:hover { border-color: var(--navy); box-shadow: var(--shadow); }
.doc-card img { width: 100%; height: 170px; object-fit: cover; object-position: top; background: var(--surface); border-bottom: 1px solid var(--line); }
.doc-card .dc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.doc-card .dc-title { font-weight: 600; color: var(--ink); line-height: 1.3; }
.doc-card .dc-sum { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card .dc-meta { font-size: 11.5px; color: var(--faint); display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.acl { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.acl.public { background: var(--drive-soft); color: var(--drive); }
.acl.restricted { background: #FDE8E8; color: var(--red); }
.notice { border: 1px solid var(--line); background: var(--surface); padding: 12px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 18px; }
.notice.info { border-color: #C9D6FF; background: var(--blue-soft); }
.flash-msg { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.flash-msg.success { background: var(--drive-soft); color: var(--drive); }
.flash-msg.error { background: #FDE8E8; color: var(--red); }
.data-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; }
.table-list a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 3px; color: var(--text); font-size: 13px; }
.table-list a:hover { background: var(--surface); text-decoration: none; }
.table-list a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.table-list a.locked { color: var(--faint); }
.data-table-wrap { border: 1px solid var(--line); overflow: auto; max-height: 62vh; }
table.data { border-collapse: collapse; font-size: 12.5px; width: 100%; }
table.data th { position: sticky; top: 0; background: var(--surface); text-align: left; border-bottom: 2px solid var(--navy); font-weight: 600; color: var(--ink); }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
table.data tr:hover td { background: #FAFBFF; }
.sql-box { width: 100%; min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
details.schema pre { background: var(--surface); padding: 12px; font-size: 11.5px; white-space: pre-wrap; max-height: 300px; overflow: auto; }

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero:after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border: 60px solid rgba(34, 81, 255, .35); border-radius: 50%; }
.login-hero > * { position: relative; z-index: 1; }
.login-hero:after { z-index: 0; }
.login-hero h1 { color: #fff; font-size: 46px; line-height: 1.08; max-width: 560px; margin: 0; }
.login-hero h1 em { font-style: normal; color: #7FA0FF; }
.login-hero p { color: #B7C3D0; max-width: 520px; font-size: 15px; }
.login-form { padding: 56px; display: flex; flex-direction: column; justify-content: center; max-width: 560px; }
.login-form h2 { font-size: 26px; margin: 0 0 6px; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 22px; }
.persona { text-align: left; border: 1px solid var(--line); background: #fff; padding: 12px; border-radius: var(--radius); }
.persona:hover, .persona.sel { border-color: var(--blue); background: var(--blue-soft); }
.persona b { display: block; color: var(--ink); }
.persona span { font-size: 12px; color: var(--muted); }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row label { font-size: 12px; font-weight: 600; color: var(--muted); }

.arch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0; }
.arch .box { border: 1px solid var(--line); padding: 16px; border-radius: var(--radius); }
.arch .box h4 { margin: 0 0 6px; font-family: var(--serif); font-size: 17px; color: var(--navy); }
.prose { max-width: 820px; font-size: 15px; }
.prose h2 { margin-top: 32px; }

@media (max-width: 1200px) {
  .app { grid-template-columns: 240px minmax(0, 1fr) 0; }
  .evidence { position: fixed; right: 0; top: 60px; bottom: 0; width: 400px; box-shadow: var(--shadow); z-index: 25; transform: translateX(100%); transition: .2s; }
  .app.show-evidence .evidence { transform: none; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .sidebar { display: none; }
  .nav { display: none; }
  .rec-grid { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .modal-box { grid-template-columns: 1fr; }
  .modal-side { display: none; }
  .evidence { width: 100%; }
}

/* ------------------------------------------------ v2: modules, attachments, figures, math, inline charts */
.mod-switch { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 8px; }
.mod-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin: 0 2px 6px; }
.mod-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.mod-btn { border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 4px 9px; border-radius: 999px; font-size: 12px; }
.mod-btn:hover { border-color: var(--navy); color: var(--ink); }
.mod-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.mod-tag { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.chip.mod { background: var(--navy); color: #fff; border-color: var(--navy); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 200; box-shadow: var(--shadow); max-width: 90vw; }
.composer.drop { outline: 2px dashed var(--blue); outline-offset: 3px; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 3px 8px 3px 3px; font-size: 12px; color: var(--ink); max-width: 280px; text-decoration: none !important; }
.att-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.att-chip svg { width: 16px; height: 16px; margin-left: 4px; }
.att-chip button { border: 0; background: none; color: var(--faint); font-size: 16px; line-height: 1; padding: 0 2px; }
.att-chip.loading { opacity: .7; }
.msg.user .att-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.msg.user .att-chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.math-block { overflow-x: auto; padding: 6px 0; margin: 6px 0; }
.answer .katex { font-size: 1.08em; }
.inline-chart { margin: 12px 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; background: #fff; height: 320px; display: flex; flex-direction: column; }
.inline-chart .ic-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.inline-chart .ic-head .ic-png { margin-left: auto; }
.inline-chart canvas { flex: 1; min-height: 0; }
.chart-building { border: 1px dashed var(--line); padding: 14px; color: var(--muted); font-size: 13px; border-radius: var(--radius); margin: 10px 0; }
.chart-error { background: #FDE8E8; }
.export-wrap { position: relative; display: inline-flex; }
.export-menu { position: absolute; bottom: 36px; right: 0; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; min-width: 170px; z-index: 30; }
.export-menu a { padding: 7px 10px; color: var(--text); font-size: 13px; border-radius: 4px; }
.export-menu a:hover { background: var(--surface); text-decoration: none; }
.form-callout { display: flex; gap: 10px; align-items: center; border: 1px solid #C9D6FF; background: var(--blue-soft); color: var(--navy); padding: 10px 14px; border-radius: 6px; margin: 10px 0; text-decoration: none !important; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.quick .chip { cursor: pointer; }
.quick .chip:hover { border-color: var(--blue); color: var(--blue); }
.tag-ml { font-size: 10.5px; background: #EDE9FE; color: #6D28D9; padding: 0 6px; border-radius: 3px; font-weight: 700; }
.ev-id.U { background: #FEF3C7; color: var(--amber); }
.ev-id.M { background: #EDE9FE; color: #6D28D9; }
.ev-id.R { background: #F1F3F6; color: var(--navy); }
.ev-id.F { background: var(--blue-soft); color: var(--blue); }
.cite.U { background: #FEF3C7; color: var(--amber); }
.cite.M { background: #EDE9FE; color: #6D28D9; }
.cite.R { background: #E5E7EB; color: var(--navy); }
.cite.F { background: var(--blue-soft); color: var(--blue); }
.kind-badge { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 3px; background: var(--surface-2); color: var(--muted); vertical-align: 1px; }
.kind-badge.chart { background: #E0F2FE; color: #0369A1; }
.kind-badge.table { background: #ECFDF5; color: var(--green); }
.kind-badge.formula { background: #EDE9FE; color: #6D28D9; }
.kind-badge.photo { background: #FEF3C7; color: var(--amber); }
.kind-badge.diagram { background: #FCE7F3; color: #9D174D; }
.fig-wrap { background: var(--surface); border: 1px solid var(--line-2); border-radius: 3px; text-align: center; padding: 6px; }
.fig-img { max-width: 100%; max-height: 220px; cursor: zoom-in; }
.latex { overflow-x: auto; padding: 4px 0; }
.mono { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.kv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.kv-tags .tag, .lineage .tag { display: inline-block; font-size: 11px; border: 1px solid var(--line); padding: 0 6px; border-radius: 3px; background: var(--surface); }
.prob { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; }
.pbar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.pbar span { display: block; height: 100%; background: #6D28D9; }
.pbar.alt span { background: var(--cyan); }
.dot.other { background: #6D28D9; }
.bar-split .o { background: #6D28D9; }
.viewer-main { position: relative; background: var(--surface-2); display: flex; align-items: center; justify-content: center; min-height: 0; }
.viewer-main iframe { width: 100%; height: 100%; border: 0; }
.viewer-main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.vf { display: grid; grid-template-columns: 90px 1fr; gap: 8px; padding: 8px; border: 1px solid var(--line-2); border-radius: 4px; margin-bottom: 6px; }
.vf.used { border-color: var(--blue); background: var(--blue-soft); }
.vf img { width: 90px; max-height: 90px; object-fit: contain; background: #fff; }
.fig-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.fig-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.fig-card img { max-width: 100%; max-height: 260px; object-fit: contain; background: var(--surface); border: 1px solid var(--line-2); cursor: zoom-in; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.sheet-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.sheet-tabs a { padding: 6px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 4px 4px 0 0; color: var(--muted); font-size: 13px; }
.sheet-tabs a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
td.f { background: #F5F3FF; }
td.f:hover { outline: 1px solid #6D28D9; }

.ev-tabs { overflow-x: auto; }
.ev-tab { white-space: nowrap; padding: 8px 9px; }

/* ------------------------------------------------ Drive explorer */
a.ev-tab { text-decoration: none !important; display: inline-block; }
.drive-summary { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.ds-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.ds-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin-bottom: 4px; }
.ds-big { font: 600 18px var(--serif); color: var(--navy); }
.ftype { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.ftype.gdoc { background: #E8F0FE; color: #1A73E8; }
.ftype.gsheet { background: #E6F4EA; color: #188038; }
.ftype.pdf { background: #FCE8E6; color: #C5221F; }
.ftype.csv { background: #FEF7E0; color: #B06000; }
.ftype.folder { background: #F1F3F6; color: var(--navy); }
.ficon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; font-size: 12px; margin-right: 6px; color: #fff; background: #9AA0A6; }
.ficon.gdoc { background: #1A73E8; } .ficon.gsheet { background: #188038; } .ficon.pdf { background: #C5221F; } .ficon.csv { background: #B06000; }
.who { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); margin: 1px 2px 1px 0; white-space: nowrap; }
.who.owner { background: var(--navy); color: #fff; border-color: var(--navy); }
.pchip { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 3px; margin: 1px 2px 1px 0; background: #F1F3F6; color: var(--faint); white-space: nowrap; }
.pchip.on { background: var(--drive-soft); color: var(--drive); font-weight: 600; }
/* Fixed layout + an explicit per-column width budget (summing to 100%) so the tree table always fits the
   page - long owner/persona/chip lists wrap onto extra lines within their column instead of forcing the
   whole table (and page) wider than the viewport and triggering horizontal scroll. */
table.tree { table-layout: fixed; width: 100%; }
table.tree td { white-space: normal; vertical-align: middle; overflow-wrap: break-word; }
table.tree tr.frow td { background: #FAFBFC; border-top: 1px solid var(--line); }
.tw { border: 0; background: none; color: var(--muted); width: 18px; padding: 0; cursor: pointer; }
@media (max-width: 1000px) { .drive-summary { grid-template-columns: 1fr; } }

table.tree th:nth-child(1), table.tree td:nth-child(1) { width: 21%; }
table.tree th:nth-child(2), table.tree td:nth-child(2) { width: 7%; }
table.tree th:nth-child(3), table.tree td:nth-child(3) { width: 16%; }
table.tree th:nth-child(4), table.tree td:nth-child(4) { width: 10%; }
table.tree th:nth-child(5), table.tree td.personas { width: 20%; }
table.tree th:nth-child(6), table.tree td:nth-child(6) { width: 9%; white-space: nowrap; }
table.tree th:nth-child(7), table.tree td:nth-child(7) { width: 6%; }
table.tree th:nth-child(8), table.tree td:nth-child(8) { width: 11%; }
/* Name column: wrap full titles onto extra lines within the fixed column width (like every other column
   here already does) rather than truncating them with an ellipsis - the title is usually the one thing
   you actually need to read in full. */
table.tree td:first-child { white-space: normal; }
.page:has(table.tree) { max-width: 1560px; }

.who.me { background: var(--blue-soft); color: var(--blue); border-color: #C9D6FF; font-weight: 600; }

.access-banner { display: flex; gap: 10px; align-items: flex-start; border: 1px solid #F5C2C0; background: #FEF2F2; color: #7F1D1D; border-radius: 6px; padding: 10px 14px; margin: 4px 0 12px; font-size: 13px; }
.access-banner svg { flex: none; margin-top: 2px; color: var(--red); }
.access-banner ul { margin: 4px 0 6px; padding-left: 18px; }
.access-banner code { background: #fff; padding: 0 4px; border-radius: 3px; }
.access-banner a { color: #7F1D1D; text-decoration: underline; }
.cur-access { background: #fff; border: 1px solid #F5C2C0; border-radius: 6px; padding: 8px 12px; margin: 6px 0; color: var(--text); }
.cur-access ul { margin: 4px 0 0; padding-left: 18px; }
.cur-access li { margin: 2px 0; }
.cite.A { background: #FEE2E2; color: var(--red); }

.req-box { background: #fff; border: 1px solid #F5C2C0; border-radius: 6px; padding: 10px 12px; margin: 8px 0; color: var(--text); }
.req-box ol { margin: 6px 0 8px; padding-left: 20px; }
.req-box li { margin: 3px 0; }
.req-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.req-actions input { flex: 1; min-width: 220px; padding: 5px 8px; font-size: 12.5px; }
.req-status { color: var(--green); }

/* ------------------------------------------------ Access governance */
h2.sec { font-size: 20px; margin: 22px 0 10px; }
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.fcol { display: flex; flex-direction: column; gap: 8px; }
.fnode { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 4px; padding: 8px 12px; min-width: 170px; max-width: 250px; }
.fnode b { display: block; color: var(--ink); font-size: 13px; }
.fnode span { font-size: 11.5px; color: var(--muted); }
.fnode.drive { border-left-color: var(--drive); } .fnode.pfs { border-left-color: var(--pfs); } .fnode.mod { border-left-color: #6D28D9; }
.fnode.llm { border-left-color: var(--cyan); } .fnode.ok { border-left-color: var(--green); } .fnode.deny { border-left-color: var(--red); }
.farrow { font-size: 22px; color: var(--faint); }
table.matrix th, table.matrix td { padding: 4px 6px; font-size: 11.5px; }
table.matrix th.grp { text-align: center; background: var(--navy); color: #fff; border-right: 2px solid #fff; }
table.matrix th.rot { height: 150px; vertical-align: bottom; white-space: nowrap; padding: 4px 2px; }
table.matrix th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 500; }
table.matrix th.hs span { color: var(--red); }
table.matrix td.c { text-align: center; min-width: 26px; }
table.matrix td.y { background: #ECFDF5; color: var(--green); font-weight: 700; }
table.matrix td.n { background: #FAFAFA; color: #C4C9D0; }
table.matrix td.heat { background: color-mix(in srgb, #0E8A6A calc(var(--p) * 1%), #FEF2F2); color: #0B1F33; font-size: 10.5px; }
table.matrix .sticky { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 170px; }
.cov { display: inline-block; width: 100%; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; vertical-align: middle; }
.cov > span { display: block; height: 100%; background: var(--drive); }
.cov.alt > span { background: var(--pfs); }
.cov.big { height: 8px; width: 110px; }
.req-card { border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.req-card.approved { border-left-color: var(--green); } .req-card.rejected, .req-card.revoked { border-left-color: var(--faint); } .req-card.expired { border-left-color: #9CA3AF; }
.req-head { display: flex; justify-content: space-between; gap: 12px; }
.req-id { font-weight: 700; color: var(--navy); }
.req-q { font-family: var(--serif); font-size: 16px; color: var(--ink); margin: 4px 0; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--amber-soft); color: var(--amber); }
.status-pill.approved { background: var(--drive-soft); color: var(--green); } .status-pill.rejected, .status-pill.revoked, .status-pill.expired { background: var(--surface-2); color: var(--muted); }
.req-items { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.req-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 4px; }
.req-item .kind { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.kind.pfs_table { background: var(--pfs-soft); color: var(--pfs); } .kind.drive_files { background: var(--drive-soft); color: var(--drive); } .kind.entitlement { background: #EDE9FE; color: #6D28D9; }
.req-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ucard { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; background: #fff; }
.ucard summary { list-style: none; cursor: pointer; padding: 12px 14px; }
.ucard summary::-webkit-details-marker { display: none; }
.uhead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.gauge { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.stat { text-align: center; } .stat b { display: block; font: 600 20px var(--serif); } .stat span { font-size: 11px; color: var(--muted); }
.ubody { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; padding: 0 14px 14px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.fbar { display: grid; grid-template-columns: 170px 1fr 44px; gap: 8px; align-items: center; margin: 3px 0; font-size: 12px; }
.fbar .fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manage { background: var(--surface); border-radius: 6px; padding: 10px 12px; }
.chk { display: block; margin: 2px 0; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .ubody { grid-template-columns: 1fr; } }

/* ------------------------------------------------ How it works */
.hiw-title { font-size: 34px; line-height: 1.15; color: var(--navy); margin: 6px 0 10px; max-width: 1000px; }
.hiw-toc { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.hiw-toc a { font-size: 12.5px; border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; color: var(--muted); text-decoration: none; }
.hiw-toc a:hover { border-color: var(--blue); color: var(--blue); }
.hiw-sec { margin-top: 34px; }
.hiw-sec h2 { font-size: 24px; margin: 0 0 12px; }
.diagram { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; overflow-x: auto; }
.diagram svg { width: 100%; min-width: 900px; height: auto; font-family: var(--sans); }
.diagram .col { font-size: 11px; letter-spacing: .14em; fill: var(--faint); text-anchor: middle; font-weight: 700; }
.diagram .box rect, .diagram .ent rect { fill: #fff; stroke: var(--line); stroke-width: 1.2; }
.diagram .box.pfs rect { fill: var(--pfs-soft); stroke: var(--pfs); } .diagram .box.drive rect { fill: var(--drive-soft); stroke: var(--drive); }
.diagram .box.up rect { fill: #FEF3C7; stroke: var(--amber); } .diagram .box.ml rect { fill: #EDE9FE; stroke: #6D28D9; }
.diagram .box.ing rect { fill: var(--surface); } .diagram .box.vis rect { fill: #E0F2FE; stroke: #0369A1; }
.diagram .box.idx rect { fill: #F8FAFF; stroke: var(--navy); stroke-width: 1.5; }
.diagram .box.orch > rect:first-child { fill: var(--navy); stroke: var(--navy); }
.diagram .box.orch text { fill: #DDE7FF; } .diagram .box.orch text.t { fill: #fff; }
.diagram .box.orch rect.llm { fill: #0B2D45; stroke: var(--cyan); }
.diagram .box.ux rect { fill: #fff; stroke: var(--navy); } .diagram .box.deny rect { fill: #FEF2F2; stroke: var(--red); }
.diagram text.t { font-size: 13.5px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.diagram text.s { font-size: 11.5px; fill: var(--muted); text-anchor: middle; } .diagram text.s.left { text-anchor: start; }
.diagram text.k { font: 600 22px var(--serif); fill: var(--navy); text-anchor: middle; }
.diagram text.n { font-size: 11px; fill: var(--blue); text-anchor: middle; font-weight: 600; }
.diagram .ar { fill: none; stroke: #9AA5B1; stroke-width: 1.4; marker-end: url(#ah); }
.diagram .ar.dash { stroke-dasharray: 5 4; } .diagram .ar.pfsl { stroke: var(--pfs); }
.diagram .ar2 { fill: none; stroke: var(--navy); stroke-width: 1.5; marker-end: url(#ah2); } .diagram .ar2.d { stroke: #B8C0CC; stroke-dasharray: 4 4; }
.diagram .arrowhead { fill: #9AA5B1; }
.diagram .gate { fill: var(--red); opacity: .75; } .diagram .gtxt { font-size: 11px; fill: var(--red); text-anchor: middle; font-weight: 600; }
.diagram .ent.key rect { stroke: var(--navy); stroke-width: 2; fill: #F8FAFF; } .diagram .ent.ref rect { fill: var(--surface); }
.diagram .ent.hs rect { fill: #FEF2F2; stroke: var(--red); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.step-card { position: relative; border: 1px solid var(--line); border-top: 4px solid var(--navy); border-radius: 6px; padding: 14px 14px 30px; background: #fff; }
.step-card.pfs { border-top-color: var(--pfs); } .step-card.drive { border-top-color: var(--drive); } .step-card.ml { border-top-color: #6D28D9; }
.step-card.deny { border-top-color: var(--red); } .step-card.llm { border-top-color: var(--cyan); }
.step-card .num { position: absolute; top: -14px; right: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.step-card b { color: var(--ink); } .step-card p { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.step-card .tm { position: absolute; bottom: 8px; left: 14px; font-size: 11.5px; font-weight: 700; color: var(--blue); background: var(--blue-soft); padding: 1px 8px; border-radius: 999px; }
.total { margin-top: 10px; font-size: 14px; }
.vis-flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vcol { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 200px; }
.vbox { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fff; }
.vbox b { display: block; color: var(--ink); } .vbox span { font-size: 12px; color: var(--muted); }
.vbox.strong { background: #E0F2FE; border-color: #0369A1; }
.varrow { font-size: 24px; color: var(--faint); }
.fig-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fk { border-radius: 6px; padding: 8px 10px; background: var(--surface); }
.fk b { display: block; font: 600 20px var(--serif); } .fk span { font-size: 11.5px; color: var(--muted); }
.fk.chart { background: #E0F2FE; } .fk.table { background: #ECFDF5; } .fk.formula { background: #EDE9FE; } .fk.photo { background: #FEF3C7; } .fk.diagram { background: #FCE7F3; }
.formula-demo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.formula-demo > div { border: 1px dashed var(--line); border-radius: 6px; padding: 10px 12px; background: #fff; }
.mod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mod-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: #fff; }
.mod-card b { font-family: var(--serif); font-size: 16px; color: var(--navy); } .mod-card p { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.mod-card.weathering { border-top: 3px solid #6D28D9; } .mod-card.release { border-top: 3px solid var(--cyan); } .mod-card.adhesive { border-top: 3px solid var(--amber); } .mod-card.cross { border-top: 3px solid var(--navy); } .mod-card.wiki { border-top: 3px solid var(--drive); }
@media (max-width: 1000px) { .steps, .mod-grid, .formula-demo { grid-template-columns: 1fr 1fr; } }

.global-flash { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 60; width: min(720px, 92vw); }
.global-flash .flash-msg { box-shadow: var(--shadow); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.global-flash .flash-msg button { border: 0; background: none; font-size: 18px; line-height: 1; color: inherit; cursor: pointer; }
.flash-msg.warning { background: var(--amber-soft); color: var(--amber); }
.flash-msg.info { background: var(--blue-soft); color: var(--blue); }

/* ------------------------------------------------ Weathering Assistant */
.wx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.wx-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fff; }
.wx-h { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.wx-step { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip.ex, .chip.fex { cursor: pointer; background: var(--blue-soft); color: var(--blue); border-color: #C9D6FF; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.fgrid .form-row span { font-size: 12px; font-weight: 600; color: var(--muted); }
.fgrid select, .fgrid input { width: 100%; }
.model-card { margin-top: 14px; background: var(--surface); border-radius: 6px; padding: 10px 12px; }
.metrics { display: flex; gap: 10px; margin-top: 8px; }
.metrics div { flex: 1; background: #fff; border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 8px; }
.metrics b { display: block; font: 600 18px var(--serif); color: var(--navy); } .metrics span { font-size: 11px; color: var(--muted); }
.class-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cls { border: 1px solid var(--line); border-radius: 6px; padding: 10px; opacity: .6; }
.cls.on { opacity: 1; border-width: 2px; box-shadow: var(--shadow); }
.cls.c1.on { border-color: var(--green); background: #ECFDF5; } .cls.c2.on { border-color: var(--amber); background: #FFFBEB; } .cls.c3.on { border-color: var(--red); background: #FEF2F2; }
.cls-name { font-weight: 700; color: var(--ink); } .cls-p { font: 600 24px var(--serif); color: var(--navy); }
.cls .pbar span { background: var(--navy); }
.de-scale { margin-top: 14px; }
.scale { position: relative; display: flex; height: 24px; border-radius: 4px; overflow: visible; margin-top: 6px; font-size: 11px; font-weight: 700; }
.scale span { display: grid; place-items: center; color: #fff; }
.scale .zA { width: 30%; background: var(--green); border-radius: 4px 0 0 4px; } .scale .zB { width: 30%; background: #D97706; } .scale .zC { width: 40%; background: var(--red); border-radius: 0 4px 4px 0; }
.scale i { position: absolute; top: -6px; width: 4px; height: 36px; background: var(--navy); border-radius: 2px; transform: translateX(-2px); box-shadow: 0 0 0 2px #fff; }
.ticks { position: relative; height: 14px; font-size: 10.5px; color: var(--faint); }
.ticks span { position: absolute; transform: translateX(-50%); } .ticks span:first-child { left: 0; transform: none; }
.checks { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); }
.check .ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; background: var(--faint); }
.check.pass { background: #ECFDF5; border-color: #A7F3D0; } .check.pass .ico { background: var(--green); }
.check.fail { background: #FEF2F2; border-color: #FECACA; } .check.fail .ico { background: var(--red); }
.check.warn { background: #FFFBEB; border-color: #FDE68A; } .check.warn .ico { background: #D97706; }
.check.info .ico { background: var(--blue); }
.empty-state { text-align: center; padding: 40px 20px; } .empty-state .big { font-size: 40px; }
table.whatif { width: 100%; border-collapse: separate; border-spacing: 4px; }
table.whatif th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 600; }
table.whatif td { text-align: center; border-radius: 6px; padding: 10px 4px; }
table.whatif td b { display: block; font-size: 16px; } table.whatif td span { font-size: 11px; font-weight: 700; }
table.whatif td.gA { background: #D1FAE5; color: #065F46; } table.whatif td.gB { background: #FEF3C7; color: #92400E; } table.whatif td.gC { background: #FEE2E2; color: #991B1B; }
table.whatif td.cur { outline: 3px solid var(--navy); }
.form-result { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.fr-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rule-card { border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 6px; padding: 12px 14px; background: #fff; }
.rule-card.applied { border-left-color: #6D28D9; background: #FAF5FF; }
.rule-card .rid { font-size: 11px; font-weight: 700; color: #6D28D9; letter-spacing: .05em; }
.rule-card b { color: var(--ink); } .rule-card p { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
@media (max-width: 1000px) { .wx-grid, .fgrid { grid-template-columns: 1fr; } }

/* ------------------------------------------------ Trust: grounding, guardrails, evals */
.trust-badge { border: 0; font: 600 11.5px var(--sans); padding: 3px 9px; border-radius: 999px; cursor: pointer; }
.trust-badge.hi { background: #DCFCE7; color: #166534; } .trust-badge.mid { background: #FEF3C7; color: #92400E; } .trust-badge.lo { background: #FEE2E2; color: #991B1B; }
.trust-sec { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 12px; background: #fff; }
.ts-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ts-h b { font-family: var(--serif); font-size: 15px; color: var(--ink); }
.ts-score { font: 700 14px var(--sans); padding: 1px 9px; border-radius: 999px; }
.ts-score.hi { background: #DCFCE7; color: #166534; } .ts-score.mid { background: #FEF3C7; color: #92400E; } .ts-score.lo { background: #FEE2E2; color: #991B1B; }
.tm-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0; }
.tm-bar { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.tm-bar span { display: block; height: 100%; border-radius: 999px; }
.tm-bar.hi span { background: #16A34A; } .tm-bar.mid span { background: #D97706; } .tm-bar.lo span { background: #DC2626; }
.tm-row b { text-align: right; }
.ts-note { font-size: 12px; padding: 6px 8px; border-radius: 5px; margin-top: 6px; }
.ts-note.ok { background: #F0FDF4; color: #166534; } .ts-note.warn { background: #FFFBEB; color: #92400E; }
.claims { margin-top: 8px; font-size: 12px; } .claims summary { cursor: pointer; color: var(--blue); }
.claim { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.cl-st { width: 16px; flex: none; font-weight: 700; } .claim.grounded .cl-st { color: #16A34A; } .claim.uncited .cl-st { color: var(--faint); } .claim.unsupported .cl-st { color: #DC2626; }
.cl-nums { margin-top: 3px; } .num { font-size: 10.5px; padding: 0 6px; border-radius: 3px; margin-right: 4px; background: #F1F5F9; }
.num.exact { background: #DCFCE7; color: #166534; } .num.derived { background: #E0F2FE; color: #075985; } .num.other-source { background: #FEF3C7; color: #92400E; } .num.unsupported { background: #FEE2E2; color: #991B1B; }
.gr { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.gr:last-child { border-bottom: 0; }
.gr-i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; background: var(--faint); flex: none; margin-top: 1px; }
.gr.passed .gr-i { background: #16A34A; } .gr.applied .gr-i { background: var(--blue); } .gr.corrected .gr-i { background: #7C3AED; } .gr.flagged .gr-i { background: #D97706; } .gr.blocked .gr-i { background: #DC2626; }
.gr-st { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

.claim.matched .cl-st { color: #0369A1; }
.via { font-size: 10px; color: #0369A1; background: #E0F2FE; padding: 0 5px; border-radius: 3px; }

.fig-sec-h { font: 600 13px var(--sans); color: var(--ink); margin: 12px 0 6px; } .fig-sec-h span { font-weight: 400; font-size: 11px; color: var(--faint); margin-left: 4px; }
.ev-card.rel { border-style: dashed; }

.ev-card pre.sql { white-space: pre; overflow-x: auto; max-height: 260px; line-height: 1.45; }
