/* ── Nautilus design tokens v2.0 ─────────────────────────────── */
:root {
  /* Primary brand */
  --color-navy:               #0E1F3D;
  --color-navy-mid:           #1B2E45;
  --color-navy-light:         #2A4060;

  /* Accent — sage */
  --color-iris:               #A1B0AB;
  --color-iris-soft:          #C9DAD4;
  --color-iris-muted:         #E7EEEC;

  /* Surfaces */
  --color-surface:            #EAE6DE;
  --color-surface-raised:     #F5F2EC;
  --color-surface-sidebar:    #FFFFFF;
  --color-surface-panel:      #FFFFFF;
  --color-surface-input:      #FFFFFF;
  --color-surface-nav:        #FFFFFF;
  --color-surface-file:       #F5F7F6;  /* file attachment chip tint */
  --color-surface-overlay:    rgba(0,0,0,0.45);  /* modal backdrop */

  /* Borders */
  --color-border:             #D4CFC5;
  --color-border-subtle:      #E2DDD6;
  --color-border-strong:      #B8B3A9;  /* emphasis / hover state */
  --color-border-neutral:     #E5E5E5;  /* cool gray dividers, form separators */
  --color-border-file:        #D0D9D6;  /* file attachment chip border */

  /* Text */
  --color-text-primary:       #0E1F3D;
  --color-text-secondary:     #4A5568;
  --color-text-hint:          #8A95A3;
  --color-text-disabled:      #AAAAAA;
  --color-text-on-navy:       #FFFFFF;
  --color-text-on-navy-muted: #94A3B8;
  --color-text-on-dark-muted: rgba(255,255,255,0.75); /* secondary text on dark navbar */

  /* Interactive states */
  --color-interactive-hover:         rgba(14,31,61,0.06);  /* generic hover background */
  --color-interactive-active:        rgba(14,31,61,0.08);  /* nav/tab selected wash */
  --color-interactive-hover-on-dark: rgba(255,255,255,0.10); /* hover bg on dark navbar */

  /* Navigation text hierarchy — alpha tints of navy, auto-follow palette swaps */
  --color-nav-text:           color-mix(in srgb, var(--color-navy) 50%, transparent);
  --color-nav-text-hover:     color-mix(in srgb, var(--color-navy) 85%, transparent);
  --color-nav-text-muted:     color-mix(in srgb, var(--color-navy) 40%, transparent);
  --color-nav-text-ghost:     color-mix(in srgb, var(--color-navy) 28%, transparent);
  --color-border-faint:       color-mix(in srgb, var(--color-navy) 12%, transparent);
  --color-accent-faint:       color-mix(in srgb, var(--color-iris) 30%, transparent);

  /* Semantic status */
  --color-success:            #15803D;
  --color-warning:            #92400E;
  --color-danger:             #C8102E;
  --color-burgundy:           #7F1D1D;  /* urgent CTA (no jurisdiction set) */

  /* Semantic role tokens — each independently swappable per palette */
  --color-role-interactive:      #6B7E79;                     /* pane selectors, tabs, nav active, focus rings */
  --color-role-interactive-soft: var(--color-iris-muted);
  --color-role-pinned:           #A1B0AB;                     /* starred/pinned source cards, pin button */
  --color-role-pinned-soft:      #E7EEEC;
  --color-role-chip:             var(--color-iris);           /* citation chips, workflow chips, doc tags */
  --color-role-chip-soft:        var(--color-iris-muted);
  --color-role-chip-text:        var(--color-navy);
  --color-role-message:          var(--color-navy);           /* user chat bubble text */
  --color-role-message-soft:     #FAF8F3;                     /* user chat bubble background — warm off-white */
  --color-role-cta:              #A1B0AB;                     /* primary action buttons */
  --color-role-cta-hover:        #7AA396;

  /* Result card states */
  --color-state-pinned-bg:      var(--color-role-pinned-soft);
  --color-state-pinned-border:  var(--color-role-pinned);
  --color-state-relevant-bg:    #F0FDF4;
  --color-state-relevant-border:#86EFAC;
  --color-state-mentioned-bg:   #DBEAFE;
  --color-state-mentioned-border:#93C5FD;
  /* Vote / inline-rating states */
  --color-state-accept-bg:          #DCFCE7;
  --color-state-accept-border:      #4ADE80;
  --color-state-accept-border-soft: #BBF7D0;
  --color-state-reject-bg:          #FEE2E2;
  --color-state-reject-border:      #F87171;
  --color-state-reject-border-soft: #FECACA;
  --color-state-flag-bg:            #FFF7ED;
  --color-state-flag-border:        #FB923C;
  --color-state-flag-text:          #C2410C;
  --color-state-accept-tint:        color-mix(in srgb, var(--color-success) 8%, transparent);
  --color-state-reject-tint:        color-mix(in srgb, var(--color-danger)  8%, transparent);
  /* Vote card states — olive (relevant/check) vs teal (starred/pin) */
  --vote-relevant-accent:           #336500;
  --vote-relevant-glyph:            #123F00;
  --vote-relevant-bg:               #E5EBE1;
  --vote-relevant-bg-hover:         #D3DFC8;
  --vote-relevant-border:           #427700;
  --vote-star-accent:               #006C5D;
  --vote-star-glyph:                #00574A;
  --vote-star-bg:                   #C9E6DF;
  --vote-star-bg-hover:             #B1D4CD;
  --vote-star-border:               #006C5D;
  --vote-idle-border:               var(--color-border);
  --vote-idle-glyph:                var(--color-text-hint);

  /* Risk score bars */
  --color-risk-high:            #D97706;
  --color-risk-medium:          #CA8A04;
  --color-risk-low:             #16A34A;

  /* Selected / focused surface (light navy tint) */
  --color-surface-selected:     #F2F5F4;
  --color-border-selected:      #C3D5CF;

  /* Table / list row separator */
  --color-border-row:           #F0EEEA;

  /* Primary button hover — one step darker than navy */
  --color-button-primary-hover: #1A3460;

  /* Category palette — bg + fg pairs for chips, badges, doc-type labels */
  --color-cat-navy-bg:        #E5ECF8;  /* drafts, submissions, legal research */
  --color-cat-navy-fg:        #0E1F3D;
  --color-cat-green-bg:       #F0FDF4;  /* output, summaries, chronology */
  --color-cat-green-fg:       #15803D;
  --color-cat-emerald-bg:     #D1FAE5;  /* key points */
  --color-cat-emerald-fg:     #065F46;
  --color-cat-amber-bg:       #FEF3C7;  /* client alerts, review, checklist */
  --color-cat-amber-fg:       #78350F;
  --color-cat-red-bg:         #FDECEA;  /* risk, legal notice */
  --color-cat-red-fg:         #9B1C1C;
  --color-cat-rose-bg:        #FFE4E6;  /* action items */
  --color-cat-rose-fg:        #9F1239;
  --color-cat-purple-bg:      #EDE9F8;  /* argument builder */
  --color-cat-purple-fg:      #4C1D95;
  --color-cat-violet-bg:      #EDE9FE;  /* legal analysis, subject, graph */
  --color-cat-violet-fg:      #5B21B6;
  --color-cat-indigo-bg:      #E0E7FF;  /* legal brief */
  --color-cat-indigo-fg:      #4338CA;
  --color-cat-sky-bg:         #E0F2FE;  /* narrative */
  --color-cat-sky-fg:         #075985;
  --color-cat-teal-bg:        #CCFBF1;  /* legal letters */
  --color-cat-teal-fg:        #0F766E;
  --color-cat-slate-bg:       #F1F5F9;  /* memo */
  --color-cat-slate-fg:       #475569;
  --color-cat-gray-bg:        #F0F0F0;  /* neutral / default */
  --color-cat-gray-fg:        #555555;

  /* Typography */
  --font-sans:                'Inter', system-ui, sans-serif;
  --font-serif:               'Lora', Georgia, serif;
  --font-mono:                ui-monospace, monospace;

  /* Border radius */
  --radius-sm:                4px;
  --radius-badge:             6px;
  --radius-md:                8px;
  --radius-lg:                12px;
  --radius-xl:                16px;
  --radius-pill:              999px;

  /* Shadows */
  --shadow-sm:                0 1px 3px rgba(14,31,61,0.08);
  --shadow-md:                0 4px 12px rgba(14,31,61,0.10);
  --shadow-lg:                0 8px 24px rgba(14,31,61,0.12);

  /* Legacy aliases — keep existing CSS working */
  --canvas:       var(--color-surface);
  --surface:      var(--color-surface-panel);
  --surfaceAlt:   var(--color-surface-raised);
  --ink:          var(--color-text-primary);
  --ink2:         var(--color-navy-mid);
  --muted:        var(--color-text-secondary);
  --border:       var(--color-border);
  --borderStrong: var(--color-border-strong);
  --rule:         var(--color-border-subtle);
  --accent:       var(--color-role-interactive);
  --accentHover:  var(--color-iris-soft);
  --accentSoft:   var(--color-role-interactive-soft);
  --accentInk:    var(--color-navy);
  --good:         var(--color-success);
  --warn:         var(--color-warning);
  --bad:          var(--color-danger);
  --radius:       var(--radius-md);
  --hint:         var(--color-text-hint);
  --disabled:     var(--color-text-disabled);

}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* ── App shell ──────────────────────────────────────────────── */

#app {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── Left sidebar ───────────────────────────────────────────── */

#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-surface-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
  border-right: 0.5px solid var(--color-border);
}

#sidebar.collapsed { width: 56px; }
#sidebar.collapsed .sidebar-top {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  height: auto;
}
#sidebar.collapsed .sidebar-brand  { justify-content: center; width: 100%; }
#sidebar.collapsed .logo-wordmark  { display: none; }
#sidebar.collapsed .logo-mark      { display: none; }
#sidebar.collapsed .sidebar-nav    { padding-left: 0; padding-right: 0; }
#sidebar.collapsed .sidebar-nav-main { padding-left: 0; padding-right: 0; }
#sidebar.collapsed .sidebar-footer { padding-left: 0; padding-right: 0; justify-content: center; }

.sidebar-top {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.logo-mark {
  color: var(--ink);
  flex-shrink: 0;
  opacity: 1;
  display: block;
}

.logo-wordmark {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-navy);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#sidebar-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, transform 0.2s ease;
}
#sidebar-toggle:hover { color: var(--color-text-secondary); background: var(--color-surface-raised); }
#sidebar.collapsed #sidebar-toggle { transform: rotate(180deg); }

/* Hide labels when collapsed */
.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s, max-width 0.2s;
  max-width: 160px;
}
#sidebar.collapsed .sidebar-label {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

.create-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.25rem 0.6rem 0.5rem;
  padding: 0.48rem 0.7rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--color-nav-text-hover);
  font-size: 0.84rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.create-btn:hover { background: var(--color-interactive-hover); color: var(--ink); }
#sidebar.collapsed .create-btn { justify-content: center; padding: 0.48rem 0; margin: 0.25rem 0 0.6rem; gap: 0; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.15rem 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.7rem;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-nav-text);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  width: 100%;
  position: relative;
}
.nav-item:hover { background: var(--color-surface-raised); color: var(--color-nav-text-hover); }
.nav-item.active {
  background: var(--color-role-interactive-soft);
  color: var(--color-role-interactive);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--color-role-interactive);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { flex-shrink: 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 0.52rem 0; gap: 0; }

/* Sidebar workflow sub-items */
.sidebar-workflows { display: flex; flex-direction: column; gap: 0.08rem; padding: 0.1rem 0; }
.sidebar-workflow-item { font-size: 0.78rem; padding: 0.42rem 0.7rem 0.42rem 1.2rem; color: var(--color-nav-text-muted); }
.sidebar-wf-icon { display: flex; align-items: center; flex-shrink: 0; }
.sidebar-wf-icon svg { width: 15px; height: 15px; }
.sidebar-workflow-item.active { color: var(--ink); background: var(--color-interactive-active); font-weight: 600; }
#sidebar.collapsed .sidebar-workflow-item { justify-content: center; padding: 0.42rem 0; gap: 0; }
.sidebar-tools-divider { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-nav-text-ghost); padding: 0.8rem 1.2rem 0.3rem; }
#sidebar.collapsed .sidebar-tools-divider { display: none; }
.sidebar-tool-item { padding-left: 0.85rem; }

/* ── Vertical phase stepper ───────────────────────────────── */
.phase-track { display: flex; flex-direction: column; padding: 0.5rem 0 0.2rem; }
.phase-track-item { display: flex; align-items: center; gap: 0.7rem; background: none; border: none; cursor: pointer; padding: 0.28rem 0.7rem 0.28rem 0.85rem; text-align: left; width: 100%; transition: background 0.12s; }
.phase-track-item:hover { background: var(--color-interactive-hover); }
.phase-track-icon { display: flex; align-items: center; flex-shrink: 0; color: var(--color-nav-text-muted); transition: color 0.15s; }
.phase-track-icon svg { width: 15px; height: 15px; }
.phase-track-connector { width: 1.5px; height: 12px; background: var(--color-border-faint); margin-left: calc(0.85rem + 7px); }
.phase-track-label { font-size: 0.78rem; color: var(--color-nav-text-muted); transition: color 0.15s; }
.phase-track-item.active .phase-track-icon { color: var(--ink); }
.phase-track-item.active .phase-track-label { color: var(--ink); font-weight: 600; }
.phase-track-item:hover .phase-track-icon { color: var(--color-nav-text-hover); }
#sidebar.collapsed .phase-track-item { justify-content: center; padding: 0.28rem 0; }
#sidebar.collapsed .phase-track-label { display: none; }
#sidebar.collapsed .phase-track-connector { margin-left: calc(50% - 0.75px); }


.sidebar-spacer {
  flex: 1;
}

.sidebar-nav-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  overflow-x: hidden;
  padding: 0 0.5rem 0.1rem;
  min-height: 0;
}

#sidebar-history {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-faint) transparent;
}

.sidebar-nav-header {
  color: var(--color-nav-text);
  font-size: 0.78rem;
  font-weight: 400;
}
.sidebar-nav-header.active {
  background: var(--color-role-interactive-soft);
  color: var(--color-role-interactive);
  font-weight: 500;
}
.sidebar-nav-header:hover { background: var(--color-surface-raised); color: var(--color-nav-text-hover); }

.sidebar-nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: 0 0.5rem;
  flex-shrink: 0;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.5rem;
  border-top: 1px solid var(--color-border-subtle);
}

.sidebar-global-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem 0;
}

.sidebar-ctrl-btn {
  font-size: 0.72rem;
  color: var(--color-nav-text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: inherit;
}
.sidebar-ctrl-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

.sidebar-signout {
  color: var(--color-nav-text);
  font-size: 0.75rem;
}
.sidebar-signout:hover { color: var(--ink); }

.sidebar-account-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.sidebar-account-name {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-account-role {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-role-interactive);
  color: var(--surface);
  font-size: 0.68rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

/* ── Main area ──────────────────────────────────────────────── */

#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────── */

#topbar {
  width: 44px;
  flex-shrink: 0;
  background: var(--color-surface-panel);
  border-left: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 2px;
}

.topbar-left { flex-shrink: 0; }

.topbar-workflow-id {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}

.topbar-workflow-star {
  color: var(--bad);
  font-size: 0.6rem;
  line-height: 1;
}

.topbar-nautilus {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
}

#topbar-workflow-label {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}


.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.topbar-link {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--hint);
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  transition: color 0.12s;
}
.topbar-link:hover { color: var(--ink); background: var(--color-surface-raised); }
.topbar-matter-summary { color: var(--ink); font-weight: 600; }
.topbar-matter-summary:hover { background: var(--color-interactive-active); }

/* Hide chat panel on chatless phases */
body.phase-chatless #chat-panel { display: none !important; }

/* Thread regenerate bar */
.thread-regen-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 1rem 0.45rem 1.1rem; border-bottom: 1px solid var(--color-border-neutral); background: var(--surface); gap: 0.75rem; flex-shrink: 0; }
.thread-regen-label { font-size: 0.72rem; color: var(--color-nav-text); letter-spacing: 0.02em; }
.thread-regen-btn { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 600; color: var(--ink); background: none; border: 1px solid var(--color-border-faint); border-radius: 4px; padding: 0.28rem 0.65rem; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.thread-regen-btn:hover { background: var(--color-interactive-hover); border-color: var(--color-nav-text-muted); }
.draft-regen-btn { border: none; font-size: 0.7rem; padding: 0.2rem 0.5rem; }

.analytics-btn {
  background: none;
  border: none;
  color: var(--hint);
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.analytics-btn:hover { color: var(--ink); background: var(--color-surface-raised); }

/* ── Language selector ──────────────────────────────────────── */

#lang-selector { display: none; }

.lang-dropdown {
  position: relative;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  line-height: 1;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  transition: border-color 0.12s, background 0.12s;
}
.lang-code {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}
.lang-btn svg { opacity: 0.6; }
.lang-btn:hover {
  border-color: var(--color-iris-soft);
  background: var(--color-surface-raised);
}
.lang-btn:hover .lang-code { color: var(--color-text-primary); }
.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-surface-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 140px;
  z-index: 200;
}
.lang-menu.open { display: block; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.lang-option:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }
.lang-option.active { background: var(--color-role-interactive-soft); font-weight: 500; color: var(--color-role-interactive); }


/* ── Domain toggle ──────────────────────────────────────────── */

.domain-toggle {
  display: flex;
  border: 1px solid var(--color-border-neutral);
  border-radius: 6px;
  overflow: hidden;
}
.domain-btn {
  background: none;
  border: none;
  color: var(--hint);
  padding: 0.28rem 0.8rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.domain-btn + .domain-btn { border-left: 1px solid var(--color-border-neutral); }
.domain-btn:hover  { color: var(--ink); background: var(--color-surface-raised); }
.domain-btn.active { color: var(--ink); background: var(--color-interactive-active); font-weight: 600; }

/* ── Workspace ──────────────────────────────────────────────── */

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  gap: 0;
  margin: 0;
  border: none;
}

/* ── Workspace panels (3-pane collapsible layout) ───────────── */

.workspace-panel {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transition: flex 0.2s ease;
  min-width: 0;
}

.workspace-panel.panel-collapsed { flex: 0 0 36px !important; }

/* Collapsed strip: hidden by default, grows to 36px when panel collapses */
.panel-collapsed-strip {
  flex: 0 0 0px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: flex 0.2s ease;
  background: var(--surface);
  border-right: 1px solid var(--color-border-neutral);
  color: var(--borderStrong);
}
.workspace-panel.panel-collapsed .panel-collapsed-strip {
  flex: 0 0 36px;
}
.panel-collapsed-strip:hover { color: var(--hint); background: var(--color-surface-raised); }

.panel-strip-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.6rem;
  font-weight: 700;
  color: inherit;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Panel main: inner column container */
.panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transition: flex 0.2s ease;
}
.workspace-panel.panel-collapsed .panel-main { flex: 0 0 0px; }

