/* ── Counselor design tokens ────────────────────────────────── */
:root {
  --canvas:       #f4f1ea;
  --surface:      #ffffff;
  --surfaceAlt:   #fafaf6;
  --ink:          #0B1E3E;
  --ink2:         #1f2a44;
  --muted:        #6b7488;
  --border:       #e6e1d4;
  --borderStrong: #d4cdb8;
  --rule:         #ece6d6;
  --accent:       #2057d6;
  --accentHover:  #1a47b8;
  --accentSoft:   #e8efff;
  --accentInk:    #0a2a7a;
  --good:         #256a4a;
  --warn:         #b5530b;
  --bad:          #a52727;
  --radius:       8px;
  --radius-sm:    6px;
  --radius-lg:    12px;
  --shadow-sm:    0 1px 0 rgba(11,30,62,.04), 0 1px 2px rgba(11,30,62,.04);
  --shadow-md:    0 4px 12px rgba(11,30,62,.06), 0 1px 2px rgba(11,30,62,.04);
  --font-sans:    'Geist', 'Inter', 'Helvetica Neue', system-ui, sans-serif;
  --font-serif:   'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

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

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #fff;
  color: #111;
  display: flex;
  flex-direction: column;
}

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

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

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

#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #ebebeb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
  border-right: 1px solid #e5e5e5;
}

#sidebar.collapsed { width: 52px; }
#sidebar.collapsed .sidebar-top    { justify-content: center; padding-left: 0; padding-right: 0; }
#sidebar.collapsed .logo-wordmark  { 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; }

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem 0.45rem;
  flex-shrink: 0;
  min-width: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
}

.logo-mark {
  color: #0e1f3d;
  flex-shrink: 0;
  opacity: 1;
  display: block;
}

.logo-wordmark {
  font-family: 'Raleway', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(14,31,61,0.65);
  letter-spacing: 0.25em;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: rgba(14,31,61,0.3);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.2s ease;
}
#sidebar-toggle:hover { color: rgba(14,31,61,0.7); background: none; }
#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: rgba(14,31,61,0.7);
  font-size: 0.81rem;
  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: rgba(14,31,61,0.06); color: #0e1f3d; }
#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: 7px;
  background: none;
  color: rgba(14,31,61,0.45);
  font-size: 0.83rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  width: 100%;
}
.nav-item:hover { background: rgba(14,31,61,0.05); color: rgba(14,31,61,0.8); }
.nav-item.active { background: rgba(14,31,61,0.07); color: #0e1f3d; font-weight: 600; }
.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: rgba(14,31,61,0.4); }
.sidebar-wf-icon { display: flex; align-items: center; flex-shrink: 0; }
.sidebar-wf-icon svg { width: 15px; height: 15px; }
.sidebar-workflow-item.active { color: #0e1f3d; background: rgba(14,31,61,0.07); 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: rgba(14,31,61,0.28); 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: rgba(14,31,61,0.04); }
.phase-track-icon { display: flex; align-items: center; flex-shrink: 0; color: rgba(14,31,61,0.3); transition: color 0.15s; }
.phase-track-icon svg { width: 15px; height: 15px; }
.phase-track-connector { width: 1.5px; height: 12px; background: rgba(14,31,61,0.12); margin-left: calc(0.85rem + 7px); }
.phase-track-label { font-size: 0.78rem; color: rgba(14,31,61,0.4); transition: color 0.15s; }
.phase-track-item.active .phase-track-icon { color: #0e1f3d; }
.phase-track-item.active .phase-track-label { color: #0e1f3d; font-weight: 600; }
.phase-track-item:hover .phase-track-icon { color: rgba(14,31,61,0.6); }
#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.1rem 0.5rem;
  min-height: 0;
}

#sidebar-history {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(14,31,61,0.1) transparent;
}

.sidebar-nav-header {
  color: rgba(14,31,61,0.6);
  font-size: 0.82rem;
  font-weight: 500;
}
.sidebar-nav-header.active {
  background: none;
  color: #0e1f3d;
  font-weight: 600;
}
.sidebar-nav-header:hover { background: rgba(14,31,61,0.05); color: rgba(14,31,61,0.85); }

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

.sidebar-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 0 0.5rem;
  flex-shrink: 0;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.5rem;
}

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

.sidebar-ctrl-btn {
  font-size: 0.72rem;
  color: rgba(14,31,61,0.5);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: inherit;
}
.sidebar-ctrl-btn:hover { color: #0e1f3d; background: rgba(14,31,61,0.06); }

.sidebar-signout {
  color: rgba(14,31,61,0.45);
  font-size: 0.75rem;
}
.sidebar-signout:hover { color: #0e1f3d; }

.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: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0e1f3d;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

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

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

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

#topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0.3rem 1rem;
  background: transparent;
}

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

.topbar-workflow-id {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #0e1f3d;
}

.topbar-workflow-star {
  color: #c8102e;
  font-size: 0.6rem;
  line-height: 1;
}

.topbar-nautilus {
  font-family: 'Raleway', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #0e1f3d;
}

#topbar-workflow-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #0e1f3d;
}


