/* ═════════════════════════════════════════════════════════════
   BriefProposal SPA — Phase 1A
   Mobile-first. Editorial-minimal. DM Sans + Crimson Pro display.
   ═════════════════════════════════════════════════════════════ */

:root {
  --font-sans:    'DM Sans', system-ui, sans-serif;
  --font-display: 'Crimson Pro', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  --bg:           #f7f8fa;
  --surface:      #ffffff;
  --surface2:     #f2f3f7;
  --border:       #e4e6ed;
  --border2:      #d0d3df;

  --text1:        #12141a;
  --text2:        #5a5f72;
  --text3:        #9299af;

  --accent:       #2563eb;
  --accent-bg:    #eff4ff;
  --accent-border:#bfcffc;

  --pass:         #16a34a;
  --pass-bg:      #f0fdf4;
  --warn:         #d97706;
  --warn-bg:      #fffbeb;
  --fail:         #dc2626;
  --fail-bg:      #fef2f2;

  --topbar-h:     56px;
  --tabbar-h:     60px;
  --sidenav-w:    260px;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;

  --shadow-1:     0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);
  --shadow-2:     0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text1);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); font-size: 0.85em; padding: 1px 6px; background: var(--surface2); border-radius: 4px; }
pre { font-family: var(--font-mono); font-size: 0.8em; white-space: pre-wrap; word-break: break-word; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════ */

#app { min-height: 100dvh; }

/* TOP BAR */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
}
.topbar__menu {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text2);
}
.topbar__menu:hover { background: var(--surface2); color: var(--text1); }
.topbar__brand {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.topbar__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text1);
  color: white;
  border-radius: 8px;
  letter-spacing: 0.02em;
}
.topbar__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__actions { display: flex; gap: 8px; align-items: center; }
.topbar__link {
  font-size: 13px;
  color: var(--text2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: 0.15s;
}
.topbar__link:hover { color: var(--text1); border-color: var(--border2); background: var(--surface2); }

/* SIDE NAV */
.sidenav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidenav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 50;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top);
}
.sidenav.is-open { transform: translateX(0); box-shadow: var(--shadow-2); }
.sidenav__head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidenav__brand {
  display: flex; gap: 10px; align-items: center;
}
.sidenav__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text1); color: white; border-radius: 8px;
}
.sidenav__name {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}
.sidenav__sub {
  display: block;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sidenav__close {
  width: 32px; height: 32px;
  font-size: 24px;
  color: var(--text2);
  border-radius: 50%;
}
.sidenav__close:hover { background: var(--surface2); color: var(--text1); }

.sidenav__nav { padding: 12px 8px; flex: 1; }
.sidenav__group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  padding: 16px 12px 6px;
  font-weight: 600;
}
.navitem {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  transition: 0.12s;
}
.navitem:hover { background: var(--surface2); color: var(--text1); }
.navitem.is-active {
  background: var(--accent-bg);
  color: var(--accent);
}
.navitem__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; font-size: 13px; color: var(--text3);
}
.navitem.is-active .navitem__icon { color: var(--accent); }
.navitem__pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--surface2);
  color: var(--text2);
  border-radius: 10px;
  font-family: var(--font-mono);
}
.navitem__pill.is-pass { background: var(--pass-bg); color: var(--pass); }
.navitem__pill.is-warn { background: var(--warn-bg); color: var(--warn); }
.navitem__pill.is-fail { background: var(--fail-bg); color: var(--fail); }

.sidenav__foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.sidenav__hint {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
}
.sidenav__hint a { color: var(--accent); }

.drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }

/* MAIN VIEW */
.view {
  padding: 20px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  max-width: 100%;
  min-height: calc(100dvh - var(--topbar-h));
}

/* BOTTOM TAB BAR (mobile only) */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
}
.tabitem {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 4px;
  transition: color 0.12s;
}
.tabitem:hover { color: var(--text1); }
.tabitem.is-active { color: var(--accent); }
.tabitem svg { stroke-width: 1.6; }

/* ═══════════════════════════════════════════════════════════
   PAGE PRIMITIVES
   ═══════════════════════════════════════════════════════════ */

.page { max-width: 920px; margin: 0 auto; }
.page__head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.page__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page__lede {
  color: var(--text2);
  margin: 8px 0 24px;
  font-size: 15px;
  max-width: 64ch;
}
.page__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* BUTTON */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text1);
  font-size: 14px;
  font-weight: 500;
  transition: 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface2); border-color: var(--border2); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--text1);
  color: white;
  border-color: var(--text1);
}
.btn--primary:hover { background: #1f2937; border-color: #1f2937; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card__kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  font-weight: 600;
}
.card__score {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card__body { color: var(--text2); margin-bottom: 14px; font-size: 14px; }
.card__foot { margin-top: 12px; }
.card--feature {
  background: linear-gradient(180deg, var(--accent-bg), var(--surface) 60%);
  border-color: var(--accent-border);
}

/* GRID */
.grid { display: grid; gap: 14px; }
.grid--cards { grid-template-columns: 1fr; }

/* KEY-VALUE LIST */
.kv { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--text3); }
.kv dd { color: var(--text1); font-weight: 500; font-family: var(--font-mono); font-size: 13px; }