/* Panel collapse/expand buttons */
.panel-collapse-btn {
  background: none;
  border: none;
  color: var(--color-border-neutral);
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.panel-collapse-btn:hover { color: var(--muted); background: var(--color-surface-raised); }

#pane-toggles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}
.pane-toggle-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 1px solid var(--color-border-neutral);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.pane-toggle-btn svg { width: 17px; height: 17px; }
.pane-toggle-btn::after { display: none; }
.pane-toggle-btn:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }
.pane-toggle-btn.active { color: var(--color-role-interactive); background: var(--color-role-interactive-soft); border-color: var(--color-iris); }


/* ── Chat panel ─────────────────────────────────────────────── */

#chat-panel { flex: 1 1 0; }

#chat-panel .panel-main {
  background: var(--canvas);
  border: none;
  overflow: hidden;
  position: relative;
}
#chat-panel.chatting .panel-main { background: var(--surface); }

/* Chat collapse button: absolute top-right, visible in chat mode */
.chat-collapse-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  display: none;
}
body.chatting-active #chat-main .chat-collapse-btn { display: flex; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.msg-user      { align-self: flex-end; }
.msg-assistant { align-self: flex-start; }

.msg-label {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.msg-content {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.msg-user .msg-content {
  background: var(--color-cat-violet-bg);
  color: var(--ink);
  border-bottom-right-radius: 3px;
}

.msg-assistant .msg-content {
  background: var(--color-cat-violet-bg);
  color: var(--ink);
  border-bottom-left-radius: 3px;
}

/* Markdown in AI messages */
.msg-assistant .msg-content h1,
.msg-assistant .msg-content h2,
.msg-assistant .msg-content h3 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0.8rem 0 0.3rem;
}
.msg-assistant .msg-content h1:first-child,
.msg-assistant .msg-content h2:first-child,
.msg-assistant .msg-content h3:first-child { margin-top: 0; }
.msg-assistant .msg-content p { margin-bottom: 0.5rem; }
.msg-assistant .msg-content p:last-child { margin-bottom: 0; }
.msg-assistant .msg-content ul,
.msg-assistant .msg-content ol { padding-left: 1.25rem; margin-bottom: 0.5rem; }
.msg-assistant .msg-content li { margin-bottom: 0.2rem; }
.msg-assistant .msg-content strong { font-weight: 600; }

/* Typing indicator */
.msg-typing {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 2rem;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--disabled);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

@keyframes btn-dots {
  0%   { content: "."; }
  33%  { content: ".."; }
  66%  { content: "..."; }
  100% { content: ""; }
}
.btn-loading::after {
  content: "";
  animation: btn-dots 1.2s steps(1, end) infinite;
  display: inline-block;
  width: 1.2em;
  text-align: left;
}

/* Chat form */
#chat-form {
  flex: none;
  border-top: 1px solid var(--color-border-neutral);
  padding: 0.75rem;
  background: var(--surface);
}

#chat-form textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 6px;
  resize: none;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 0.5rem;
}

#chat-form textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#status {
  font-size: 0.8rem;
  color: var(--hint);
}

button {
  padding: 0.45rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--color-role-cta);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}

button:hover    { background: var(--color-role-cta-hover); }
button:disabled { background: var(--disabled); color: #FFFFFF; cursor: not-allowed; }

/* ── Draft panel ─────────────────────────────────────────────── */

#draft-panel { flex: 1 1 0; }

#draft-panel .panel-main {
  background: var(--surface);
  overflow: hidden;
}

.draft-panel-header {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--color-border-neutral);
  background: var(--color-surface-raised);
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
}

.draft-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.draft-panel-icon {
  color: var(--hint);
  flex-shrink: 0;
}

.draft-doc-type-tag {
  font-size: 0.69rem;
  color: var(--ink);
  background: none;
  border: 1px solid var(--color-border-selected);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.draft-doc-type-tag { display: none !important; }

.draft-header-actions,
.panel-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.panel-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--color-nav-text);
  cursor: pointer;
  position: relative;
}
.panel-icon-btn:hover { background: var(--color-interactive-hover); color: var(--ink); }
.panel-icon-btn::after {
  content: attr(data-label);
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  white-space: nowrap;
  font-size: 0.69rem;
  font-weight: 500;
  background: var(--ink);
  color: var(--surface);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 10;
}
.panel-icon-btn:hover::after { opacity: 1; }

/* Draft setup screen */
#draft-setup, #summary-setup {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}
#draft-panel.draft-active #draft-setup { display: none; }

.draft-setup-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.draft-setup-icon { color: var(--ink); opacity: 0.5; }

.draft-setup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.draft-setup-sub {
  font-size: 0.82rem;
  color: var(--hint);
  margin: -0.75rem 0 0;
}

.draft-setup-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.draft-setup-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--disabled);
}

.draft-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.draft-type-pill {
  background: none;
  border: 1px solid var(--color-border-neutral);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.draft-type-pill:hover { background: var(--color-surface-raised); color: var(--ink); border-color: var(--disabled); }
.draft-type-pill.active { background: var(--color-cat-navy-bg); border-color: var(--ink); color: var(--ink); font-weight: 500; }

.draft-type-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.83rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.draft-type-input:focus { border-color: var(--ink); }
.draft-type-input::placeholder { color: var(--color-border-neutral); }

.draft-tpl-opts {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.draft-tpl-opt {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.draft-tpl-opt:hover { border-color: var(--disabled); background: var(--color-surface-raised); }
.draft-tpl-opt.draft-tpl-selected { border-color: var(--ink); background: var(--color-surface-selected); cursor: default; }
.draft-tpl-opt.draft-tpl-soon { opacity: 0.4; cursor: default; }
.draft-tpl-opt.draft-tpl-soon:hover { border-color: var(--color-border-neutral); background: none; }

.draft-tpl-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
}
.draft-tpl-opt.draft-tpl-selected .draft-tpl-name { color: var(--ink); }

.draft-tpl-desc { font-size: 0.72rem; color: var(--disabled); }

.draft-generate-btn {
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  width: 100%;
}

.draft-upload-zone {
  border: 1.5px dashed var(--color-border-neutral);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--disabled);
  text-align: center;
}
.draft-upload-zone:hover,
.draft-upload-zone.drag-over { border-color: var(--ink); background: var(--color-surface-file); color: var(--ink); }
.draft-upload-text { font-size: 0.8rem; }
.draft-upload-browse { color: var(--ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.draft-upload-hint { font-size: 0.69rem; color: var(--color-border-neutral); }
#draft-file-input { display: none; }

.draft-upload-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.draft-upload-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  background: var(--color-surface-file);
  border: 1px solid var(--color-border-file);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--ink);
}
.draft-upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-upload-remove {
  background: none;
  border: none;
  color: var(--disabled);
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.draft-upload-remove:hover { color: var(--bad); background: none; }

/* ── Chat file upload chips ── */
#chat-file-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.25rem; }
#chat-file-list[hidden] { display: none; }
.chat-file-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem;
  background: var(--color-surface-file);
  border: 1px solid var(--color-border-file);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--ink);
}
.chat-file-chip svg { flex-shrink: 0; color: var(--hint); }
.chat-file-chip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.chat-file-remove {
  background: none;
  border: none;
  color: var(--disabled);
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.chat-file-remove:hover { color: var(--bad); background: none; }
.chat-file-chip.chip-uploading { opacity: 0.7; }
.chat-file-chip.chip-uploading .chat-file-chip-name::after { content: " (uploading…)"; font-style: italic; color: var(--hint); }
.draft-upload-item.uploading { opacity: 0.7; }
.draft-upload-item.uploading .draft-upload-item-name::after { content: " (uploading…)"; font-style: italic; color: var(--hint); }

.msg-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--color-surface-file);
  border: 1px solid var(--color-border-file);
  border-radius: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
  cursor: default;
}
.msg-file-badge svg { flex-shrink: 0; }
.msg-file-badge-clickable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.msg-file-badge-clickable:hover {
  background: var(--color-surface-selected);
  border-color: var(--color-border-selected);
}

.draft-setup-note {
  font-size: 0.73rem;
  color: var(--color-border-neutral);
  line-height: 1.5;
  text-align: center;
  margin: -0.5rem 0 0;
}

/* ── Shared panel header (all 4 Argument Builder panes) ──────── */

.panel-header {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--color-border-neutral);
  background: var(--color-surface-raised);
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
  width: 100%;
}


.panel-header-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  flex: 1;
}

.panel-header-title--raleway {
  font-family: var(--font-sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-header-title--upper {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  flex: 1;
}

.panel-header-count {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--hint);
  letter-spacing: 0;
  text-transform: none;
}

/* Draft Submission: chat, sources, draft */
#workspace.drafting #chat-panel    { order: 0; }
#workspace.drafting #sources-panel { order: 1; }
#workspace.drafting #draft-panel   { order: 2; }

/* Argument Outline: chat, sources, outline */
#workspace.outlining #chat-panel     { order: 0; }
#workspace.outlining #sources-panel  { order: 1; }
#workspace.outlining #outline-panel  { display: flex !important; flex: 1 1 0; order: 2; }

/* Summary: chat, sources, summary */
#workspace.summary-active #chat-panel     { order: 0; }
#workspace.summary-active #sources-panel  { order: 1; }
#workspace.summary-active #summary-panel  { display: flex !important; flex: 1 1 0; order: 2; }

/* Remove home-state horizontal padding so the full-width header aligns to panel edges */
#chat-panel .panel-main { padding: 0; }

/* Hide the floating absolute collapse button — header has its own */
#chat-panel.chatting .chat-collapse-btn { display: none !important; }

#chat-panel-header { display: none; }
#chat-panel.chatting #chat-panel-header { display: flex; }
#sources-panel-header { display: flex; }

/* ── Argument Builder: Outline panel ────────────────────────── */

#outline-panel { flex: 1 1 0; }

#outline-panel .panel-main {
  background: var(--surface);
  border-right: 1px solid var(--color-border-neutral);
  overflow: hidden;
}


.outline-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.outline-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.outline-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.outline-claim-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 70px;
  border: 1px solid var(--color-border-neutral);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--color-surface-raised);
  transition: border-color 0.12s, background 0.12s;
}
.outline-claim-input:focus { outline: none; border-color: var(--ink); background: var(--surface); }

.outline-entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.outline-entry-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-border-neutral);
  min-width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.outline-entry-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-border-neutral);
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font-size: 0.83rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--color-surface-raised);
  transition: border-color 0.12s, background 0.12s;
}
.outline-entry-input:focus { outline: none; border-color: var(--ink); background: var(--surface); }
.outline-entry-counter { border-color: var(--color-state-reject-bg); background: var(--color-state-reject-bg); }
.outline-entry-counter:focus { border-color: var(--bad) !important; }

.outline-entry-remove {
  background: none !important;
  border: none !important;
  color: var(--color-border-neutral);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.1s;
}
.outline-entry-remove:hover { color: var(--bad); background: none !important; }

.outline-add-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px dashed var(--color-border-neutral);
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  font-family: inherit;
  color: var(--disabled);
  cursor: pointer;
  align-self: flex-start;
  transition: border-color 0.12s, color 0.12s;
}
.outline-add-btn:hover { border-color: var(--ink); color: var(--ink); }

.outline-build-btn {
  padding: 0.58rem 1rem;
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  margin-top: 0.25rem;
}

/* ── Summary panel ───────────────────────────────────────────── */
.summary-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  padding: 1.5rem;
}
.summary-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--disabled);
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
  min-height: 200px;
}
.summary-content {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--ink);
}
.summary-content h1, .summary-content h2, .summary-content h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1em;
  font-weight: 600;
}
.summary-content p { margin: 0 0 0.75rem; }
.summary-content ul, .summary-content ol { margin: 0 0 0.75rem; padding-left: 1.4em; }

/* ── Client Alert panels ─────────────────────────────────────── */

#workspace.client-alert-active #draft-panel,
#workspace.client-alert-active #outline-panel,
#workspace.client-alert-active #chat-panel,
#workspace.client-alert-active #sources-panel { display: none !important; }

#workspace.client-alert-active #alert-form-panel,
#workspace.client-alert-active #alert-preview-panel { display: flex !important; }

#alert-form-panel  { flex: 1 1 0; }
#alert-preview-panel { flex: 1 1 0; }

#alert-form-panel .panel-main {
  background: var(--surface);
  border-right: 1px solid var(--color-border-neutral);
  overflow: hidden;
}

#alert-preview-panel .panel-main {
  background: var(--surface);
  overflow: hidden;
}

.alert-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.alert-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.alert-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--color-surface-raised);
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-input:focus { border-color: var(--ink); background: var(--surface); }

.alert-textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--color-surface-raised);
  resize: vertical;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-textarea:focus { border-color: var(--ink); background: var(--surface); }

.alert-tone-pills {
  display: flex;
  gap: 0.4rem;
}

.alert-tone-pill {
  padding: 0.32rem 0.8rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 20px;
  background: none;
  font-size: 0.78rem;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.alert-tone-pill:hover { border-color: var(--disabled); color: var(--ink); }
.alert-tone-pill.active { border-color: var(--ink); color: var(--ink); background: var(--color-surface-selected); font-weight: 500; }

.alert-preview-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.alert-preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--disabled);
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.alert-preview-empty strong { color: var(--hint); }

.alert-preview-content {
  flex: 1;
  padding: 2rem;
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--ink);
  overflow-y: auto;
}
.alert-preview-content h1 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; color: var(--ink); }
.alert-preview-content h2 { font-size: 0.9rem; font-weight: 600; margin: 1.2rem 0 0.3rem; color: var(--ink); }
.alert-preview-content h3 { font-size: 0.85rem; font-weight: 600; margin: 1rem 0 0.2rem; }
.alert-preview-content p  { margin-bottom: 0.75rem; }
.alert-preview-content ul { margin: 0.4rem 0 0.75rem 1.2rem; }
.alert-preview-content li { margin-bottom: 0.3rem; }
.alert-preview-content .alert-meta { font-size: 0.75rem; color: var(--hint); margin-bottom: 1.5rem; border-bottom: 1px solid var(--color-border-neutral); padding-bottom: 0.75rem; }

/* ── Generate Chronology panels ─────────────────────────────── */

#workspace.chronology-active #draft-panel,
#workspace.chronology-active #outline-panel,
#workspace.chronology-active #alert-form-panel,
#workspace.chronology-active #alert-preview-panel,
#workspace.chronology-active #chat-panel,
#workspace.chronology-active #sources-panel { display: none !important; }

#workspace.chronology-active #chrono-input-panel,
#workspace.chronology-active #chrono-timeline-panel { display: flex !important; }

#chrono-input-panel   { flex: 1 1 0; }
#chrono-timeline-panel { flex: 1 1 0; }

#chrono-input-panel .panel-main {
  background: var(--surface);
  border-right: 1px solid var(--color-border-neutral);
  overflow: hidden;
}

#chrono-timeline-panel .panel-main {
  background: var(--surface);
  overflow: hidden;
}

.chrono-input-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chrono-upload-zone {
  border: 1.5px dashed var(--color-border-neutral);
  border-radius: 7px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--hint);
  font-size: 0.82rem;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-upload-zone:hover,
.chrono-upload-zone.drag-over { border-color: var(--ink); background: var(--color-surface-file); color: var(--ink); }
.chrono-upload-hint { font-size: 0.72rem; color: var(--disabled); }
.chrono-upload-zone input[type="file"] { display: none; }

.chrono-or {
  text-align: center;
  font-size: 0.72rem;
  color: var(--disabled);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chrono-paste {
  width: 100%;
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--color-surface-raised);
  resize: none;
  outline: none;
  min-height: 160px;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-paste:focus { border-color: var(--ink); background: var(--surface); }

.chrono-timeline-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chrono-timeline-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--disabled);
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.chrono-timeline-empty strong { color: var(--hint); }

.chrono-timeline-list {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chrono-event {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0 1rem;
  position: relative;
  padding-bottom: 1.5rem;
}

.chrono-event::before {
  content: '';
  position: absolute;
  left: 148px;
  top: 6px;
  bottom: 0;
  width: 1px;
  background: var(--color-border-neutral);
}
.chrono-event:last-child::before { display: none; }

.chrono-event-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hint);
  text-align: right;
  padding-top: 2px;
  line-height: 1.4;
}

.chrono-event-dot {
  position: absolute;
  left: 144px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--ink);
}

.chrono-event-content {
  padding-left: 1.25rem;
}

.chrono-event-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.chrono-event-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Transcribe Hearing panels ───────────────────────────────── */

#workspace.transcribe-active #draft-panel,
#workspace.transcribe-active #outline-panel,
#workspace.transcribe-active #alert-form-panel,
#workspace.transcribe-active #alert-preview-panel,
#workspace.transcribe-active #chrono-input-panel,
#workspace.transcribe-active #chrono-timeline-panel,
#workspace.transcribe-active #chat-panel,
#workspace.transcribe-active #sources-panel { display: none !important; }

#workspace.transcribe-active #transcribe-input-panel,
#workspace.transcribe-active #transcribe-output-panel { display: flex !important; }

#transcribe-input-panel  { flex: 1 1 0; }
#transcribe-output-panel { flex: 1 1 0; }

#transcribe-input-panel .panel-main  { background: var(--surface); border-right: 1px solid var(--color-border-neutral); overflow: hidden; }
#transcribe-output-panel .panel-main { background: var(--surface); overflow: hidden; }