.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: #999;
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  transition: color 0.12s;
}
.topbar-link:hover { color: #111; background: #f0f0f0; }
.topbar-matter-summary { color: #0e1f3d; font-weight: 600; }
.topbar-matter-summary:hover { background: rgba(14,31,61,0.08); }

/* 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 #e5e5e5; background: #fff; gap: 0.75rem; flex-shrink: 0; }
.thread-regen-label { font-size: 0.72rem; color: rgba(14,31,61,0.45); letter-spacing: 0.02em; }
.thread-regen-btn { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; font-weight: 600; color: #0e1f3d; background: none; border: 1px solid rgba(14,31,61,0.22); border-radius: 4px; padding: 0.28rem 0.65rem; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.thread-regen-btn:hover { background: rgba(14,31,61,0.06); border-color: rgba(14,31,61,0.4); }
.draft-regen-btn { border: none; font-size: 0.7rem; padding: 0.2rem 0.5rem; }

.analytics-btn {
  background: none;
  border: none;
  color: #999;
  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: #111; background: #f0f0f0; }

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

.lang-dropdown {
  position: relative;
  margin-left: 0.4rem;
}
.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s;
}
.lang-code {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #444;
}
.lang-btn:hover {
  border-color: #e5e5e5;
  background: #f0f0f0;
}
.lang-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 0.3rem;
  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: 5px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: #333;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
}

.lang-option:hover { background: #f0f0f0; }
.lang-option.active { background: #e8edf5; font-weight: 500; color: #0e1f3d; }


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

.domain-toggle {
  display: flex;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
}
.domain-btn {
  background: none;
  border: none;
  color: #888;
  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 #e5e5e5; }
.domain-btn:hover  { color: #111; background: #f0f0f0; }
.domain-btn.active { color: #0e1f3d; background: rgba(14,31,61,0.07); 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: #fff;
  border-right: 1px solid #e5e5e5;
  color: #c0bdba;
}
.workspace-panel.panel-collapsed .panel-collapsed-strip {
  flex: 0 0 36px;
}
.panel-collapsed-strip:hover { color: #888; background: #fafafa; }

.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: #ccc;
  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: #555; background: #f0f0f0; }

#pane-toggles {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.pane-toggle-btn {
  background: none;
  border: none;
  color: #aaa;
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  position: relative;
}
.pane-toggle-btn::after {
  content: '';
  display: block;
  height: 2px;
  border-radius: 1px;
  background: #0e1f3d;
  position: absolute;
  bottom: 2px;
  left: 0.65rem;
  right: 0.65rem;
  transform: scaleX(0);
  transition: transform 0.15s;
}
.pane-toggle-btn:hover { color: #555; background: #f0f0f0; }
.pane-toggle-btn.active { color: #0e1f3d; font-weight: 600; background: none; }
.pane-toggle-btn.active::after { transform: scaleX(1); }


/* ── 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: #999;
  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: #eeecf0;
  color: #111;
  border-bottom-right-radius: 3px;
}

.msg-assistant .msg-content {
  background: #eeecf0;
  color: #111;
  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: #bbb;
  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 #e5e5e5;
  padding: 0.75rem;
  background: #fff;
}

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

#chat-form textarea:focus {
  outline: none;
  border-color: #0e1f3d;
}

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

#status {
  font-size: 0.8rem;
  color: #888;
}

button {
  padding: 0.45rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #0e1f3d;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

button:hover    { background: #1a3460; }
button:disabled { background: #aaa; cursor: not-allowed; }

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

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

#draft-panel .panel-main {
  background: #fff;
  overflow: hidden;
}

.draft-panel-header {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
}

.draft-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.draft-panel-icon {
  color: #888;
  flex-shrink: 0;
}

.draft-doc-type-tag {
  font-size: 0.69rem;
  color: #0e1f3d;
  background: none;
  border: 1px solid #c8d8f0;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.draft-doc-type-tag:empty { display: none; }

.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: rgba(14,31,61,0.45);
  cursor: pointer;
  position: relative;
}
.panel-icon-btn:hover { background: rgba(14,31,61,0.06); color: #0e1f3d; }
.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: #0e1f3d;
  color: #fff;
  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: #0e1f3d; opacity: 0.5; }

.draft-setup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  margin: 0;
}

.draft-setup-sub {
  font-size: 0.82rem;
  color: #999;
  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: #aaa;
}

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

.draft-type-pill {
  background: none;
  border: 1px solid #e5e5e5;
  color: #666;
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.draft-type-pill:hover { background: #f0f0f0; color: #111; border-color: #bbb; }
.draft-type-pill.active { background: #e5ecf8; border-color: #0e1f3d; color: #0e1f3d; font-weight: 500; }

.draft-type-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.83rem;
  border: 1px solid #e5e5e5;
  border-radius: 7px;
  background: #fff;
  color: #111;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.draft-type-input:focus { border-color: #0e1f3d; }
.draft-type-input::placeholder { color: #ccc; }

.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 #e5e5e5;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.draft-tpl-opt:hover { border-color: #aaa; background: #fafafa; }
.draft-tpl-opt.draft-tpl-selected { border-color: #0e1f3d; background: #f0f4fb; cursor: default; }
.draft-tpl-opt.draft-tpl-soon { opacity: 0.4; cursor: default; }
.draft-tpl-opt.draft-tpl-soon:hover { border-color: #e5e5e5; background: none; }

.draft-tpl-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #333;
}
.draft-tpl-opt.draft-tpl-selected .draft-tpl-name { color: #0e1f3d; }

.draft-tpl-desc { font-size: 0.72rem; color: #aaa; }

.draft-generate-btn {
  background: #0e1f3d;
  color: #fff;
  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-generate-btn:hover { background: #1a3460; }

.draft-upload-zone {
  border: 1.5px dashed #e5e5e5;
  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: #aaa;
  text-align: center;
}
.draft-upload-zone:hover,
.draft-upload-zone.drag-over { border-color: #0e1f3d; background: #f5f7fc; color: #0e1f3d; }
.draft-upload-text { font-size: 0.8rem; }
.draft-upload-browse { color: #0e1f3d; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.draft-upload-hint { font-size: 0.69rem; color: #ccc; }
#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: #f5f7fc;
  border: 1px solid #d5e0f0;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #0e1f3d;
}
.draft-upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-upload-remove {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.draft-upload-remove:hover { color: #c8102e; 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: #f5f7fc;
  border: 1px solid #d5e0f0;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #333;
}
.chat-file-chip svg { flex-shrink: 0; color: #667; }
.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: #aaa;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.chat-file-remove:hover { color: #c8102e; 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: #889; }
.draft-upload-item.uploading { opacity: 0.7; }
.draft-upload-item.uploading .draft-upload-item-name::after { content: " (uploading…)"; font-style: italic; color: #889; }

.msg-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: #f5f7fc;
  border: 1px solid #d5e0f0;
  border-radius: 5px;
  font-size: 0.72rem;
  color: #556;
  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: #e8edfa;
  border-color: #b0c4e8;
}

.draft-setup-note {
  font-size: 0.73rem;
  color: #ccc;
  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 #e5e5e5;
  background: #fafafa;
  flex-shrink: 0;
  gap: 0.5rem;
  height: 38px;
  width: 100%;
}


.panel-header-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #666;
  flex: 1;
}

.panel-header-title--raleway {
  font-family: 'Raleway', sans-serif;
  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: #444;
  flex: 1;
}

.panel-header-count {
  font-weight: 400;
  font-size: 0.72rem;
  color: #999;
  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: #fff;
  border-right: 1px solid #e5e5e5;
  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: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.outline-claim-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 70px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #111;
  background: #fafafa;
  transition: border-color 0.12s, background 0.12s;
}
.outline-claim-input:focus { outline: none; border-color: #0e1f3d; background: #fff; }

.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: #ccc;
  min-width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.outline-entry-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font-size: 0.83rem;
  font-family: inherit;
  color: #111;
  background: #fafafa;
  transition: border-color 0.12s, background 0.12s;
}
.outline-entry-input:focus { outline: none; border-color: #0e1f3d; background: #fff; }
.outline-entry-counter { border-color: #f0d5d5; background: #fff8f8; }
.outline-entry-counter:focus { border-color: #c8102e !important; }

.outline-entry-remove {
  background: none;
  border: none;
  color: #ddd;
  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: #c8102e; }

.outline-add-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px dashed #e5e5e5;
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  font-family: inherit;
  color: #aaa;
  cursor: pointer;
  align-self: flex-start;
  transition: border-color 0.12s, color 0.12s;
}
.outline-add-btn:hover { border-color: #0e1f3d; color: #0e1f3d; }

.outline-build-btn {
  padding: 0.58rem 1rem;
  background: #0e1f3d;
  color: #fff;
  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;
}
.outline-build-btn:hover { background: #1a3460; }

/* ── 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: #bbb;
  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: #1a1a1a;
}
.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: #fff;
  border-right: 1px solid #e5e5e5;
  overflow: hidden;
}

#alert-preview-panel .panel-main {
  background: #fff;
  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: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #e5e5e5;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafafa;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-input:focus { border-color: #0e1f3d; background: #fff; }

.alert-textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #e5e5e5;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafafa;
  resize: vertical;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.alert-textarea:focus { border-color: #0e1f3d; background: #fff; }

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

.alert-tone-pill {
  padding: 0.32rem 0.8rem;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  background: none;
  font-size: 0.78rem;
  font-family: inherit;
  color: #666;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.alert-tone-pill:hover { border-color: #aaa; color: #111; }
.alert-tone-pill.active { border-color: #0e1f3d; color: #0e1f3d; background: #e8edf5; 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: #bbb;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.alert-preview-empty strong { color: #888; }

.alert-preview-content {
  flex: 1;
  padding: 2rem;
  font-size: 0.88rem;
  line-height: 1.75;
  color: #111;
  overflow-y: auto;
}
.alert-preview-content h1 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; color: #0e1f3d; }
.alert-preview-content h2 { font-size: 0.9rem; font-weight: 600; margin: 1.2rem 0 0.3rem; color: #0e1f3d; }
.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: #888; margin-bottom: 1.5rem; border-bottom: 1px solid #e5e5e5; 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: #fff;
  border-right: 1px solid #e5e5e5;
  overflow: hidden;
}

#chrono-timeline-panel .panel-main {
  background: #fff;
  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 #e5e5e5;
  border-radius: 7px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #888;
  font-size: 0.82rem;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-upload-zone:hover,
.chrono-upload-zone.drag-over { border-color: #0e1f3d; background: #f5f7fc; color: #0e1f3d; }
.chrono-upload-hint { font-size: 0.72rem; color: #bbb; }
.chrono-upload-zone input[type="file"] { display: none; }

.chrono-or {
  text-align: center;
  font-size: 0.72rem;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chrono-paste {
  width: 100%;
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  color: #111;
  background: #fafafa;
  resize: none;
  outline: none;
  min-height: 160px;
  transition: border-color 0.12s, background 0.12s;
}
.chrono-paste:focus { border-color: #0e1f3d; background: #fff; }

.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: #bbb;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
}
.chrono-timeline-empty strong { color: #888; }

.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: #e5e5e5;
}
.chrono-event:last-child::before { display: none; }

.chrono-event-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  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: #0e1f3d;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #0e1f3d;
}

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

.chrono-event-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 0.2rem;
}

.chrono-event-desc {
  font-size: 0.8rem;
  color: #555;
  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: #fff; border-right: 1px solid #e5e5e5; overflow: hidden; }
#transcribe-output-panel .panel-main { background: #fff; 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 #e5e5e5;
  border-radius: 7px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #888;
  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: #0e1f3d; background: #f5f7fc; color: #0e1f3d; }
.transcribe-upload-zone input[type="file"] { display: none; }

.transcribe-file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0f4fb;
  border: 1px solid #c5d3ec;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: #0e1f3d;
}
.transcribe-file-info span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transcribe-file-remove {
  background: none; border: none; cursor: pointer; color: #888; font-size: 0.9rem; padding: 0 0.2rem;
  line-height: 1; flex-shrink: 0;
}
.transcribe-file-remove:hover { color: #c8102e; }

.transcribe-divider {
  text-align: center;
  font-size: 0.72rem;
  color: #bbb;
  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 #e5e5e5;
  border-radius: 6px;
  background: none;
  font-size: 0.82rem;
  font-family: inherit;
  color: #444;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.transcribe-record-btn:hover { border-color: #0e1f3d; color: #0e1f3d; }
.transcribe-record-btn.recording { border-color: #c8102e; color: #c8102e; background: #fff5f5; }
.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: #c8102e;
  font-variant-numeric: tabular-nums;
}

.transcribe-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.transcribe-progress-label { font-size: 0.78rem; color: #666; }
.transcribe-progress-bar { height: 4px; background: #e8e5df; border-radius: 2px; overflow: hidden; }
.transcribe-progress-fill {
  height: 100%;
  background: #0e1f3d;
  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: #999;
  margin-top: 0.75rem;
}
.transcribe-section-label:first-child { margin-top: 0; }

.transcribe-summary {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #111;
  background: #fff;
  border-left: 3px solid #0e1f3d;
  padding: 0.75rem 1rem;
  border-radius: 0 5px 5px 0;
}

.transcribe-transcript {
  font-size: 0.82rem;
  line-height: 1.8;
  color: #333;
  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: #fff; border-right: 1px solid #e5e5e5; overflow: hidden; }
#checklist-list-panel  .panel-main { background: #fff; 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: #0e1f3d;
  padding: 0.5rem 0 0.4rem;
  border-bottom: 1px solid #e5e5e5;
  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 #e5e5e5;
}
.checklist-item:last-child { border-bottom: none; }

.checklist-checkbox {
  width: 15px;
  height: 15px;
  accent-color: #0e1f3d;
  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: #111;
  line-height: 1.4;
}
.checklist-item.done .checklist-item-label { text-decoration: line-through; color: #aaa; }

.checklist-item-note {
  font-size: 0.75rem;
  color: #888;
  font-style: italic;
}

.checklist-assignee {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  padding-top: 2px;
}

.checklist-due {
  font-size: 0.72rem;
  color: #888;
  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: #fff; border-right: 1px solid #e5e5e5; overflow: hidden; }
#risk-register-panel .panel-main { background: #fff; border-right: 1px solid #e5e5e5; overflow: hidden; }
#risk-matrix-panel   .panel-main { background: #fff; 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: #fafafa;
  border-bottom: 1px solid #e5e5e5;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-weight: 600;
  color: #666;
  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 #e5e5e5;
  vertical-align: top;
  color: #111;
  line-height: 1.4;
}
.risk-table tr:last-child td { border-bottom: none; }
.risk-table tr:hover td { background: #fafafa; }

.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: #fde8e8; color: #c8102e; }
.risk-badge-high     { background: #fdf0e0; color: #b45309; }
.risk-badge-medium   { background: #fef9e0; color: #92690a; }
.risk-badge-low      { background: #e8f5ee; color: #166534; }

.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: #fff;
}
.risk-score-critical { background: #c8102e; }
.risk-score-high     { background: #d97706; }
.risk-score-medium   { background: #ca8a04; }
.risk-score-low      { background: #16a34a; }

.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: #fff;
  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;
  gap: 0.2rem;
  border-bottom: 1px solid #e5e5e5;
  padding: 0.35rem 0;
  flex-shrink: 0;
}

#tab-bar .tab {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: none;
  color: rgba(14,31,61,0.4);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

#tab-bar .tab:hover { color: rgba(14,31,61,0.7); background: rgba(14,31,61,0.05); }

#tab-bar .tab.active {
  color: #0e1f3d;
  background: rgba(14,31,61,0.07);
  font-weight: 600;
}

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

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

.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  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: #0e1f3d;
  margin-bottom: 0.15rem;
  word-break: break-word;
}

.card-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: #666;
  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: #0e1f3d;
  background: #e5ecf8;
  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: #dcfce7;
  color: #166534;
  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: #f0f0f0; color: #666; }
.via-graph  { background: #f3eaff; color: #6b21a8; }

.score {
  font-size: 0.68rem;
  color: #aaa;
  margin-left: auto;
}

.path {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0e1f3d;
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.article-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0e1f3d;
  margin-bottom: 0.3rem;
}

.via-reason {
  font-size: 0.7rem;
  color: #888;
  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: #e5ecf8; color: #0e1f3d; }
.chip-type       { background: #f0fdf4; color: #15803d; }
.chip-year       { background: #f5f5f5; color: #555;    }
.chip-parties    { background: #fff7ed; color: #92400e; }
.chip-obligation { background: #fef3c7; color: #78350f; font-style: italic; }
.chip-subject    { background: #f3e8ff; color: #6b21a8; }

.excerpt {
  font-size: 0.8rem;
  color: #333;
  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: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pdf-link:hover { color: #0e1f3d; }

.doc-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.doc-link:hover { color: #0e1f3d; }

.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: #999; 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: #e5ecf8; color: #0e1f3d; }
.tag-case { background: #fef3e8; color: #b45309; }

.no-results { font-size: 0.85rem; color: #aaa; }

/* ── 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: #888;
}

.source-section-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  background: #0e1f3d;
  padding: 0.05rem 0.45rem;
  border-radius: 99px;
}

.source-card {
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: #fafafa;
}

.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: #0e1f3d;
  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;
}

.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: #1a1a1a;
  line-height: 1.6;
  font-weight: 500;
  background: #f8f7f4;
  border-left: 3px solid #0e1f3d;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0 0;
  border-radius: 0 4px 4px 0;
}

.source-card-description {
  font-size: 0.75rem;
  color: #888;
  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: #999;
  white-space: nowrap;
}

.source-field-value {
  font-size: 0.78rem;
  color: #333;
}

.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: #e8ecf1;
  color: #3a506b;
}

.source-tag-matched { background: #dff0df; color: #2b6e2b; }
.source-tag-unmatched { background: #fce8e8; color: #9e3333; }

.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: #0e1f3d;
  background: #fff;
  border: 1px solid #c5cdd8;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.source-doc-btn:hover {
  background: #edf1f7;
  border-color: #0e1f3d;
}

.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: #f8f8f8;
  border-color: #e0e0e0;
  color: #aaa;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.extract-vote-good:hover, .extract-vote-good.voted { background: #dcfce7; border-color: #4ade80; color: #15803d; }
.extract-vote-bad:hover,  .extract-vote-bad.voted  { background: #fee2e2; border-color: #f87171; color: #b91c1c; }

.extract-note {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: #444;
  background: #fafaf9;
  border: 1px solid #e5e2dc;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.extract-note::placeholder { color: #bbb; }
.extract-note:focus { outline: none; border-color: #a0aec0; }
.extract-note-saved { animation: extractNoteSaved 0.9s ease forwards; }
@keyframes extractNoteSaved {
  0%   { border-color: #4ade80; box-shadow: 0 0 0 2px #bbf7d0; }
  60%  { border-color: #4ade80; box-shadow: 0 0 0 2px #bbf7d0; }
  100% { border-color: #e5e2dc; box-shadow: none; }
}

.source-articles-container {
  margin-top: 0.5rem;
  border-top: 1px solid #e2e6ed;
  padding-top: 0.5rem;
}

.articles-chapter-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #0e1f3d;
  margin: 0.6rem 0 0.3rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #e2e6ed;
}

.article-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0f2f5;
}

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

.article-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: #2c5282;
  margin-bottom: 0.15rem;
}

.article-text {
  font-size: 0.7rem;
  color: #374151;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

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

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

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

#modal {
  background: #fff;
  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: #aaa;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
}
#modal-close:hover { background: #f0f0f0; color: #333; }

.modal-path {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0e1f3d;
  margin-bottom: 0.25rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0e1f3d;
  margin-bottom: 0.6rem;
  line-height: 1.35;
}

.modal-excerpt {
  font-size: 0.845rem;
  color: #222;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e5e5;
}

.modal-file-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #333;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.modal-file-content {
  font-size: 0.82rem;
  color: #222;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8f9fc;
  border: 1px solid #e5e8f0;
  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: #c8c8c8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.card.is-pinned {
  border-color: #93c5fd;
  background: #eff6ff;
}

.card.is-relevant {
  border-color: #86efac;
  background: #f0fdf4;
}

.card.result-mentioned {
  border-color: #93c5fd;
  background: #dbeafe;
}

.card.is-irrelevant {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #9ca3af;
}

.card.is-bad-extract {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #9ca3af;
}

/* Vote buttons */
.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;
  font-weight: 400;
}
.vote-btn.vote-accept      { background: #f0fdf4; border-color: #bbf7d0; color: #86efac; }
.vote-btn.vote-reject      { background: #fef2f2; border-color: #fecaca; color: #fca5a5; }
.vote-btn.vote-bad-extract { background: #fffbeb; border-color: #fde68a; color: #fcd34d; }
.vote-btn.vote-accept:hover      { background: #dcfce7; border-color: #4ade80; color: #15803d; }
.vote-btn.vote-reject:hover      { background: #fee2e2; border-color: #f87171; color: #b91c1c; }
.vote-btn.vote-bad-extract:hover { background: #fff7ed; border-color: #fb923c; color: #c2410c; }
.vote-btn.vote-accept.voted      { background: #dcfce7; border-color: #4ade80; color: #15803d; }
.vote-btn.vote-reject.voted      { background: #fee2e2; border-color: #f87171; color: #b91c1c; }
.vote-btn.vote-bad-extract.voted { background: #fff7ed; border-color: #fb923c; color: #c2410c; }

/* 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 #e5e5e5;
}
.modal-vote-label {
  font-size: 0.78rem;
  color: #888;
}

/* Pin button */
.pin-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 0.15rem 0.4rem;
  color: #93c5fd;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.2;
  min-width: 1.6rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 400;
  flex-shrink: 0;
}
.pin-btn:hover     { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pin-btn.is-pinned { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }

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

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

.sources-trust-label {
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #15803d;
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  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: hidden on desktop */
#mobile-tab-bar { display: none; }

/* 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: rgba(255,255,255,0.75);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
  }
  .topbar-settings-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

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

  /* Hide "Set client matter" button — too complex for mobile home state */
  .home-context-btns .home-ctx-btn:not([id]) { 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;
  }

  /* 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: 6px;
    padding: 5px 0 6px;
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #e5e2dc;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }
  .mobile-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.2s, transform 0.2s;
  }
  .mobile-dot.active { background: #0e1f3d; transform: scale(1.3); }

  /* 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: #fafafa;
    min-height: 0;
  }

  .mvh-header {
    padding: 1.25rem 1.1rem 0.75rem;
    border-bottom: 1px solid #e8e5df;
    flex-shrink: 0;
  }

  .mvh-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    margin: 0;
  }

  .mvh-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
  }

  .mvh-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    cursor: pointer;
    transition: background 0.1s;
  }
  .mvh-item:hover { background: #f0f0f0; }
  .mvh-item-name {
    flex: 1;
    font-size: 0.85rem;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mvh-item-time {
    font-size: 0.72rem;
    color: #aaa;
    flex-shrink: 0;
  }
  .mvh-empty {
    padding: 2rem 1.1rem;
    font-size: 0.83rem;
    color: #aaa;
    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: #fff;
    border-top: 1px solid #e5e5e5;
    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: #aaa;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.15s;
  }
  .mob-tab:hover { color: #555; }
  .mob-tab.active { color: #0e1f3d; background: rgba(14,31,61,0.07); font-weight: 600; border-radius: 8px; }
  .mob-tab.active svg { stroke: #0e1f3d; }

  /* 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 #e8e5df;
  }
  #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; }
}

/* ── 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 #e5e5e5;
  border-radius: 0;
  background: #fff;
  padding: 0.75rem;
  max-width: none;
  margin: 0;
  overflow: visible;
}
#chat-panel.chatting #chat-form textarea {
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  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: #0e1f3d;
}

/* ── 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: #c8102e;
  font-size: 0.72rem;
  line-height: 1;
}

.home-wordmark {
  font-family: 'Raleway', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #0e1f3d;
}

/* 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 #e5e5e5;
  border-radius: 6px;
  background: none;
  color: #666;
  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: #f0f0f0; color: #111; border-color: #bbb; }
.home-ctx-btn.vault-active { border-color: #0e1f3d; color: #0e1f3d; }

.vault-dropdown { position: relative; }
.vault-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e5e5e5;
  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: #333;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
}
.vault-option:hover { background: #f0f0f0; }
.vault-option.active { background: #e8edf5; font-weight: 500; color: #0e1f3d; }

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

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

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

/* Home action row */
#home-action-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fafafa;
  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 #e5e5e5;
  color: #666;
  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: #f0f0f0; color: #111; }

#home-ask-btn {
  background: #0e1f3d;
  color: #fff;
  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:hover { background: #1a3460; }
#home-ask-btn:disabled { background: #aaa; 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 #e5e5e5;
  border-radius: 99px;
  background: none;
  color: #666;
  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: #0e1f3d; color: #0e1f3d; background: none; }
.pill-add { color: #bbb; font-size: 0.8rem; }
.home-pill:hover .pill-add { color: #0e1f3d; }

/* ── 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: #aaa;
  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: #e5e5e5 transparent;
}

.workflow-card {
  flex-shrink: 0;
  width: 162px;
  background: #fff;
  border: 1px solid #e5e5e5;
  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: #bbb; }

.wf-icon { color: #777; flex-shrink: 0; }
.wf-title { font-size: 0.83rem; font-weight: 600; color: #111; 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: #e5ecf8; color: #0e1f3d; }
.wf-output { background: #f0fdf4; color: #15803d; }
.wf-review { background: #fef3c7; color: #78350f; }
.wf-steps  { font-size: 0.69rem; color: #bbb; }

/* ── 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: #fafafa;
  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: #111;
  margin: 0;
}

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

.wfv-search-wrap {
  position: relative;
  max-width: 320px;
}

.wfv-search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}

.wfv-search-input {
  width: 100%;
  padding: 0.42rem 0.75rem 0.42rem 2rem;
  font-family: inherit;
  font-size: 0.82rem;
  border: 1px solid #e5e5e5;
  border-radius: 7px;
  background: #fff;
  color: #111;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.wfv-search-input:focus { border-color: #0e1f3d; }

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

.wfv-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  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: #aaa; }
.wfv-card-actionable:hover { border-color: #0e1f3d; box-shadow: 0 2px 14px rgba(14,31,61,0.13); }
.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: #ccc;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.wf-pin-btn.pinned { color: #0e1f3d; }
.wf-pin-btn:not(.pinned):hover { color: #888; }
.wf-pin-btn.pinned:hover { color: #c0392b; }

.wfv-card .wf-icon { color: #6b7280; }
.wfv-card .wf-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111;
  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: #f3e8ff; color: #6b21a8; }

/* ── 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;
}

.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: #0e1f3d;
  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 #e5e5e5;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.lib-type-pill:hover { border-color: #0e1f3d; color: #0e1f3d; }
.lib-type-pill.active { background: #0e1f3d; border-color: #0e1f3d; color: #fff; }

/* ── History view ── */

.hist-clear-all-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 0.78rem;
  color: #999;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}
.hist-clear-all-btn:hover { color: #c0392b; background: #fdf0ef; }

.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: #c0c0c0;
  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-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
  transition: background 0.1s;
}
.hist-item:hover { background: #f5f5f5; }
.hist-item:hover .history-delete { opacity: 1; }

.hist-item[data-domain="maritime"]    { border-left-color: #0e1f3d; }
.hist-item[data-domain="swiss"]       { border-left-color: #9b1c1c; }
.hist-item[data-domain="swiss_family"]{ border-left-color: #c47a00; }
.hist-item[data-domain="montenegro"]  { border-left-color: #166534; }

.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: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-item-query {
  font-size: 0.78rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-item-meta {
  font-size: 0.7rem;
  color: #bbb;
}

.hist-item-time {
  font-size: 0.72rem;
  color: #bbb;
  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: #bbb;
  line-height: 1;
}
.hist-icon-results { color: #166534; 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: #eef1f8;
  color: #0e1f3d;
  border: 1px solid #d0d8ea;
  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: #e5ecf8; color: #0e1f3d; }
.hist-domain-swiss         { background: #fdecea; color: #9b1c1c; }
.hist-domain-swiss_family  { background: #fff3e0; color: #7c4700; }
.hist-domain-montenegro    { background: #e6f4ea; color: #166534; }

.hist-wf-legal-research      { background: #f0f0f0; color: #555; }
.hist-wf-draft-submission    { background: #e5ecf8; color: #0e1f3d; }
.hist-wf-support-argument    { background: #ede9f8; color: #4c1d95; }
.hist-wf-summary             { background: #f0fdf4; color: #15803d; }
.hist-wf-client-alert        { background: #fef3c7; color: #78350f; }
.hist-wf-generate-chronology { background: #f0fdf4; color: #15803d; }
.hist-wf-transcribe-hearing  { background: #f0f0f0; color: #555; }
.hist-wf-closing-checklist   { background: #fef3c7; color: #78350f; }
.hist-wf-assess-risk         { background: #fdecea; color: #9b1c1c; }

/* ── Templates view ── */

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

.tpl-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  min-height: 110px;
}
.tpl-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.09); border-color: #0e1f3d; }

.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: #e5ecf8; color: #0e1f3d; }
.tpl-brief      { background: #fef3c7; color: #78350f; }
.tpl-letter     { background: #f0fdf4; color: #15803d; }
.tpl-contract   { background: #fdecea; color: #9b1c1c; }
.tpl-notice     { background: #f3e8ff; color: #6b21a8; }

.tpl-name {
  font-size: 0.845rem;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
  flex: 1;
}

.tpl-jurisdiction {
  font-size: 0.72rem;
  color: #888;
}

.tpl-modified {
  font-size: 0.69rem;
  color: #bbb;
  margin-top: auto;
}

/* ── Favourites view ── */

.fav-tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid #e5e2dc;
  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: rgba(14,31,61,0.4);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.fav-tab:hover  { color: rgba(14,31,61,0.7); background: rgba(14,31,61,0.05); }
.fav-tab.active { color: #0e1f3d; background: rgba(14,31,61,0.07); font-weight: 600; }

.fav-content { margin-top: 1.25rem; }
.fav-list { display: flex; flex-direction: column; gap: 0; border: 1px solid #e5e2dc; border-radius: 8px; overflow: hidden; }

.fav-extract {
  padding: 1rem;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fff;
  cursor: pointer;
  transition: background 0.1s;
}
.fav-extract:last-child { border-bottom: none; }
.fav-extract:hover { background: #f5f5f5; }

.fav-extract-text {
  font-size: 0.845rem;
  color: #333;
  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: #888;
  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: #bbb;
}

.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: #f5f5f5; }

.vault-item-title {
  flex: 1;
  min-width: 0;
  font-size: 0.845rem;
  font-weight: 500;
  color: #111;
  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: #f0f0f0;
  color: #555;
}
.vault-wf-draft-submission  { background: #e5ecf8; color: #0e1f3d; }
.vault-wf-support-argument  { background: #ede9f8; color: #4c1d95; }
.vault-wf-summary           { background: #f0fdf4; color: #15803d; }
.vault-wf-client-alert      { background: #fef3c7; color: #78350f; }
.vault-wf-generate-chronology { background: #f0fdf4; color: #15803d; }
.vault-wf-closing-checklist { background: #fef3c7; color: #78350f; }
.vault-wf-assess-risk       { background: #fdecea; color: #9b1c1c; }

.vault-client {
  font-size: 0.75rem;
  color: #999;
  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: #e5ecf8; color: #0e1f3d; }
.hist-doc-summary { background: #f0fdf4; color: #15803d; }

/* Per-subtype colors for Documents view */
.doc-chip-submission      { background: #dbeafe; color: #1e40af; }
.doc-chip-legal-brief     { background: #e0e7ff; color: #4338ca; }
.doc-chip-legal-letter    { background: #ccfbf1; color: #0f766e; }
.doc-chip-contract-clause { background: #fef3c7; color: #b45309; }
.doc-chip-legal-notice    { background: #fee2e2; color: #b91c1c; }
.doc-chip-memo            { background: #f1f5f9; color: #475569; }

.doc-chip-key-points    { background: #d1fae5; color: #065f46; }
.doc-chip-narrative     { background: #e0f2fe; color: #075985; }
.doc-chip-legal-analysis{ background: #ede9fe; color: #5b21b6; }
.doc-chip-timeline      { background: #ffedd5; color: #c2410c; }
.doc-chip-action-items  { background: #ffe4e6; color: #9f1239; }

/* ── 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 #f0f0f0;
  transition: background 0.1s;
}
.doc-item:first-child { border-top: 1px solid #f0f0f0; }
.doc-item:hover { background: #f7f7f7; }

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

.doc-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111;
  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: #aaa;
  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: rgba(255,255,255,0.1) transparent;
}

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

.sidebar-collapsed-char {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(14,31,61,0.35);
  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;
  max-height: 38vh;
  padding: 0.15rem 0 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(14,31,61,0.1) transparent;
}

/* Section labels (details summaries only) */
.sidebar-section-label { font-size: 0.8rem; font-weight: 500; color: rgba(14,31,61,0.6); }
.sidebar-section-label.active { background: none; box-shadow: none; color: #0e1f3d; 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: rgba(14,31,61,0.6); }

.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: rgba(14,31,61,0.55);
  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: rgba(14,31,61,0.05); color: rgba(14,31,61,0.85); }

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

.history-empty {
  font-size: 0.75rem;
  color: rgba(14,31,61,0.28);
  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: rgba(14,31,61,0.05); }
.history-item.active { background: rgba(14,31,61,0.07); }
.history-item.active .history-name { color: #0e1f3d; 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: rgba(14,31,61,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.history-time {
  font-size: 0.67rem;
  color: rgba(14,31,61,0.28);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-delete {
  background: none;
  border: none;
  padding: 0.1rem 0.25rem;
  font-size: 0.7rem;
  color: rgba(14,31,61,0.25);
  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: #c8102e; background: rgba(14,31,61,0.05); }

/* ── 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 #e5e5e5;
  color: #888;
  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: #bbb; color: #333; background: #f0f0f0; }
.msg-action-btn.copied { border-color: #86efac; color: #166534; background: #f0fdf4; }
.msg-action-btn.dim    { color: #ccc; cursor: default; }
.msg-action-btn.dim:hover { border-color: #e5e5e5; color: #ccc; 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: #bbb;
  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: #555; background: #f0f0f0; }
.footer-icon-btn:disabled { color: #ddd; cursor: not-allowed; background: none; }
.draft-trigger-btn:not(:disabled) { color: #0e1f3d; }

.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 #e5e5e5;
  color: rgba(14,31,61,0.35);
  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: rgba(14,31,61,0.7); 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 #e5e5e5;
  background: #fff;
  flex-shrink: 0;
}

.editor-style-select {
  font-family: inherit;
  font-size: 0.72rem;
  color: #555;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
  cursor: pointer;
  height: 24px;
  outline: none;
  flex-shrink: 0;
}
.editor-style-select:focus { border-color: #0e1f3d; }

.editor-sep {
  width: 1px;
  height: 16px;
  background: #e5e5e5;
  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: #666;
  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: #f0f0f0; color: #111; border-color: #e5e5e5; }
.editor-tool-btn.active { background: #e8ecf5; color: #0e1f3d; border-color: #c5d0e8; }
.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: #fff8e6; color: #92400e; border-color: #fde68a; }


/* 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: #111;
  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 #e5e5e5;
  padding: 0.75rem;
  background: #fff;
  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: 'Courier New', monospace;
  font-size: 0.81rem;
  background: #e5e5e5;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
#editor-body a { color: #0e1f3d; 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 #e5e5e5;
  background: #fafafa;
  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: #111;
  outline: none;
  min-height: 0;
}
#summary-panel.summary-generated #summary-editor-body { display: block; }
#summary-panel.summary-generated .editor-footer { display: flex; }
#summary-panel.summary-generated #summary-setup { display: none; }

#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: 'Courier New', monospace;
  font-size: 0.81rem;
  background: #e5e5e5;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
#summary-editor-body a { color: #0e1f3d; text-underline-offset: 2px; }

/* UCI (tracked changes / redline) mode */
#editor-body.uci-mode ins {
  background: #dcfce7;
  color: #15803d;
  text-decoration: none;
  border-radius: 2px;
}
#editor-body.uci-mode del {
  background: #fee2e2;
  color: #b91c1c;
  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: #fee2e2; color: #b91c1c; }
.priority-badge[data-priority="2"] { background: #fef3c7; color: #92400e; }
.priority-badge[data-priority="3"] { background: #f0f0f0; color: #666; }

/* ══════════════════════════════════════════════════════════════
   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: 42px; box-sizing: border-box; padding-bottom: 0; }

.logo-wordmark {
  font-family: var(--font-sans);
  letter-spacing: 0.22em;
  color: rgba(11,30,62,.55);
}

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

.nav-item { color: var(--muted); border-radius: var(--radius-sm); }
.nav-item:hover { background: rgba(11,30,62,.05); color: var(--ink); }
.nav-item.active { background: rgba(11,30,62,.07); color: var(--ink); font-weight: 600; }

.sidebar-nav-header { color: var(--muted); font-size: 0.81rem; }
.sidebar-nav-header.active { color: var(--ink); background: none; }
.sidebar-nav-header:hover { background: rgba(11,30,62,.04); color: var(--ink2); }

.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: rgba(11,30,62,.07); }

.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: rgba(11,30,62,.05); }

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

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

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

.ws-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.matter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.7rem;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-topbar-sep { color: var(--border); font-size: 0.85rem; }

.ws-topbar-domain {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── 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(--accentSoft);
  color: var(--accentInk);
  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 {
  flex-direction: column;
  align-items: center;
  width: 54px;
  flex-shrink: 0;
  padding: 0.85rem 0 0.75rem;
  background: var(--surface);
  border-left: 1px solid var(--border);
  gap: 0.15rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
#topbar::-webkit-scrollbar { display: none; }

.pane-rail-header {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
  margin-bottom: 0.6rem;
  padding: 0 0.3rem;
  opacity: 0.7;
}

#pane-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0 0.4rem;
  align-items: stretch;
}

.pane-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease-out, color 0.12s ease-out;
  font-size: 0;
}
.pane-toggle-btn:hover { background: rgba(11,30,62,.07); color: var(--ink); }
.pane-toggle-btn.active { background: var(--accentSoft); color: var(--accent); }

/* ── 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: rgba(11,30,62,.06); }

.panel-collapse-btn { color: var(--muted); }
.panel-collapse-btn:hover { color: var(--ink); background: rgba(11,30,62,.06); }

/* ── 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(--accentSoft);
  color: var(--accentInk);
  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(--accentSoft);
  color: var(--accent);
  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: #d4e3ff; }

/* ── 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;
}

/* Hide the old brand mark (nautilus spiral + ✦ Nautilus ✦) in home state */
.home-brand-mark { display: none; }

/* 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); }

/* Vault dropdown — restyle to match chip */
.vault-dropdown { position: relative; }
#vault-btn { box-shadow: var(--shadow-sm); }

/* 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;
}
#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: #fff;
  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-ask-btn:hover { background: #1a3460; }

.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: rgba(11,30,62,.06); }

/* Chat state send button */
#chat-send-btn {
  background: var(--ink);
  color: #fff;
  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-send-btn:hover { background: #1a3460; }

/* 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 {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.9rem;
  transition: color 0.12s, border-color 0.12s;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.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: #fff;
  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(--surfaceAlt); }

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

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

.editor-style-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surfaceAlt);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.78rem;
}

.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: rgba(11,30,62,.06); }

#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 {
  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(--accent); 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: #fff;
  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,
.outline-build-btn:hover { background: #1a3460; }

/* 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: rgba(11,30,62,.06); border-color: var(--borderStrong); }

/* Search inputs */
.wfv-search-input,
.lib-search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-sans);
}
.wfv-search-input:focus,
.lib-search-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accentSoft); }

/* 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: rgba(11,30,62,.06); }
.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: rgba(11,30,62,.06); color: var(--ink); }
.extract-vote-btn.voted-good { color: var(--good); border-color: var(--good); background: rgba(37,106,74,.06); }
.extract-vote-btn.voted-bad  { color: var(--bad);  border-color: var(--bad);  background: rgba(165,39,39,.06); }

/* 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.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.9rem 0.7rem 0.2rem;
  opacity: 0.6;
  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-pinned { background: var(--accentSoft); border-left: 2px solid var(--accent); }
.card.is-relevant { opacity: 1; }
.card.is-irrelevant { opacity: 0.4; }
.card.is-bad-extract { opacity: 0.35; }

.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.2rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.card:hover .card-actions { opacity: 1; }

.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: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  font-size: 0;
}
.pin-btn:hover { color: var(--ink); background: rgba(11,30,62,.05); border-color: var(--borderStrong); }
.pin-btn.is-pinned { color: var(--accent); border-color: var(--accent); background: rgba(14,31,61,.08); }
.pin-btn.is-pinned svg { fill: var(--accent); stroke: var(--accent); }
.pin-btn.is-pinned:hover { color: var(--accent); border-color: var(--accent); background: rgba(14,31,61,.12); }

/* Vote buttons → minimal icon style */
.vote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.vote-btn:hover { background: rgba(11,30,62,.05); color: var(--ink); border-color: var(--borderStrong); }
.vote-btn.vote-accept { background: none; border-color: var(--border); color: var(--muted); }
.vote-btn.vote-reject { background: none; border-color: var(--border); color: var(--muted); }
.vote-btn.vote-accept.voted { background: rgba(37,106,74,.08); color: var(--good); border-color: var(--good); }
.vote-btn.vote-reject.voted { background: rgba(165,39,39,.08); color: var(--bad); border-color: var(--bad); }
.vote-btn.vote-accept:hover { background: rgba(37,106,74,.08); color: var(--good); border-color: var(--good); }
.vote-btn.vote-reject:hover { background: rgba(165,39,39,.08); color: var(--bad); border-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(--accentSoft);
  color: var(--accentInk);
  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(--accentSoft); color: var(--accentInk); }
.doc-item .doc-chip-legal-brief     { background: #ede9f8; color: #4c1d95; }
.doc-item .doc-chip-legal-letter    { background: #f0fdf4; color: var(--good); }
.doc-item .doc-chip-contract-clause { background: #fef3c7; color: #78350f; }
.doc-item .doc-chip-legal-notice    { background: #fdecea; color: var(--bad); }
.doc-item .doc-chip-memo            { background: var(--canvas); color: var(--ink2); }
.doc-item .doc-chip-key-points      { background: var(--accentSoft); color: var(--accentInk); }
.doc-item .doc-chip-narrative       { background: #f0fdf4; color: var(--good); }
.doc-item .doc-chip-legal-analysis  { background: #ede9f8; color: #4c1d95; }
.doc-item .doc-chip-timeline        { background: #fef3c7; color: #78350f; }
.doc-item .doc-chip-action-items    { background: #fdecea; color: var(--bad); }
.doc-item .hist-doc-draft           { background: var(--accentSoft); color: var(--accentInk); }
.doc-item .hist-doc-summary         { background: #f0fdf4; 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: rgba(11,30,62,0.09); color: var(--ink); }
.wf-output { background: var(--accentSoft); color: var(--accentInk); }
.wf-review { background: #fff3ea; color: var(--warn); }
.wf-extract { background: #ede9f8; color: #4c1d95; }

/* 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;
}

.wfv-topbar {
  padding: 22px 36px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wfv-crumb {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.wfv-page-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}

.wfv-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
  max-width: 560px;
  line-height: 1.55;
}

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

.wfv-tabs-wrap {
  display: flex;
  gap: 3px;
  background: var(--surfaceAlt);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.wfv-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.12s, background 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.wfv-tab.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.wfv-tab:hover:not(.active) { background: var(--accentSoft); color: var(--accent); }

/* Inline search in toolbar */
.wfv-search-inline {
  margin-left: auto;
  max-width: 260px;
}

.wfv-search-inline .wfv-search-input {
  background: var(--canvas);
  border-color: var(--border);
  font-size: 12px;
  padding: 6px 10px 6px 28px;
}

/* Scroll area */
.wfv-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 36px 36px;
  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;
}

/* Kill fav-tab underline when displayed as vault-style pills */
.vault-tabs .fav-tab             { border-bottom: none !important; }
.vault-tabs .fav-tab.active      { border-bottom: none !important; border-bottom-color: transparent !important; }

/* 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-topbar {
  padding: 22px 36px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

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

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

.create-btn {
  background: var(--ink) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600;
}
.create-btn:hover { background: #1a3460 !important; color: #fff !important; }
.create-btn svg { stroke: #fff; }

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

#hist-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Strip card treatment from hist-item inside the view */
#hist-list .hist-item {
  background: transparent;
  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;
}
#hist-list .hist-group:last-child .hist-item:last-child {
  border-bottom: none !important;
}
#hist-list .hist-item:hover {
  background: var(--surfaceAlt) !important;
  box-shadow: none !important;
}

/* Domain stripe colors — Counselor palette */
#hist-list .hist-item[data-domain="maritime"]     { border-left-color: var(--ink) !important; }
#hist-list .hist-item[data-domain="swiss"]        { border-left-color: var(--bad) !important; }
#hist-list .hist-item[data-domain="swiss_family"] { border-left-color: var(--warn) !important; }
#hist-list .hist-item[data-domain="montenegro"]   { border-left-color: var(--good) !important; }

/* 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: rgba(165,39,39,.06); }

/* ── 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(--accentSoft); color: var(--accentInk); 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(--accent);
  border-color: var(--border);
}
.outline-add-btn:hover { background: var(--accentSoft); border-color: var(--accent); }

/* ── 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: #86efac; color: var(--good); background: #f0fdf4; }
.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-select {
  color: var(--ink2);
  background: var(--surface);
  border-color: var(--border);
}
.editor-style-select:focus { border-color: var(--accent); }

.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: #fff8e6; color: var(--warn); border-color: #fde68a; }

/* ── 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(--accentInk);
  background: var(--accentSoft);
  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: #fff5f5; }

.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: #fde8e8; color: var(--bad); }
.risk-badge-high     { background: #fdf0e0; color: var(--warn); }
.risk-badge-medium   { background: #fef9e0; color: #92690a; }
.risk-badge-low      { background: #e8f5ee; color: var(--good); }

.risk-score-critical { background: var(--bad); }
.risk-score-high     { background: var(--warn); }
.risk-score-medium   { background: #ca8a04; }
.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: #fef3c7; color: #78350f; }

.hist-wf-generate-chronology,
.vault-wf-generate-chronology { background: #f0fdf4; color: var(--good); }

.hist-wf-assess-risk,
.vault-wf-assess-risk { background: #fdecea; 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;
}

.vault-topbar {
  padding: 18px 24px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  flex-shrink: 0;
}

.vault-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}

.vault-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.vault-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 280px;
  font-size: 12.5px;
  color: var(--muted);
  flex-shrink: 0;
  transition: border-color 0.12s;
}
.vault-search-bar:focus-within { border-color: var(--borderStrong); }

.vault-search-bar input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
  font-family: var(--font-sans);
  flex: 1;
  min-width: 0;
}
.vault-search-bar input::placeholder { color: var(--muted); }

/* Toolbar */
.vault-toolbar {
  padding: 10px 24px;
  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: var(--surfaceAlt);
  border-radius: var(--radius);
  padding: 2px;
  border: 1px solid var(--border);
}

.vault-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.vault-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.vault-tab:hover:not(.active) { background: var(--accentSoft); color: var(--accent); }

.vault-filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  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 rgba(11,30,62,.10), 0 2px 6px rgba(11,30,62,.06);
  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: #dce8ff; color: var(--accent); }


/* List body + group headers */
.vault-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 24px 24px;
  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;
}

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

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

.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: #fff;
  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: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-sans);
  white-space: nowrap;
}

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

.vvt-btn {
  width: 24px;
  height: 24px;
  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: #fff;
  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: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}