/* BULLET LIST */
.bullets { list-style: none; padding: 0; }
.bullets li {
  position: relative;
  padding: 6px 0 6px 20px;
  font-size: 14px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.bullets li:last-child { border-bottom: 0; }
.bullets li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--text3);
  font-family: var(--font-mono);
}

/* MUTED */
.muted { color: var(--text3); font-size: 14px; }

/* ═══════════════════════════════════════════════════════════
   VALIDATOR PAGE
   ═══════════════════════════════════════════════════════════ */

.banner {
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}
.banner__score {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.banner__num {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.banner__num.is-pass { color: var(--pass); }
.banner__num.is-warn { color: var(--warn); }
.banner__num.is-fail { color: var(--fail); }
.banner__den { color: var(--text3); font-size: 18px; font-weight: 500; }
.banner__meta { display: flex; gap: 18px; font-size: 13px; color: var(--text2); }
.banner__meta strong { font-family: var(--font-mono); color: var(--text1); }
.banner__when { font-size: 12px; color: var(--text3); font-family: var(--font-mono); }

.cats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.cat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.cat__head:hover { background: var(--surface2); }
.cat__icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.cat__icon.is-pass { background: var(--pass); }
.cat__icon.is-warn { background: var(--warn); }
.cat__icon.is-fail { background: var(--fail); }
.cat__title { flex: 1; min-width: 0; }
.cat__name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.cat__desc {
  font-size: 12px;
  color: var(--text3);
}
.cat__counts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.cat__chevron {
  color: var(--text3);
  font-size: 18px;
  transition: transform 0.2s;
}
.cat.is-open .cat__chevron { transform: rotate(90deg); }

.cat__body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 4px 0;
}
.cat.is-open .cat__body { display: block; }

.finding {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.finding:last-child { border-bottom: 0; }
.finding__sev {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
}
.finding__sev.is-pass { color: var(--pass); }
.finding__sev.is-warn { color: var(--warn); }
.finding__sev.is-fail { color: var(--fail); }
.finding__title { font-weight: 500; }
.finding__loc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  word-break: break-all;
}
.finding__detail { color: var(--text2); margin-top: 2px; }
.finding__hint {
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--accent-bg);
  border-left: 2px solid var(--accent);
  font-size: 12px;
  color: var(--text2);
  border-radius: 0 4px 4px 0;
}