.transcribe-input-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transcribe-upload-zone {
  border: 1.5px dashed var(--color-border-neutral);
  border-radius: 7px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--hint);
  font-size: 0.82rem;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.transcribe-upload-zone:hover,
.transcribe-upload-zone.drag-over { border-color: var(--ink); background: var(--color-surface-file); color: var(--ink); }
.transcribe-upload-zone input[type="file"] { display: none; }

.transcribe-file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-surface-selected);
  border: 1px solid var(--color-border-selected);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--ink);
}
.transcribe-file-info span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transcribe-file-remove {
  background: none; border: none; cursor: pointer; color: var(--hint); font-size: 0.9rem; padding: 0 0.2rem;
  line-height: 1; flex-shrink: 0;
}
.transcribe-file-remove:hover { color: var(--bad); }

.transcribe-divider {
  text-align: center;
  font-size: 0.72rem;
  color: var(--disabled);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.transcribe-record-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.transcribe-record-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--color-border-neutral);
  border-radius: 6px;
  background: none;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.transcribe-record-btn:hover { border-color: var(--ink); color: var(--ink); }
.transcribe-record-btn.recording { border-color: var(--bad); color: var(--bad); background: var(--color-state-reject-bg); }
.transcribe-record-btn.recording svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.transcribe-timer {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bad);
  font-variant-numeric: tabular-nums;
}

.transcribe-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.transcribe-progress-label { font-size: 0.78rem; color: var(--muted); }
.transcribe-progress-bar { height: 4px; background: var(--color-border-row); border-radius: 2px; overflow: hidden; }
.transcribe-progress-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.transcribe-output-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.transcribe-output-content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transcribe-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hint);
  margin-top: 0.75rem;
}
.transcribe-section-label:first-child { margin-top: 0; }

.transcribe-summary {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  border-left: 3px solid var(--ink);
  padding: 0.75rem 1rem;
  border-radius: 0 5px 5px 0;
}

.transcribe-transcript {
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--ink);
  white-space: pre-wrap;
  font-family: inherit;
}

/* ── Closing Checklist panels ────────────────────────────────── */

#workspace.checklist-active #draft-panel,
#workspace.checklist-active #outline-panel,
#workspace.checklist-active #alert-form-panel,
#workspace.checklist-active #alert-preview-panel,
#workspace.checklist-active #chrono-input-panel,
#workspace.checklist-active #chrono-timeline-panel,
#workspace.checklist-active #transcribe-input-panel,
#workspace.checklist-active #transcribe-output-panel,
#workspace.checklist-active #chat-panel,
#workspace.checklist-active #sources-panel { display: none !important; }

#workspace.checklist-active #checklist-setup-panel,
#workspace.checklist-active #checklist-list-panel { display: flex !important; }

#checklist-setup-panel { flex: 0 0 320px; }
#checklist-list-panel  { flex: 1 1 0; }

#checklist-setup-panel .panel-main { background: var(--surface); border-right: 1px solid var(--color-border-neutral); overflow: hidden; }
#checklist-list-panel  .panel-main { background: var(--surface); overflow: hidden; }

.checklist-list-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.checklist-list-content {
  flex: 1;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.checklist-category {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checklist-category-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink);
  padding: 0.5rem 0 0.4rem;
  border-bottom: 1px solid var(--color-border-neutral);
  margin-bottom: 0.25rem;
}

.checklist-item {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: start;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--color-border-neutral);
}
.checklist-item:last-child { border-bottom: none; }

.checklist-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--ink);
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.checklist-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.checklist-item-label {
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.4;
}
.checklist-item.done .checklist-item-label { text-decoration: line-through; color: var(--disabled); }

.checklist-item-note {
  font-size: 0.75rem;
  color: var(--hint);
  font-style: italic;
}

.checklist-assignee {
  font-size: 0.72rem;
  color: var(--hint);
  white-space: nowrap;
  padding-top: 2px;
}

.checklist-due {
  font-size: 0.72rem;
  color: var(--hint);
  white-space: nowrap;
  padding-top: 2px;
}

/* ── Assess Risk panels ──────────────────────────────────────── */

#workspace.risk-active #draft-panel,
#workspace.risk-active #outline-panel,
#workspace.risk-active #alert-form-panel,
#workspace.risk-active #alert-preview-panel,
#workspace.risk-active #chrono-input-panel,
#workspace.risk-active #chrono-timeline-panel,
#workspace.risk-active #transcribe-input-panel,
#workspace.risk-active #transcribe-output-panel,
#workspace.risk-active #checklist-setup-panel,
#workspace.risk-active #checklist-list-panel,
#workspace.risk-active #chat-panel,
#workspace.risk-active #sources-panel { display: none !important; }

#workspace.risk-active #risk-input-panel,
#workspace.risk-active #risk-register-panel,
#workspace.risk-active #risk-matrix-panel { display: flex !important; }

#risk-input-panel    { flex: 0 0 280px; }
#risk-register-panel { flex: 1 1 0; }
#risk-matrix-panel   { flex: 0 0 360px; }

#risk-input-panel    .panel-main { background: var(--surface); border-right: 1px solid var(--color-border-neutral); overflow: hidden; }
#risk-register-panel .panel-main { background: var(--surface); border-right: 1px solid var(--color-border-neutral); overflow: hidden; }
#risk-matrix-panel   .panel-main { background: var(--surface); overflow: hidden; }

.risk-register-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.risk-register-table-wrap {
  flex: 1;
  overflow: auto;
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.risk-table th {
  position: sticky;
  top: 0;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border-neutral);
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 1;
}
.risk-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--color-border-neutral);
  vertical-align: top;
  color: var(--ink);
  line-height: 1.4;
}
.risk-table tr:last-child td { border-bottom: none; }
.risk-table tr:hover td { background: var(--color-surface-raised); }

.risk-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.risk-badge-critical { background: var(--color-state-reject-bg); color: var(--bad); }
.risk-badge-high     { background: var(--color-cat-amber-bg); color: var(--warn); }
.risk-badge-medium   { background: var(--color-cat-amber-bg); color: var(--warn); }
.risk-badge-low      { background: var(--color-state-accept-bg); color: var(--good); }

.risk-score {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--surface);
}
.risk-score-critical { background: var(--bad); }
.risk-score-high     { background: var(--color-risk-high); }
.risk-score-medium   { background: var(--color-risk-medium); }
.risk-score-low      { background: var(--color-risk-low); }

.risk-matrix-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 0;
}

.risk-matrix-svg-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.risk-matrix-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
}

/* ── Sources panel ───────────────────────────────────────────── */

#sources-panel { flex: 1 1 0; }

#sources-panel .panel-main {
  background: var(--surface);
  border: none;
  overflow: hidden;
}

/* Collapse btn sits at end of tab-bar */
.sources-collapse-btn { margin-left: auto; }

/* ── Results panel ──────────────────────────────────────────── */

#results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#tab-bar {
  display: flex;
  background: var(--color-surface-panel);
  flex-shrink: 0;
}

#tab-bar .tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0;
  font-size: 0.6875rem;
  font-weight: 400;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  outline: none;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

#tab-bar .tab:hover { color: var(--color-text-primary); background: var(--color-surface-raised); }

#tab-bar .tab.active {
  color: var(--color-text-primary);
  font-weight: 500;
  background: var(--color-interactive-active);
}

.tab-pane {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.25rem 1rem 0;
  min-height: 0;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.card-titles {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.15rem;
  word-break: break-word;
}

.card-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  word-break: break-word;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.source-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--color-cat-navy-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.rank-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--color-state-accept-bg);
  color: var(--good);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.via-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.via-vector { background: var(--color-surface-raised); color: var(--muted); }
.via-graph  { background: var(--color-cat-violet-bg); color: var(--color-cat-violet-fg); }

.score {
  font-size: 0.68rem;
  color: var(--disabled);
  margin-left: auto;
}

.path {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.article-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.via-reason {
  font-size: 0.7rem;
  color: var(--hint);
  margin-bottom: 0.35rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  font-size: 0.67rem;
  font-weight: 600;
}

.chip-law        { background: var(--color-cat-navy-bg); color: var(--ink); }
.chip-type       { background: var(--color-cat-green-bg); color: var(--good); }
.chip-year       { background: var(--color-surface-raised); color: var(--muted);    }
.chip-parties    { background: var(--color-state-flag-bg); color: var(--warn); }
.chip-obligation { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); font-style: italic; }
.chip-subject    { background: var(--color-cat-violet-bg); color: var(--color-cat-violet-fg); }

.excerpt {
  font-size: 0.8rem;
  color: var(--ink);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pdf-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pdf-link:hover { color: var(--ink); }

.doc-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.doc-link:hover { color: var(--ink); }

.graph-ctx {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.graph-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
}

.graph-label { color: var(--hint); white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 500;
}

.tag-law  { background: var(--color-cat-navy-bg); color: var(--ink); }
.tag-case { background: var(--color-cat-amber-bg); color: var(--warn); }

.no-results { font-size: 0.85rem; color: var(--disabled); }

/* ── Sources tab ────────────────────────────────────────────── */

.source-section { margin-bottom: 1.25rem; }

.source-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.source-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--hint);
}

.source-section-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--surface);
  background: var(--ink);
  padding: 0.05rem 0.45rem;
  border-radius: 99px;
}

.source-card {
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--color-surface-raised);
}

.source-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.source-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
  flex: 1;
}

.source-card-abbr {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--color-cat-gray-bg);
  color: var(--color-cat-gray-fg);
}

.source-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-bottom: 0.35rem;
}

.source-card-court-output {
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.6;
  font-weight: 500;
  background: var(--surfaceAlt);
  border-left: 3px solid var(--ink);
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0 0;
  border-radius: 0 4px 4px 0;
}

.source-card-description {
  font-size: 0.75rem;
  color: var(--hint);
  line-height: 1.5;
  font-style: italic;
  margin: 0.4rem 0 0;
}

.source-field {
  display: flex;
  gap: 0.3rem;
  align-items: baseline;
}

.source-field-label {
  font-size: 0.7rem;
  color: var(--hint);
  white-space: nowrap;
}

.source-field-value {
  font-size: 0.78rem;
  color: var(--ink);
}

.source-tags { margin-bottom: 0.35rem; }

.source-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.15rem;
}

.source-tag {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--color-surface-selected);
  color: var(--muted);
}

.source-tag-matched { background: var(--color-state-accept-bg); color: var(--good); }
.source-tag-unmatched { background: var(--color-state-reject-bg); color: var(--bad); }

.source-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--color-border-selected);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.source-doc-btn:hover {
  background: var(--surfaceAlt);
  border-color: var(--ink);
}

.source-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.source-extract-votes {
  display: flex;
  gap: 0.2rem;
  margin-left: auto;
}

.extract-vote-btn {
  border: 1px solid;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.2;
  min-width: 1.6rem;
  text-align: center;
  background: var(--surfaceAlt);
  border-color: var(--color-border-neutral);
  color: var(--disabled);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.extract-vote-good:hover, .extract-vote-good.voted { background: var(--color-state-accept-bg); border-color: var(--color-state-accept-border); color: var(--good); }
.extract-vote-bad:hover,  .extract-vote-bad.voted  { background: var(--color-state-reject-bg); border-color: var(--color-state-reject-border); color: var(--bad); }

.extract-note {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surfaceAlt);
  border: 1px solid var(--color-border-row);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.extract-note::placeholder { color: var(--disabled); }
.extract-note:focus { outline: none; border-color: var(--hint); }
.extract-note-saved { animation: extractNoteSaved 0.9s ease forwards; }
@keyframes extractNoteSaved {
  0%   { border-color: var(--color-state-accept-border); box-shadow: 0 0 0 2px var(--color-state-accept-border-soft); }
  60%  { border-color: var(--color-state-accept-border); box-shadow: 0 0 0 2px var(--color-state-accept-border-soft); }
  100% { border-color: var(--color-border-row); box-shadow: none; }
}

.source-articles-container {
  margin-top: 0.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
}

.articles-chapter-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0.6rem 0 0.3rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--rule);
}

.article-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--surfaceAlt);
}

.article-item:last-child { border-bottom: none; }

.article-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-button-primary-hover);
  margin-bottom: 0.15rem;
}

.article-text {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.article-xrefs {
  margin-top: 0.25rem;
}

/* ── Modal ──────────────────────────────────────────────────── */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-surface-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#modal-overlay[hidden] { display: none; }

#modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem 1.75rem 1.5rem;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
}

#modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--disabled);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
}
#modal-close:hover { background: var(--color-surface-raised); color: var(--ink); }

.modal-path {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.6rem;
  line-height: 1.35;
}

.modal-excerpt {
  font-size: 0.845rem;
  color: var(--ink);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-neutral);
}

.modal-file-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.modal-file-content {
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surfaceAlt);
  border: 1px solid var(--color-border-row);
  border-radius: 6px;
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
}

/* Card clickability */
.card {
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover {
  border-color: var(--color-border-neutral);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.card.result-mentioned {
  border-color: var(--color-state-mentioned-border);
  background: var(--color-state-mentioned-bg);
}

/* Modal vote row */
.modal-vote-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-neutral);
}
.modal-vote-label {
  font-size: 0.78rem;
  color: var(--hint);
}

#version-badge { display: none !important; }

/* ── Sources trust label ─────────────────────────────── */

.sources-trust-label {
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--good);
  background: var(--color-cat-green-bg);
  border-bottom: 1px solid var(--color-state-accept-border-soft);
  padding: 0.35rem 1rem;
  text-align: center;
}


/* ── Responsive ─────────────────────────────────────────────── */

.mobile-indicator { display: none; }

/* Settings gear: hidden on desktop */
.topbar-settings-btn { display: none; }

/* Swipe dots: hidden on desktop */
.workspace-swipe-dots { display: none; }

/* Mobile shortcuts: hidden everywhere except mobile home */
#mobile-shortcuts { display: none; }

/* Mobile tab bar + drawer: hidden on desktop */
#mobile-tab-bar { display: none; }
#mobile-nav-drawer { display: none; }
#mobile-drawer-backdrop { display: none; }

/* Right rail: mobile only uses swipe, no pane toggles needed */
@media (max-width: 640px) { #topbar { display: none !important; } }

/* Mobile history view: hidden by default (JS-managed) */
#mobile-history-view { display: none; }


@media (max-width: 640px) {
  html, body { overflow-x: hidden; }

  /* Hide desktop sidebar — bottom tab bar handles nav */
  #sidebar { display: none; }

  /* Topbar: compact */
  #topbar { padding: 0 0.75rem; }
  #pane-toggles { gap: 0; }
  .pane-toggle-btn { font-size: 0.73rem; padding: 0.25rem 0.5rem; }
  .topbar-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--color-text-on-dark-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
  }
  .topbar-settings-btn:hover { color: var(--surface); background: var(--color-interactive-hover-on-dark); }

  /* Main area: column with tab bar at bottom */
  #main-area { padding-bottom: 0; }

  /* Practice area dropdown hidden on mobile until jurisdiction selected */
  #area-btn:disabled { display: none; }

  /* Hide admin version badge — overlaps tab bar on mobile */
  #version-badge { display: none !important; }



  /* Workspace: horizontal slide between chat and sources */
  #workspace {
    flex-direction: column;
    padding: 0;
    gap: 0;
    overflow: clip;
    position: relative;
  }

  /* On mobile: panels fill the workspace absolutely,
     strips and collapse buttons hidden — swipe dots handle navigation */
  .panel-collapse-btn { display: none; }
  .panel-collapsed-strip { display: none; }
  /* panel-collapsed is a desktop concept — on mobile it makes panel-main zero-width */
  .workspace-panel.panel-collapsed { flex: none !important; }
  .workspace-panel.panel-collapsed .panel-main { flex: 1 !important; }

  /* All swipe panels are absolutely positioned within workspace */
  #chat-panel, #sources-panel,
  #draft-panel, #summary-panel, #outline-panel {
    position: absolute;
    inset: 0;
    flex: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }

  /* When swipe dots are visible, shrink panels so dots don't overlay pane-composer */
  #workspace.results-ready #chat-panel,
  #workspace.results-ready #sources-panel,
  #workspace.results-ready #draft-panel,
  #workspace.results-ready #summary-panel,
  #workspace.results-ready #outline-panel {
    bottom: 34px;
  }

  /* Pane3 panels start off-screen right by default */
  #draft-panel, #summary-panel, #outline-panel {
    transform: translateX(200%);
  }

  #chat-panel .panel-main,
  #sources-panel .panel-main {
    overflow-y: auto;
    height: 100%;
  }

  /* 2-panel positions */
  #workspace.show-chat    #chat-panel    { transform: translateX(0); }
  #workspace.show-chat    #sources-panel { transform: translateX(100%); }
  #workspace.show-sources #chat-panel    { transform: translateX(-100%); }
  #workspace.show-sources #sources-panel { transform: translateX(0); }

  /* Pane3 intermediate positions (so swiping feels continuous) */
  #workspace.show-sources #draft-panel,
  #workspace.show-sources #summary-panel,
  #workspace.show-sources #outline-panel { transform: translateX(100%); }

  /* Show-pane3 state */
  #workspace.show-pane3 #chat-panel      { transform: translateX(-200%); }
  #workspace.show-pane3 #sources-panel   { transform: translateX(-100%); }
  #workspace.show-pane3 #draft-panel,
  #workspace.show-pane3 #summary-panel,
  #workspace.show-pane3 #outline-panel   { transform: translateX(0); }

  /* Swipe dots inside workspace */
  .workspace-swipe-dots {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 7px 0 8px;
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--color-border-row);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }
  .mobile-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .mobile-dot::before {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-border-neutral);
    transition: background 0.2s, transform 0.2s;
  }
  .mobile-dot.active::before {
    background: var(--ink);
    transform: scale(1.4);
  }
  .mobile-dot::after {
    content: attr(data-label);
    font-size: 9px;
    font-family: inherit;
    font-weight: 500;
    color: var(--disabled);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .mobile-dot.active::after {
    color: var(--ink);
    font-weight: 600;
  }

  /* Only show swipe dots when in chatting + results visible state */
  #workspace:not(.results-ready) .workspace-swipe-dots { display: none; }

  /* Sources panel: tab pane padding */
  /* Extra bottom padding so swipe dots don't cover last result card */
  .tab-pane { padding: 0.75rem 0.5rem 2.5rem; }

  /* Mobile history view: full-height scrollable */
  #mobile-history-view {
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    background: var(--color-surface-raised);
    min-height: 0;
  }

  .mvh-header {
    padding: 1.25rem 1.1rem 0.75rem;
    border-bottom: 1px solid var(--color-border-row);
    flex-shrink: 0;
  }

  .mvh-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
  }

  .mvh-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem 2rem;
  }

  .mvh-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
  }
  .mvh-item:hover { border-color: var(--borderStrong); box-shadow: var(--shadow-sm); }
  .mvh-item-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mvh-item-time {
    font-size: 0.72rem;
    color: var(--disabled);
    flex-shrink: 0;
  }
  .mvh-empty {
    padding: 2rem 1.1rem;
    font-size: 0.83rem;
    color: var(--disabled);
    text-align: center;
  }

  /* Workflows view on mobile */
  #workflows-view { padding: 1.25rem 1rem; }
  .wfv-grid { grid-template-columns: repeat(2, 1fr); }
  .wfv-header { max-width: 100%; }

  /* Mobile bottom tab bar */
  #mobile-tab-bar {
    display: flex;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--color-border-neutral);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.5rem 0.25rem 0.4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--disabled);
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.15s;
  }
  .mob-tab:hover { color: var(--muted); }
  .mob-tab.active { color: var(--ink); background: var(--color-interactive-active); font-weight: 600; border-radius: 8px; }
  .mob-tab.active svg { stroke: var(--ink); }

  /* Mobile nav drawer (left slide) */
  #mobile-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 39;
  }
  #mobile-drawer-backdrop.open { display: block; }

  #mobile-nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 72vw;
    max-width: 300px;
    background: var(--surface);
    border-right: 1px solid var(--color-border-neutral);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: env(safe-area-inset-top, 0px);
  }
  #mobile-nav-drawer.open { transform: translateX(0); }

  .mob-drawer-handle { display: none; }

  .mob-drawer-nav {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0 0.5rem;
    flex: 1;
  }

  .mob-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1.5rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }
  .mob-drawer-item:hover { background: var(--color-interactive-active); }
  .mob-drawer-item svg { flex-shrink: 0; stroke: var(--muted); }
  .mob-drawer-item--new { font-weight: 600; color: var(--accent, #2057D6); }
  .mob-drawer-item--new svg { stroke: var(--accent, #2057D6); }
  .mob-drawer-divider { height: 1px; background: var(--color-border-neutral); margin: 0.25rem 1.5rem; }

  /* Fix home brand centering */
  .home-brand-mark { width: 100%; align-items: center; }
  .home-brand-title { justify-content: center; }

  /* Mobile home: centered, input pinned to bottom */
  #chat-panel:not(.chatting) .panel-main {
    display: flex;
    flex-direction: column;
    padding: 0;
  }
  #chat-panel:not(.chatting) #home-header {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 0.5rem;
  }
  #chat-panel:not(.chatting) #chat-form {
    order: 10;
    padding: 0 0.75rem 0.5rem;
    border-top: 1px solid var(--color-border-row);
  }
  #chat-panel:not(.chatting) #home-pills {
    order: 9;
    padding: 0.5rem 0.75rem 0;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  #chat-panel:not(.chatting) #home-pills::-webkit-scrollbar { display: none; }
  #chat-panel:not(.chatting) #home-workflows { display: none; }
  /* Keep home-action-row visible on mobile so Ask/mic buttons are accessible;
     hide only the attach button which isn't useful on mobile home state */
  #chat-panel:not(.chatting) #home-attach-btn { display: none; }

  /* Mobile shortcuts: hidden — buttons not yet implemented */
  #mobile-shortcuts { display: none !important; }

  /* ── History view mobile layout ─────────────────────────────── */
  #history-view .page-topbar {
    padding: 16px 16px 0;
    gap: 10px;
    align-items: flex-start;
  }
  #history-view .page-topbar-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  #history-view #hist-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  #history-view #hist-tabs::-webkit-scrollbar { display: none; }
  #history-view .hist-clear-all-btn { display: none; }
  #history-view .page-topbar-right { padding-top: 2px; }
  #history-view .page-search {
    border-radius: 50%;
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-radius 0.2s, width 0.2s, padding 0.2s;
  }
  #history-view .page-search input { display: none; }
  #history-view .page-search.search-open {
    border-radius: var(--radius);
    width: 180px;
    height: auto;
    padding: 4px 8px;
  }
  #history-view .page-search.search-open input { display: block; width: 100%; }
  #history-view .lv-scroll { padding: 4px 16px 80px; }
  #history-view .hist-item-title { white-space: normal; }

  /* ── Documents view mobile layout ───────────────────────────── */
  #documents-view .page-topbar {
    padding: 16px 16px 0;
    gap: 10px;
    align-items: flex-start;
  }
  #documents-view .page-topbar-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  #documents-view .page-sub { display: none; }
  #documents-view #doc-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  #documents-view #doc-tabs::-webkit-scrollbar { display: none; }
  #documents-view .vault-filters-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 12px;
    gap: 8px;
  }
  #documents-view .vault-filters-row::-webkit-scrollbar { display: none; }
  #documents-view .vault-view-toggle { display: none; }
  /* Search: compact circle icon; expands when .search-open */
  #documents-view .page-topbar-right { padding-top: 2px; }
  #documents-view .page-search {
    border-radius: 50%;
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-radius 0.2s, width 0.2s, padding 0.2s;
  }
  #documents-view .page-search input { display: none; }
  #documents-view .page-search.search-open {
    border-radius: var(--radius);
    width: 180px;
    height: auto;
    padding: 4px 8px;
  }
  #documents-view .page-search.search-open input { display: block; width: 100%; }
  /* Cards: allow title to wrap instead of truncating */
  #documents-view .vdr-title { white-space: normal; }
}

/* ── Phase 2: Home screen ───────────────────────────────────── */

/* Home state: scrollable column, content centered */
#chat-panel:not(.chatting) .panel-main {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 2rem 2.5rem;
}

/* Hide messages and chat footer in home state */
#messages                    { display: none; }
.form-footer                 { display: none; }

/* Chat state: restore panel layout */
#chat-panel.chatting .panel-main { overflow: hidden; }
#chat-panel.chatting #messages       { display: flex; flex: 1; }
#chat-panel.chatting .form-footer    { display: flex; }
#chat-panel.chatting #home-header    { display: none; }
#chat-panel.chatting #home-action-row { display: none; }
#chat-panel.chatting #home-pills     { display: none; }
#chat-panel.chatting #home-workflows { display: none; }

/* Chat state: restore form styling */
#chat-panel.chatting #chat-form {
  border: none;
  border-top: 1px solid var(--color-border-neutral);
  border-radius: 0;
  background: var(--surface);
  padding: 0.75rem;
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: visible;
}
#chat-panel.chatting #chat-form textarea {
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  min-height: unset;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.15s;
}
#chat-panel.chatting #chat-form textarea:focus {
  border-color: var(--ink);
}

/* ── Home header: brand mark ── */

#home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 0 2rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.home-brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.75rem;
}

.home-brand-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.home-star {
  color: var(--bad);
  font-size: 0.72rem;
  line-height: 1;
}

.home-wordmark {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
}

/* Context buttons */

.home-context-btns {
  display: flex;
  gap: 0.5rem;
}

.home-ctx-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.home-ctx-btn:hover { background: var(--color-surface-raised); color: var(--ink); border-color: var(--disabled); }
.home-ctx-btn.vault-active { border-color: var(--ink); color: var(--ink); }

.vault-dropdown { position: relative; }
.vault-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 0.3rem;
  min-width: 160px;
  z-index: 200;
}
.vault-menu.open { display: block; }
.vault-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
}
.vault-option:hover { background: var(--color-surface-raised); }
.vault-option.active { background: var(--color-surface-selected); font-weight: 500; color: var(--ink); }

/* ── Home form: unified input box ── */

#chat-panel:not(.chatting) #chat-form {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  border: 1px solid var(--color-border-neutral);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
  padding: 0;
  border-top: 1px solid var(--color-border-neutral);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

#chat-panel:not(.chatting) #chat-form textarea {
  border: none;
  border-bottom: 1px solid var(--color-border-neutral);
  border-radius: 0;
  padding: 1rem 1.1rem;
  font-size: 0.93rem;
  margin-bottom: 0;
  min-height: 80px;
  background: var(--surface);
}
#chat-panel:not(.chatting) #chat-form textarea:focus {
  outline: none;
  border-color: var(--color-border-neutral);
}

/* Home action row */
#home-action-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface-raised);
  gap: 0.4rem;
}

.home-action-btns {
  display: flex;
  flex: 1;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.home-action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--color-border-neutral);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.home-action-btn:hover { background: var(--color-surface-raised); color: var(--ink); }

#home-ask-btn {
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 0.38rem 1.2rem;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
#home-ask-btn:disabled { background: var(--disabled); cursor: not-allowed; }

/* ── Source pills ── */

#home-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.85rem 0 0;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

.home-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 99px;
  background: none;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.home-pill:hover { border-color: var(--ink); color: var(--ink); background: none; }
.pill-add { color: var(--disabled); font-size: 0.8rem; }
.home-pill:hover .pill-add { color: var(--ink); }

/* ── Workflow cards ── */

#home-workflows {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding-top: 1.75rem;
}

.home-workflows-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--disabled);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.7rem;
}

.home-workflows-scroll {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-neutral) transparent;
}

.workflow-card {
  flex-shrink: 0;
  width: 162px;
  background: var(--surface);
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.workflow-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); border-color: var(--disabled); }

.wf-icon { color: var(--hint); flex-shrink: 0; }
.wf-title { font-size: 0.83rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.wf-meta  { display: flex; align-items: center; gap: 0.4rem; margin-top: auto; padding-top: 0.25rem; }
.wf-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wf-draft  { background: var(--color-cat-navy-bg); color: var(--ink); }
.wf-output { background: var(--color-cat-green-bg); color: var(--good); }
.wf-review { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.wf-steps  { font-size: 0.69rem; color: var(--disabled); }

/* ── Workflows full-view (Phase 7) ── */

#workflows-view {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--color-surface-raised);
  min-height: 0;
}

.wfv-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 860px;
}

.wfv-title-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.wfv-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.wfv-view-all {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wfv-view-all:hover { color: var(--ink); }


.wfv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.9rem;
  max-width: 860px;
}

.wfv-card {
  background: var(--surface);
  border: 1px solid var(--color-border-neutral);
  border-radius: 10px;
  padding: 1.1rem 1rem 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: box-shadow 0.12s, border-color 0.12s;
  min-height: 120px;
}
.wfv-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.09); border-color: var(--disabled); }
.wfv-card-actionable:hover { border-color: var(--ink); box-shadow: 0 2px 14px var(--color-border-faint); }
.wfv-card { position: relative; }

.wf-pin-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.65rem;
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--color-border-neutral);
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.wf-pin-btn.pinned { color: var(--ink); }
.wf-pin-btn:not(.pinned):hover { color: var(--hint); }
.wf-pin-btn.pinned:hover { color: var(--bad); }

.wfv-card .wf-icon { color: var(--muted); }
.wfv-card .wf-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wfv-card .wf-meta { margin-top: auto; padding-top: 0.3rem; }

/* Extract badge */
.wf-extract { background: var(--color-cat-violet-bg); color: var(--color-cat-violet-fg); }

/* ── Shared library view base ── */

#history-view, #favourites-view, #documents-view, #sources-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2rem 2.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

#analytics-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2rem 2.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.anly-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.anly-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.anly-domain-select {
  padding: 0.28rem 0.6rem;
  font-size: 0.75rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}
.anly-refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.anly-refresh-btn:hover { border-color: var(--ink); color: var(--ink); }
#anly-loading {
  text-align: center;
  color: var(--muted);
  margin-top: 3rem;
  font-size: 0.9rem;
}
#anly-error-msg {
  text-align: center;
  color: var(--bad);
  margin-top: 3rem;
  font-size: 0.9rem;
  display: none;
}
.anly-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin: 2rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
}
.anly-section-title:first-child { margin-top: 0; }
.anly-stat-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .anly-stat-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .anly-stat-row { grid-template-columns: repeat(2, 1fr); } }
.anly-stat-card {
  background: var(--surface);
  border: 1px solid var(--color-border-row);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
}
.anly-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hint);
  margin-bottom: 0.35rem;
}
.anly-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.anly-stat-sub {
  font-size: 0.75rem;
  color: var(--disabled);
  margin-top: 0.25rem;
}
.anly-stat-sub .positive { color: var(--good); font-weight: 600; }
.anly-stat-sub .negative { color: var(--bad); font-weight: 600; }
.anly-card {
  background: var(--surface);
  border: 1px solid var(--color-border-row);
  border-radius: 10px;
  padding: 1.3rem 1.5rem;
  margin-bottom: 1.5rem;
}
.anly-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
}
.anly-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.anly-two-col .anly-card { margin-bottom: 0; }
@media (max-width: 800px) { .anly-two-col { grid-template-columns: 1fr; } }
.anly-chart-wrap { position: relative; height: 220px; }
.anly-donut-wrap { position: relative; height: 200px; display: flex; align-items: center; justify-content: center; }
.anly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.anly-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
  padding: 0 0.4rem 0.5rem 0;
  border-bottom: 1px solid var(--color-border-neutral);
}
.anly-table th.anly-num { text-align: right; }
.anly-table td {
  padding: 0.5rem 0.4rem 0.5rem 0;
  border-bottom: 1px solid var(--color-border-row);
  vertical-align: middle;
}
.anly-table td.anly-num { text-align: right; font-variant-numeric: tabular-nums; }
.anly-table tr:last-child td { border-bottom: none; }
.anly-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--color-button-primary-hover);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  transition: background 0.12s;
}
.anly-expand-btn:hover { background: var(--color-surface-selected); }
.anly-detail-row { display: none; }
.anly-detail-row.open { display: table-row; }
.anly-detail-cell {
  padding: 0.75rem 1rem;
  background: var(--surfaceAlt);
  border-bottom: 1px solid var(--color-border-neutral);
}
.anly-detail-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.5rem 0 0.3rem;
}
.anly-detail-section-title:first-child { margin-top: 0; }
.anly-detail-table {
  width: 100%;
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  border-collapse: collapse;
}
.anly-detail-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--color-border-neutral);
}
.anly-detail-table td {
  padding: 0.3rem 0.4rem 0.3rem 0;
  border-bottom: 1px solid var(--color-border-row);
  vertical-align: middle;
}
.anly-token-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.3rem 1.5rem;
  font-size: 0.85rem;
  align-items: baseline;
}
.anly-token-summary .label { color: var(--hint); font-weight: 500; }
.anly-token-summary .tokens { font-variant-numeric: tabular-nums; }
.anly-token-summary .cost { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.anly-token-summary .total-row { border-top: 1px solid var(--color-border-row); padding-top: 0.4rem; margin-top: 0.2rem; }
.anly-token-summary .total-row .label { font-weight: 700; color: var(--ink); }
.anly-token-summary .total-row .cost { color: var(--ink); }
.anly-truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.anly-footer-note {
  font-size: 0.7rem;
  color: var(--disabled);
  text-align: center;
  padding: 1rem 0 2rem;
}

/* ── Validation view ─────────────────────────────────────────────────────── */
#validation-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2rem 2.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
#vld-loading {
  text-align: center;
  color: var(--muted);
  margin-top: 3rem;
  font-size: 0.9rem;
}
#vld-error-msg {
  text-align: center;
  color: var(--bad);
  margin-top: 3rem;
  font-size: 0.9rem;
  display: none;
}
.vld-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.vld-view-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.28rem 0.7rem;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.vld-view-btn:not(:last-child) { border-right: 1px solid var(--border); }
.vld-view-btn.active { background: var(--ink); color: var(--surface); }
.vld-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin: 2rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
}
.vld-card {
  background: var(--surface);
  border: 1px solid var(--color-border-row);
  border-radius: 10px;
  padding: 1.3rem 1.5rem;
  margin-bottom: 1rem;
}
.vld-run-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.vld-run-header:hover { opacity: 0.8; }
.vld-run-arrow {
  font-size: 0.7rem;
  color: var(--hint);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.vld-run-arrow.open { transform: rotate(90deg); }
.vld-run-meta { display: flex; align-items: baseline; gap: 1rem; flex: 1; min-width: 0; }
.vld-run-date { font-size: 0.85rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.vld-run-comment { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vld-run-domains-count { font-size: 0.7rem; color: var(--hint); white-space: nowrap; }
.vld-run-body { display: none; margin-top: 1rem; }
.vld-run-body.open { display: block; }
.vld-domain-block { margin-bottom: 1.25rem; }
.vld-domain-block:last-child { margin-bottom: 0; }
.vld-domain-name {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.vld-domain-stat { font-size: 0.72rem; font-weight: 400; color: var(--hint); text-transform: none; letter-spacing: normal; }
.vld-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 700px) { .vld-metrics-grid { grid-template-columns: 1fr; } }
.vld-metric-box { background: var(--surfaceAlt); border: 1px solid var(--color-border-neutral); border-radius: 6px; padding: 0.75rem 1rem; }
.vld-metric-box-title { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hint); margin-bottom: 0.5rem; }
.vld-metric-row { display: flex; justify-content: space-between; font-size: 0.78rem; padding: 0.15rem 0; }
.vld-metric-label { color: var(--muted); }
.vld-metric-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.vld-metric-val.good { color: var(--good); }
.vld-metric-val.warn { color: var(--warn); }
.vld-metric-val.bad { color: var(--bad); }
.vld-detail-sub-title { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0.5rem 0 0.25rem; }
.vld-detail-sub-title:first-child { margin-top: 0; }
.vld-cases-toggle {
  background: none;
  border: 1px solid var(--color-border-neutral);
  color: var(--color-button-primary-hover);
  padding: 0.25rem 0.7rem;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.vld-cases-toggle:hover { background: var(--color-surface-selected); }
.vld-cases-section { display: none; margin-top: 0.75rem; }
.vld-cases-section.open { display: block; }
.vld-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.vld-table th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
  padding: 0 0.4rem 0.5rem 0;
  border-bottom: 1px solid var(--color-border-neutral);
}
.vld-table th.vld-num { text-align: right; }
.vld-table td { padding: 0.45rem 0.4rem 0.45rem 0; border-bottom: 1px solid var(--color-border-row); vertical-align: top; }
.vld-table td.vld-num { text-align: right; font-variant-numeric: tabular-nums; }
.vld-table tr:last-child td { border-bottom: none; }
.vld-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--color-button-primary-hover);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  transition: background 0.12s;
}
.vld-expand-btn:hover { background: var(--color-surface-selected); }
.vld-detail-row { display: none; }
.vld-detail-row.open { display: table-row; }
.vld-detail-cell { padding: 0.75rem 1rem; background: var(--surfaceAlt); border-bottom: 1px solid var(--color-border-neutral); }
.vld-id-list { font-size: 0.72rem; color: var(--muted); word-break: break-all; }
.vld-id-list .correct { color: var(--good); }
.vld-id-list .missed { color: var(--bad); }
.vld-id-list .extra { color: var(--warn); }
.vld-id-list span { margin-right: 0.3rem; }
.vld-cmp-domain { margin-bottom: 2rem; }
.vld-cmp-domain-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.vld-cmp-domain-name { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
.vld-cmp-kind-toggle { display: inline-flex; border: 1px solid var(--color-border-neutral); border-radius: 4px; overflow: hidden; }
.vld-cmp-kind-btn { background: none; border: none; padding: 0.2rem 0.6rem; font-size: 0.68rem; font-family: inherit; cursor: pointer; color: var(--muted); transition: background 0.12s, color 0.12s; }
.vld-cmp-kind-btn:not(:last-child) { border-right: 1px solid var(--color-border-neutral); }
.vld-cmp-kind-btn.active { background: var(--ink); color: var(--surface); }
.vld-cmp-table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
.vld-cmp-table th { text-align: center; font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hint); padding: 0.3rem 0.4rem 0.5rem; border-bottom: 2px solid var(--color-border-neutral); }
.vld-cmp-table th.left { text-align: left; }
.vld-cmp-table th.group-header { border-bottom: 1px solid var(--color-border-neutral); color: var(--ink); font-size: 0.66rem; font-weight: 700; }
.vld-cmp-table td { padding: 0.4rem 0.4rem; border-bottom: 1px solid var(--color-border-row); text-align: center; font-variant-numeric: tabular-nums; }
.vld-cmp-table td.left { text-align: left; }
.vld-cmp-table tr.run-separator td { border-bottom: 2px solid var(--rule); }
.vld-cmp-run-date { font-weight: 600; color: var(--ink); font-size: 0.78rem; white-space: nowrap; }
.vld-cmp-run-comment { font-size: 0.72rem; color: var(--hint); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vld-cmp-val-good { color: var(--good); font-weight: 600; }
.vld-cmp-val-warn { color: var(--warn); font-weight: 600; }
.vld-cmp-val-bad { color: var(--bad); font-weight: 600; }
.vld-cmp-val-neutral { color: var(--ink); }
.vld-cmp-delta { font-size: 0.62rem; margin-left: 0.15rem; }
.vld-cmp-delta.up { color: var(--good); }
.vld-cmp-delta.down { color: var(--bad); }

.lib-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.lib-title-row { display: flex; align-items: baseline; gap: 1rem; }

.lib-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.lib-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.lib-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.lib-type-pill {
  background: none;
  border: 1px solid var(--color-border-neutral);
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.lib-type-pill:hover { border-color: var(--ink); color: var(--ink); }
.lib-type-pill.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ── History view ── */

.hist-clear-all-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--hint);
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}
.hist-clear-all-btn:hover { color: var(--bad); background: var(--color-cat-red-bg); }

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hist-group {
  margin-bottom: 1.25rem;
}