.raw {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.raw summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--text2);
}
.raw pre {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  max-height: 420px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   PROGRESS DOCK + TOAST
   ═══════════════════════════════════════════════════════════ */

.progress-dock {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  z-index: 60;
  box-shadow: var(--shadow-2);
  animation: slideUp 0.25s ease;
}
.progress-dock__head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.progress-dock__label { font-weight: 600; font-size: 14px; }
.progress-dock__pct  { font-family: var(--font-mono); font-size: 13px; color: var(--text2); }
.progress-dock__bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-dock__bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0;
}
.progress-dock__detail {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--font-mono);
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text1);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 70;
  box-shadow: var(--shadow-2);
  animation: toastIn 0.2s ease;
}
.toast.is-pass { background: var(--pass); }
.toast.is-warn { background: var(--warn); }
.toast.is-fail { background: var(--fail); }
@keyframes toastIn { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ═══════════════════════════════════════════════════════════
   DESKTOP / TABLET BREAKPOINTS
   Mobile-first means desktop is the override.
   ═══════════════════════════════════════════════════════════ */

@media (min-width: 720px) {
  html { font-size: 16px; }
  .grid--cards { grid-template-columns: repeat(2, 1fr); }
  .page__head { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .banner {
    grid-template-columns: auto 1fr auto;
    align-items: center;
  }
}

@media (min-width: 1024px) {
  .topbar__menu { display: none; }
  .sidenav {
    position: sticky;
    top: 0;
    height: 100dvh;
    transform: none;
  }
  .sidenav__close { display: none; }
  .drawer-scrim { display: none !important; }
  .tabbar { display: none; }
  .view {
    padding-bottom: 32px;
  }
  /* layout = sidenav left, content right */
  #app {
    display: grid;
    grid-template-columns: var(--sidenav-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "side topbar"
      "side main";
    min-height: 100dvh;
  }
  .topbar { grid-area: topbar; }
  .sidenav { grid-area: side; }
  .view    { grid-area: main; padding: 28px 32px; }
  .progress-dock { right: 24px; left: auto; width: 360px; bottom: 24px; }
  .toast { bottom: 32px; }
  .grid--cards { grid-template-columns: repeat(3, 1fr); }
  .page__title { font-size: 34px; }
}

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

/* ═══════════════════════════════════════════════════════════
   PHASE 1B — Ingest, Ask, Hallucination Meter
   ═══════════════════════════════════════════════════════════ */

/* DOC TYPE PICKER */
.docpick { display: flex; flex-direction: column; gap: 8px; }
.docpick__opt {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: 0.12s;
}
.docpick__opt:hover { border-color: var(--border2); background: var(--surface2); }
.docpick__opt input { accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.docpick__opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.docpick__name { font-weight: 600; font-size: 14px; }
.docpick__sub  { color: var(--text3); font-size: 12px; margin-top: 2px; }

/* DROPZONE */
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
  background: var(--surface2);
}
.dropzone:hover, .dropzone:focus, .dropzone.is-drag {
  border-color: var(--accent);
  background: var(--accent-bg);
  outline: none;
}
.dropzone__icon {
  font-size: 28px;
  color: var(--text3);
  font-family: var(--font-display);
}
.dropzone__title { font-weight: 600; font-size: 15px; margin-top: 6px; }
.dropzone__hint  { color: var(--text3); font-size: 12px; margin-top: 4px; }

/* FILE LIST */
.filelist {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.filelist__row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.filelist__row:last-child { border-bottom: 0; }
.filelist__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist__size { color: var(--text3); font-family: var(--font-mono); font-size: 12px; }
.filelist__status {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  font-weight: 600;
  background: var(--surface2); color: var(--text2);
}
.filelist__status.is-pass { background: var(--pass-bg); color: var(--pass); }
.filelist__status.is-fail { background: var(--fail-bg); color: var(--fail); }

/* FIELD */
.field { display: block; }
.field__label {
  display: block; font-size: 12px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  margin-bottom: 6px;
}
.field__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text1);
  font-size: 14px;
  font-family: var(--font-sans);
}
.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
textarea.field__input { resize: vertical; min-height: 70px; }

/* ANSWER */
.askanswer {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* HALLUCINATION METER */
.hallu__band {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text2);
}
.hallu__band.is-green { background: var(--pass-bg); color: var(--pass); }
.hallu__band.is-amber { background: var(--warn-bg); color: var(--warn); }
.hallu__band.is-red   { background: var(--fail-bg); color: var(--fail); }
.hallu__row {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 14px;
}
.hallu__bar {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: var(--surface2);
  overflow: hidden;
  position: relative;
}
.hallu__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pass), var(--warn) 50%, var(--fail));
  border-radius: 6px;
  transition: width 0.4s ease;
  width: 0;
}
.hallu__score {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.hallu__den { color: var(--text3); font-size: 14px; }

.hallu__components {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.hallu__comp {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.hallu__comp__name { font-weight: 500; }
.hallu__comp__val  {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}
.hallu__comp__val.is-pass { color: var(--pass); }
.hallu__comp__val.is-warn { color: var(--warn); }
.hallu__comp__val.is-fail { color: var(--fail); }

.hallu__details summary {
  cursor: pointer; font-size: 13px; color: var(--text2); margin-top: 12px;
}
.hallu__explain {
  font-size: 13px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text2);
  line-height: 1.55;
}
.hallu__explain h4 { font-size: 13px; margin: 6px 0 2px; color: var(--text1); }

/* CITATIONS */
.citations {
  margin: 0; padding: 0; list-style: none;
  counter-reset: cit;
  display: flex; flex-direction: column; gap: 8px;
}
.citations li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}
.citations li::before {
  counter-increment: cit;
  content: "[" counter(cit) "]";
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}
.citations__name {
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.citations__meta {
  font-family: var(--font-mono);
  color: var(--text3);
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.citations__view-btn {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 8px;
  border: 1px solid var(--accent-border, #c7d7f0);
  background: var(--accent-bg, #eef3fc);
  color: var(--accent, #2563eb);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: background .12s, color .12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.citations__view-btn:hover {
  background: var(--accent, #2563eb);
  color: #fff;
}
.citations__excerpt {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 4px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

@media (min-width: 720px) {
  .docpick { flex-direction: row; }
  .docpick__opt { flex: 1; }
  .hallu__components { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   PHASE 2 — Cases, Court Dates, Briefs, Modals
   ═══════════════════════════════════════════════════════════ */

/* FILTER BAR (chip toggles) */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 14px;
}
.filterbar__chip {
  display: inline-flex; align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  background: var(--surface);
  transition: 0.12s;
}
.filterbar__chip:has(input:checked) {
  background: var(--text1); color: white; border-color: var(--text1);
}
.filterbar__chip input { display: none; }

/* CASE ROW */
.caserow {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: 0.12s;
}
.caserow:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.caserow__main { flex: 1; min-width: 0; }
.caserow__name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.caserow__meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; align-items: center; }
.caserow__next { font-family: var(--font-mono); font-size: 12px; flex-shrink: 0; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface2);
  color: var(--text2);
}
.badge--active   { background: var(--accent-bg); color: var(--accent); }
.badge--won      { background: var(--pass-bg);   color: var(--pass); }
.badge--settled  { background: var(--accent-bg); color: var(--accent); }
.badge--closed   { background: var(--surface2);  color: var(--text2); }
.badge--lost     { background: var(--fail-bg);   color: var(--fail); }
.badge--draft    { background: var(--surface2);  color: var(--text2); }
.badge--review   { background: var(--warn-bg);   color: var(--warn); }
.badge--filed    { background: var(--pass-bg);   color: var(--pass); }
.badge--superseded { background: var(--surface2); color: var(--text3); text-decoration: line-through; }
.badge--scheduled { background: var(--accent-bg); color: var(--accent); }
.badge--completed { background: var(--pass-bg);   color: var(--pass); }
.badge--adjourned { background: var(--warn-bg);   color: var(--warn); }
.badge--cancelled { background: var(--surface2);  color: var(--text3); }

/* CASE FOLDER (3-panel) */
.case-folder {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.case-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.case-pane__head {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.case-pane__head::after {
  content: "▾";
  color: var(--text3);
  font-size: 13px;
  transition: transform 0.2s;
}
.case-pane[open] .case-pane__head::after { transform: rotate(180deg); }
.case-pane__body {
  padding: 0 16px 16px;
  display: flex; flex-direction: column; gap: 10px;
}

/* TIMELINE */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline__item {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.timeline__item:last-child { border-bottom: 0; }
.timeline__date {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text2); font-weight: 500;
}
.timeline__title {
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.timeline__meta { font-size: 12px; }
.timeline__note {
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text2);
}
.timeline__item--completed .timeline__date { color: var(--pass); }
.timeline__item--cancelled .timeline__date { color: var(--text3); text-decoration: line-through; }

/* BRIEF CARD */
.brief { transition: 0.12s; }
.brief:hover { border-color: var(--accent); }
.brief__versions { margin-top: 10px; font-size: 12px; }
.brief__versions summary { cursor: pointer; color: var(--text2); font-weight: 500; }
.brief__versions ul {
  margin-top: 6px; padding-left: 16px;
  color: var(--text3);
}
.brief__versions li { padding: 2px 0; font-family: var(--font-mono); font-size: 11px; }

/* DOC LIST in case folder */
.doclist__row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.doclist__row:last-child { border-bottom: 0; }
.doclist__name { font-weight: 500; }
.doclist__meta { font-family: var(--font-mono); font-size: 11px; margin-top: 2px; }

/* MODAL */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.5);
  animation: fadeIn 0.2s ease;
}
.modal__panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.25s ease;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.modal__panel--wide { max-width: 920px; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
}
.modal__head h2 { font-size: 18px; font-weight: 600; }
.modal__body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex; flex-direction: column; gap: 12px;
}
.modal__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* INLINE HALLUCINATION PILL (in brief modal) */
.hallu-inline {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.hallu-inline__label { font-weight: 500; }
.hallu-inline__score {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700;
}

/* Desktop layout for case folder: 3 columns */
@media (min-width: 1024px) {
  .case-folder { grid-template-columns: 1fr 1.2fr 1fr; align-items: start; }
  .case-pane { position: sticky; top: 16px; max-height: calc(100vh - 80px); overflow-y: auto; }
  .modal { align-items: center; }
  .modal__panel { border-radius: var(--radius-lg); max-height: 85vh; }
}

/* ═══════════════════════════════════════════════════════════
   PHASE 10/11 — Auth: login screen, user menu, change-password
   Mobile-first: full-screen panel; desktop: centred card.
   ═══════════════════════════════════════════════════════════ */

.loginpage {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
}
.login__panel {
  width: 100%;
  max-width: 420px;
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login__brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.login__mark {
  width: 44px; height: 44px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: var(--font-display);
}
.login__name { font-weight: 700; font-size: 20px; }
.login__sub  { color: var(--text3); font-size: 13px; }
.login__submit { margin-top: 8px; width: 100%; }
.login__hint {
  font-size: 12px; color: var(--text3);
  margin-top: 8px; line-height: 1.5;
}
.login__hint code {
  background: var(--surface2);
  padding: 1px 4px; border-radius: 3px; font-size: 11px;
}
.login__error {
  background: var(--fail-bg);
  color: var(--fail);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--fail);
}

/* Top-bar user menu */
.topbar__user {
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.topbar__user:hover { border-color: var(--accent); }
.topbar__userinitial {
  width: 28px; height: 28px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.topbar__useremail {
  font-weight: 500;
  max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__userrole {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
}
@media (max-width: 720px) {
  .topbar__useremail, .topbar__userrole { display: none; }
}

.usermenu {
  position: fixed;
  top: 60px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  z-index: 50;
  min-width: 200px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.usermenu[hidden] { display: none; }
.topbar__user[hidden] { display: none; }

/* Password reveal toggle ------------------------------------- */
.field__pwwrap {
  position: relative;
  display: block;
}
.field__pwwrap .field__input {
  width: 100%;
  padding-right: 44px;
}
.field__pwtoggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  color: var(--text2);
  border-radius: 4px;
  user-select: none;
}
.field__pwtoggle:hover { background: var(--surface2); color: var(--text); }
.field__pwtoggle:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field__pwtoggle.is-on { color: var(--accent); }

/* Extraction-failures modal ---------------------------------- */
.ef-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ef-modal[hidden] { display: none; }
.ef-modal__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.ef-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.ef-modal__title { margin: 0; font-size: 18px; }
.ef-modal__body { padding: 20px; font-size: 13px; }
.usermenu__item {
  background: none;
  border: 0;
  padding: 12px 16px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.usermenu__item:last-child { border-bottom: 0; }
.usermenu__item:hover { background: var(--surface2); }

@media (min-width: 720px) {
  .login__panel { padding: 36px 32px; }
}

/* ═══════════════════════════════════════════════════════════
   PHASE 10/11 PART B + Phase 3 — additional styles
   ═══════════════════════════════════════════════════════════ */

.login__success {
  background: var(--pass-bg);
  color: var(--pass);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--pass);
  white-space: pre-wrap;
}

.codeblock {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  overflow-x: auto;
}

.kv {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.kv > div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--text3); margin: 0; font-weight: 500; }
.kv dd { margin: 0; }

/* ═══════════════════════════════════════════════════════════════
   CONVERSE WITH AI — redesigned chat UI
   ═══════════════════════════════════════════════════════════════ */

/* Page shell — fills the viewport column, flex column */
.ask-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);   /* full height minus topbar */
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ── History scroll area ─────────────────────────────────────── */
.ask-history {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* ── Empty state ─────────────────────────────────────────────── */
.ask-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 60px 24px 40px;
  flex: 1;
}
.ask-empty__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
}
.ask-empty__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text1);
  margin: 0;
}
.ask-empty__sub {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  max-width: 360px;
  margin: 0;
}

/* ── Suggestion chips ────────────────────────────────────────── */
.ask-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.ask-chip {
  font-size: 12px;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: var(--font-sans);
}
.ask-chip:hover {
  background: var(--surface2);
  color: var(--text1);
  border-color: var(--border2);
}

/* ── Message rows ────────────────────────────────────────────── */
.ask-msg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: askFadeIn .2s ease;
}
@keyframes askFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ask-msg-row--user { align-items: flex-end; }
.ask-msg-row--ai   { align-items: flex-start; }

.ask-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
}
.ask-bubble--user {
  background: var(--text1);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.ask-bubble--error {
  background: #fff5f5;
  color: #a02a2a;
  border: 1px solid #fec5c5;
  border-bottom-left-radius: 4px;
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
}
.ask-msg-meta {
  font-size: 11px;
  color: var(--text3);
  padding: 0 4px;
  font-family: var(--font-mono);
}

/* ── Thinking stream ─────────────────────────────────────────── */
.ask-thinking {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ask-thinking__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
}
.ask-thinking__dots {
  display: flex;
  gap: 4px;
}
.ask-thinking__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text2);
  animation: askDotPulse 1.4s ease-in-out infinite;
}
.ask-thinking__dot:nth-child(2) { animation-delay: .2s; }
.ask-thinking__dot:nth-child(3) { animation-delay: .4s; }
@keyframes askDotPulse {
  0%,80%,100% { opacity: .2; transform: scale(.8); }
  40%          { opacity: 1;  transform: scale(1);  }
}
.ask-thinking__steps {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ask-thinking__step {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text3);
  transition: color .2s;
}
.ask-thinking__step svg { flex-shrink: 0; }
.ask-thinking__step--active { color: var(--text1); font-weight: 500; }
.ask-thinking__step--done   { color: #2a8642; }
.ask-thinking__step--done svg { stroke: #2a8642; }
.ask-thinking__pbar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.ask-thinking__pfill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .45s ease;
}

/* ── Answer card ─────────────────────────────────────────────── */
.ask-answer-card {
  max-width: 88%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  overflow: hidden;
}
.ask-answer-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.ask-answer-card__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-family: var(--font-mono);
}
.ask-answer-card__badge--restored {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  opacity: 0.7;
}
.ask-answer-card__latency {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  margin-left: auto;
}
.ask-hallu-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.ask-hallu-badge--low  { background: #f0faf3; color: #2a8642; border: 1px solid #c3e6cb; }
.ask-hallu-badge--mid  { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.ask-hallu-badge--high { background: #fff5f5; color: #a02a2a; border: 1px solid #fec5c5; }

.ask-answer-card__body {
  padding: 16px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text1);
  white-space: pre-wrap;
  word-break: break-word;
}

/* winner / near-tie badges */
.ask-winner-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
}
.ask-neartie-bar {
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-left: 3px solid #b08c39;
  background: #fff8e8;
  color: #5a4400;
  font-size: 12.5px;
  border-radius: 0 6px 6px 0;
}

/* compare panel inside answer card */
.ask-compare-wrap {
  padding: 0 16px 12px;
}
.ask-compare-wrap details summary {
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
  padding: 6px 0;
}
#askCompareList {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Citations row ───────────────────────────────────────────── */
.ask-answer-card__cit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.ask-cit-label {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  margin-right: 4px;
}
.ask-cit-tag {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  cursor: pointer;
  font-family: var(--font-mono);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Answer card action bar ──────────────────────────────────── */
.ask-answer-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.ask-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .12s, color .12s;
}
.ask-action-btn:hover { background: var(--surface2); color: var(--text1); }
.ask-action-btn--active { color: var(--accent); border-color: var(--accent-border); }

/* ── RAG Log button — inline next to Answer / restored labels ── */
.ask-rag-log-btn {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent-border, #c7d7f0);
  background: var(--accent-bg, #eef3fc);
  color: var(--accent, #2563eb);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
  text-decoration: none;
  margin-left: 6px;
}
.ask-rag-log-btn:hover {
  background: var(--accent, #2563eb);
  color: #fff;
}
.ask-rag-log-btn--unavailable {
  cursor: default;
  opacity: 0.4;
  pointer-events: none;
}
.ask-rag-log-btn--entry {
  font-size: 10px;
  padding: 1px 6px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ── Hallucination details card (after answer card) ─────────── */
.ask-hallu-card {
  max-width: 88%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

/* ── Full citations card ─────────────────────────────────────── */
.ask-citations-card {
  max-width: 88%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.ask-citations-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

/* ── Compose bar ─────────────────────────────────────────────── */
.ask-compose {
  padding: 12px 20px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;  /* needed for askComposeOverlay absolute positioning */
}
.ask-compose__box {
  border: 1px solid var(--border2);
  border-radius: 20px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  overflow: hidden;
}
.ask-compose__box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.ask-compose__ta {
  width: 100%;
  padding: 14px 18px 10px;
  font-size: 14px;
  line-height: 1.5;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text1);
  resize: none;
  min-height: 50px;
  max-height: 200px;
  font-family: var(--font-sans);
  display: block;
}
.ask-compose__ta::placeholder { color: var(--text3); }
.ask-compose__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 10px;
}
.ask-consensus-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-sans);
}
.ask-consensus-toggle input { accent-color: var(--accent); }
.ask-consensus-hint {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  margin-left: 2px;
}
.ask-compose__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.ask-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.ask-icon-btn:hover { background: var(--surface2); color: var(--text1); }
.ask-icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.ask-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--text1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: opacity .15s;
  flex-shrink: 0;
}
.ask-send-btn:hover   { opacity: .82; }
.ask-send-btn:disabled { opacity: .35; cursor: not-allowed; }
.ask-compose__hint {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin: 7px 0 0;
}

/* ── Voice modal (bottom sheet) ──────────────────────────────── */
.ask-voice-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: askFadeIn .18s ease;
}
.ask-voice-sheet {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 40px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 -4px 32px rgba(0,0,0,.12);
  animation: askSlideUp .22s ease;
}
@keyframes askSlideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.ask-voice-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background .2s;
}
.ask-voice-ring--active {
  background: #fff5f5;
}
.ask-voice-ring--active::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid #e53e3e;
  animation: askRipple 1.2s ease-out infinite;
  opacity: .5;
}
@keyframes askRipple { 0%{transform:scale(1);opacity:.5} 100%{transform:scale(1.45);opacity:0} }
.ask-voice-ring svg { color: var(--text2); transition: color .2s; }
.ask-voice-ring--active svg { color: #e53e3e; }
.ask-voice-status {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
}
.ask-voice-transcript {
  font-size: 13px;
  color: var(--text2);
  min-height: 18px;
  max-width: 300px;
  line-height: 1.45;
}
.ask-voice-btns {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.ask-voice-stop {
  padding: 10px 28px;
  border-radius: 20px;
  border: none;
  background: var(--text1);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
}
.ask-voice-cancel {
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-sans);
}


/* ── Answer card full width ──────────────────────────────── */
.ask-answer-card {
  max-width: 100% !important;
  width: 100%;
}
.ask-hallu-card,
.ask-citations-card {
  max-width: 100% !important;
  width: 100%;
}

/* ── Inline hallucination meter in answer header ─────────── */
.ask-hallu-inline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  margin-right: 12px;
}
.ask-hallu-inline__meter {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.ask-hallu-inline__fill {
  height: 100%;
  border-radius: 2px;
  transition: width .4s;
}
.ask-hallu-inline__label {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 8px;
}

/* ── Citation tag with view button ──────────────────────── */
.ask-cit-tag-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ask-cit-view-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: background .12s;
}
.ask-cit-view-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Document viewer sheet ───────────────────────────────── */
.ask-doc-viewer-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 32px rgba(0,0,0,.14);
  animation: askSlideUp .22s ease;
}
.ask-doc-viewer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.ask-doc-viewer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ask-doc-viewer-page {
  font-size: 12px;
  color: var(--text2);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.ask-doc-viewer-frame {
  flex: 1;
  border: none;
  width: 100%;
}

/* ── Save to Brief modal ─────────────────────────────────── */
.ask-brief-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  margin: 0 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
  animation: askFadeIn .18s ease;
}
.ask-brief-select,
.ask-brief-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text1);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .15s;
}
.ask-brief-select:focus,
.ask-brief-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}