.hist-group-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--hint);
  padding: 0 0.85rem 0.35rem;
}

.hist-item {
  display: flex;
  align-items: flex-start;
  padding: 0.55rem 0.5rem 0.55rem 0.85rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.hist-item:hover { background: var(--color-surface-raised); }
.hist-item:hover .history-delete { opacity: 1; }

.hist-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hist-item-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.hist-item-title {
  flex: 1;
  min-width: 0;
  font-size: 0.845rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-item-query {
  font-size: 0.78rem;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-item-meta {
  font-size: 0.7rem;
  color: var(--disabled);
}

.hist-item-time {
  font-size: 0.72rem;
  color: var(--disabled);
  white-space: nowrap;
  flex-shrink: 0;
}

.hist-wf-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.hist-item-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--disabled);
  line-height: 1;
}
.hist-icon-results { color: var(--good); opacity: 0.5; }

.hist-draft-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--surfaceAlt);
  color: var(--ink);
  border: 1px solid var(--color-border-selected);
  flex-shrink: 0;
}

.hist-domain-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.hist-domain-maritime      { background: var(--color-cat-navy-bg); color: var(--color-cat-navy-fg, var(--ink)); }
.hist-domain-swiss         { background: var(--color-cat-red-bg); color: var(--color-cat-red-fg); }
.hist-domain-swiss_family  { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg, var(--warn)); }
.hist-domain-montenegro    { background: var(--color-cat-green-bg); color: var(--good); }

.hist-item-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.hist-wf-legal-research      { background: var(--color-surface-raised); color: var(--muted); }
.hist-wf-draft-submission    { background: var(--color-cat-navy-bg); color: var(--ink); }
.hist-wf-support-argument    { background: var(--color-cat-purple-bg); color: var(--color-cat-purple-fg); }
.hist-wf-summary             { background: var(--color-cat-green-bg); color: var(--good); }
.hist-wf-client-alert        { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.hist-wf-generate-chronology { background: var(--color-cat-green-bg); color: var(--good); }
.hist-wf-transcribe-hearing  { background: var(--color-surface-raised); color: var(--muted); }
.hist-wf-closing-checklist   { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.hist-wf-assess-risk         { background: var(--color-cat-red-bg); color: var(--color-cat-red-fg); }

/* ── Templates view ── */

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  min-height: 116px;
}
.tpl-card:hover { border-color: var(--borderStrong); box-shadow: var(--shadow-sm); }

.tpl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tpl-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tpl-submission { background: var(--color-cat-navy-bg); color: var(--ink); }
.tpl-brief      { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.tpl-letter     { background: var(--color-cat-green-bg); color: var(--good); }
.tpl-contract   { background: var(--color-cat-red-bg); color: var(--color-cat-red-fg); }
.tpl-notice     { background: var(--color-cat-violet-bg); color: var(--color-cat-violet-fg); }

.tpl-name {
  font-size: 0.845rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  flex: 1;
}

.tpl-jurisdiction {
  font-size: 0.72rem;
  color: var(--hint);
}

.tpl-modified {
  font-size: 0.69rem;
  color: var(--disabled);
  margin-top: auto;
}

/* ── Favourites view ── */

.fav-tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid var(--color-border-row);
  margin-top: 0.25rem;
  padding-bottom: 0.35rem;
}

.fav-tab {
  background: none;
  border: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--color-nav-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.fav-tab:hover  { color: var(--color-nav-text-hover); background: var(--color-interactive-hover); }
.fav-tab.active { color: var(--ink); background: var(--color-interactive-active); font-weight: 600; }

.fav-content { margin-top: 1.25rem; }
.fav-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--color-border-row); border-radius: 8px; overflow: hidden; }

.fav-extract {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-neutral);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.1s;
}
.fav-extract:last-child { border-bottom: none; }
.fav-extract:hover { background: var(--color-surface-raised); }

.fav-extract-text {
  font-size: 0.845rem;
  color: var(--ink);
  line-height: 1.55;
  font-style: italic;
  margin: 0;
}

.fav-extract-foot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fav-extract-source {
  font-size: 0.72rem;
  color: var(--hint);
  font-weight: 500;
}

/* ── Vault view ── */

.vault-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.vault-empty {
  padding: 3rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--disabled);
}

.vault-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 0.5rem 0.85rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}
.vault-item:hover { background: var(--color-surface-raised); }

.vault-item-title {
  flex: 1;
  min-width: 0;
  font-size: 0.845rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vault-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
  background: var(--color-surface-raised);
  color: var(--muted);
}
.vault-wf-draft-submission  { background: var(--color-cat-navy-bg); color: var(--ink); }
.vault-wf-support-argument  { background: var(--color-cat-purple-bg); color: var(--color-cat-purple-fg); }
.vault-wf-summary           { background: var(--color-cat-green-bg); color: var(--good); }
.vault-wf-client-alert      { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.vault-wf-generate-chronology { background: var(--color-cat-green-bg); color: var(--good); }
.vault-wf-closing-checklist { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.vault-wf-assess-risk       { background: var(--color-cat-red-bg); color: var(--color-cat-red-fg); }

.vault-client {
  font-size: 0.75rem;
  color: var(--hint);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 4rem;
  text-align: right;
}

/* ── Document chips (Conversations tab) ── */
.hist-doc-chips {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.hist-doc-chip {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.14rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.hist-doc-draft   { background: var(--color-cat-navy-bg); color: var(--ink); }
.hist-doc-summary { background: var(--color-cat-green-bg); color: var(--good); }

/* Per-subtype colors for Documents view */
.doc-chip-submission      { background: var(--color-state-mentioned-bg); color: var(--color-button-primary-hover); }
.doc-chip-legal-brief     { background: var(--color-cat-indigo-bg); color: var(--color-cat-indigo-fg); }
.doc-chip-legal-letter    { background: var(--color-cat-teal-bg); color: var(--color-cat-teal-fg); }
.doc-chip-contract-clause { background: var(--color-cat-amber-bg); color: var(--warn); }
.doc-chip-legal-notice    { background: var(--color-state-reject-bg); color: var(--bad); }
.doc-chip-memo            { background: var(--color-cat-slate-bg); color: var(--color-cat-slate-fg); }

.doc-chip-key-points    { background: var(--color-cat-emerald-bg); color: var(--color-cat-emerald-fg); }
.doc-chip-narrative     { background: var(--color-cat-sky-bg); color: var(--color-cat-sky-fg); }
.doc-chip-legal-analysis{ background: var(--color-cat-violet-bg); color: var(--color-cat-violet-fg); }
.doc-chip-timeline      { background: var(--color-state-flag-bg); color: var(--color-state-flag-text); }
.doc-chip-action-items  { background: var(--color-cat-rose-bg); color: var(--color-cat-rose-fg); }

/* ── Document items (Documents tab) ── */
.doc-item {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-surface-raised);
  transition: background 0.1s;
}
.doc-item:first-child { border-top: 1px solid var(--color-surface-raised); }
.doc-item:hover { background: var(--surfaceAlt); }

.doc-item-type { align-self: flex-start; margin-bottom: 0.1rem; }

.doc-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-item-meta {
  font-size: 0.71rem;
  color: var(--disabled);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panels hidden until triggered */
#sources-panel                  { display: none; }
#sources-panel.sources-visible  { display: flex; }
#draft-panel                    { display: none; }
#draft-panel.draft-visible      { display: flex; }

/* ── Phase 3: Sidebar content ───────────────────────────────── */

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0.5rem 0.5rem;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-interactive-hover-on-dark) transparent;
}

#sidebar.collapsed .sidebar-content { display: none; }

.sidebar-collapsed-char {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-nav-text-muted);
  letter-spacing: 0.05em;
}
#sidebar.collapsed .sidebar-nav-header { justify-content: center; padding: 0.52rem 0; gap: 0; }
#sidebar.collapsed #sidebar-history { display: none; }

#sidebar-history {
  overflow-y: auto;
  padding: 0.15rem 0 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-faint) transparent;
}

/* Section labels (details summaries only) */
.sidebar-section-label { font-size: 0.8rem; font-weight: 500; color: var(--color-nav-text-hover); }
.sidebar-section-label.active { background: none; box-shadow: none; color: var(--ink); font-weight: 600; }

.sidebar-tools-chevron { margin-left: auto; flex-shrink: 0; transition: transform 0.18s ease; }
#sidebar-tools-toggle.active .sidebar-tools-chevron { transform: rotate(180deg); }
#sidebar-history-toggle.active .sidebar-tools-chevron { transform: rotate(180deg); }

.sidebar-tools-list { display: none; flex-direction: column; padding-bottom: 0.2rem; }
.sidebar-tools-list.open { display: flex; }
#sidebar.collapsed .sidebar-tools-list { display: none !important; }
#sidebar.collapsed .sidebar-tools-chevron { display: none; }

/* details summary inherits .sidebar-section-label and is clickable */
details.sidebar-details > summary.sidebar-section-label {
  cursor: pointer;
  margin-top: 0.35rem;
}
details.sidebar-details > summary.sidebar-section-label::-webkit-details-marker { display: none; }
details.sidebar-details > summary.sidebar-section-label:hover { color: var(--color-nav-text-hover); }

.sidebar-chevron {
  flex-shrink: 0;
  transition: transform 0.18s ease;
  transform: rotate(0deg);
}
details.sidebar-details[open] > summary .sidebar-chevron { transform: rotate(90deg); }

.sidebar-details-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.3rem;
}

/* Items inside details sections (templates, favourites) */
.sidebar-item-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-nav-text);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.38rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
}
.sidebar-item-btn:hover { background: var(--color-interactive-hover); color: var(--color-nav-text-hover); }

/* History list */
.sidebar-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.25rem;
}

.history-empty {
  font-size: 0.75rem;
  color: var(--color-nav-text-ghost);
  padding: 0.3rem 0.5rem 0.5rem;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.38rem 0.55rem 0.38rem 1.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 0;
}
.history-item:hover { background: var(--color-interactive-hover); }
.history-item.active { background: var(--color-interactive-active); }
.history-item.active .history-name { color: var(--ink); font-weight: 600; }

.history-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.history-name {
  font-size: 0.78rem;
  color: var(--color-nav-text-hover);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.history-time {
  font-size: 0.67rem;
  color: var(--color-nav-text-ghost);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-delete {
  background: none;
  border: none;
  padding: 0.1rem 0.25rem;
  font-size: 0.7rem;
  color: var(--color-border-faint);
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
  line-height: 1;
}
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { color: var(--bad); background: var(--color-interactive-hover); }

/* ── Phase 5: Message actions + follow-ups ──────────────────── */

.msg-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.msg-action-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--color-border-neutral);
  color: var(--hint);
  font-size: 0.73rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.22rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.msg-action-btn:hover  { border-color: var(--disabled); color: var(--ink); background: var(--color-surface-raised); }
.msg-action-btn.copied { border-color: var(--color-state-relevant-border); color: var(--good); background: var(--color-cat-green-bg); }
.msg-action-btn.dim    { color: var(--color-border-neutral); cursor: default; }
.msg-action-btn.dim:hover { border-color: var(--color-border-neutral); color: var(--color-border-neutral); background: none; }


/* ── Phase 5: Input bar upgrade ─────────────────────────────── */

.footer-icons {
  display: flex;
  gap: 0.1rem;
  flex-shrink: 0;
}

.footer-icon-btn {
  background: none;
  border: none;
  color: var(--disabled);
  padding: 0.3rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.12s, background 0.12s;
}
.footer-icon-btn:hover { color: var(--muted); background: var(--color-surface-raised); }
.footer-icon-btn:disabled { color: var(--color-border-neutral); cursor: not-allowed; background: none; }
.draft-trigger-btn:not(:disabled) { color: var(--ink); }

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* Client-ready Summary shortcut */
.sidebar-shortcut-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--color-border-neutral);
  color: var(--color-nav-text-muted);
  font-size: 0.77rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.65rem 0.25rem 0.4rem;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: color 0.15s;
}
.sidebar-shortcut-link:hover { color: var(--color-nav-text-hover); background: none; }

/* ── Phase 6: Draft Editor (lives in #draft-panel) ──────────── */

/* Editor toolbar: hidden until draft-active */
#editor-toolbar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.2rem;
  gap: 0.08rem;
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid var(--color-border-neutral);
  background: var(--surface);
  flex-shrink: 0;
}

.editor-style-picker {
  position: relative;
  flex-shrink: 0;
}
.editor-style-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  cursor: pointer;
  height: 24px;
  line-height: 1;
  letter-spacing: -0.01em;
}
.editor-style-btn:hover { background: var(--color-surface-raised); color: var(--ink); }
.editor-style-picker.open .editor-style-btn { background: var(--color-surface-selected); color: var(--ink); }

.editor-style-menu {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--color-border-neutral);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 120px;
  padding: 3px 0;
}
.editor-style-picker.open .editor-style-menu { display: block; }

.editor-style-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  color: var(--ink2);
  font-family: inherit;
  white-space: nowrap;
  box-shadow: none;
}
.editor-style-opt:hover { background: var(--color-surface-raised); color: var(--ink); }
.editor-style-opt--p  { font-size: 0.78rem; }
.editor-style-opt--h1 { font-size: 0.95rem; font-weight: 700; }
.editor-style-opt--h2 { font-size: 0.85rem; font-weight: 700; }
.editor-style-opt--h3 { font-size: 0.8rem;  font-weight: 600; }

.editor-sep {
  width: 1px;
  height: 16px;
  background: var(--color-border-neutral);
  margin: 0 0.1rem;
  flex-shrink: 0;
  align-self: center;
}

.editor-tool-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.editor-toolbar-spacer {
  flex: 1;
  min-width: 0.2rem;
}

.editor-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 400;
  padding: 0.15rem 0.28rem;
  border-radius: 4px;
  cursor: pointer;
  height: 24px;
  min-width: 24px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.editor-tool-btn:hover  { background: var(--color-surface-raised); color: var(--ink); border-color: var(--color-border-neutral); }
.editor-tool-btn.active { background: var(--color-surface-selected); color: var(--ink); border-color: var(--color-border-selected); }
.editor-fmt { font-size: 0.78rem; }

.editor-uci-toggle {
  font-size: 0.69rem;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}
.editor-uci-toggle.active { background: var(--color-cat-amber-bg); color: var(--warn); border-color: var(--color-state-flag-border); }


/* Editor shown only in draft-active state */
#draft-panel.draft-active #editor-toolbar { display: flex; }

/* Editor body: editable content area, hidden until draft-active */
#editor-body {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--ink);
  outline: none;
  min-height: 0;
}
#draft-panel.draft-active #editor-body { display: block; }
/* copy btn in header also shown in draft-active */
#draft-panel.draft-active #editor-copy-btn { display: inline-flex !important; }

.editor-footer {
  display: none;
  flex-shrink: 0;
  border-top: 1px solid var(--color-border-neutral);
  padding: 0.75rem;
  background: var(--surface);
  justify-content: flex-end;
}
#draft-panel.draft-active .editor-footer { display: flex; }
#outline-panel .editor-footer { display: flex; }

#editor-body h1 { font-size: 1.05rem; font-weight: 700; margin: 0.9rem 0 0.4rem; }
#editor-body h2 { font-size: 0.93rem; font-weight: 700; margin: 0.8rem 0 0.35rem; }
#editor-body h3 { font-size: 0.86rem; font-weight: 600; margin: 0.7rem 0 0.3rem; }
#editor-body h1:first-child,
#editor-body h2:first-child,
#editor-body h3:first-child { margin-top: 0; }
#editor-body p { margin-bottom: 0.5rem; }
#editor-body p:last-child { margin-bottom: 0; }
#editor-body ul,
#editor-body ol { padding-left: 1.3rem; margin-bottom: 0.5rem; }
#editor-body li { margin-bottom: 0.15rem; }
#editor-body strong { font-weight: 600; }
#editor-body code {
  font-family: var(--font-mono);
  font-size: 0.81rem;
  background: var(--color-border-neutral);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
#editor-body a { color: var(--ink); text-underline-offset: 2px; }

/* ── Summary editor (mirrors draft editor) ───────────────────── */
#summary-editor-toolbar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--color-border-neutral);
  background: var(--surface);
  flex-wrap: wrap;
  min-height: 36px;
}
#summary-panel.summary-generated #summary-editor-toolbar { display: flex; }

#summary-editor-body {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  min-height: 0;
}
#summary-panel.summary-generated #summary-editor-body { display: block; }
#summary-panel.summary-generated .editor-footer { display: flex; }
.sources-footer { display: flex; }
.editor-footer button, .sources-footer button, .pane-composer .footer-right button {
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--color-navy);
}
.editor-footer button:hover, .sources-footer button:hover, .pane-composer .footer-right button:hover {
  background: var(--color-button-primary-hover);
}
#summary-panel.summary-generated #summary-setup { display: none; }

/* ── Pane composer (shared input form for all panes) ─────────── */
.pane-composer {
  display: none;
  flex-shrink: 0;
  border-top: 1px solid var(--color-border-neutral);
  background: var(--surface);
  padding: 0.75rem;
  width: 100%;
}
/* Visibility: mirrors the old editor-footer rules */
#draft-panel.draft-active    .pane-composer { display: block; }
#summary-panel.summary-generated .pane-composer { display: block; }
#outline-panel.outline-active .pane-composer { display: block; }
#outline-intro { display: flex; flex-direction: column; gap: 1.2rem; }
#outline-panel.outline-active #outline-intro { display: none; }
#outline-panel.outline-active #outline-generate-btn,
#outline-panel.outline-active .draft-setup-note { display: none; }
#sources-panel               .pane-composer { display: block; }

.pane-composer-input {
  font-family: var(--font-sans);
  color: var(--ink2);
  display: block;
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border-neutral);
  border-radius: 8px;
  resize: none;
  background: var(--surface);
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.15s;
  outline: none;
  line-height: 1.5;
  overflow-y: hidden;
  max-height: 10rem;
}
.pane-composer-input:focus { border-color: var(--ink); }
.pane-composer-input::placeholder { color: var(--muted); }

.pane-composer .form-footer { display: flex; }

#summary-editor-body h1 { font-size: 1.05rem; font-weight: 700; margin: 0.9rem 0 0.4rem; }
#summary-editor-body h2 { font-size: 0.93rem; font-weight: 700; margin: 0.8rem 0 0.35rem; }
#summary-editor-body h3 { font-size: 0.86rem; font-weight: 600; margin: 0.7rem 0 0.3rem; }
#summary-editor-body h1:first-child,
#summary-editor-body h2:first-child,
#summary-editor-body h3:first-child { margin-top: 0; }
#summary-editor-body p { margin-bottom: 0.5rem; }
#summary-editor-body p:last-child { margin-bottom: 0; }
#summary-editor-body ul,
#summary-editor-body ol { padding-left: 1.3rem; margin-bottom: 0.5rem; }
#summary-editor-body li { margin-bottom: 0.15rem; }
#summary-editor-body strong { font-weight: 600; }
#summary-editor-body code {
  font-family: var(--font-mono);
  font-size: 0.81rem;
  background: var(--color-border-neutral);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
#summary-editor-body a { color: var(--ink); text-underline-offset: 2px; }

/* UCI (tracked changes / redline) mode */
#editor-body.uci-mode ins {
  background: var(--color-state-accept-bg);
  color: var(--good);
  text-decoration: none;
  border-radius: 2px;
}
#editor-body.uci-mode del {
  background: var(--color-state-reject-bg);
  color: var(--bad);
  text-decoration: line-through;
  border-radius: 2px;
}

/* Per-section priority badges */
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  margin-right: 0.3rem;
  vertical-align: middle;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
}
.priority-badge[data-priority="1"] { background: var(--color-state-reject-bg); color: var(--bad); }
.priority-badge[data-priority="2"] { background: var(--color-cat-amber-bg); color: var(--warn); }
.priority-badge[data-priority="3"] { background: var(--color-surface-raised); color: var(--muted); }

/* ══════════════════════════════════════════════════════════════
   COUNSELOR REDESIGN OVERRIDES
   All rules below override earlier declarations to apply the
   Counselor visual language. DOM IDs / functional classes are
   never renamed — only appearance is changed.
   ══════════════════════════════════════════════════════════════ */

/* ── Global shell ───────────────────────────────────────────── */

body {
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--ink2);
}

#app {
  background: var(--canvas);
}

/* ── Sidebar ────────────────────────────────────────────────── */

#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-top { border-bottom: 1px solid var(--rule); height: 44px; box-sizing: border-box; padding-bottom: 0; }

.logo-wordmark {
  font-family: var(--font-sans);
  letter-spacing: 0.22em;
  color: var(--color-nav-text);
}

.sidebar-divider { background: var(--border); }

.nav-item { color: var(--color-nav-text); font-size: 0.78rem; border-radius: var(--radius-sm); }
.nav-item:hover { background: var(--color-surface-raised); color: var(--color-nav-text-hover); }
.nav-item.active { background: var(--color-interactive-active); color: var(--ink); font-weight: 500; }

.sidebar-nav-header { color: var(--color-nav-text); font-size: 0.78rem; }
.sidebar-nav-header:hover { background: var(--color-surface-raised); color: var(--color-nav-text-hover); }

.create-btn {
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surfaceAlt);
  margin: 0.3rem 0.6rem 0.55rem;
}
.create-btn:hover { background: var(--canvas); border-color: var(--borderStrong); color: var(--ink); }

.sidebar-workflow-item { color: var(--muted); }
.sidebar-workflow-item.active { color: var(--ink); background: var(--color-interactive-active); }

.phase-track-label { color: var(--muted); }
.phase-track-item.active .phase-track-label { color: var(--ink); }
.phase-track-item.active .phase-track-icon { color: var(--ink); }
.phase-track-connector { background: var(--border); }

.sidebar-ctrl-btn { color: var(--muted); }
.sidebar-ctrl-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

.avatar { background: var(--ink); }

/* ── Workspace topbar (matter chip + domain) ────────────────── */

#workspace-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 12px 0 14px;
  background: var(--color-surface-panel);
  border-bottom: 0.5px solid var(--color-border);
}

.ws-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ws-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.ws-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 8px 0 10px;
  background: var(--color-surface-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-badge);
  max-width: 320px;
}

.ws-tab-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.ws-tab-src {
  font-size: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-role-interactive);
  background: var(--color-role-interactive-soft);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.ws-tab-src:empty { display: none; }

.ws-tab-close {
  width: 16px;
  height: 16px;
  padding: 0;
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-hint);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.ws-tab-close:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }

#topbar-badges .ws-tab:first-child { background: var(--color-iris-muted); border-color: var(--color-iris); }
.ws-tab-jur { border-color: var(--color-iris); background: var(--color-iris-muted); }
.ws-tab-jur .ws-tab-label { color: var(--color-role-interactive); }
.ws-tab-area .ws-tab-label { color: var(--color-text-secondary); }

.ws-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  flex-shrink: 0;
}
.ws-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 24px;
  padding: 0 0.6rem;
  background: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-badge);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--color-text-hint);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.ws-add-btn:hover:not(:disabled) { border-color: var(--borderStrong); color: var(--ink2); }
.ws-add-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.vault-option.is-selected { opacity: 0.4; cursor: not-allowed; }

/* ── Home topbar ────────────────────────────────────────────── */

#home-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.home-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.home-topbar-workspace {
  color: var(--muted);
  font-weight: 500;
}

.home-topbar-crumb-sep {
  color: var(--muted);
  font-size: 0.85rem;
}

.home-topbar-thread {
  color: var(--ink);
  font-weight: 500;
}

.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}

.home-topbar-security {
  color: var(--muted);
}

.home-topbar-bell {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--muted);
  transition: color 0.12s;
}
.home-topbar-bell:hover { color: var(--ink); }

/* ── Pinned sources strip ───────────────────────────────────── */

#pinned-strip {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pinned-strip-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 34px;
  overflow: hidden;
}

.pinned-strip-heading {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}

.pinned-chips {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
  align-items: center;
}
.pinned-chips::-webkit-scrollbar { display: none; }

.pinned-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.55rem;
  background: var(--color-role-chip-soft);
  color: var(--color-role-chip-text);
  border-radius: 5px;
  font-size: 0.71rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.pinned-add-btn {
  font-size: 0.71rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.14rem 0.5rem;
  cursor: not-allowed;
  flex-shrink: 0;
  white-space: nowrap;
  opacity: 0.6;
  font-family: var(--font-sans);
}

/* ── Right rail (pane toggles) ──────────────────────────────── */

#topbar {
  width: 44px;
  flex-shrink: 0;
  background: var(--color-surface-panel);
  border-left: 0.5px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 2px;
}

.pane-rail-header {
  font-size: 0.5625rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-hint);
  text-align: center;
  line-height: 1.25;
  padding: 2px 0 12px;
  user-select: none;
  opacity: 0.7;
}

#pane-panel-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border-neutral);
  width: 100%;
}

#pane-toggles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  width: 100%;
}

.pane-toggle-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-neutral);
  background: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.pane-toggle-btn svg { width: 17px; height: 17px; }
.pane-toggle-btn:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }
.pane-toggle-btn.active { color: var(--color-role-interactive); background: var(--color-role-interactive-soft); border-color: var(--color-iris); }

/* ── Main area & workspace ──────────────────────────────────── */

#main-area { background: var(--canvas); }

#workspace { background: var(--canvas); gap: 6px; padding: 6px; }

/* ── Workspace panels ───────────────────────────────────────── */

.workspace-panel { border-right: none; }

.panel-collapsed-strip {
  background: var(--surfaceAlt);
  border-right: 1px solid var(--border);
  color: var(--border);
}
.panel-collapsed-strip:hover { background: var(--canvas); color: var(--muted); }

.panel-main { background: var(--surface); }

.draft-panel-header,
.panel-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-header-title,
.draft-panel-title,
.outline-panel-title { color: var(--ink); font-size: 0.82rem; font-weight: 600; }

.panel-header-title--upper { color: var(--ink2); }
.panel-header-count { color: var(--muted); }
.draft-panel-icon { color: var(--muted); }
.draft-doc-type-tag { color: var(--accent); border-color: var(--accent); opacity: 0.85; }

.panel-icon-btn { color: var(--muted); }
.panel-icon-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

.panel-collapse-btn { color: var(--muted); }
.panel-collapse-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

/* ── Chat / messages ────────────────────────────────────────── */

#messages { background: var(--surface); }

.msg-assistant .msg-content { color: var(--ink2); }
.msg-assistant .msg-label { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }

/* User message bubble: accent-soft tint */
.msg.msg-user .msg-content {
  background: var(--color-role-message-soft);
  color: var(--color-role-message);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 0.87rem;
}

/* Inline citation chips */
.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  background: var(--color-role-chip-soft);
  color: var(--color-role-chip);
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-mono);
  transition: background 0.12s;
}
.citation-chip:hover { background: var(--color-surface-selected); }

/* ── Home / empty state ─────────────────────────────────────── */

/* Vertically center home content in the panel */
#chat-panel:not(.chatting) .panel-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
}
#chat-panel:not(.chatting) #home-header,
#chat-panel:not(.chatting) #chat-form {
  width: 100%;
}

#home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 2rem 1.5rem;
}

.home-greeting-wrap {
  text-align: center;
  max-width: 600px;
}

.home-tod-greeting {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 0.2rem;
  letter-spacing: -0.02em;
}

.home-greeting {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 0.65rem;
}

.home-greeting-sub {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.home-brand-mark { display: flex; }

/* Context buttons (vault, matter) — row below greeting */
.home-context-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.home-ctx-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s, border-color 0.12s;
}
.home-ctx-btn:hover { background: var(--canvas); border-color: var(--borderStrong); }
.home-ctx-btn svg { color: var(--muted); }

/* Jurisdiction + practice area dropdowns */
.vault-dropdown { position: relative; }
#jur-btn { box-shadow: var(--shadow-sm); }
#topbar-domain-label.domain-unset { color: var(--color-burgundy); background: var(--color-surface-raised); }
#jur-btn:not(.vault-active) { background: var(--color-burgundy); border-color: var(--color-burgundy); color: var(--surface); }
#jur-btn:not(.vault-active) svg { color: var(--surface); }
#jur-btn:not(.vault-active):hover { background: var(--color-burgundy); border-color: var(--color-burgundy); }
#area-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Chat form / composer ─ card treatment */
#chat-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: 0 auto 1.5rem;
  padding: 0;
  overflow: hidden;
  width: calc(100% - 4rem);
  max-width: 660px;
}

#input {
  font-family: var(--font-sans);
  color: var(--ink2);
  background: transparent;
  border: none;
  padding: 0.9rem 1rem 0.6rem;
  font-size: 0.9rem;
  line-height: 1.55;
  resize: none;
  width: 100%;
  outline: none;
  overflow-y: hidden;
  max-height: 10rem;
}
#input::placeholder { color: var(--muted); }

#home-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem 0.5rem;
  border-top: 1px solid var(--rule);
  background: var(--surfaceAlt);
}

#home-ask-btn {
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.38rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s;
}

.home-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s, color 0.12s;
}
.home-action-btn:hover { background: var(--canvas); color: var(--ink); }

.footer-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.footer-icon-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

/* Chat state send button */
#chat-send-btn {
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s;
}

/* Chat state footer */
.form-footer {
  border-top: 1px solid var(--rule);
  background: var(--surfaceAlt);
}

/* ── Sources panel (Laws & Cases) ───────────────────────────── */

#results-panel { background: var(--surface); }

#tab-bar {
  display: flex;
  background: var(--surface);
}

.tab {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  outline: none;
  padding: 0.6rem 0;
  transition: color 0.12s, background 0.12s;
}
.tab.active { color: var(--ink); background: var(--color-role-interactive-soft); }
.tab:hover { color: var(--ink2); }

/* Law / case result cards ─ code badge + relevance score */

.law-code-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  background: var(--ink);
  color: var(--surface);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.source-relevance {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* Source card hover */
.source-card,
.law-item,
.case-item {
  border-bottom: 1px solid var(--rule);
  transition: background 0.12s ease-out;
}
.source-card:hover,
.law-item:hover,
.case-item:hover { background: var(--color-surface-selected); }

/* ── Draft / editor panels ──────────────────────────────────── */

#editor-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.editor-style-btn { color: var(--ink2); }
.editor-style-menu { border-color: var(--border); background: var(--surface); }
.editor-style-opt { color: var(--ink2); }
.editor-style-opt:hover { background: var(--color-interactive-hover); }

.editor-tool-btn {
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.editor-tool-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }

#editor-body {
  font-family: var(--font-serif);
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--ink2);
  background: var(--surface);
  padding: 1.25rem 1.5rem;
}

/* ── Summary panel ──────────────────────────────────────────── */

#summary-editor-body {
  font-family: var(--font-serif);
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--ink2);
  background: var(--surface);
  padding: 1.25rem 1.5rem;
}

/* ── Workflow / vault / library views ───────────────────────── */

#workflows-view,
#history-view,
#documents-view,
#sources-view,
#favourites-view,
#analytics-view,
#validation-view {
  background: var(--canvas);
}

.lib-header,
.wfv-header { background: var(--canvas); border-bottom: 1px solid var(--border); }

.lib-title,
.wfv-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.fav-tab {
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s;
}
.fav-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.fav-tab:hover { color: var(--ink2); }

/* Workflow grid cards */
.wf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s ease-out, border-color 0.12s ease-out;
}
.wf-card:hover { box-shadow: var(--shadow-md); border-color: var(--borderStrong); }
.wf-card.pinned { border-color: var(--color-state-pinned-border); box-shadow: var(--shadow-md); }

/* Draft setup */
.draft-setup-inner { background: var(--surface); }
.draft-setup-title { color: var(--ink); font-family: var(--font-sans); }
.draft-setup-sub { color: var(--muted); }
.draft-setup-label { color: var(--ink); font-size: 0.78rem; font-weight: 600; }
.draft-setup-note { color: var(--muted); font-size: 0.75rem; }

.draft-type-pill {
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--ink2);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.draft-type-pill:hover { background: var(--surfaceAlt); border-color: var(--borderStrong); }
.draft-type-pill.active { background: var(--accentSoft); border-color: var(--accent); color: var(--accentInk); font-weight: 600; }