/* ── My Briefs SPA layout ────────────────────────────────── */
.briefs-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 700px) {
  .briefs-layout { grid-template-columns: 1fr; }
}
.briefs-list-col { display: flex; flex-direction: column; gap: 6px; }
.brief-spa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.brief-spa-card:hover { border-color: var(--border2); background: var(--surface2); }
.brief-spa-card--active { border-color: var(--accent); background: var(--accent-bg); }
.brief-spa-card__title { font-weight: 600; font-size: 13px; color: var(--text1); margin-bottom: 4px; }
.brief-spa-card__meta  { font-size: 11px; color: var(--text2); display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.brief-spa-card__date  { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }
.brief-spa-status { font-size: 10px; padding: 1px 6px; border-radius: 6px; }
.brief-spa-status--draft  { background: var(--surface2); color: var(--text3); }
.brief-spa-status--final  { background: #f0faf3; color: #2a8642; }

/* ── Brief entry blocks ──────────────────────────────────── */
.brief-entry-block       { padding: 4px 0; }
.brief-entry-block--hidden {
  opacity: 0.55;
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 6px,
    rgba(255,193,7,0.06) 6px, rgba(255,193,7,0.06) 12px
  );
  border-radius: 6px;
  padding: 4px 8px;
}
.brief-entry-block__head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.brief-entry-block__num  { font-family: var(--font-mono); font-size: 11px; color: var(--accent); background: var(--accent-bg); padding: 2px 6px; border-radius: 4px; flex-shrink: 0; margin-top: 1px; }
.brief-entry-block__q    { font-weight: 600; font-size: 13px; color: var(--text1); line-height: 1.4; }
.brief-entry-block__ans  { font-size: 13px; color: var(--text2); line-height: 1.65; white-space: pre-wrap; margin-bottom: 10px; max-height: 180px; overflow-y: auto; }
.brief-entry-block__notes { font-size: 12px; margin-top: 8px; resize: vertical; }
.brief-entry-cits        { margin-bottom: 10px; }
.brief-entry-cits__label { font-size: 11px; font-weight: 600; color: var(--text3); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.brief-entry-cit         { font-size: 12px; color: var(--text2); padding: 3px 0; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }


/* ── Session brief bar (auto-save indicator) ─────────────── */
.ask-session-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: #f0faf3;
  border-bottom: 1px solid #c3e6cb;
  font-size: 12px;
  color: #2a5f3a;
  flex-shrink: 0;
}
.ask-session-bar svg { stroke: #2a8642; flex-shrink: 0; }
.ask-session-bar__label { color: #2a5f3a; }
.ask-session-bar__name {
  font-weight: 600;
  color: #1a4a2a;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline dotted;
  font-family: var(--font-sans);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ask-session-bar__name:hover { color: #2a8642; }
.ask-session-bar__sep { color: #a8c8b0; }
.ask-session-bar__link {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #2a8642;
  padding: 0;
  font-family: var(--font-sans);
  text-decoration: underline dotted;
}
.ask-session-bar__link:hover { color: #1a4a2a; }

/* ── Brief list enhancements ─────────────────────────────── */
.brief-spa-card__titlerow {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}
.brief-spa-rename {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text3);
  padding: 0 2px;
  flex-shrink: 0;
  margin-top: -1px;
  line-height: 1;
}
.brief-spa-rename:hover { color: var(--accent); }
.brief-spa-badge--auto {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  background: #f0faf3;
  color: #2a8642;
  border: 1px solid #c3e6cb;
  margin-bottom: 5px;
  letter-spacing: .02em;
}
.brief-spa-card--auto {
  border-left: 3px solid #c3e6cb;
}
.brief-spa-card--auto.brief-spa-card--active {
  border-left-color: #2a8642;
}


/* ── Metadata Review page ────────────────────────────────── */
.mrv-overview { margin-bottom: 16px; }
.mrv-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.mrv-ov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .12s;
}
.mrv-ov-card:hover { border-color: var(--border2); }
.mrv-ov-card--active { border-color: var(--accent); background: var(--accent-bg); }
.mrv-ov-card__title { font-size: 12px; font-weight: 600; color: var(--text1); margin-bottom: 8px; }
.mrv-ov-card__bar {
  height: 4px; background: var(--border); border-radius: 2px;
  overflow: hidden; display: flex; margin-bottom: 6px;
}
.mrv-ov-card__fill { height: 100%; transition: width .3s; }
.mrv-ov-card__meta { font-size: 11px; color: var(--text2); }

.mrv-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.mrv-field-tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.mrv-field-tab {
  font-size: 12px; padding: 5px 12px; border-radius: 16px;
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text2); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  font-family: var(--font-sans);
}
.mrv-field-tab:hover { background: var(--surface2); color: var(--text1); }
.mrv-field-tab--active {
  background: var(--accent-bg); color: var(--accent);
  border-color: var(--accent-border); font-weight: 600;
}
.mrv-filters { display: flex; gap: 8px; align-items: center; }

.mrv-stats-bar {
  font-size: 12px; color: var(--text2); padding: 6px 0 10px;
  display: flex; gap: 16px; flex-wrap: wrap;
  font-family: var(--font-mono);
}

.mrv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mrv-table th {
  text-align: left; padding: 10px 12px;
  background: var(--surface2); color: var(--text2);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mrv-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.mrv-row:hover td { background: var(--surface2); }
.mrv-val-cell { max-width: 380px; }
.mrv-val-display {
  display: block; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: text;
}
.mrv-val-input { width: 100%; min-width: 200px; }
.mrv-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
  font-family: var(--font-mono);
}
.mrv-actions { display: flex; gap: 4px; white-space: nowrap; }

.mrv-pagination {
  display: flex; gap: 6px; align-items: center;
  margin-top: 16px; flex-wrap: wrap;
}


/* ── Brief-first session start ───────────────────────────── */
.ask-brief-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 520px;
}
.ask-brief-start__input-row {
  display: flex;
  gap: 10px;
  width: 100%;
}
.ask-brief-start__input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text1);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ask-brief-start__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.ask-brief-start__btn {
  padding: 10px 20px;
  border-radius: 12px;
  border: none;
  background: var(--text1);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: opacity .15s;
}
.ask-brief-start__btn:hover { opacity: .85; }
.ask-brief-start__or {
  font-size: 12px;
  color: var(--text3);
}

/* ── MRV action status ───────────────────────────────────── */
#mrvActionStatus {
  transition: opacity .3s;
}


/* ── MRV progress animations ─────────────────────────────── */
@keyframes mrvSyncAnim {
  from { width: 20%; }
  to   { width: 90%; }
}

/* ── Critical: .navitem and .sidenav__group have display rules that beat
   the HTML [hidden] attribute. These !important overrides fix that. ──────── */
.navitem[hidden]        { display: none !important; }
.sidenav__group[hidden] { display: none !important; }

/* ── Auth shell visibility — JS-controlled, overrides all breakpoints ───── */
.sidenav--hidden { display: none !important; }
.tabbar--hidden  { display: none !important; }

/* ── Wallet hidden before login ──────────────────────────────────────────── */
body:not(.is-authed) #bp-wallet-widget { display: none !important; }

/* When not authenticated, collapse the sidenav grid column so the
   login page fills the full width */
@media (min-width: 1024px) {
  body:not(.is-authed) #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
}