.draft-generate-btn,
.outline-build-btn {
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.draft-generate-btn:hover,

/* Draft template options */
.draft-tpl-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  transition: border-color 0.12s, background 0.12s;
}
.draft-tpl-opt:hover:not(.draft-tpl-soon) { border-color: var(--borderStrong); background: var(--surfaceAlt); }
.draft-tpl-selected { border-color: var(--accent); background: var(--accentSoft); }
.draft-tpl-name { color: var(--ink); font-weight: 500; font-size: 0.82rem; }
.draft-tpl-desc { color: var(--muted); font-size: 0.75rem; }

/* Upload zones */
.draft-upload-zone,
.chrono-upload-zone,
.transcribe-upload-zone {
  border: 1px dashed var(--borderStrong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--muted);
  transition: border-color 0.12s, background 0.12s;
}
.draft-upload-zone:hover,
.chrono-upload-zone:hover,
.transcribe-upload-zone:hover { border-color: var(--accent); background: var(--accentSoft); }

/* ── Modal ──────────────────────────────────────────────────── */

#modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Vault / documents list ─────────────────────────────────── */

.vault-item,
.hist-item,
.fav-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.12s ease-out;
}
.vault-item:hover,
.hist-item:hover,
.fav-item:hover { box-shadow: var(--shadow-md); }

/* Thread regen bar */
.thread-regen-bar { background: var(--surfaceAlt); border-bottom: 1px solid var(--border); }
.thread-regen-label { color: var(--muted); }
.thread-regen-btn { color: var(--ink); border-color: var(--border); }
.thread-regen-btn:hover { background: var(--color-interactive-hover); border-color: var(--borderStrong); }

/* Outline / argument builder inputs */
.outline-claim-input,
.outline-entry-input,
.alert-input,
.alert-textarea,
.chrono-paste,
.draft-type-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink2);
  font-family: var(--font-sans);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.outline-claim-input:focus,
.outline-entry-input:focus,
.alert-input:focus,
.alert-textarea:focus,
.chrono-paste:focus,
.draft-type-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accentSoft);
}

/* Outline add button */
.outline-add-btn { color: var(--accent); font-size: 0.78rem; }
.outline-add-btn:hover { color: var(--accentHover); background: var(--accentSoft); }

/* Vote / feedback buttons */
.vote-btn { color: var(--muted); }
.vote-btn:hover { color: var(--ink); background: var(--color-interactive-hover); }
.vote-btn.voted-up { color: var(--good); }
.vote-btn.voted-down { color: var(--bad); }

/* ── Source extraction feedback ─────────────────────────────── */
.extract-vote-btn { color: var(--muted); border-color: var(--border); border-radius: var(--radius-sm); }
.extract-vote-btn:hover { background: var(--color-interactive-hover); color: var(--ink); }
.extract-vote-btn.voted-good { color: var(--good); border-color: var(--good); background: var(--color-state-accept-tint); }
.extract-vote-btn.voted-bad  { color: var(--bad);  border-color: var(--bad);  background: var(--color-state-reject-tint); }

/* Note textarea */
.extract-note-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink2);
  font-family: var(--font-sans);
}
.extract-note-textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accentSoft); }

/* ── Scrollbars (subtle) ────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--borderStrong); }

/* ── Sidebar group labels ───────────────────────────────────── */

.sidebar-group-label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-hint);
  padding: 0.875rem 1rem 0.375rem;
  pointer-events: none;
}
#sidebar.collapsed .sidebar-group-label { display: none; }

.sidebar-group-label-action {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-see-all-btn {
  pointer-events: all;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0.2rem;
  opacity: 0.7;
  font-family: inherit;
}
.sidebar-see-all-btn:hover { opacity: 1; color: var(--ink); }

/* ── Result cards (Laws & Cases pane) ───────────────────────── */

.card {
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 0.9rem 1rem;
  margin-bottom: 0;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.12s ease-out;
}
.card:last-child { border-bottom: none; }
.card:hover { background: var(--surfaceAlt); }
.card.is-relevant       { background: var(--vote-relevant-bg); }
.card.is-relevant:hover { background: var(--vote-relevant-bg-hover); }
.card.is-pinned         { background: var(--vote-star-bg); }
.card.is-pinned:hover   { background: var(--vote-star-bg-hover); }
.card.is-irrelevant { opacity: 0.4; background: var(--surface); border-color: var(--rule); color: inherit; }
.card.is-bad-extract { opacity: 0.35; background: var(--surface); border-color: var(--rule); color: inherit; }
.card.is-irrelevant:hover { opacity: 0.6; background: var(--surfaceAlt); }
.card.is-bad-extract:hover { background: var(--surfaceAlt); }

.card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.card-titles {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.card-article {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.card-law-name {
  font-size: 0.71rem;
  color: var(--muted);
  margin-top: 0.18rem;
  margin-bottom: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-subtitle {
  font-size: 0.72rem;
  color: var(--muted);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.card:hover .card-actions { opacity: 1; }
.card.is-pinned .card-actions,
.card.is-relevant .card-actions,
.card.is-irrelevant .card-actions,
.card.is-bad-extract .card-actions { opacity: 1; }
/* Voted at rest: show only the active button; hover reveals all */
.card.is-pinned:not(:hover) .vote-btn { opacity: 0; }
.card.is-relevant:not(.is-pinned):not(:hover) .pin-btn,
.card.is-relevant:not(:hover) .vote-btn.vote-reject { opacity: 0; }
.card.is-irrelevant:not(:hover) .pin-btn,
.card.is-irrelevant:not(:hover) .vote-btn.vote-accept { opacity: 0; }

.excerpt {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--ink2);
  line-height: 1.6;
  margin-top: 0.45rem;
  -webkit-line-clamp: 4;
}

/* Pin button → clean icon */
.pin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border: none;
  color: var(--vote-idle-glyph);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s, opacity 0.12s;
  font-size: 0;
}
.pin-btn:hover           { background: var(--color-interactive-hover); color: var(--ink); }
.pin-btn.is-pinned       { background: none; color: var(--vote-star-accent); }
.pin-btn.is-pinned svg   { fill: var(--vote-star-glyph); stroke: var(--vote-star-glyph); }
.pin-btn.is-pinned:hover { background: var(--color-interactive-hover); color: var(--vote-star-accent); }

/* Vote buttons → minimal icon style */
.vote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--vote-idle-glyph);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.vote-btn:hover { background: var(--color-interactive-hover); color: var(--ink); }
.vote-btn.vote-accept { color: var(--vote-idle-glyph); }
.vote-btn.vote-reject { color: var(--vote-idle-glyph); }
.vote-btn.vote-accept.voted { color: var(--vote-relevant-glyph); }
.vote-btn.vote-reject.voted { color: var(--bad); }
.vote-btn.vote-accept:hover { background: var(--color-interactive-hover); color: var(--ink); }
.vote-btn.vote-reject:hover { background: var(--color-interactive-hover); color: var(--ink); }
.vote-btn.vote-accept.voted:hover { color: var(--vote-relevant-glyph); }
.vote-btn.vote-reject.voted:hover { color: var(--bad); }

/* ── Chat messages ───────────────────────────────────────────── */

.msg { padding: 0.6rem 1rem; }

.msg-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.msg-assistant .msg-content {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--ink2);
}

.msg-user { display: flex; justify-content: flex-end; padding: 0.5rem 1rem; }
.msg-user .msg-label { display: none; }
.msg-user .msg-content {
  background: var(--color-role-message-soft);
  color: var(--color-role-message);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.87rem;
  line-height: 1.55;
  max-width: 85%;
}

/* ── Right rail: suppress old text-indicator on pane buttons ── */
.pane-toggle-btn::after { display: none !important; }

/* ── Pinned strip: only show when a conversation is active ──── */
body:not(.chatting-active) #pinned-strip { display: none !important; }

/* ── Chat form not shown in home state inside views ─────────── */
#history-view #chat-form,
#documents-view #chat-form,
#workflows-view #chat-form { display: none; }

/* ── Document list rows — Counselor row layout ──────────────── */

#vault-list {
  border-color: var(--border);
}

.doc-item {
  display: grid;
  grid-template-columns: 86px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 0.7rem 1.1rem 0.7rem 0.85rem;
  border: none !important;
  border-bottom: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  background: var(--surface);
  transition: background 0.12s ease-out;
}
.doc-item:first-child { border-top: none !important; }
.doc-item:last-child { border-bottom: none !important; }
.doc-item:hover { background: var(--surfaceAlt); }

/* Type tile — left column, spans both rows */
.doc-item .doc-item-type {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.2rem 0.4rem;
  margin-bottom: 0;
  align-self: center;
}

/* Title — right column, row 1 */
.doc-item .doc-item-title {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  -webkit-line-clamp: unset;
}

/* Meta — right column, row 2 */
.doc-item .doc-item-meta {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Type tile colors — Counselor palette */
.doc-item .doc-chip-submission      { background: var(--color-role-chip-soft); color: var(--color-role-chip-text); }
.doc-item .doc-chip-legal-brief     { background: var(--color-cat-purple-bg); color: var(--color-cat-purple-fg); }
.doc-item .doc-chip-legal-letter    { background: var(--color-cat-green-bg); color: var(--good); }
.doc-item .doc-chip-contract-clause { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.doc-item .doc-chip-legal-notice    { background: var(--color-cat-red-bg); color: var(--bad); }
.doc-item .doc-chip-memo            { background: var(--canvas); color: var(--ink2); }
.doc-item .doc-chip-key-points      { background: var(--color-role-chip-soft); color: var(--color-role-chip-text); }
.doc-item .doc-chip-narrative       { background: var(--color-cat-green-bg); color: var(--good); }
.doc-item .doc-chip-legal-analysis  { background: var(--color-cat-purple-bg); color: var(--color-cat-purple-fg); }
.doc-item .doc-chip-timeline        { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.doc-item .doc-chip-action-items    { background: var(--color-cat-red-bg); color: var(--bad); }
.doc-item .hist-doc-draft           { background: var(--color-role-chip-soft); color: var(--color-role-chip-text); }
.doc-item .hist-doc-summary         { background: var(--color-cat-green-bg); color: var(--good); }

/* ── Workflow grid cards — Counselor redesign ───────────────── */

.wfv-card {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
  padding: 0.9rem 1rem 0.8rem;
  min-height: auto;
  gap: 0.45rem;
  transition: box-shadow 0.12s ease-out, border-color 0.12s ease-out;
}
.wfv-card:hover { box-shadow: var(--shadow-md) !important; border-color: var(--borderStrong) !important; }
.wfv-card-actionable:hover { border-color: var(--accent) !important; }

/* Icon tile */
.wfv-card .wf-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--canvas);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink2);
  flex-shrink: 0;
  margin-bottom: 0.15rem;
}

.wfv-card .wf-title {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.35;
}

.wfv-card .wf-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.3rem;
}

/* Badge chips */
.wf-badge {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}
.wf-draft  { background: var(--color-interactive-active); color: var(--ink); }
.wf-output { background: var(--color-role-chip-soft); color: var(--color-role-chip-text); }
.wf-review { background: var(--color-cat-amber-bg); color: var(--warn); }
.wf-extract { background: var(--color-cat-purple-bg); color: var(--color-cat-purple-fg); }

/* Steps meta — mono muted */
.wfv-card .wf-steps {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0;
}

/* Pin button aligned to Counselor palette */
.wf-pin-btn { color: var(--border); }
.wf-pin-btn.pinned { color: var(--ink); }
.wf-pin-btn:not(.pinned):hover { color: var(--muted); }
.wf-pin-btn.pinned:hover { color: var(--bad); }

/* ── Tools page redesign ─────────────────────────────────────── */

/* Page topbar */
#workflows-view {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--canvas);
  flex: 1;
  padding: 0;
  gap: 0;
}

/* Toolbar */
.wfv-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 36px;
  height: 44px;
  box-sizing: border-box;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wfv-tabs-wrap {
  display: flex;
  gap: 0;
  background: none;
  border-radius: 0;
  padding: 0;
  border: none;
}

.wfv-tab {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.wfv-tab.active { color: var(--ink); font-weight: 600; background: none; box-shadow: none; border-bottom-color: var(--color-navy); }
.wfv-tab:hover:not(.active) { color: var(--ink2); background: none; }

/* Scroll area */
.wfv-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 36px 40px;
  min-height: 0;
}

/* Section */
.wfv-section {
  margin-bottom: 32px;
}

.wfv-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.wfv-section-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.wfv-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.wfv-section-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.wfv-section-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* 4-column section grid */
.wfv-section-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.wfv-section-grid-flat {
  grid-template-columns: repeat(4, 1fr);
}

/* Rich card */
.wfv-card2 {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s ease-out, border-color 0.12s ease-out;
}
.wfv-card2:hover { box-shadow: var(--shadow-md); border-color: var(--borderStrong); }
.wfv-card2-feat:hover { border-color: var(--accent) !important; }

/* Description popover */
.wfv-tooltip {
  display: none;
  position: fixed;
  z-index: 9000;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--font-serif);
  color: var(--ink2);
  line-height: 1.55;
  box-shadow: var(--shadow-md);
}

/* Pin button */
.wfv-pin2 {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--border);
  border-radius: 4px;
  padding: 0;
  transition: color 0.12s;
}
.wfv-pin2:hover { color: var(--muted); }

/* Card top row: icon tile + name/steps */
.wfv-card2-top {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.wfv-ico-tile {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wfv-card2-names {
  min-width: 0;
  padding-top: 1px;
}

.wfv-card2-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.wfv-card2-steps {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Description */
.wfv-card2-desc {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink2);
  line-height: 1.5;
  flex: 1;
}

/* Footer */
.wfv-card2-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.wfv-card2-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}

.wfv-card2-launch {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Favourites — topbar+toolbar+scroll layout (matches Vault/Tools) ── */

#favourites-view {
  overflow: hidden !important;
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  width: 100% !important;
  flex-direction: column;
}

/* Chats tab — same row style as History */
.fav-chats .hist-item {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--rule) !important;
  border-left: 3px solid transparent !important;
  box-shadow: none !important;
  padding: 0.55rem 0.75rem 0.55rem 0.85rem;
}
.fav-chats .hist-item:last-child { border-bottom: none !important; }
.fav-chats .hist-item:hover { background: var(--surfaceAlt) !important; box-shadow: none !important; }

/* Extracts tab — individual cards with gap */
.fav-extracts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fav-extracts .fav-extract {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom: 1px solid var(--border);
  padding: 14px;
  transition: box-shadow 0.12s ease-out;
}
.fav-extracts .fav-extract:hover { box-shadow: var(--shadow-md); }
.fav-extract-text { font-family: var(--font-serif); font-size: 13px; color: var(--ink2); line-height: 1.55; font-style: italic; margin: 0; }
.fav-extract-source { font-size: 11px; color: var(--muted); font-weight: 500; }


.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 36px;
  height: 44px;
  box-sizing: border-box;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 36px 40px;
  min-height: 0;
  margin-top: 0 !important;
}

/* ── New thread button — solid navy primary CTA ─────────────── */

.create-btn {
  background: var(--ink) !important;
  color: var(--surface) !important;
  border: none !important;
  font-weight: 600;
}
.create-btn svg { stroke: var(--surface); }

/* ── History view — flat row list ───────────────────────────── */

#hist-list {
  /* plain container — card styling is on .hist-items-card per section */
}

/* Group labels — eyebrow style */
.hist-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.6rem 0.85rem 0.3rem;
}

/* Item typography */
.hist-item-title { color: var(--ink); font-size: 0.845rem; }
.hist-item-query { color: var(--muted); font-size: 0.78rem; }
.hist-item-meta  { color: var(--muted); font-size: 0.7rem; }
.hist-item-time  {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
}

/* History delete button */
.history-delete { color: var(--muted); }
.history-delete:hover { color: var(--bad); background: var(--color-state-reject-tint); }

/* ── Home screen — max-width alignment & polish ─────────────── */

/* Widen all home-state columns to 760px */
#home-header,
#chat-panel:not(.chatting) #chat-form,
#home-starters {
  max-width: 760px;
}

/* Vault menu — Counselor tokens */
.vault-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.vault-option { color: var(--ink2); font-size: 0.82rem; border-radius: var(--radius-sm); }
.vault-option:hover { background: var(--canvas); }
.vault-option.active { background: var(--color-interactive-active); color: var(--color-text-primary); font-weight: 500; }

/* Source pills — Counselor tokens */
.home-pill {
  border-color: var(--border);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.76rem;
}
.home-pill:hover { border-color: var(--ink); color: var(--ink); background: none; }
.pill-add { color: var(--border); }

/* ── Home starter prompts ────────────────────────────────────── */

#home-starters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem 2rem;
  box-sizing: border-box;
}

/* Hide in chat state */
#chat-panel.chatting #home-starters { display: none; }

.home-starter {
  text-align: left;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--font-sans);
  transition: background 0.12s ease-out, border-color 0.12s ease-out, box-shadow 0.12s ease-out;
}
.home-starter:hover {
  background: var(--surfaceAlt);
  border-color: var(--borderStrong);
  box-shadow: var(--shadow-sm);
}

.home-starter-icon {
  color: var(--muted);
  display: block;
  margin-bottom: 0.1rem;
}

.home-starter-title {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.3;
  display: block;
}

.home-starter-meta {
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
}

/* ── Counselor: Draft / Summary setup form ───────────────────────── */
.draft-setup-label { color: var(--muted); }

.draft-type-input {
  border-color: var(--border);
  background: var(--canvas);
  color: var(--ink);
}
.draft-type-input:focus { border-color: var(--accent); background: var(--surface); }
.draft-type-input::placeholder { color: var(--muted); }

.draft-tpl-name { color: var(--ink2); }
.draft-tpl-desc { color: var(--muted); }

.draft-tpl-opt {
  border-color: var(--border);
  background: var(--surface);
}
.draft-tpl-opt:hover { border-color: var(--borderStrong); background: var(--surfaceAlt); }
.draft-tpl-opt.draft-tpl-selected { border-color: var(--accent); background: var(--accentSoft); }
.draft-tpl-opt.draft-tpl-selected .draft-tpl-name { color: var(--accentInk); }

.draft-setup-icon { color: var(--ink); opacity: 0.35; }

/* ── Counselor: Outline / Argument builder ───────────────────────── */
.outline-label { color: var(--muted); }

.outline-claim-input,
.outline-entry-input {
  border-color: var(--border);
  background: var(--canvas);
  color: var(--ink);
}
.outline-claim-input:focus,
.outline-entry-input:focus { border-color: var(--accent); background: var(--surface); }
.outline-claim-input::placeholder,
.outline-entry-input::placeholder { color: var(--muted); }

.outline-entry-num { color: var(--muted); }

.outline-add-btn {
  color: var(--muted);
  border-color: var(--color-text-hint);
}
.outline-add-btn:hover { background: var(--color-role-interactive-soft); border-color: var(--color-role-interactive); color: var(--ink); }

/* ── Counselor: Draft type pills ────────────────────────────────── */
.draft-type-pill {
  border-color: var(--border);
  background: var(--surface);
  color: var(--ink2);
}
.draft-type-pill:hover { border-color: var(--borderStrong); background: var(--surfaceAlt); }
.draft-type-pill.active { border-color: var(--accent); background: var(--accentSoft); color: var(--accentInk); }

/* ── Counselor: Assistant message background ────────────────────── */
.msg-assistant .msg-content {
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}

/* ── Counselor: Typing indicator dots ───────────────────────────── */
.dot { background: var(--muted); opacity: 0.5; }

/* ── Counselor: Message action buttons ──────────────────────────── */
.msg-action-btn {
  border-color: var(--border);
  color: var(--muted);
}
.msg-action-btn:hover { border-color: var(--borderStrong); color: var(--ink2); background: var(--surfaceAlt); }
.msg-action-btn.copied { border-color: var(--color-state-relevant-border); color: var(--good); background: var(--color-cat-green-bg); }
.msg-action-btn.dim { color: var(--border); }
.msg-action-btn.dim:hover { border-color: var(--border); color: var(--border); background: none; }

/* ── Counselor: Draft editor toolbar ───────────────────────────── */
#editor-toolbar {
  border-bottom-color: var(--border);
  background: var(--surface);
}

.editor-sep { background: var(--border); }

.editor-style-btn { color: var(--ink2); }
.editor-style-menu { border-color: var(--border); }
.editor-style-opt { color: var(--ink2); }
.editor-style-opt:hover { background: var(--surfaceAlt); }

.editor-tool-btn { color: var(--muted); }
.editor-tool-btn:hover { background: var(--surfaceAlt); color: var(--ink2); border-color: var(--border); }
.editor-tool-btn.active { background: var(--accentSoft); color: var(--accent); border-color: var(--accentSoft); }

.editor-uci-toggle.active { background: var(--color-cat-amber-bg); color: var(--warn); border-color: var(--color-state-flag-border); }

/* ── Counselor: Draft editor body + footer ──────────────────────── */
#editor-body {
  color: var(--ink2);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.7;
}

.editor-footer {
  border-top-color: var(--border);
  background: var(--surface);
}

/* ── Counselor: Draft doc type tag ──────────────────────────────── */
.draft-doc-type-tag {
  color: var(--color-role-chip-text);
  background: var(--color-role-chip-soft);
  border-color: transparent;
}

/* ── Counselor: Thread regen bar ────────────────────────────────── */
.thread-regen-bar {
  background: var(--surface);
  border-bottom-color: var(--border);
}
.thread-regen-btn {
  color: var(--ink);
  border-color: var(--border);
}
.thread-regen-btn:hover { background: var(--canvas); border-color: var(--borderStrong); }

/* ── Counselor: Alert panel ─────────────────────────────────────── */
.alert-input,
.alert-textarea {
  border-color: var(--border);
  background: var(--canvas);
  color: var(--ink);
}
.alert-input:focus,
.alert-textarea:focus { border-color: var(--accent); background: var(--surface); }
.alert-input::placeholder,
.alert-textarea::placeholder { color: var(--muted); }

.alert-tone-pill { border-color: var(--border); color: var(--muted); background: var(--surface); }
.alert-tone-pill:hover { border-color: var(--borderStrong); color: var(--ink2); }
.alert-tone-pill.active { border-color: var(--accent); color: var(--accentInk); background: var(--accentSoft); }

.alert-preview-empty strong { color: var(--muted); }
.alert-preview-content h1,
.alert-preview-content h2 { color: var(--ink); }
.alert-preview-content .alert-meta { color: var(--muted); border-bottom-color: var(--border); }
.alert-preview-content { color: var(--ink2); }

/* ── Counselor: Chronology panel ────────────────────────────────── */
.chrono-upload-zone { border-color: var(--border); }
.chrono-upload-zone.drag-over { border-color: var(--accent); background: var(--accentSoft); color: var(--accentInk); }
.chrono-upload-hint { color: var(--muted); }

.chrono-paste {
  border-color: var(--border);
  background: var(--canvas);
  color: var(--ink);
}
.chrono-paste:focus { border-color: var(--accent); background: var(--surface); }

.chrono-timeline-empty strong { color: var(--muted); }

/* ── Counselor: Transcribe panel ────────────────────────────────── */
#transcribe-input-panel .panel-main,
#transcribe-output-panel .panel-main { background: var(--surface); border-right-color: var(--border); }

.transcribe-upload-zone { border-color: var(--border); }
.transcribe-upload-zone.drag-over { border-color: var(--accent); background: var(--accentSoft); color: var(--accentInk); }

.transcribe-file-remove:hover { color: var(--bad); }

.transcribe-record-btn { border-color: var(--border); color: var(--muted); }
.transcribe-record-btn:hover { border-color: var(--ink); color: var(--ink); }
.transcribe-record-btn.recording { border-color: var(--bad); color: var(--bad); background: var(--color-state-reject-bg); }

.transcribe-progress-label { color: var(--muted); }
.transcribe-progress-bar { background: var(--border); }

/* ── Counselor: Checklist panel ─────────────────────────────────── */
#checklist-setup-panel .panel-main,
#checklist-list-panel .panel-main { background: var(--surface); border-right-color: var(--border); }

.checklist-category-title { color: var(--ink); border-bottom-color: var(--border); }
.checklist-item { border-bottom-color: var(--border); }
.checklist-item-label { color: var(--ink2); }
.checklist-item.done .checklist-item-label { color: var(--muted); }
.checklist-item-note { color: var(--muted); }
.checklist-assignee,
.checklist-due { color: var(--muted); }
.checklist-checkbox { accent-color: var(--ink); }

/* ── Counselor: Risk panel ──────────────────────────────────────── */
#risk-input-panel .panel-main,
#risk-register-panel .panel-main,
#risk-matrix-panel .panel-main { background: var(--surface); border-right-color: var(--border); }

.risk-table tr:hover td { background: var(--surfaceAlt); }

.risk-badge-critical { background: var(--color-state-reject-bg); color: var(--bad); }
.risk-badge-high     { background: var(--color-cat-amber-bg); color: var(--warn); }
.risk-badge-medium   { background: var(--color-cat-amber-bg); color: var(--warn); }
.risk-badge-low      { background: var(--color-state-accept-bg); color: var(--good); }

.risk-score-critical { background: var(--bad); }
.risk-score-high     { background: var(--warn); }
.risk-score-medium   { background: var(--color-risk-medium); }
.risk-score-low      { background: var(--good); }

/* ── Counselor: History + Vault workflow type chips ─────────────── */
.hist-wf-client-alert,
.vault-wf-client-alert,
.hist-wf-closing-checklist,
.vault-wf-closing-checklist { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }

.hist-wf-generate-chronology,
.vault-wf-generate-chronology { background: var(--color-cat-green-bg); color: var(--good); }

.hist-wf-assess-risk,
.vault-wf-assess-risk { background: var(--color-cat-red-bg); color: var(--bad); }

.hist-wf-transcribe-hearing { background: var(--canvas); color: var(--muted); }

/* ── Vault redesign ─────────────────────────────────────────── */

#documents-view {
  flex-direction: row !important;
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  overflow: hidden !important;
}

/* Filter sidebar */
#vault-filters {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}

.vf-head {
  padding: 0 16px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.vf-group {
  padding: 10px 8px 6px 16px;
}

.vf-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.vf-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  margin-right: 8px;
}
.vf-item:hover { background: var(--canvas); }
.vf-item.active { background: var(--accentSoft); color: var(--accentInk); font-weight: 500; }

.vf-type-row { gap: 7px; justify-content: flex-start; }
.vf-type-row .vf-count { margin-left: auto; }

.vf-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.vf-count {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.vf-more {
  color: var(--muted);
  font-size: 12px;
  justify-content: flex-start;
}

/* Main content */
#vault-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Toolbar */
.vault-toolbar {
  padding: 0 24px;
  height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vault-tabs {
  display: flex;
  gap: 0;
  background: none;
  border-radius: 0;
  padding: 0;
  border: none;
}

.vault-tab {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: color 0.12s, border-color 0.12s;
}
.vault-tab.active {
  color: var(--ink);
  font-weight: 600;
  background: none;
  box-shadow: none;
  border-bottom-color: var(--color-navy);
}
.vault-tab:hover:not(.active) { color: var(--ink2); background: none; }

.vault-filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--surfaceAlt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.vault-filter-btn:hover { border-color: var(--accent); background: var(--accentSoft); color: var(--accent); }
.vault-filter-btn.vault-filter-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
  font-weight: 600;
}
.vault-filter-btn.vault-filter-active:hover {
  border-color: var(--accentHover);
  color: var(--accentHover);
  background: var(--surface);
}

.vault-filter-menu {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--color-border-faint), 0 2px 6px var(--color-interactive-hover);
  z-index: 500;
  min-width: 180px;
  padding: 4px 4px 6px;
  overflow: hidden;
}
.vault-filter-menu.open { display: block; }

.vfm-head {
  padding: 9px 12px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3px;
}

.vfm-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.vault-filter-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  text-align: left;
}
.vault-filter-opt:hover { background: var(--canvas); }
.vault-filter-opt.active { font-weight: 600; background: var(--accentSoft); color: var(--accent); }
.vault-filter-opt.active::after {
  content: '✓';
  margin-left: auto;
  padding-left: 14px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.vault-filter-opt.active:hover { background: var(--color-surface-selected); color: var(--accent); }


/* List body + group headers */
.vault-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 36px 40px;
  background: var(--canvas);
}

.vault-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 0 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  background: var(--canvas);
}

.vgh-rule {
  width: 20px;
  height: 1px;
  background: var(--borderStrong);
  flex-shrink: 0;
}

/* List view rows */
.vault-doc-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 17px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 11px;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.vault-doc-row:hover { border-color: var(--borderStrong); box-shadow: var(--shadow-sm); }

.vdr-icon {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.vdr-tile {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18);
}

.vdr-chip {
  position: absolute;
  bottom: -5px;
  right: -4px;
  background: var(--surface);
  border: 1.5px solid;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.4;
  font-family: var(--font-sans);
}

.vdr-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vdr-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vdr-meta {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}


.vdr-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11.5px;
  flex-shrink: 0;
}

.vdr-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vdr-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--surface);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.vdr-tile-sage {
  background: var(--color-iris-muted);
  color: #6B7E79;
  box-shadow: none;
}

.vdr-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.vdr-summary  { background: var(--color-cat-navy-bg); color: var(--color-cat-navy-fg); }
.vdr-brief    { background: var(--color-iris-muted); color: var(--ink2); }
.vdr-letter   { background: var(--color-iris-muted); color: var(--ink2); }
.vdr-memo     { background: var(--color-cat-slate-bg); color: var(--color-cat-slate-fg); }
.vdr-notice   { background: var(--color-cat-red-bg); color: var(--color-cat-red-fg); }
.vdr-argument { background: var(--color-cat-navy-bg); color: var(--color-cat-navy-fg); }
.vdr-contract { background: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.vdr-draft    { background: var(--color-surface-raised); color: var(--muted); }

/* ── Vault view toggle ──────────────────────────────────────────────────────── */
.vault-view-toggle {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--surfaceAlt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}

.vvt-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
}
.vvt-btn svg { display: block; flex-shrink: 0; }
.vvt-btn:hover:not(.active) { background: var(--accentSoft); color: var(--accent); }
.vvt-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.vvt-btn.active:hover {
  background: var(--surface);
  color: var(--accentHover);
}

/* ── Vault grid view ────────────────────────────────────────────────────────── */
.vault-grid-body {
  flex: 1;
  overflow-y: auto;
  background: var(--canvas);
  padding: 4px 24px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-content: start;
}

.vault-group-head.vgh-span {
  grid-column: 1 / -1;
}

.vault-grid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.12s ease-out, border-color 0.12s ease-out;
}
.vault-grid-card:hover { box-shadow: var(--shadow-md); border-color: var(--borderStrong); }

.vgc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.vgc-badge-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.vgc-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--surface);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.vgc-date {
  font-size: 11px;
  color: var(--muted);
}

.vgc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vgc-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vgc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.vgc-time {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.vgc-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ── Library-view shared layout (History + Sources) ───────────── */

#history-view,
#sources-view {
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  overflow: hidden !important;
}

/* ── Unified page header (all main views) ─────────────────── */
.page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 36px 18px;
  flex-shrink: 0;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
  white-space: nowrap;
}

.page-sub {
  display: none;
}

.page-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.page-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.page-search {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 200px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  transition: border-color 0.12s;
}
.page-search:focus-within { border-color: var(--borderStrong); }
.page-search svg { color: var(--muted); flex-shrink: 0; }
.page-search input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
  font-family: var(--font-sans);
  flex: 1;
  min-width: 0;
}
.page-search input::placeholder { color: var(--muted); }

.lv-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 36px;
  height: 44px;
  box-sizing: border-box;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lv-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 36px 40px;
  background: var(--canvas);
}

/* History view item overrides for full-page list */
#history-view .hist-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#history-view .hist-group {
  margin-bottom: 6px;
}

#history-view .hist-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--canvas);
}

#history-view .hist-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 11px;
  padding: 17px 22px;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
#history-view .hist-item:hover { border-color: var(--borderStrong); box-shadow: var(--shadow-sm); }

#history-view .hist-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

#history-view .hist-item-time {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Sources list area */
#sources-view #sources-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Source card token refresh */
#sources-view .source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s, border-color 0.12s;
}
#sources-view .source-card:hover { box-shadow: var(--shadow-md); border-color: var(--borderStrong); }

#sources-view .source-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

#sources-view .source-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0 8px;
}

#sources-view .source-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

#sources-view .source-section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--accentSoft);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 99px;
}

#sources-view .source-doc-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.75rem;
}
#sources-view .source-doc-btn:hover {
  border-color: var(--borderStrong);
  background: var(--surfaceAlt);
}

#sources-view .extract-note {
  background: var(--canvas);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink2);
}
#sources-view .extract-note::placeholder { color: var(--muted); }
#sources-view .extract-note:focus { border-style: solid; border-color: var(--accent); outline: none; }

/* ── Report Issue button ─────────────────────────────────────────────── */

/* ── Report Issue modal ──────────────────────────────────────────────── */
#report-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

#report-modal-overlay[hidden] { display: none; }

#report-modal {
  background: var(--color-surface-panel);
  border-radius: var(--radius-lg);
  width: min(480px, 92vw);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
}

.report-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.report-modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.report-modal-close-btn {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--hint);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s;
}

.report-modal-close-btn:hover { color: var(--ink); background: var(--color-surface-raised); }

.report-session-context {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.report-session-context[hidden] { display: none; }

.report-session-label { flex-shrink: 0; }

.report-session-chip {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--ink2);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-issue-textarea {
  width: 100%;
  border: 1px solid var(--color-border-neutral);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--color-surface-input);
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.report-issue-textarea:focus { border-color: var(--accent); }
.report-issue-textarea::placeholder { color: var(--hint); }

.report-char-count {
  font-size: 0.7rem;
  color: var(--hint);
  text-align: right;
  margin-top: -8px;
}

.report-issue-error {
  font-size: 0.8rem;
  color: var(--bad);
  background: var(--color-state-reject-tint);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.report-issue-error[hidden] { display: none; }

.report-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.report-cancel-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 7px 16px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-sans);
  transition: background 0.12s, color 0.12s;
}

.report-cancel-btn:hover { background: var(--color-surface-raised); color: var(--ink); }

.report-submit-btn {
  background: var(--color-navy);
  color: var(--color-text-on-navy);
  border: none;
  border-radius: var(--radius-md);
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s;
}

.report-submit-btn:not(:disabled):hover { background: var(--color-button-primary-hover); }
.report-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Toast ───────────────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--color-navy);
  color: var(--color-text-on-navy);
  padding: 9px 20px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Admin Issues View ───────────────────────────────────────────────── */
#issues-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 2rem 2.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.issues-filters {
  display: flex;
  gap: 6px;
  padding: 0 1.5rem 1rem;
}

.issues-filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-sans);
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.issues-filter-btn:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }

.issues-filter-btn.active {
  background: var(--color-text-primary);
  border-color: var(--color-text-primary);
  color: var(--color-surface-panel);
}

.issues-session-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-role-interactive);
  text-decoration: none;
}

.issues-session-link:hover { text-decoration: underline; }

.issues-expand-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--color-role-interactive);
  cursor: pointer;
  padding: 0 3px;
  text-decoration: underline;
  font-family: var(--font-sans);
}

.issues-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.issues-status-open {
  background: var(--color-cat-amber-bg);
  color: var(--color-cat-amber-fg);
}

.issues-status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 22px 3px 9px;
  cursor: pointer;
  font-family: var(--font-sans);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23555'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 7px 5px;
}

.issues-status-select:disabled { opacity: 0.5; cursor: wait; }

.issues-status-select--open    { background-color: var(--color-cat-amber-bg); color: var(--color-cat-amber-fg); }
.issues-status-select--pending { background-color: var(--color-cat-sky-bg);   color: var(--color-cat-sky-fg); }
.issues-status-select--closed  { background-color: var(--color-cat-green-bg); color: var(--color-cat-green-fg); }

.issues-pagination {
  display: flex;
  justify-content: center;
  padding: 16px 0 24px;
}

/* ── vault-filters-row: keeps filters together in one flex row ── */
.vault-filters-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

