:root {
  /* DEFAULT = light theme (beige paper, slate ink, deep teal). The dark
     palette below applies only when body.theme-dark is set. */
  --bg: #f5f0e6;          /* warm beige paper */
  --panel: #ffffff;
  --panel-2: #ecead8;
  --text: #1c2128;        /* near-black slate */
  --text-strong: #0b0e13;
  --muted: #5f6b7a;       /* blue-grey */
  --accent: #0d5b54;      /* deep teal */
  --accent-on: #ffffff;
  --user: #e6e2d2;
  --border: #cfc8b3;
  --radius: 0;
  --shadow-deep: 0 10px 40px rgba(40, 40, 60, .18);

  --conf-high-fg: #14624f;     --conf-high-bd: #8fd1bb;
  --conf-medium-fg: #8b6914;   --conf-medium-bd: #d5c191;
  --conf-low-fg: #a23030;      --conf-low-bd: #e0a3a3;
  --verify-ok-fg: #14624f;
  --verify-warn-fg: #8b5a14;   --verify-warn-bg: #fbf2dc;   --verify-warn-bd: #d8b67a;
  --lang-warn-fg: #5b3f7a;     --lang-warn-bg: #efe6f5;     --lang-warn-bd: #c7adde;
  --error-fg: #a23030;         --error-bg: rgba(162,48,48,.08);   --error-bd: rgba(162,48,48,.28);
  --code-fg: #815a06;
  --quote-bg: rgba(13, 91, 84, .07);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Iowan Old Style", serif;
}

/* Explicit light keeps the same — `body.theme-light` is a no-op against
   :root defaults, but the class still exists for symmetry with theme-dark. */
body.theme-light { /* same as :root */ }

/* --- Dark theme (opt-in via toggle / OS preference) --- */
body.theme-dark {
  --bg: #0f1012;
  --panel: #17181c;
  --panel-2: #1f2127;
  --text: #ececf1;
  --text-strong: #ffffff;
  --muted: #9a9ba6;
  --accent: #10a37f;
  --accent-on: #04231b;
  --user: #2a2b32;
  --border: #2c2e36;
  --shadow-deep: 0 10px 40px rgba(0, 0, 0, .45);

  --conf-high-fg: #7ee2b8;     --conf-high-bd: #2f6f57;
  --conf-medium-fg: #e8c97a;   --conf-medium-bd: #6f5d2f;
  --conf-low-fg: #e69a9a;      --conf-low-bd: #6f3434;
  --verify-ok-fg: #7ee2b8;
  --verify-warn-fg: #e6b35a;   --verify-warn-bg: #2a2310;   --verify-warn-bd: #6f5d2f;
  --lang-warn-fg: #c8a8e6;     --lang-warn-bg: #1f1729;     --lang-warn-bd: #4a3b6a;
  --error-fg: #e06c6c;         --error-bg: rgba(224,108,108,.12);  --error-bd: rgba(224,108,108,.35);
  --code-fg: #e9d59a;
  --quote-bg: rgba(16, 163, 127, .05);
}

* { box-sizing: border-box; }
/* Cornered design — strip every border-radius site-wide. The component
   styles below still set radii (so this can be reversed by removing this
   block), but everything renders sharp until then. */
* { border-radius: 0 !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; background: var(--bg); color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  transition: background .25s ease, color .25s ease;
}

/* Sidebar — three states driven by body[data-sidebar-state]:
     "full"    (default): 264px, all content visible
     "compact": 60px rail with just icon buttons (uses .sidebar-rail)
     "hidden":  off-canvas, hamburger restores it

   The body data attribute is set by app.js and persisted to localStorage. */
.sidebar {
  width: 264px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px; gap: 12px;
  flex: 0 0 264px;
  transition: width .2s ease, flex-basis .2s ease, transform .2s ease;
}

/* Thin clickable rail on the right edge of the sidebar — clicking
   cycles full → compact → hidden → full. The visible "grip" is a vertical
   bar that fades up on hover so the affordance is discoverable without
   shouting. */
.sidebar { position: relative; }
.sidebar-edge {
  position: absolute; top: 0; right: 0; height: 100%; width: 8px;
  background: transparent; border: 0; padding: 0;
  cursor: ew-resize;
  display: grid; place-items: center;
  z-index: 5;
  transition: background .15s ease;
}
.sidebar-edge:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sidebar-edge-grip {
  width: 3px; height: 36px;
  background: var(--border);
  transition: background .15s ease, height .15s ease;
}
.sidebar-edge:hover .sidebar-edge-grip {
  background: var(--accent); height: 60px;
}
/* Rail variant: handle on the right edge of the compact rail. */
.sidebar-rail { position: relative; }
.sidebar-rail .rail-edge { margin-top: auto; }
.sidebar-rail .sidebar-edge { right: 0; }

/* Compact rail (icon-only nav). Hidden by default; shown when
   body[data-sidebar-state="compact"]. */
.sidebar-rail {
  width: 60px; flex: 0 0 60px;
  background: var(--panel); border-right: 1px solid var(--border);
  display: none; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 6px;
}
.sidebar-rail .rail-brand {
  background: transparent; border: 0; cursor: pointer; padding: 4px;
  display: grid; place-items: center;
}
.sidebar-rail .rail-brand .logo { font-size: 24px; line-height: 1; }
.sidebar-rail .rail-divider {
  height: 1px; width: 28px; background: var(--border); margin: 4px 0;
}
.sidebar-rail .rail-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent; color: var(--muted); border: 1px solid transparent;
  cursor: pointer; transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.sidebar-rail .rail-btn:hover {
  color: var(--text); background: var(--panel-2); border-color: var(--border);
}
.sidebar-rail .rail-btn .icon { width: 18px; height: 18px; }
.sidebar-rail .rail-btn-accent {
  background: var(--accent); color: var(--accent-on);
  border-color: var(--accent);
}
.sidebar-rail .rail-btn-accent:hover {
  background: var(--accent); color: var(--accent-on);
  filter: brightness(1.06);
}

/* State: compact — hide full sidebar, show rail. */
body[data-sidebar-state="compact"] .sidebar { display: none; }
body[data-sidebar-state="compact"] .sidebar-rail { display: flex; }
/* State: hidden — neither shown. */
body[data-sidebar-state="hidden"] .sidebar,
body[data-sidebar-state="hidden"] .sidebar-rail { display: none; }

/* The "collapse" button (between brand and close) is only useful on
   wider viewports where compact is the meaningful next-state. The
   close (×) does the right thing on mobile. */
.sidebar-collapse { display: none; }
@media (min-width: 900px) {
  .sidebar-collapse { display: inline-flex; margin-left: auto; }
  .sidebar-close { display: none; }
}

.brand { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }
.logo {
  font-family: var(--font-serif);
  font-weight: 700; font-size: 28px; letter-spacing: -1.2px;
  color: var(--accent);
  font-feature-settings: "ss01" on;
}
/* Topbar title also uses serif so the brand reads consistently */
.title { font-family: var(--font-serif); font-weight: 600; font-size: 17px; }
.title small { font-family: var(--font-sans); }
/* Empty-state hero + assistant headings — serif for legal-document feel */
.empty h1 { font-family: var(--font-serif); }
.msg .body h1,
.msg .body h2,
.msg .body h3,
.msg .body h4.sect { font-family: var(--font-serif); }
/* Disclaimer stays italic serif — feels like a real legal footnote */
.msg .body .disclaimer-final { font-family: var(--font-serif); }
/* --- Inline SVG icon system --- */
.icon {
  width: 16px; height: 16px;
  display: inline-block; vertical-align: middle;
  flex: 0 0 16px;
  pointer-events: none;
}
.icon-lg { width: 28px; height: 28px; flex-basis: 28px; }

/* --- Omnibar (search-only) + dedicated new-chat button below --- */
.omnibar-wrap { position: relative; margin: 6px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.omnibar {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.omnibar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.omnibar-icon { color: var(--muted); flex: 0 0 16px; }
.omnibar-input {
  flex: 1; background: transparent; color: var(--text);
  border: 0; outline: none;
  padding: 7px 0;
  font: inherit; font-size: 13px;
  min-width: 0;
}
.omnibar-input::placeholder { color: var(--muted); }
.omnibar-input::-webkit-search-cancel-button { display: none; }

/* Dedicated new-chat button — accent-filled, full-width pill below
   the search bar. The Cmd-K of this app. */
.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 9px 12px;
  background: var(--accent); color: var(--accent-on, #fff);
  border: 1px solid var(--accent);
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: .1px;
  cursor: pointer;
  transition: filter .12s ease, transform .05s ease;
}
.new-chat-btn:hover { filter: brightness(1.06); }
.new-chat-btn:active { transform: translateY(1px); }
.new-chat-btn .icon { width: 14px; height: 14px; }
.search-results {
  margin-top: 4px;
  max-height: 50vh; overflow-y: auto;
  border: 1px solid var(--border); background: var(--panel);
}
.search-results[hidden] { display: none !important; }
.search-group-head {
  font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  padding: 8px 12px; background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline;
}
.search-group-count {
  font-size: 10px; font-weight: 700; letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 1px 6px;
}
.search-hit {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; text-align: left; background: transparent; border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  cursor: pointer;
  padding: 9px 12px; color: var(--text);
  transition: background .12s ease;
}
.search-hit:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.search-hit:last-child { border-bottom: none; }
.search-hit-icon {
  flex: 0 0 22px; height: 22px;
  display: inline-grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  margin-top: 1px;
}
.search-hit-icon .icon { width: 13px; height: 13px; }
.search-hit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.search-title {
  font-size: 12.5px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-snippet {
  font-size: 11.5px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.45;
}
.search-title mark, .search-snippet mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent); padding: 0 2px;
  font-weight: 600;
}
.search-empty { padding: 16px 12px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* Search-result filter chips — type + date range. Single-select per group. */
.search-filters {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 4px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
}
.search-filters[hidden] { display: none !important; }
.search-filter-group { display: flex; gap: 4px; flex-wrap: wrap; }
.search-filter {
  background: transparent; border: 1px solid var(--border);
  padding: 3px 8px; font-size: 11px; cursor: pointer; color: var(--muted);
  font: inherit; font-size: 11px;
}
.search-filter:hover { color: var(--text); border-color: var(--accent); }
.search-filter.active {
  background: var(--accent); color: var(--accent-on); border-color: var(--accent);
}


/* Sidebar sections — accordion: only one section expanded at a time.
   The section containing the active item ("ÚJ" tab in conversations, the
   currently open chat, an active client filter, etc.) is auto-opened by
   app.js via `.is-open`; clicking another head switches the open section
   and persists the choice in localStorage. */
.side-section {
  display: flex; flex-direction: column; min-height: 0;
  margin-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.side-section:first-of-type { margin-top: 4px; border-top: 0; }
.side-section-head {
  font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: color .12s ease, background .12s ease;
}
.side-section-head:hover { color: var(--text); background: var(--panel-2); }
.side-section-head:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.side-section.is-open .side-section-head {
  color: var(--text-strong); opacity: 1;
}
.side-section-title {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0;
}
.side-section-title .icon { width: 13px; height: 13px; opacity: .7; flex: 0 0 13px; }
.side-section-title .icon.chev {
  width: 10px; height: 10px; flex: 0 0 10px;
  transition: transform .18s ease;
  opacity: .55;
}
.side-section.is-open .side-section-title .icon.chev {
  transform: rotate(90deg);
  opacity: .8;
}

/* Reasoning trace ("Hogyan jutottam ide") — collapsible <details> block
   inside the HIVATKOZÁSOK panel body. Each step gets a numbered chip,
   a colored dot for ok/error, the tool's HU-label, its args one-liner,
   and a short result summary. The "answer" step gets a green check
   icon and serif title so it reads as the conclusion. */
.trace-panel {
  margin: 8px 12px 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.trace-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 11.5px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
  transition: color .12s ease;
}
.trace-summary::-webkit-details-marker { display: none; }
.trace-summary:hover { color: var(--text); }
.trace-summary .icon {
  width: 12px; height: 12px;
  transition: transform .15s ease;
}
.trace-panel[open] .trace-summary .icon { transform: rotate(180deg); }
.trace-count {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  padding: 1px 7px; border: 1px solid var(--border);
  background: var(--panel);
  text-transform: none; letter-spacing: 0;
}
.trace-list {
  margin: 0; padding: 4px 0 8px;
  list-style: none;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.trace-row {
  display: grid;
  grid-template-columns: 24px 18px 1fr;
  gap: 8px; align-items: flex-start;
  padding: 8px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.trace-row:last-child { border-bottom: 0; }
.trace-step {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.trace-icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding-top: 4px;
}
.trace-icon .icon { width: 12px; height: 12px; color: var(--verify-ok-fg); }
.trace-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: .8;
}
.trace-row.err .trace-dot { background: #b34747; }
.trace-row-answer { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.trace-body { min-width: 0; }
.trace-title {
  font-size: 12.5px; color: var(--text); font-weight: 500;
  line-height: 1.4;
}
.trace-title code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--muted);
  background: transparent; padding: 0;
}
.trace-args {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--muted);
  margin-top: 2px;
  word-break: break-word;
}
.trace-detail {
  font-size: 12px; color: var(--text);
  margin-top: 3px; line-height: 1.45;
  opacity: .85;
}
.trace-meta {
  font-size: 10.5px; color: var(--accent);
  margin-top: 2px;
  font-weight: 600;
}
.trace-row-answer .trace-title {
  font-family: var(--font-serif); font-size: 13.5px;
  font-weight: 600; color: var(--text-strong);
}

/* Body — collapsed sections hide their body completely. The chevron
   rotation still animates so the close/open feels alive. */
.side-section-body {
  display: flex; flex-direction: column;
  min-height: 0;
}
.side-section:not(.is-open) > .side-section-body { display: none; }
/* Hide section-head actions on collapsed sections so the "+" / "⤓" don't
   look clickable when the body underneath is hidden. */
.side-section:not(.is-open) .side-section-action {
  opacity: 0; pointer-events: none;
}
/* Open section gets a bit more breathing room above the body. */
.side-section.is-open > .side-section-body {
  padding-top: 2px;
}
.side-section-action {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: color .12s ease, border-color .12s ease;
}
.side-section-action:hover { color: var(--accent); border-color: var(--accent); }
.side-section-action .icon { width: 12px; height: 12px; }

/* Client / matter folders — same row shape as conversations. */
.client-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; max-height: 22vh; }
.client-row {
  display: flex; align-items: center;
}
.client-row:hover { background: var(--panel-2); }
.client-row.active {
  background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--accent);
}
.client-item {
  flex: 1; background: transparent; border: none; cursor: pointer;
  padding: 6px 10px; min-width: 0; text-align: left; color: var(--text);
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.client-del {
  flex: 0 0 24px; height: 22px; margin-right: 4px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; opacity: 0;
  transition: opacity .12s ease, color .12s ease;
}
.client-row:hover .client-del { opacity: 1; }
.client-del:hover { color: #e06c6c; }

/* Section-head actions — group "+" and "⤓" for the deadlines header. */
.side-section-actions { display: inline-flex; gap: 4px; }
.side-section-actions .side-section-action { text-decoration: none; }

/* Deadlines list — date chip + label. Overdue rows tint red. */
.deadline-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; max-height: 24vh; }
.deadline-row { display: flex; align-items: center; }
.deadline-row:hover { background: var(--panel-2); }
.deadline-row.overdue .deadline-date { color: #e06c6c; font-weight: 600; }
.deadline-item {
  flex: 1; background: transparent; border: none; cursor: pointer;
  padding: 5px 10px; min-width: 0; text-align: left; color: var(--text);
  display: flex; flex-direction: column; gap: 1px; line-height: 1.25;
}
.deadline-date { font-size: 11px; color: var(--muted); letter-spacing: .2px; }
.deadline-label {
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deadline-del {
  flex: 0 0 24px; height: 22px; margin-right: 4px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; opacity: 0;
  transition: opacity .12s ease, color .12s ease;
}
.deadline-row:hover .deadline-del { opacity: 1; }
.deadline-del:hover { color: #e06c6c; }

/* Inline chip showing which client a conversation is tagged to. */
.conv-client-chip {
  display: inline-block; padding: 0 5px;
  background: rgba(13, 91, 84, .14); color: var(--accent);
  font-size: 10px; margin-left: 4px;
  max-width: 80px; overflow: hidden; text-overflow: ellipsis;
  vertical-align: baseline;
}

/* Conversation-row action buttons (tag / rename / pin / share / del /
   restore / purge). Idle state: zero width + zero opacity so the title
   gets the FULL row width. Hover (or row.active, or pin.is-pinned which
   communicates persistent state) expands them back to 22px.
   This trades a tiny layout shift on hover for a far more readable title
   list — previously 5×22px ≈ 110px were silently reserved off-screen. */
.conv-tag, .conv-rename, .conv-pin, .conv-restore, .conv-purge,
.conv-del, .conv-share {
  flex: 0 0 0; width: 0; height: 24px;
  padding: 0; margin: 0; overflow: hidden;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 12px; line-height: 1;
  opacity: 0;
  transition:
    flex-basis .15s ease, width .15s ease, margin .15s ease,
    opacity .15s ease, color .12s ease, background .12s ease;
}
.conv-row:hover .conv-tag,
.conv-row:hover .conv-rename,
.conv-row:hover .conv-pin,
.conv-row:hover .conv-restore,
.conv-row:hover .conv-purge,
.conv-row:hover .conv-del,
.conv-row:hover .conv-share,
.conv-row.active .conv-tag,
.conv-row.active .conv-rename,
.conv-row.active .conv-pin,
.conv-row.active .conv-del,
.conv-row.active .conv-share,
.conv-pin.is-pinned {
  flex: 0 0 22px; width: 22px; opacity: 1;
}
.conv-del { font-size: 16px; }
.conv-row:hover .conv-del { margin-right: 4px; }
.conv-pin.is-pinned { color: var(--accent); }
.conv-tag:hover,
.conv-rename:hover,
.conv-pin:hover,
.conv-restore:hover,
.conv-share:hover { color: var(--accent); background: var(--panel); }
.conv-purge:hover,
.conv-del:hover { color: #e06c6c; background: var(--panel); }

/* Trash drawer rows — non-interactive title (no loadConversation), only
   restore + purge actions on the right. */
.conv-row.trashed { opacity: .78; }
.conv-item-static {
  flex: 1; background: transparent; border: none; padding: 6px 10px;
  min-width: 0; text-align: left; color: var(--muted);
  display: flex; flex-direction: column; gap: 1px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.conv-list, .doc-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv-list { max-height: 42vh; }
.doc-list  { max-height: 32vh; }
.conv-empty { color: var(--muted); font-size: 12px; padding: 8px 10px; opacity: .7; }

/* Document rows in the sidebar — same shape as conversation rows */
.doc-row {
  display: flex; align-items: center;
  /* Enable smooth height collapse on leave + transition for moves. */
  overflow: hidden;
  transition: background .12s ease;
}
.doc-row:hover { background: var(--panel-2); }
/* Enter: fade + slide in from the left edge of the sidebar.
   Leave: fade + slide out + height collapse so the next row eases up. */
@keyframes doc-row-enter {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes doc-row-leave {
  from { opacity: 1; max-height: 60px; transform: translateX(0); }
  to   { opacity: 0; max-height: 0; transform: translateX(-12px); padding-top: 0; padding-bottom: 0; margin: 0; }
}
.doc-row-entering {
  animation: doc-row-enter .28s cubic-bezier(.2, .8, .2, 1) both;
}
.doc-row-leaving {
  animation: doc-row-leave .22s cubic-bezier(.6, 0, .8, .2) both;
  pointer-events: none;
}
.doc-item {
  flex: 1; background: transparent; border: none; cursor: pointer;
  padding: 7px 10px; min-width: 0; text-align: left;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.doc-item .doc-icon { flex: 0 0 16px; font-size: 14px; opacity: .85; }
.doc-meta-col {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1;
}
.doc-item .doc-title {
  font-size: 12.5px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.doc-item .doc-meta {
  font-size: 10.5px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.conv-row {
  position: relative;
  display: flex; align-items: center;
  border-radius: 8px;
}
.conv-row:hover { background: var(--panel-2); }
.conv-row.active { background: var(--panel-2); }
.conv-row.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  background: var(--accent); border-radius: 2px;
}
.conv-item {
  flex: 1; background: transparent; border: none; cursor: pointer;
  padding: 8px 10px; min-width: 0;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  color: var(--text);
}
.conv-item .conv-title {
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-row:not(.active) .conv-item .conv-title { color: #c0c2cf; }
.conv-item .conv-meta {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* .conv-del / .conv-share are now handled by the unified action-button
   block above (flex: 0 0 0 idle, 0 0 22px on hover). */
/* Legacy sidebar-foot — kept as a no-op shell in case any third-party CSS
   targeted these classes; the model selector now lives under the composer. */
.sidebar-foot { display: none; }
.sidebar-foot label { font-size: 12px; color: var(--muted); }
.sidebar-foot select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px;
}

/* Chat column */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--border);
}
.title { font-weight: 600; }
.title small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.status { color: var(--accent); font-size: 12px; }
.status.bad { color: #e06c6c; }

.messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.empty {
  max-width: 720px; margin: 8vh auto 4vh; padding: 0 22px;
  text-align: center; color: var(--muted);
}
.empty h1 {
  color: var(--text-strong); font-weight: 600; font-size: 38px; letter-spacing: -.6px;
  margin: 0 0 12px; line-height: 1.15;
}
.empty p { font-size: 14px; max-width: 540px; margin: 0 auto 22px; line-height: 1.55; }
.empty .disclaimer {
  font-size: 12px; margin-top: 28px; opacity: .7; font-style: italic;
}

/* Empty-state quickstart — two-column card grid with icon + title + subtitle.
   Cards auto-send on click (see app.js delegated handler). */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px auto 0;
  max-width: 760px;
  text-align: left;
}
.prompt-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  padding: 16px 18px;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s ease, background .15s ease,
              transform .08s ease, box-shadow .15s ease;
  text-align: left;
}
.prompt-card:hover {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow:
    0 1px 3px color-mix(in srgb, var(--accent) 22%, transparent),
    0 4px 12px -4px color-mix(in srgb, var(--accent) 14%, transparent);
  transform: translateY(-1px);
}
.prompt-card:active { transform: translateY(0); }
.prompt-card-icon {
  flex: 0 0 38px; height: 38px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  transition: background .15s ease;
}
.prompt-card:hover .prompt-card-icon {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.prompt-card-icon .icon { width: 20px; height: 20px; }
.prompt-card-body {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding-top: 2px;
}
.prompt-card-title {
  font-size: 14px; font-weight: 600; color: var(--text-strong); line-height: 1.2;
  letter-spacing: -.1px;
}
.prompt-card-desc {
  font-size: 12.5px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 700px) {
  .prompt-grid { grid-template-columns: 1fr; max-width: 100%; gap: 10px; }
}

.msg {
  max-width: 760px; margin: 0 auto; padding: 14px 22px;
  display: flex; gap: 14px;
  align-items: flex-start;  /* avatar pins to the top of the body, not centered */
}

/* Role badge — assistant: "be" wordmark in accent. User: same shape
   carrying the user's initial (or the person glyph for anon), so the
   conversation reads symmetric on both sides. */
.msg .role {
  flex: 0 0 28px; height: 28px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.msg.assistant .role { background: var(--accent); color: var(--accent-on); }
/* User role badge — outlined (transparent fill, accent border + text)
   to mirror the topbar avatar style. */
.msg .role.role-user {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  font-size: 11px;
  letter-spacing: .3px;
}
.msg .role.role-user .icon { width: 15px; height: 15px; }

/* ----- USER MESSAGE — right-aligned accent bubble. The badge appears
   AFTER the body so the avatar pins to the right edge of the row,
   symmetric with the assistant badge on the left. ----- */
.msg.user {
  justify-content: flex-end;
  flex-direction: row-reverse;
  padding: 8px 22px;
}
.msg.user .body {
  width: 100%;              /* fill the column, which itself caps at 78% */
  background: var(--accent);
  color: var(--accent-on);
  padding: 11px 16px;
  border: 1px solid var(--accent);
  line-height: 1.55;
  font-size: 15px;
}
/* Force every inline color override inside the user bubble back to the
   readable on-accent token — otherwise the global body rules would draw
   slate text on a teal background. */
.msg.user .body,
.msg.user .body p,
.msg.user .body strong,
.msg.user .body em,
.msg.user .body a { color: var(--accent-on); }
.msg.user .body a { border-bottom-color: rgba(255,255,255,.6); }
.msg.user .body code {
  background: rgba(255,255,255,.18); color: inherit; padding: 0 4px;
}
/* User shouldn't get the assistant feedback buttons. */
.msg.user .msg-actions { display: none; }

/* Image thumbnails inside a user bubble — when an image was sent the model
   saw it via a multimodal attachment; we also render a small preview here
   so the conversation transcript shows what was attached. */
.msg.user .body .att-thumbs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.msg.user .body .att-thumb {
  max-width: 120px; max-height: 120px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.25);
}

/* ----- ASSISTANT MESSAGE — left-aligned, flowing text, no bubble ----- */
.msg.assistant { justify-content: flex-start; }
.msg .body {
  flex: 1; min-width: 0;
  line-height: 1.72; color: var(--text); font-size: 15.5px;
}

/* Typography hierarchy — distinct weights, sizes, and colors */
.msg .body p { margin: .75em 0; }
.msg .body p:first-child { margin-top: 0; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body strong { color: var(--text-strong); font-weight: 600; }
/* Italic text inherits the regular body color — earlier it used --muted
   which on the beige background rendered the parenthetical descriptions
   nearly invisible (e.g. "(név, lakcím, személyazonosító okmány száma)"). */
.msg .body em { color: var(--text); font-style: italic; }

.msg .body h1 {
  font-size: 26px; font-weight: 700; line-height: 1.25;
  color: var(--text-strong); margin: 1.2em 0 .4em; letter-spacing: -.3px;
}
.msg .body h2 {
  font-size: 21px; font-weight: 600; line-height: 1.3;
  color: var(--text-strong); margin: 1.5em 0 .55em;
  padding-top: .9em; border-top: 1px solid var(--border);
}
.msg .body h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.msg .body h3 {
  font-size: 18px; font-weight: 600; line-height: 1.35;
  color: var(--accent); margin: 1.2em 0 .4em;
  text-transform: none; letter-spacing: 0;
}
.msg .body h4 {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 1.1em 0 .3em; text-transform: uppercase; letter-spacing: .8px;
}

/* "Section header" — emitted by the renderer when a paragraph is entirely
   `**bold:**`. The model uses this pattern for subsection breaks
   (Javaslatom:, A lehetséges forgatókönyvek:, Fontos figyelmeztetések:).
   Make them clearly distinguishable from inline-bold text. */
.msg .body h4.sect {
  font-size: 17px; font-weight: 600; color: var(--text-strong);
  text-transform: none; letter-spacing: 0;
  margin: 1.7em 0 .5em;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--border);
}
.msg .body h4.sect:first-child { margin-top: 0; }
/* Tiny accent dot before each section heading — subtle hierarchy cue. */
.msg .body h4.sect::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  background: var(--accent); border-radius: 50%;
  margin-right: 10px; vertical-align: middle; transform: translateY(-2px);
}

/* Lists — generous breathing room, accent markers, deeper indent */
.msg .body ul, .msg .body ol {
  padding-left: 26px; margin: .8em 0;
}
.msg .body li {
  margin: .55em 0; color: var(--text); padding-left: 4px;
}
.msg .body li > p:first-child { margin-top: 0; }
.msg .body li > p:last-child { margin-bottom: 0; }
.msg .body ul li::marker { color: var(--accent); font-size: 1.1em; }
.msg .body ol li::marker { color: var(--accent); font-weight: 600; }

/* Nested lists get a touch less spacing */
.msg .body li > ul, .msg .body li > ol { margin: .35em 0 .35em 0; }

/* Inline code + blocks */
.msg .body pre {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 12px; overflow-x: auto;
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}
.msg .body code {
  background: var(--panel-2); padding: 1px 5px; color: var(--code-fg);
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  font-size: .92em;
}
.msg .body a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.msg .body a:hover { border-bottom-style: solid; }

/* Inline citation refs — Ptk. 6:8. § style markers that pop a statute
   tooltip on click. Subtle until hovered so a paragraph reads cleanly. */
.cite-ref {
  cursor: pointer;
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  padding-bottom: 1px;
  transition: background .12s ease, color .12s ease;
}
.cite-ref:hover { background: var(--quote-bg); }
.msg.user .body .cite-ref { color: var(--accent-on); border-bottom-color: rgba(255,255,255,.6); }
.msg.user .body .cite-ref:hover { background: rgba(255,255,255,.15); }

/* Floating popover triggered by clicking a cite-ref */
.cite-popover {
  position: fixed; z-index: 600;
  width: min(420px, calc(100vw - 16px));
  max-height: 50vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-deep);
  font-family: var(--font-sans);
}
.cite-popover-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.cite-popover-ref {
  font-family: var(--font-serif);
  font-size: 14px; font-weight: 600; color: var(--text-strong);
}
.cite-popover-close {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 2px 6px;
}
.cite-popover-close:hover { color: var(--text); }
.cite-popover-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 14px;
  font-family: var(--font-serif);
  font-size: 13.5px; line-height: 1.6; color: var(--text);
  white-space: pre-wrap;
}
.cite-popover-foot {
  padding: 7px 12px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
  background: var(--panel-2);
}
.cite-popover-foot a { color: var(--accent); text-decoration: none; }
.cite-popover-foot a:hover { text-decoration: underline; }
.cite-popover-status {
  padding: 1px 6px; border: 1px solid var(--border);
}

/* Hover variant — lighter chrome, no close button, smaller. The body is
   truncated to ~600 chars by the JS; the "kattintásra rögzít" hint lets
   the user know clicking turns it into the persistent click-popover. */
.cite-popover.cite-popover-hover {
  border-color: var(--border);
  animation: cite-hover-in .14s ease-out;
  max-width: 440px;
  max-height: 40vh;
}
.cite-popover.cite-popover-hover .cite-popover-head {
  padding: 6px 10px;
}
.cite-popover.cite-popover-hover .cite-popover-ref {
  font-size: 12.5px;
}
.cite-popover-hint {
  font-size: 10.5px; color: var(--muted); letter-spacing: .3px;
  text-transform: uppercase; opacity: .8;
}
.cite-popover.cite-popover-hover .cite-popover-body {
  padding: 10px 12px;
  font-size: 13px;
}
.cite-popover.cite-popover-hover .cite-popover-foot {
  padding: 5px 10px;
  font-size: 11px;
}
@keyframes cite-hover-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Agent-error card — shown when the upstream provider (OpenRouter / etc.)
   returns 429 / 5xx / auth / timeout. Replaces the old "Hiba: <raw json>"
   chip with a categorized message + optional retry button. */
.agent-error {
  padding: 14px 16px;
  background: var(--verify-warn-bg);
  border: 1px solid var(--verify-warn-bd);
  display: flex; flex-direction: column; gap: 10px;
}
.agent-error-head { color: var(--text); font-weight: 500; }
.agent-error-hint { font-size: 12px; color: var(--muted); }
.agent-stopped { margin-top: 8px; font-size: 12px; color: var(--muted); font-style: italic; }
/* The composer button as a Stop control while a response streams. */
#send.sending { background: var(--danger, #d33); color: #fff; cursor: pointer; }
/* Hide tool-call internals and the model/provider selector from the user. */
.tool-strip { display: none !important; }
.src-tools { display: none !important; }
#provider { display: none !important; }
.agent-error-retry { align-self: flex-start; padding: 6px 14px; font-size: 13px; }
.agent-error-auth   { background: var(--error-bg);     border-color: var(--error-bd); }
.agent-error-auth .agent-error-head { color: var(--error-fg); }

/* Block-quotes (for cited statute text the answer pulls inline) */
.msg .body blockquote {
  margin: .8em 0; padding: .55em 14px;
  border-left: 3px solid var(--accent); background: var(--quote-bg);
  color: var(--text);
}
.msg .body blockquote p { margin: .3em 0; }

/* Horizontal rules — the model can emit `---` for section breaks */
.msg .body hr {
  border: none; border-top: 1px solid var(--border); margin: 1.2em 0;
}

/* Tables */
.msg .body table {
  border-collapse: collapse; width: 100%; margin: .8em 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.msg .body th, .msg .body td {
  text-align: left; padding: 8px 11px; border-bottom: 1px solid var(--border);
}
.msg .body th { background: var(--panel-2); font-weight: 600; color: #f5f5fa; }
.msg .body tr:last-child td { border-bottom: none; }

/* Trailing disclaimer — small, dimmed, separated. JS wraps the last
   paragraph in `.disclaimer-final` when it matches the disclaimer pattern. */
.msg .body .disclaimer-final {
  margin-top: 1.4em; padding-top: .8em;
  border-top: 1px solid var(--border);
  font-size: 12px; line-height: 1.45;
  color: #7e8090; font-style: italic;
}
.msg .body .disclaimer-final::before {
  content: "ⓘ "; font-style: normal; color: var(--muted);
}
.msg { position: relative; }
/* Body + action buttons in a vertical stack — actions land BELOW the body
   instead of floating over its first paragraph (the old layout was a real
   readability problem on long answers). */
.msg .body-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
}
/* User message is tucked toward the right but with enough width to be
   comfortably readable. The chat-details rail eats 240px on the right;
   plus the small left-of-bubble padding for the "off-center" feel. */
.msg.user .body-col {
  flex: 0 1 auto;
  max-width: 78%;
  margin-left: auto;
  align-items: flex-end;
}
@media (min-width: 900px) {
  .msg.user { padding-left: 12%; }  /* keep the bubble visibly off-center */
}
@media (max-width: 900px) {
  .msg.user .body-col { max-width: 88%; }
}
@media (max-width: 600px) {
  .msg.user .body-col { max-width: 88%; }
}

/* Action row: clean grouped pill of icon buttons, right-aligned under the
   assistant body. Always faintly visible (no hover-only) so users discover
   them; brightens on hover. */
.msg-actions {
  display: inline-flex; gap: 4px;
  margin-top: 12px;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  opacity: .72;
  transition: opacity .18s ease, border-color .18s ease;
}
.msg-actions:hover { opacity: 1; border-color: var(--text); }
.msg:hover .msg-actions { opacity: 1; }

/* While a streaming answer is mid-arrival, hide the row but reserve space
   so layout doesn't jump when they appear. */
.msg.assistant .body.streaming ~ .msg-actions,
.msg.assistant .body-col:has(.body.streaming) .msg-actions {
  visibility: hidden;
}

.msg-actions button {
  background: transparent; color: var(--muted); border: 0;
  width: 30px; height: 28px;
  display: inline-grid; place-items: center;
  padding: 0; cursor: pointer; line-height: 1;
  transition: color .12s ease, background .12s ease;
}
.msg-actions button:hover { color: var(--text); background: var(--panel); }
.msg-actions button.voted { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.msg-actions button .icon { width: 16px; height: 16px; }
.copy-btn { /* legacy alias retained for any old code paths */ }

/* ====================================================================
   Pinned-section sub-header in the sidebar conversation list.
   ==================================================================== */
.conv-subhead {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}
.conv-subhead .icon { width: 11px; height: 11px; }
.conv-subhead-count {
  font-size: 9.5px; padding: 1px 6px;
  background: var(--accent); color: var(--accent-on);
  letter-spacing: 0;
}
.conv-subhead-quiet {
  margin-top: 4px;
  color: var(--muted);
  background: transparent;
  border-top-color: var(--border); border-bottom: 0;
}
.is-pinned-row { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* Bulk selection checkbox — collapsed to 0-width by default so the
   title takes the full row. Row-hover OR bulk-mode expands it back. */
.conv-select {
  flex: 0 0 0; width: 0; height: 22px;
  display: inline-grid; place-items: center;
  cursor: pointer; opacity: 0; overflow: hidden;
  margin-right: 0;
  transition: flex-basis .15s ease, width .15s ease, margin .15s ease, opacity .12s ease;
}
.conv-row:hover .conv-select,
body.bulk-mode .conv-select {
  flex: 0 0 18px; width: 18px; opacity: 1; margin-right: 1px;
}
.conv-check { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
body.bulk-mode .conv-row .conv-check:checked + * { /* placeholder */ }

/* ====================================================================
   Bulk-action toolbar — slides in above the conv list when ≥1 row
   is selected. Hosts batch verbs (delete, pin, unpin, tag).
   ==================================================================== */
.bulk-toolbar {
  display: none;
  align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 6px 0;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  font-size: 12px;
}
body.bulk-mode .bulk-toolbar { display: flex; }
.bulk-toolbar .bulk-count {
  font-weight: 700; color: var(--accent);
  margin-right: 4px;
}
.bulk-toolbar button {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 9px; cursor: pointer;
  font: inherit; font-size: 11.5px;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.bulk-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.bulk-toolbar button.danger:hover { border-color: #b34747; color: #b34747; }
.bulk-toolbar button .icon { width: 12px; height: 12px; }
.bulk-toolbar .bulk-clear { margin-left: auto; color: var(--muted); }

/* ====================================================================
   Per-message token meter — sits under the assistant body after the
   sources event lands. Collapsed: one quiet pill (latency · tokens).
   Expanded: per-bucket breakdown. Click-to-toggle, persisted in
   localStorage so the preference sticks.
   ==================================================================== */
/* Standalone .token-meter widget is RETIRED — the breakdown now lives
   inside the HIVATKOZÁSOK panel as `.token-panel` (see below). The rule
   below hides any orphan that gets injected by a stale render path. */
.token-meter { display: none !important; }

/* Token-felhasználás — collapsible <details> at the top of the
   HIVATKOZÁSOK body. Matches the trace-panel design language so the
   two read as siblings: chevron + uppercase title + small meta chip
   on the right. */
.token-panel {
  margin: 8px 12px 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.token-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 11.5px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
  transition: color .12s ease;
}
.token-summary::-webkit-details-marker { display: none; }
.token-summary:hover { color: var(--text); }
.token-summary .icon {
  width: 12px; height: 12px;
  transition: transform .15s ease;
}
.token-panel[open] .token-summary .icon { transform: rotate(180deg); }
.token-summary-meta {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 1px 7px; border: 1px solid var(--border);
  background: var(--panel);
  text-transform: none; letter-spacing: 0;
}
.token-grid {
  padding: 8px 12px 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.tm-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 18px; padding: 3px 0;
  color: var(--text);
}
.tm-row .tm-k { color: var(--muted); }
.tm-row .tm-v { font-variant-numeric: tabular-nums; font-weight: 500; }
.tm-row-soft { padding-left: 12px; }
.tm-row-soft .tm-k { font-size: 10.5px; }
.tm-row-soft .tm-v { color: var(--muted); }
.tm-sub {
  display: inline-block; margin-left: 6px;
  font-size: 9.5px; font-weight: 500; letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--accent);
  padding: 1px 5px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tm-row-total {
  margin-top: 4px; padding-top: 6px;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.tm-row-total .tm-k { color: var(--text-strong); font-weight: 600; }
.tm-row-total .tm-v { color: var(--accent); font-weight: 700; }

/* ====================================================================
   Tool activity — compact inline strip directly under the thinking row.
   Several tools can fire in one turn; they share a single horizontal
   strip instead of each occupying its own full-width row. After the
   message finishes (sources event), `.tool-strip.done` softens further.
   ==================================================================== */
.tool-strip {
  max-width: 760px; margin: 2px auto 8px; padding: 0 22px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  transition: opacity .25s ease;
}
.tool-strip-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600;
  opacity: .8;
  flex: 0 0 auto;
}
.tool-strip-items {
  display: flex; gap: 6px; flex-wrap: wrap;
  flex: 1 1 auto; min-width: 0;
}
.tool-strip.done { opacity: .65; }
.tool-strip.done:hover { opacity: 1; }

/* Individual tool chip — small, gray, blended. The `.dot` is the only
   colored element so the eye picks up the running tool quickly without
   the whole row screaming for attention. The element must be a <div>
   (not <span>) because it nests a block-level `.tool-detail` panel
   inside it; HTML parsers auto-close spans before flow content. */
.tool {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  position: relative;
}
.tool .chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 3px 9px; cursor: pointer; font-family: var(--font-sans);
  line-height: 1.4;
  white-space: nowrap;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.tool .chip:hover { color: var(--text); background: var(--panel); border-color: var(--accent); }
.tool .chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: .5;
  flex: 0 0 7px;
}
.tool.tool-running .chip .dot {
  background: var(--accent); opacity: 1;
  animation: tool-dot-pulse 1.2s ease-in-out infinite;
}
.tool.tool-done .chip .dot { background: var(--verify-ok-fg); opacity: .8; }
.tool.tool-err .chip .dot { background: #b34747; opacity: .9; }
.tool.open .chip { color: var(--text); border-color: var(--accent); background: var(--panel); }
@keyframes tool-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: .55; }
}

/* When a chip is opened, the detail panel floats below it as a
   dropdown card. Hidden by default via [hidden]; revealed when the
   open class is added to the parent .tool. */
.tool-detail {
  position: absolute; left: 0; top: calc(100% + 6px);
  min-width: 320px; max-width: 560px;
  z-index: 5;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 6px 24px -8px rgba(20, 20, 30, .25);
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.tool-detail[hidden] { display: none !important; }

.tool-section {
  background: var(--panel); border: 1px solid var(--border);
}
.tool-section-head {
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.tool-section-head code {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 11px; color: var(--accent); background: none; padding: 0;
  text-transform: none; letter-spacing: 0;
}
.tool-section pre {
  margin: 0; padding: 12px;
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  color: var(--text); background: var(--panel-2);
  max-height: 280px; overflow-y: auto;
}
.tool-result-pre.err { color: var(--error-fg); }

/* Document card — reads as proper "attached document" metadata under the
   message: icon block on the left, title + format chips + meta line in
   the middle, Megnyitás CTA on the right. The card animates in alongside
   the sidebar row when generated. */
.doc-card {
  max-width: 760px; margin: 10px auto 16px; padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: 0 2px 8px -4px rgba(20, 20, 30, .08);
  animation: doc-card-in .32s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes doc-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.doc-card-row { display: flex; align-items: center; gap: 14px; }
.doc-card-icon {
  flex: 0 0 40px; width: 40px; height: 48px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--accent);
  font-size: 18px; font-weight: 700;
  font-family: var(--font-sans);
  position: relative;
}
.doc-card-icon::after {
  /* Corner-fold detail to read as a document icon. */
  content: ""; position: absolute; top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid; border-width: 0 8px 8px 0;
  border-color: transparent var(--panel) transparent transparent;
}
.doc-card-meta { flex: 1; min-width: 0; }
.doc-card h4 {
  margin: 0 0 4px; font-size: 14.5px; font-weight: 600;
  color: var(--text-strong); font-family: var(--font-sans);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-card-sub {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.doc-card-formats {
  display: inline-flex; gap: 4px;
}
.doc-card-fmt {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase;
  padding: 1px 6px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border);
}
.doc-card-sub .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--muted); opacity: .4;
  display: inline-block;
}
.doc-card .doc-edit {
  flex: 0 0 auto; padding: 7px 14px; font-size: 13px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.doc-card-errors {
  margin-top: 8px; font-size: 12px; color: var(--error-fg);
}

/* ====================================================================
   Sources / references panel — collapsible card with iconified header,
   per-citation rows that expand to show the full § text, and chip-style
   confidence / verification / timing badges.

   Visual policy: clearly visible BUT subordinate. The default state is
   collapsed (see app.js `be.sourcesOpen` localStorage flag); the header
   reads as "click to see references" without competing with the answer.
   ==================================================================== */
/* ====================================================================
   Message metadata stack — 4 collapsible accordion panels per assistant
   turn (Token-felhasználás / Hogyan jutottam ide / Dokumentumok /
   Hivatkozások). Only one can be open at a time within the same stack
   (mutual exclusion wired in addSources). Default = all collapsed.
   ==================================================================== */
.msg-meta-stack {
  max-width: 760px; margin: 6px auto 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.meta-panel {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  overflow: hidden;
  transition: border-color .12s ease, background .12s ease;
}
.meta-panel.collapsed { border-style: dashed; }
.meta-panel:not(.collapsed) {
  border-style: solid;
  background: var(--panel);
  border-left: 3px solid var(--accent);
}

/* Per-message Documents block — sits ABOVE the accordion, always
   visible (no toggle). Reads as the primary artefact of the turn. */
.msg-docs-block {
  padding: 10px 14px 12px;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-left: 4px solid var(--accent);
  animation: meta-body-in .2s ease-out;
}
.msg-docs-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.msg-docs-head .icon { width: 12px; height: 12px; }
.msg-docs-title { flex: 1; }
.msg-docs-count {
  display: inline-block; min-width: 18px;
  padding: 1px 7px;
  background: var(--accent); color: var(--accent-on);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0;
  text-transform: none; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Featured panel (Documents) — distinct treatment so it reads as the
   primary artefact of the turn. Solid accent-tinted background, no
   dashed-collapsed state since it always opens by default. */
.meta-panel.meta-panel-featured {
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-left: 4px solid var(--accent);
}
.meta-panel.meta-panel-featured.collapsed {
  background: color-mix(in srgb, var(--accent) 3%, transparent);
  border-style: solid;
}
.meta-panel.meta-panel-featured .meta-toggle {
  color: var(--text-strong);
  background: transparent;
}
.meta-panel.meta-panel-featured .meta-toggle:hover {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.meta-panel.meta-panel-featured .meta-ico,
.meta-panel.meta-panel-featured .meta-chev { color: var(--accent); opacity: 1; }
.meta-panel.meta-panel-featured .meta-title { color: var(--accent); font-weight: 700; }
.meta-panel.meta-panel-featured .meta-count {
  background: var(--accent); color: var(--accent-on);
  border-color: var(--accent);
}
.meta-panel.meta-panel-featured .meta-body {
  background: var(--panel);
  border-top: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
}
.meta-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 12px;
  min-height: 32px;
  background: transparent; border: 0;
  cursor: pointer; font: inherit; color: var(--muted);
  text-align: left;
  transition: background .12s ease, color .12s ease;
}
.meta-toggle:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.meta-panel:not(.collapsed) .meta-toggle {
  color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.meta-chev {
  width: 11px; height: 11px; color: var(--muted);
  transition: transform .15s ease;
  flex: 0 0 11px; opacity: .6;
}
.meta-toggle:hover .meta-chev { opacity: 1; }
.meta-panel:not(.collapsed) .meta-chev { transform: rotate(90deg); opacity: .9; color: var(--accent); }
.meta-ico {
  width: 12px; height: 12px;
  flex: 0 0 12px;
  opacity: .65;
}
.meta-panel:not(.collapsed) .meta-ico { opacity: .9; color: var(--accent); }
.meta-title {
  font-size: 11px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase;
  flex: 1 1 auto; min-width: 0;
}
.meta-count {
  display: inline-block; min-width: 16px;
  padding: 1px 7px;
  background: var(--panel); color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  text-transform: none; text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.meta-chips {
  display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap;
  flex-shrink: 0;
}
.meta-body {
  padding: 4px 0 8px;
  background: var(--panel);
  animation: meta-body-in .18s ease-out;
}
.meta-body[hidden] { display: none !important; }
@keyframes meta-body-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* COMPACT mode: the card reads as a discrete footnote strip, not a panel.
   Collapsed state hides the body and shrinks everything; expanded state
   adds a thin border-bottom but the header stays the same height. */
.sources-card {
  max-width: 760px; margin: 4px auto 14px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  overflow: hidden;
}
.sources-card.collapsed { border-style: dashed; }

/* Header acts as the toggle. Single 30px-high strip with everything
   tucked in: small chevron, tiny uppercase title, count pill, chips at
   the far right. No accent background — just panel-2 with a hover tint. */
.sources-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 10px;
  min-height: 28px;
  background: transparent; border: 0;
  cursor: pointer; font: inherit; color: var(--muted);
  text-align: left;
  transition: background .12s ease, color .12s ease;
}
.sources-toggle:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.sources-card:not(.collapsed) .sources-toggle {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.sources-card.collapsed .src-chevron { transform: rotate(-90deg); }
.src-chevron {
  width: 11px; height: 11px; color: var(--muted);
  transition: transform .15s ease;
  flex: 0 0 11px; opacity: .6;
}
.sources-toggle:hover .src-chevron { opacity: 1; color: var(--accent); }
.sources-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted);
  flex-shrink: 0;
}
.sources-card:not(.collapsed) .sources-title { color: var(--text); }
.src-count {
  display: inline-block; min-width: 14px;
  padding: 0 4px; margin-left: 3px;
  background: var(--panel); color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  font-size: 10px; font-weight: 600; letter-spacing: 0;
  text-transform: none; text-align: center;
}
.sources-chips {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: auto; flex-wrap: wrap;
}
/* Chips — pill-style, no harsh borders. Confidence + verification chips
   use a tinted SURFACE (low-alpha bg) instead of a bordered box, which
   reads as "status pill" rather than "tiny outlined button". */
.src-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; font-size: 11px; font-weight: 600;
  background: var(--panel); border: 0;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: .15px;
  border-radius: 999px;
}
.src-chip .icon { width: 11px; height: 11px; flex: 0 0 11px; }
.src-chip.conf-high,
.src-chip.verify-ok {
  color: var(--verify-ok-fg);
  background: color-mix(in srgb, var(--verify-ok-fg) 14%, var(--panel));
}
.src-chip.conf-medium,
.src-chip.verify-warn {
  color: var(--verify-warn-fg);
  background: color-mix(in srgb, var(--verify-warn-fg) 14%, var(--panel));
}
.src-chip.conf-low {
  color: var(--verify-bad-fg, #b34747);
  background: color-mix(in srgb, #b34747 12%, var(--panel));
}
.src-chip.src-meta {
  color: var(--muted);
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* Body — citation rows + tool chips. Tightened spacing so 7+ rows
   don't take half the viewport. */
.sources-body { padding: 4px 0 8px; background: var(--panel); }
.sources-body[hidden] { display: none !important; }

.sources-card ul.refs {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column;
}
.ref-row {
  padding: 5px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
}
.ref-row:last-child { border-bottom: 0; }
.ref-row-head {
  display: flex; align-items: center; gap: 10px;
  justify-content: space-between; flex-wrap: wrap;
}
.ref-label {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  min-width: 0; flex: 1;
}
a.ref-label { color: var(--accent); }
a.ref-label:hover { color: var(--text-strong); }
.ref-label .ref-icon { width: 15px; height: 15px; color: var(--muted); flex: 0 0 15px; }
.ref-label .ref-ext { width: 13px; height: 13px; opacity: .55; flex: 0 0 13px; }
.ref-row-tail {
  display: inline-flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
}
/* Soft pill — only shown for meaningful statuses (repealed/modified); the
   normal "in force" is hidden, so no shouty uppercase enum anymore. */
.ref-status {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  color: #b34747; border: 1px solid color-mix(in srgb, #b34747 35%, var(--border));
  background: color-mix(in srgb, #b34747 8%, var(--panel-2));
}
.ref-status.status-modified { color: #9a7b1f; border-color: color-mix(in srgb, #9a7b1f 35%, var(--border)); background: color-mix(in srgb, #9a7b1f 10%, var(--panel-2)); }

/* Documents subsection inside the HIVATKOZÁSOK panel body — per-message
   documents are surfaced here (and only here) since the inline doc-card
   was retired. Each row is a button: icon + title + format chips, plus
   a "Megnyitás" affordance on the right that opens the side panel. */
.src-docs-section {
  margin: 6px 12px 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-left: 3px solid var(--accent);
}
.src-docs-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.src-docs-label .icon { width: 11px; height: 11px; opacity: .7; }
.src-docs-count {
  display: inline-block; min-width: 16px;
  padding: 0 5px; margin-left: 4px;
  background: var(--accent); color: var(--accent-on);
  font-size: 10px; font-weight: 700; letter-spacing: 0;
  text-transform: none; text-align: center;
}
.src-docs-list {
  display: flex; flex-direction: column; gap: 6px;
}
.src-doc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.src-doc-row:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--panel));
}
.src-doc-icon {
  flex: 0 0 30px; width: 30px; height: 36px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--accent);
  font-size: 13px; font-weight: 700;
  font-family: var(--font-sans);
  position: relative;
}
.src-doc-icon::after {
  content: ""; position: absolute; top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid; border-width: 0 6px 6px 0;
  border-color: transparent var(--panel) transparent transparent;
}
.src-doc-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.src-doc-title {
  font-size: 13px; font-weight: 500; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.src-doc-meta {
  display: inline-flex; gap: 4px; flex-wrap: wrap;
}
.src-doc-fmt {
  font-family: var(--font-sans);
  font-size: 9.5px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase;
  padding: 1px 5px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.src-doc-row:hover .src-doc-fmt {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.src-doc-open {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .15px;
}
.src-doc-open .icon { width: 12px; height: 12px; }
.src-doc-row:hover .src-doc-open { color: var(--accent); }

/* "§ szöveg" expander button — text-only ghost button with a chevron.
   Visually subordinate so it doesn't compete with the citation label. */
.view-sec {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; color: var(--muted);
  border: 1px solid transparent;
  padding: 2px 6px; font: inherit; font-size: 11px;
  cursor: pointer; line-height: 1;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.view-sec:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.view-sec .icon {
  width: 9px; height: 9px;
  transition: transform .15s ease;
}
.sec-text.open + .view-sec .icon,
.ref-row:has(.sec-text.open) .view-sec .icon { transform: rotate(180deg); }

.sec-text {
  display: none; margin-top: 6px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--accent) 5%, var(--panel-2));
  border-left: 2px solid var(--accent);
  font-size: 12.5px; line-height: 1.5;
  white-space: pre-wrap; color: var(--text);
}
.sec-text.open { display: block; }

/* Callouts (language warnings) + tool list. */
.src-callout {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 8px 14px 4px; padding: 9px 12px;
  font-size: 12.5px; line-height: 1.4;
  border: 1px solid var(--verify-warn-bd);
  background: var(--verify-warn-bg);
  color: var(--verify-warn-fg);
}
.src-callout .icon { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }

.src-tools {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 10px 14px 0;
  font-size: 12px; color: var(--muted);
}
.src-tools .icon { width: 13px; height: 13px; flex: 0 0 13px; }
.src-tools-label { font-weight: 500; }
.src-tool-chip {
  display: inline-block; background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11.5px;
}

@media (max-width: 600px) {
  .sources-toggle { padding: 10px 12px; gap: 8px; }
  .ref-row { padding: 8px 12px; }
  .sources-chips { width: 100%; margin-left: 0; padding-top: 6px; }
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.iconbtn {
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px; cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 30px; min-height: 28px;
  text-decoration: none; line-height: 1;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.iconbtn:hover { color: var(--text); border-color: var(--text); }
.iconbtn .icon { width: 15px; height: 15px; }
.iconbtn-label { font-weight: 600; letter-spacing: .3px; }

/* ===================================================================
   Responsive — hamburger toggle, mobile-first sidebar
   ===================================================================
   Layout breakpoints:
     desktop  (>900px): sidebar always docked left, hamburger hidden
     tablet   (<=900px AND >600px): sidebar slides over chat; hamburger visible
     phone    (<=600px): tighter padding, single column, full-screen panel + sidebar
   The hamburger is the SAME control across breakpoints — at <=900px it opens
   a slide-over; on desktop it can collapse the dock too (body.sidebar-hidden). */

/* Hamburger button — hidden on desktop, shown when the sidebar is overlaid */
.hamburger {
  display: none; padding: 6px 10px; font-size: 16px; line-height: 1;
  margin-right: 10px;
}
.sidebar-close { display: none; font-size: 14px; padding: 4px 9px; }
.brand { justify-content: space-between; }

/* ====================================================================
   Cmd+K command palette — Linear / Raycast style.
   Centered modal with a search input + filtered list of jumps and
   actions. Keyboard-first: arrow keys navigate, Enter selects, Esc
   closes. Backdrop click also closes.
   ==================================================================== */
.palette-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 16, 18, .58);
  z-index: 200;
  display: grid; place-items: start center;
  padding-top: 14vh;
  opacity: 0; pointer-events: none;
  transition: opacity .12s ease;
}
.palette-backdrop:not([hidden]) { opacity: 1; pointer-events: auto; }
.palette-backdrop[hidden] { display: none !important; }
.palette {
  width: min(640px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 22px 56px -12px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column;
  max-height: 70vh; overflow: hidden;
}
.palette-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.palette-input-icon { color: var(--muted); flex: 0 0 16px; }
.palette-input {
  flex: 1; background: transparent; color: var(--text);
  border: 0; outline: none;
  font: inherit; font-size: 15px;
}
.palette-input::placeholder { color: var(--muted); }
.palette-input::-webkit-search-cancel-button { display: none; }
.palette-kbd, .palette-foot kbd {
  font: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
  padding: 2px 6px; min-width: 22px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--muted); text-align: center;
}
.palette-results { flex: 1; overflow-y: auto; padding: 6px 0; }
.palette-group-title {
  font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600;
  padding: 10px 18px 4px;
}
.palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px; cursor: pointer;
  font-size: 13.5px; color: var(--text);
  background: transparent; border: 0; width: 100%; text-align: left;
}
.palette-item:hover, .palette-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.palette-item .icon {
  width: 16px; height: 16px; color: var(--accent); flex: 0 0 16px;
}
.palette-item .label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.palette-item .sub {
  color: var(--muted); font-size: 11.5px; flex: 0 0 auto;
}
.palette-empty {
  padding: 30px 18px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.palette-foot {
  display: flex; align-items: center; gap: 16px; justify-content: flex-end;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 11px; color: var(--muted);
}
.palette-foot kbd { padding: 1px 5px; min-width: 18px; font-size: 10px; }

@media (max-width: 600px) {
  .palette-backdrop { padding-top: 8vh; }
  .palette { width: 96vw; max-height: 80vh; }
  .palette-input-wrap { padding: 12px 14px; }
}

/* ====================================================================
   Onboarding tour — full-screen overlay shown to first-time users.
   ==================================================================== */
.onboarding {
  position: fixed; inset: 0; z-index: 250;
  display: grid; place-items: center;
}
.onboarding[hidden] { display: none !important; }
.onboarding-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 16, 18, .62);
  backdrop-filter: blur(2px);
}
.onboarding-card {
  position: relative;
  width: min(460px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 32px 32px 24px;
  box-shadow: 0 22px 56px -12px rgba(0, 0, 0, .45);
}
.onboarding-progress {
  display: flex; gap: 6px; margin-bottom: 22px;
}
.ob-dot {
  flex: 1; height: 3px;
  background: var(--border);
  transition: background .2s ease;
}
.ob-dot.active { background: var(--accent); }
.onboarding-card h2 {
  font-family: var(--font-serif); font-size: 24px;
  margin: 0 0 10px;
  color: var(--text-strong); letter-spacing: -.3px;
}
.ob-body {
  margin: 0 0 24px;
  font-size: 14.5px; line-height: 1.55;
  color: var(--text);
}
.ob-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.ob-skip {
  background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13px;
  padding: 8px 0;
}
.ob-skip:hover { color: var(--text); }
.ob-next {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-on);
  border: 0; cursor: pointer;
  padding: 10px 18px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  transition: filter .12s ease;
}
.ob-next:hover { filter: brightness(1.06); }
.ob-next .icon { width: 14px; height: 14px; transform: rotate(-90deg); }

/* ====================================================================
   Mobile bottom navigation bar — only at ≤600px. Five quick-jump
   buttons that mirror the desktop sidebar rail, app-like feel.
   ==================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 6px env(safe-area-inset-right) calc(6px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  z-index: 90;
}
.mbn-btn {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: 0; padding: 6px 4px;
  color: var(--muted); cursor: pointer;
  font: inherit; font-size: 10.5px;
  transition: color .12s ease;
}
.mbn-btn:hover, .mbn-btn.active { color: var(--accent); }
.mbn-btn .icon { width: 20px; height: 20px; }
.mbn-btn span { letter-spacing: .2px; }
.mbn-btn-accent {
  position: relative;
  color: var(--accent-on);
}
.mbn-btn-accent::before {
  content: ""; position: absolute; top: 0; left: 50%;
  transform: translate(-50%, -14px);
  width: 44px; height: 44px;
  background: var(--accent);
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
  z-index: -1;
}
.mbn-btn-accent .icon { color: var(--accent-on); width: 22px; height: 22px; position: relative; z-index: 1; margin-top: -6px; }
.mbn-btn-accent span { color: var(--accent); margin-top: 2px; font-weight: 600; }

@media (max-width: 600px) {
  .mobile-bottom-nav { display: flex; }
  /* Push the composer up so the nav doesn't cover it. */
  body.has-bottom-nav .composer { padding-bottom: 70px; }
  body.has-bottom-nav .messages { padding-bottom: 64px; }
}

/* ====================================================================
   Notes drawer — slides in from the right. Per-conversation private
   scratchpad. Auto-saves on blur and after 1.5s of idle.
   ==================================================================== */
.notes-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(380px, 92vw);
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 110;
  box-shadow: -8px 0 24px -8px rgba(0, 0, 0, .25);
  transform: translateX(0);
  transition: transform .22s ease;
}
.notes-panel[hidden] {
  display: flex !important; transform: translateX(110%); pointer-events: none;
}
.notes-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.notes-panel-head h3 {
  margin: 0; font-family: var(--font-serif);
  font-size: 16px; color: var(--text-strong);
  display: flex; align-items: baseline; gap: 8px;
}
.notes-panel-sub {
  font-family: var(--font-sans); font-size: 11px; color: var(--muted);
  font-weight: 400; letter-spacing: 0;
}
.notes-textarea {
  flex: 1; resize: none;
  background: var(--panel); color: var(--text); border: 0;
  padding: 16px 18px;
  font: inherit; font-size: 14px; line-height: 1.55;
  outline: none;
}
.notes-textarea::placeholder { color: var(--muted); }
.notes-panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 11px; color: var(--muted);
}
.notes-status { font-weight: 500; }
.notes-status.saving { color: var(--accent); }
.notes-status.error { color: var(--error-fg); }

@media (max-width: 600px) { .notes-panel { width: 100vw; } }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 99; opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.sidebar-backdrop[hidden] { display: none !important; }
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

/* Tablet (<=900px): sidebar becomes a slide-over. The 3-state machine
   (data-sidebar-state) doesn't apply on mobile — the body.sidebar-open
   class controls visibility instead. We override the data-state rules
   in this breakpoint so a stale "compact" or "hidden" desktop preference
   doesn't bleed through. */
@media (max-width: 900px) {
  .hamburger { display: inline-block; }
  .sidebar-close { display: inline-block; }
  .sidebar-collapse { display: none; }
  .sidebar-rail,
  body[data-sidebar-state="compact"] .sidebar-rail { display: none; }
  body[data-sidebar-state="compact"] .sidebar,
  body[data-sidebar-state="hidden"] .sidebar { display: flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
    z-index: 100;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: 6px 0 24px rgba(0,0,0,.4); }
  .chat { width: 100%; }
}

/* Phone (<=600px): tighter spacing all around, full-width modals */
@media (max-width: 600px) {
  .topbar { padding: 10px 12px; gap: 6px; }
  .title { font-size: 15px; }
  .title small { display: none; }
  .topbar-right { gap: 6px; }
  /* Drop the docs + export buttons on the smallest screens so the
     topbar has room for the avatar + theme + settings. The Cmd-K
     and account page already expose everything underneath. */
  #docs-link, #export-toggle { display: none; }

  .msg, .tool, .doc-card, .attachments, .composer {
    padding-left: 12px; padding-right: 12px;
  }
  .msg { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .msg.user { padding-top: 6px; padding-bottom: 6px; }
  .msg.user .body { max-width: 88%; padding: 10px 13px; font-size: 14.5px; }
  .msg .body { font-size: 14.5px; }
  .msg .body h1 { font-size: 20px; }
  .msg .body h2 { font-size: 17px; }
  .composer textarea {
    padding: 12px 14px; max-height: 220px; /* shorter cap on phones */
  }
  .composer button { width: 40px; height: 40px; }
  .attach-btn { width: 36px; height: 40px; flex: 0 0 36px; }
  .empty { margin: 6vh auto 3vh; padding: 0 14px; }
  .empty h1 { font-size: 24px; }
  .empty p { font-size: 13px; }
  .doc-card { padding: 12px 14px; }
  .msg-actions { top: 8px; right: 10px; }
  .drop-overlay .drop-card { padding: 28px 32px; font-size: 15px; }
  .conv-list { padding-bottom: 60px; } /* breathing room above the keyboard */

  /* Sources panel: stack header chips below the title so the row doesn't
     wrap awkwardly inside the toggle button. */
  .sources-card { margin-left: 8px; margin-right: 8px; }
  .sources-toggle {
    flex-wrap: wrap; padding: 10px 12px;
  }
  .sources-chips { width: 100%; margin-left: 0; padding-top: 6px; }
  .ref-row { padding: 10px 12px; }
  .ref-label { font-size: 13px; }

  /* Composer meta row gets compressed: hide the disclaimer text on
     tiny screens — it's already a permanent footer note + tooltip. */
  .composer-meta-note { display: none; }
  .composer-meta { padding: 4px 12px 10px; gap: 6px; flex-wrap: wrap; }

  /* Quota chip squeezes; avatar still readable. */
  .quota-chip { font-size: 11.5px; padding: 0 7px; min-width: 28px; height: 26px; }
  .user-chip-avatar { width: 28px; height: 28px; font-size: 12px; }
  .user-chip-logout { width: 26px; height: 26px; }
}

/* Very-narrow (<=380px): drop more chrome so the chat stays usable. */
@media (max-width: 380px) {
  .topbar { padding: 8px 10px; }
  .title { font-size: 14px; }
  .quota-chip { display: none; }            /* one fewer chip in the row */
  .composer { padding: 0 10px 6px; gap: 6px; }
  .voice-btn { display: none; }             /* paperclip + textarea + send only */
  .composer button { width: 36px; height: 38px; }
  .attach-btn { width: 32px; height: 38px; flex: 0 0 32px; }
  .empty h1 { font-size: 21px; }
  .prompt-card { padding: 12px 12px; gap: 10px; }
  .prompt-card-icon { width: 32px; height: 32px; flex-basis: 32px; }
}

/* Landscape-phone (≤900px wide AND ≤500px tall): suppress the
   empty-state's vertical margin so the keyboard doesn't push the
   composer off-screen. */
@media (max-width: 900px) and (max-height: 500px) {
  .empty { margin: 12px auto; }
  .empty h1 { font-size: 18px; margin-bottom: 6px; }
  .empty p { margin-bottom: 10px; }
  .prompt-grid { gap: 6px; margin-top: 8px; }
  .composer textarea { max-height: 120px; }
}

/* Ultra-wide (≥1600px): widen the chat column so long answers don't
   look like ribbon text. */
@media (min-width: 1600px) {
  .msg, .sources-card, .composer { max-width: 860px; }
}
/* Legacy .conf-* tokens still consulted by the chip block above; the rest
   of the old verify-warn / view-sec rules are superseded by the new
   .sources-card block earlier in this file. */
.conf-high { color: var(--conf-high-fg); border-color: var(--conf-high-bd); }
.conf-medium { color: var(--conf-medium-fg); border-color: var(--conf-medium-bd); }
.conf-low { color: var(--conf-low-fg); border-color: var(--conf-low-bd); }

/* Composer */
.composer {
  max-width: 760px; margin: 0 auto; width: 100%; padding: 0 22px 6px;
  display: flex; align-items: flex-end; gap: 10px;
}
.composer textarea {
  flex: 1; resize: none; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font: inherit;
  /* Grows with the input up to ~10 lines, then introduces an internal
     scrollbar instead of pushing the page. The JS in app.js caps the
     computed height to the same value so the two stay in sync. */
  min-height: 48px; max-height: 360px;
  line-height: 1.45;
  overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer button {
  background: var(--accent); color: var(--accent-on); border: none;
  width: 42px; height: 42px; font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
  border-radius: var(--radius);
  transition: background .15s ease, color .15s ease, filter .12s ease;
}
.composer button:hover { filter: brightness(1.05); }
.composer button .icon { width: 18px; height: 18px; }
/* While the agent is responding, the send button becomes a quiet "thinking"
   indicator — three bouncing dots — so the user sees the system is busy
   without a grey disabled-arrow stuck on screen. */
.composer button.sending {
  background: var(--panel-2); color: var(--muted); cursor: progress;
}
.composer .send-dots { display: inline-flex; gap: 4px; align-items: center; }
.composer .send-dots span {
  width: 5px; height: 5px; background: var(--accent);
  animation: bounce 1.3s ease-in-out infinite;
}
.composer .send-dots span:nth-child(2) { animation-delay: .18s; }
.composer .send-dots span:nth-child(3) { animation-delay: .36s; }
.composer button:disabled { cursor: progress; }
/* Legacy — replaced by .composer-meta below. */
.foot-note { display: none; }

/* Composer meta row — model selector + disclaimer note sit on a single
   thin line directly below the textarea, so the model choice is right
   where the user is typing instead of buried in the sidebar foot. */
.composer-meta {
  max-width: 760px; margin: 0 auto;
  padding: 6px 22px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--muted);
}
.composer-meta-label { color: var(--muted); white-space: nowrap; }
.composer-provider {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 6px; font: inherit; font-size: 11px;
  cursor: pointer;
}
.composer-provider:focus { outline: none; border-color: var(--accent); }
.composer-meta-divider { opacity: .5; }
.composer-meta-note {
  flex: 1; text-align: right; opacity: .85;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 600px) {
  .composer-meta { flex-wrap: wrap; padding: 6px 12px 10px; }
  .composer-meta-note { flex-basis: 100%; text-align: left; margin-top: 4px; }
  .composer-meta-divider { display: none; }
}

/* Streaming cursor — sits at the tail of the last paragraph while text is
   still arriving. We target the deepest inline target (the last <li> inside
   a trailing <ul>, or the last <p>) so it doesn't render a tall block. */
.msg.assistant .body.streaming > :last-child::after,
.msg.assistant .body.streaming ul:last-child li:last-child::after,
.msg.assistant .body.streaming ol:last-child li:last-child::after {
  content: "▌"; color: var(--accent);
  animation: blink 1s steps(2) infinite;
  margin-left: 2px; font-weight: 600;
  display: inline;
}
/* Suppress the outer-block cursor when the deeper-list cursor handles it,
   so a streaming list doesn't show two carets. */
.msg.assistant .body.streaming > ul:last-child::after,
.msg.assistant .body.streaming > ol:last-child::after { content: none; }
@keyframes blink { 50% { opacity: 0; } }

/* Earlier we ran a body-wide opacity tween on every token update which made
   already-rendered text visibly dim during streaming. We don't need it —
   the cursor is enough motion. Keep the keyframes for any future use but
   don't apply the animation. */
@keyframes tokenFade {
  from { opacity: .82; }
  to   { opacity: 1; }
}

/* --------------------------------------------------------------------- */
/* "Thinking" indicator — shown between user message and first assistant   */
/* text, replaced by the message bubble when the first token arrives.     */
/* --------------------------------------------------------------------- */
.thinking {
  max-width: 760px; margin: 8px auto 4px;
  padding: 14px 22px; display: flex; align-items: center; gap: 14px;
}
.thinking .role {
  flex: 0 0 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent); color: #04231b;
  font-size: 12px; font-weight: 700;
  animation: logoPulse 1.4s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(16, 163, 127, .35); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(16, 163, 127, 0); }
}
.thinking .label {
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: opacity .22s ease;
}
.thinking .dots { display: inline-flex; gap: 4px; align-items: center; margin-left: 2px; }
.thinking .dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.4s ease-in-out infinite;
}
.thinking .dots span:nth-child(2) { animation-delay: .18s; }
.thinking .dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: .35; }
  40%           { transform: translateY(-4px); opacity: 1;   }
}

/* While anything is streaming, gently glow the topbar "be" logo. */
body.streaming .logo {
  animation: logoGlow 1.6s ease-in-out infinite;
}
@keyframes logoGlow {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50%      { text-shadow: 0 0 18px rgba(16, 163, 127, .55); }
}

/* -------------------------------------------------------------------- */
/* File uploads + drag-drop                                              */
/* -------------------------------------------------------------------- */
.attachments {
  max-width: 760px; margin: 0 auto; padding: 0 22px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.attachments:empty { display: none; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px 5px 10px; font-size: 12px;
  color: var(--text);
}
.att-chip .att-kind {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--panel); color: var(--muted); text-transform: uppercase;
  letter-spacing: .6px;
}
.att-chip .att-x {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 0; font-size: 16px; line-height: 1;
}
.att-chip .att-x:hover { color: #e06c6c; }
.att-chip .att-edit {
  background: none; border: 1px solid var(--border); color: var(--accent); cursor: pointer;
  padding: 1px 7px; font-size: 11px; font-weight: 600; line-height: 1.5;
}
.att-chip .att-edit:hover:not(:disabled) { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.att-chip .att-edit:disabled { opacity: .6; cursor: default; }
.att-chip.error { border-color: #6f3434; color: #e06c6c; }
.att-chip.loading { opacity: .6; }

/* Self-custody key vault UI */
.wallet-input { width: 100%; margin: 6px 0; padding: 8px 10px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); font: inherit; font-size: 13px; }
.wallet-phrase-box { margin-top: 8px; padding: 10px; border: 1px solid var(--warn-bd, #d5c191); background: var(--warn-bg, #fbf2dc); }
.wallet-phrase { font-family: var(--font-serif, Georgia, serif); font-size: 15px; font-weight: 600; line-height: 1.8;
  letter-spacing: .3px; margin: 8px 0; padding: 10px; background: var(--panel); border: 1px solid var(--border); word-spacing: 6px; }
.wallet-recover { margin-top: 10px; }
.wallet-recover summary { cursor: pointer; font-size: 12px; color: var(--muted); }

/* Planner mode toggle + task plan (plan → execute → summarize) */
.planner-toggle.on { color: var(--accent-on); background: var(--accent); border-color: var(--accent); }
.task-plan { max-width: 760px; margin: 4px auto 10px; padding: 12px 16px; background: var(--panel);
  border: 1px solid var(--border); }
.task-plan-head { font-family: var(--font-serif, Georgia, serif); font-weight: 600; font-size: 14px; color: var(--accent);
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.task-plan-head .icon { width: 16px; height: 16px; }
.task-plan-list { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.task-plan-list li, .task-row { display: flex; align-items: flex-start; gap: 9px; padding: 4px 0; font-size: 13.5px; color: var(--text); }
.task-tick { flex: none; width: 16px; height: 16px; margin-top: 2px; border: 1.5px solid var(--border); border-radius: 50%; position: relative; }
li[data-status="in_progress"] .task-tick, .task-row[data-status="in_progress"] .task-tick { border-color: var(--accent); animation: task-pulse 1.1s infinite; }
li[data-status="completed"] .task-tick, .task-row[data-status="completed"] .task-tick { background: var(--accent); border-color: var(--accent); }
li[data-status="completed"] .task-tick::after, .task-row[data-status="completed"] .task-tick::after {
  content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
li[data-status="failed"] .task-tick, .task-row[data-status="failed"] .task-tick { border-color: var(--error-fg, #a23030); background: var(--error-fg, #a23030); }
li[data-status="completed"] .task-title, .task-row[data-status="completed"] .task-title { color: var(--muted); text-decoration: line-through; }
@keyframes task-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); } }
.task-plan.plan-summarizing { opacity: .9; }
.task-list { display: flex; flex-direction: column; gap: 2px; }
.side-empty { font-size: 12px; color: var(--muted); padding: 4px 2px; line-height: 1.5; }

/* Document editor formatting toolbar + clause picker */
.doc-edit-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 0; flex-wrap: wrap; }
.doc-edit-toolbar .fmt-btn { min-width: 30px; height: 28px; padding: 0 8px; background: var(--panel);
  border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 13px; }
.doc-edit-toolbar .fmt-btn:hover { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.doc-edit-toolbar .fmt-select { height: 28px; margin-left: auto; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); font: inherit; font-size: 12px; padding: 0 6px; cursor: pointer; }

.attach-btn {
  display: grid; place-items: center;
  width: 38px; height: 42px; flex: 0 0 38px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); color: var(--muted);
  cursor: pointer; font-size: 16px;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.attach-btn:hover { color: var(--text); border-color: var(--text); }
.attach-btn .icon { width: 18px; height: 18px; }
.composer { gap: 8px; }

/* Voice-input button — same shell as the paperclip; pulses red while
   `SpeechRecognition` is active so the user can see they're being heard. */
.voice-btn { color: var(--muted); font-size: 14px; cursor: pointer; }
.voice-btn:disabled { cursor: not-allowed; }
.voice-btn.listening {
  background: rgba(224, 108, 108, .12);
  border-color: #e06c6c;
  color: #e06c6c;
  animation: voicePulse 1.2s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 108, 108, .35); }
  50%      { box-shadow: 0 0 0 6px rgba(224, 108, 108, 0); }
}

.drop-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 16, 18, .85);
  display: grid; place-items: center;
  pointer-events: none;
}
/* `display:grid` above otherwise overrides the native `[hidden]` rule, so the
   overlay used to show on every page reload — pin it back to display:none. */
.drop-overlay[hidden] { display: none !important; }
.drop-overlay .drop-card {
  background: var(--panel); border: 2px dashed var(--accent); border-radius: 16px;
  padding: 40px 60px; font-size: 18px; color: var(--text);
  display: inline-flex; align-items: center; gap: 14px;
}
body.drag-active { cursor: copy; }

/* -------------------------------------------------------------------- */
/* Right-side CHAT DETAILS rail — slim conversation metadata sidebar.    */
/* Hidden when the doc panel opens (they share the right gutter), and    */
/* dismissible via the close button (body.chat-details-closed).          */
/* -------------------------------------------------------------------- */
/* Rail width + chrome MATCH the left sidebar: same 264px, same panel bg,
   same border treatment, same header font — so they read as a symmetric
   pair around the chat column. */
.chat-details {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 264px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 60;
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
body.doc-panel-open .chat-details,
body.chat-details-closed .chat-details {
  transform: translateX(100%);
  pointer-events: none;
}
body .chat { transition: margin-right .25s cubic-bezier(.2, .8, .2, 1); }
body:not(.doc-panel-open):not(.chat-details-closed) .chat {
  margin-right: 264px;
}
.chat-details-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.chat-details-head h3 {
  margin: 0; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
}
.chat-details-body {
  flex: 1; overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.cd-section { display: flex; flex-direction: column; gap: 4px; }
.cd-section.cd-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px;
}
.cd-label {
  font-size: 10px; font-weight: 600; letter-spacing: .7px;
  text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
}
.cd-label .icon {
  width: 11px; height: 11px;
  opacity: .7; flex: 0 0 11px;
}

/* Document list inside the chat-details rail — compact rows, click to
   open in the side panel. Each row matches the sidebar Dokumentumok
   row style but tightened for the narrower 240px rail. */
.cd-docs-list {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 2px;
}
.cd-doc-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 100%;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
  overflow: hidden;
  box-sizing: border-box;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.cd-doc-row:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--panel);
}
.cd-doc-row .cd-doc-icon {
  flex: 0 0 22px; width: 22px; height: 26px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--accent);
  font-size: 10px; font-weight: 700;
  font-family: var(--font-sans);
}
/* Meta column MUST be display:flex with min-width:0 so the title's
   text-overflow: ellipsis actually clamps. Without these the inner
   <span> can grow past the row and break out of the rail. */
.cd-doc-row .cd-doc-meta {
  flex: 1 1 auto; min-width: 0; max-width: 100%;
  display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
}
.cd-doc-row .cd-doc-title {
  display: block; width: 100%; max-width: 100%;
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-doc-row .cd-doc-fmts {
  display: block; width: 100%;
  font-size: 9.5px; color: var(--muted);
  letter-spacing: .4px; font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-value {
  font-size: 13px; color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.cd-value-title {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600;
  color: var(--text-strong);
}
.cd-value-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 18px; color: var(--text-strong);
}
.cd-value-small { font-size: 11.5px; color: var(--muted); }
.cd-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.cd-action {
  padding: 7px 9px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border);
  font: inherit; font-size: 11.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  text-align: left;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.cd-action .icon {
  width: 12px; height: 12px;
  flex: 0 0 12px;
  opacity: .7;
}
.cd-action:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--panel);
}
.cd-action:hover .icon { opacity: 1; }
.cd-action span { flex: 1 1 auto; min-width: 0; }

/* Floating reopen handle (only shown when the rail is closed). */
.chat-details-reopen {
  position: fixed; right: 14px; top: 78px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer; z-index: 61;
  transition: color .12s ease, border-color .12s ease, transform .15s ease;
}
.chat-details-reopen:hover {
  color: var(--accent); border-color: var(--accent);
  transform: translateY(-1px);
}
.chat-details-reopen[hidden] { display: none !important; }
.chat-details-reopen .icon { width: 16px; height: 16px; }

/* Mobile: rail becomes a sliding overlay instead of a column. */
@media (max-width: 900px) {
  .chat-details { width: 280px; }
  body:not(.doc-panel-open):not(.chat-details-closed) .chat { margin-right: 0; }
  body .chat-details {
    box-shadow: -12px 0 32px -16px rgba(0, 0, 0, .35);
  }
}

/* -------------------------------------------------------------------- */
/* Right-side document editor panel                                      */
/* -------------------------------------------------------------------- */
.doc-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 48vw);
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 90;
  box-shadow: -8px 0 24px rgba(0, 0, 0, .35);
}
/* `display:flex` above otherwise overrides `[hidden]` (same bug as drop-overlay). */
.doc-panel[hidden] { display: none !important; }
.doc-revise-box[hidden] { display: none !important; }
body.doc-panel-open .chat {
  margin-right: min(560px, 48vw);
}
.doc-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.doc-panel-head h3 {
  margin: 0; font-size: 15px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Doc-panel tab bar — every opened doc gets a tab. Active tab is
   highlighted with the accent left-stripe; closing the last tab closes
   the whole panel (handled in JS). Horizontal scroll on overflow so
   many tabs don't push the tools row out of view. */
.doc-tabs {
  display: flex; gap: 0;
  padding: 0 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.doc-tabs[hidden] { display: none !important; }
.doc-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px 8px 12px;
  font-size: 12.5px; color: var(--muted);
  border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  cursor: pointer;
  white-space: nowrap;
  max-width: 200px;
  position: relative;
  transition: color .12s ease, background .12s ease;
}
.doc-tab:hover { color: var(--text); background: var(--panel); }
.doc-tab.active {
  color: var(--text-strong); background: var(--panel);
  font-weight: 500;
}
.doc-tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent);
}
.doc-tab-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}
.doc-tab-close {
  background: transparent; border: 0;
  width: 18px; height: 18px;
  padding: 0; line-height: 1;
  color: var(--muted);
  cursor: pointer; font-size: 16px;
  opacity: .55;
  transition: opacity .12s ease, color .12s ease;
}
.doc-tab:hover .doc-tab-close { opacity: 1; }
.doc-tab-close:hover { color: #e06c6c; }
.doc-panel-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
}

/* Preview <-> Edit toggle */
.doc-mode-toggle {
  display: inline-flex; border: 1px solid var(--border); background: var(--panel-2);
}
.doc-mode-toggle .mode-btn {
  background: transparent; color: var(--muted); border: none;
  padding: 6px 12px; font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: var(--font-sans);
}
.doc-mode-toggle .mode-btn:hover { color: var(--text); }
.doc-mode-toggle .mode-btn.active { background: var(--panel); color: var(--text-strong); }

/* Download dropdown — primary action in the doc panel, so it gets a
   filled accent surface to stand apart from the ghost "AI" button on
   its left. The "▾" caret stays muted so the button reads "Letöltés"
   first, "menu" second. */
.doc-dl-wrap { position: relative; margin-left: auto; }
#doc-dl-toggle {
  background: var(--accent); color: var(--accent-on);
  border: 1px solid var(--accent);
  padding: 6px 12px;
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  transition: filter .12s ease;
}
#doc-dl-toggle:hover { filter: brightness(1.06); }
#doc-dl-toggle .icon { width: 14px; height: 14px; flex: 0 0 14px; }
#doc-dl-toggle .iconbtn-label { letter-spacing: .2px; }
#doc-dl-toggle .doc-dl-caret {
  font-size: 9px; opacity: .85; line-height: 1;
  transition: transform .15s ease;
  display: inline-block;
}
#doc-dl-toggle[aria-expanded="true"] {
  filter: brightness(.95);
}
#doc-dl-toggle[aria-expanded="true"] .doc-dl-caret { transform: rotate(180deg); }

.doc-dl-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow-deep); min-width: 220px; z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.doc-dl-menu[hidden] { display: none !important; }
.doc-dl-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; font-size: 13px; color: var(--text); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  transition: background .1s ease, color .1s ease;
}
.doc-dl-menu a:last-child { border-bottom: none; }
.doc-dl-menu a:hover { background: var(--panel-2); color: var(--accent); }
/* Format pill — a small chip on the left so the menu reads as a
   3-column grid of "PILL · LABEL". JS adds `data-fmt` on each link. */
.doc-dl-menu a::before {
  content: attr(data-fmt);
  text-transform: uppercase;
  font-family: var(--font-sans);
  font-size: 10.5px; font-weight: 700; letter-spacing: .6px;
  padding: 2px 6px; min-width: 38px; text-align: center;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.doc-dl-menu a:hover::before {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  color: var(--accent); border-color: var(--accent);
}

/* Preview pane — styled like a printed legal document */
.doc-preview {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 32px 36px;
  background: var(--panel); color: var(--text);
  font-family: var(--font-serif);
  font-size: 15px; line-height: 1.7;
}
.doc-preview[hidden] { display: none !important; }
.doc-preview h1 { font-family: var(--font-serif); font-size: 26px; font-weight: 700; margin: 0 0 16px; }
.doc-preview h2 { font-family: var(--font-serif); font-size: 19px; font-weight: 600; margin: 1.4em 0 .5em; padding-top: .6em; border-top: 1px solid var(--border); }
.doc-preview h3 { font-family: var(--font-serif); font-size: 16px; font-weight: 600; margin: 1.2em 0 .4em; color: var(--accent); }
.doc-preview h4.sect { font-family: var(--font-serif); font-size: 15.5px; font-weight: 600; margin: 1.4em 0 .4em; padding-bottom: .3em; border-bottom: 1px solid var(--border); color: var(--text-strong); }
.doc-preview p { margin: .75em 0; }
.doc-preview ul, .doc-preview ol { padding-left: 24px; margin: .7em 0; }
.doc-preview li { margin: .4em 0; }
.doc-preview ul li::marker { color: var(--accent); }
.doc-preview ol li::marker { color: var(--accent); font-weight: 600; }
.doc-preview strong { color: var(--text-strong); }
.doc-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.doc-preview blockquote {
  border-left: 3px solid var(--accent); background: var(--quote-bg);
  padding: .55em 14px; margin: .8em 0;
}

#doc-editor {
  flex: 1; min-height: 0;
  background: var(--panel-2); color: var(--text);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  resize: none;
  padding: 16px 18px;
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px; line-height: 1.55;
}
#doc-editor:focus { outline: none; }
.doc-revise-box {
  display: flex; gap: 8px; padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.doc-revise-box textarea {
  flex: 1; resize: vertical; min-height: 64px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 13px;
}
.doc-panel-status {
  font-size: 12px; color: var(--muted);
  padding: 8px 18px 14px; min-height: 14px;
}
.doc-panel-status.ok { color: var(--accent); }
.doc-panel-status.err { color: #e06c6c; }

.primary-btn {
  background: var(--accent); color: #04231b; border: none;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:disabled { opacity: .5; cursor: default; }

/* Doc card in chat — add an "Edit" button alongside downloads */
.doc-card .doc-card-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.doc-card .doc-edit {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.doc-card .doc-edit:hover { background: rgba(16, 163, 127, .12); }

/* Mobile: side panel goes full-width */
@media (max-width: 900px) {
  .doc-panel { width: 100vw; }
  body.doc-panel-open .chat { margin-right: 0; display: none; }
}


/* ===================================================================== */
/* Auth screen                                                            */
/* ===================================================================== */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 24px;
}
.auth-screen[hidden] { display: none !important; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px 28px;
  box-shadow: var(--shadow-deep);
}
.auth-brand { text-align: center; margin-bottom: 6px; }
.auth-brand .logo { font-size: 42px; }
.auth-tagline {
  text-align: center; color: var(--muted); margin: 0 0 18px;
  font-size: 14px; font-family: var(--font-serif); font-style: italic;
}
.auth-tabs {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 18px;
  background: var(--panel-2); border-radius: 10px;
}
.auth-tab {
  flex: 1; background: transparent; border: none;
  color: var(--muted); padding: 8px; border-radius: 8px;
  font: inherit; font-weight: 500; cursor: pointer;
}
.auth-tab.active {
  background: var(--panel); color: var(--text-strong);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: .6px;
}
.auth-form input {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font: inherit; font-size: 15px;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-form .primary-btn { padding: 11px; margin-top: 6px; font-size: 14px; }
.auth-error {
  background: var(--error-bg); border: 1px solid var(--error-bd);
  color: var(--error-fg); padding: 8px 12px; font-size: 13px;
}
.auth-error[hidden] { display: none !important; }


/* ===================================================================== */
/* Quota chip + topbar login button (freemium tier, pass 20)              */
/* ===================================================================== */
/* Icon-only chip: just the number ("3/10") or "∞" symbol. Tooltip
   (set in JS) carries the unit name. Sized to match .iconbtn. */
.quota-chip {
  font-size: 12px; font-weight: 600;
  min-width: 30px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 9px;
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--muted);
  letter-spacing: .2px;
  cursor: default;
}
.quota-chip[hidden] { display: none !important; }
.quota-chip.quota-admin {
  color: var(--accent); border-color: var(--accent);
  font-size: 18px; font-weight: 700; line-height: 1; padding-bottom: 2px;
}
.quota-chip.warn {
  color: var(--verify-warn-fg); border-color: var(--verify-warn-bd);
  background: var(--verify-warn-bg);
}

.login-link {
  font-size: 12px; padding: 5px 10px; cursor: pointer;
  color: var(--text); border-color: var(--accent);
  background: var(--panel);
}
.login-link[hidden] { display: none !important; }
.login-link:hover { background: var(--panel-2); }

.quota-banner {
  background: var(--verify-warn-bg);
  border: 1px solid var(--verify-warn-bd);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  font-size: 14px; color: var(--text);
}
.quota-banner strong { color: var(--text-strong); }
.quota-banner .primary-btn { align-self: flex-start; }

/* ===================================================================== */
/* Persistent quota lockout — shown above the composer when the user has  */
/* hit their daily message cap. Composer itself is also dimmed + disabled */
/* via body.quota-locked so they can't even attempt a send.               */
/* ===================================================================== */
.quota-lock {
  max-width: 760px; margin: 0 auto; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--verify-warn-bg);
  border: 1px solid var(--verify-warn-bd);
  border-bottom: none;
  color: var(--text); font-size: 14px;
}
.quota-lock[hidden] { display: none !important; }
.quota-lock strong { display: block; color: var(--text-strong); margin-bottom: 2px; }
.quota-lock-actions { display: flex; gap: 8px; flex-shrink: 0; }
.quota-lock .primary-btn { padding: 8px 14px; font-size: 13px; }

body.quota-locked .composer textarea,
body.quota-locked .composer .attach-btn,
body.quota-locked .composer button {
  opacity: .45; pointer-events: none;
}
body.quota-locked .composer textarea::placeholder { color: var(--muted); }

/* Tiny shake when the user nonetheless tries to type-and-send. */
.quota-lock.shake { animation: lockShake .32s ease; }
@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@media (max-width: 600px) {
  .quota-lock { flex-direction: column; align-items: stretch; }
  .quota-lock .primary-btn { width: 100%; }
}


/* ===================================================================== */
/* User chip + theme toggle in the topbar                                 */
/* ===================================================================== */
/* Icon-only avatar in the topbar. Hovering surfaces the email/name via
   the chip's title attribute. The logout button sits flush beside it. */
.user-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 0;
  padding: 0;
  font-size: 12.5px; color: var(--text);
}
.user-chip[hidden] { display: none !important; }

/* Outlined avatar: transparent fill, accent (green) border, accent font.
   Auto-shrinks the type when carrying two letters so "DM" still fits. */
.user-chip-avatar {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--accent);
  font-weight: 700; font-size: 12.5px;
  letter-spacing: .2px;
  border: 1.5px solid var(--accent);
  cursor: pointer; padding: 0;
  transition: background .12s ease;
}
.user-chip-avatar:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.user-chip-avatar .icon { width: 15px; height: 15px; }
.user-chip-avatar [hidden] { display: none !important; }

.user-chip-logout {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer; padding: 0;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.user-chip-logout:hover { color: var(--text); border-color: var(--text); }
.user-chip-logout .icon { width: 14px; height: 14px; }

/* Visually-hidden helper for the legacy #user-chip-email slot kept for
   backwards-compat readers (auth screen, settings page). */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  border: 0;
}

/* Topbar export dropdown (Letöltés ▾) — three formats in one button. */
.export-wrap { position: relative; }
.export-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 6px 24px -8px rgba(0, 0, 0, .25);
  z-index: 50;
  display: flex; flex-direction: column;
  padding: 4px;
}
.export-menu[hidden] { display: none !important; }
.export-menu-item {
  display: flex; align-items: baseline; gap: 12px;
  background: transparent; border: 0; cursor: pointer;
  padding: 9px 12px; text-align: left;
  font: inherit; color: var(--text);
  transition: background .12s ease;
}
.export-menu-item:hover { background: var(--panel-2); }
.export-menu-fmt {
  font-weight: 700; font-size: 12.5px; letter-spacing: .4px;
  color: var(--accent); width: 44px; flex: 0 0 44px;
}
.export-menu-desc { font-size: 12.5px; color: var(--muted); }

/* Global error banner — clicked to dismiss. Triggered by window-level
   error / unhandledrejection handlers in app.js. */
.global-error-banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  background: #5a1e1e; color: #ffe4e4; border: 1px solid #a64545;
  padding: 10px 16px; font-size: 13px;
  cursor: pointer; max-width: 90vw;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, .35);
}
.global-error-banner:hover { background: #6a2424; }


/* ====================================================================
   ===  CONSOLIDATED MOBILE PASS  ===================================
   Single section that overrides desktop layout across the whole app for
   screens ≤ 900px (tablet) and ≤ 600px (phone). The earlier mobile rules
   scattered through the file still apply; this section finishes the job:
   sidebars become overlays, the rail closes by default, the doc panel
   takes the full width, meta panels tighten, the bottom-bar gets thumb-
   reach, and the chat column reclaims the full viewport.
   ==================================================================== */

/* === Tablet & phone shared (≤ 900px) ============================== */
@media (max-width: 900px) {
  /* The right rail becomes a sliding overlay — never push the chat. */
  body:not(.doc-panel-open):not(.chat-details-closed) .chat { margin-right: 0; }
  .chat-details {
    width: 280px;
    box-shadow: -12px 0 32px -16px rgba(0, 0, 0, .35);
    /* Closed by default on mobile — power-user data, optional surface. */
    transform: translateX(100%);
  }
  body.chat-details-open .chat-details { transform: translateX(0); }
  .chat-details-reopen { display: grid !important; }

  /* Doc panel goes near-fullscreen so the user can actually read it. */
  .doc-panel {
    width: min(100vw, 720px);
    box-shadow: -16px 0 40px -16px rgba(0, 0, 0, .45);
  }
  body.doc-panel-open .chat { margin-right: 0; }

  /* Per-message meta panels — tighter horizontal padding so they hit the
     edge of the chat column on small screens. */
  .msg-meta-stack, .msg-docs-block { margin-left: 12px; margin-right: 12px; }
  .meta-toggle { padding: 7px 10px; }
  .meta-title { font-size: 10.5px; }

  /* Doc tabs scroll horizontally — keep them touch-friendly. */
  .doc-tab { padding: 10px 10px 10px 14px; min-height: 40px; }
  .doc-tab-close { width: 22px; height: 22px; font-size: 18px; }

  /* Top bar: shrink labels, hide non-essential text-on-icon. */
  .topbar { padding: 10px 12px; }
  .title small { display: none; }
  .topbar-right .iconbtn-label,
  .topbar-right .composer-meta-label { display: none; }
}

/* === Phone (≤ 600px) ============================================== */
@media (max-width: 600px) {
  /* Left sidebar slides over the chat instead of pushing it.
     `body.sidebar-open` triggers the slide-in. */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 86vw; max-width: 320px;
    transform: translateX(-100%);
    z-index: 80;
    transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 12px 0 32px -16px rgba(0, 0, 0, .4);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.35);
    z-index: 79; opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* Chat column reclaims full width. */
  .chat { width: 100vw; }
  /* The hamburger button MUST be visible to bring the sidebar back. */
  #sidebar-toggle { display: inline-grid !important; }

  /* Composer thumb-reach: rounder, taller, bigger send button. */
  .composer { padding: 8px 10px; gap: 6px; }
  .composer textarea { font-size: 16px; padding: 10px 10px; min-height: 44px; }
  .composer .send-btn, .composer .attach-btn, .composer .voice-btn {
    width: 44px; height: 44px;
    flex: 0 0 44px;
  }
  .composer .send-btn svg { width: 18px; height: 18px; }

  /* Bottom meta strip (Praxis / Modell) wraps neatly. */
  .composer-meta {
    display: flex; flex-wrap: wrap; gap: 8px 12px;
    font-size: 11.5px;
    padding: 6px 10px 8px;
  }

  /* Message bubbles use almost full width with a small left/right gutter. */
  .msg.user .body-col { max-width: 92%; }
  .msg.user { padding-left: 6%; }
  .msg-meta-stack, .msg-docs-block {
    margin-left: 8px; margin-right: 8px;
  }
  .meta-toggle { min-height: 36px; }  /* easier tap target */

  /* Doc-card icon block + actions become more compact. */
  .src-doc-row { padding: 8px 8px; }
  .src-doc-icon { flex: 0 0 26px; width: 26px; height: 30px; font-size: 11px; }
  .src-doc-open span { display: none; }  /* keep only the icon */
  .src-doc-open .icon { width: 14px; height: 14px; }

  /* Onboarding card + auth screen shrink to fit viewport with safe gutters. */
  .onboarding-card, .auth-card {
    width: calc(100% - 24px); margin: 12px;
    padding: 20px 18px;
  }

  /* Cmd+K palette goes full-bleed on phones — modal style. */
  .palette {
    width: calc(100% - 16px); max-height: 80vh;
    left: 8px; right: 8px; transform: none;
    top: 8px;
  }

  /* Topbar icons: hide the export dropdown until needed, keep core actions. */
  #export-toggle, #docs-link, #templates-link { display: none; }

  /* Doc panel mobile: full screen with top close-bar. */
  .doc-panel { width: 100vw; }
  .doc-panel-head { padding: 10px 14px; }
  .doc-panel-head h3 { font-size: 14px; }
  .doc-panel-tools { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .doc-preview { padding: 18px 18px 80px; font-size: 14.5px; }

  /* HIVATKOZÁSOK panel header chips wrap onto a second line cleanly. */
  .meta-chips { flex-basis: 100%; margin-top: 4px; }

  /* Hide the floating reopen handle if the rail is irrelevant on phone
     and the user explicitly closed it. They can re-enable from /account. */
  /* (keeping it on — power users may want it) */

  /* Notes panel takes full viewport on phone. */
  .notes-panel { width: 100vw; }

  /* Sidebar accordion sections — bigger tap targets. */
  .side-section-head { min-height: 44px; padding: 10px 12px; }
  .conv-row, .doc-row, .deadline-row { min-height: 44px; }
}

/* === Narrow phones (≤ 380px) ====================================== */
@media (max-width: 380px) {
  .doc-tab { padding: 8px 8px 8px 10px; max-width: 140px; }
  .doc-tab-title { max-width: 100px; }
  .meta-toggle { padding: 6px 8px; gap: 6px; }
  .meta-count { padding: 1px 5px; font-size: 10px; }
  .msg.user { padding-left: 2%; }
  .msg.user .body-col { max-width: 96%; }
}

/* Sidebar backdrop element is created on demand by the body class in JS. */
.sidebar-backdrop { display: none; }
@media (max-width: 600px) {
  .sidebar-backdrop { display: block; }
}


/* ---- Document folder tree + client chip (added) ---- */
.doc-toolbar { padding: 2px 4px 6px; }
.doc-newfolder {
  width: 100%; text-align: left; background: var(--panel-2); color: var(--text);
  border: 1px dashed var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer;
  font-size: 12px;
}
.doc-newfolder:hover { border-color: var(--accent); color: var(--accent); }
.folder-row, .doc-row {
  display: flex; align-items: center; gap: 4px; border-radius: 8px;
}
.folder-row:hover, .doc-row:hover { background: var(--panel-2); }
.folder-head {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
  background: none; border: 0; color: var(--text); cursor: pointer; padding: 5px 6px;
  font-size: 13px; text-align: left;
}
.icon.folder-chev { width: 12px; height: 12px; flex: 0 0 auto; color: var(--muted); transition: transform .15s; }
.icon.folder-chev.open { transform: rotate(90deg); }
.icon.folder-ic, .icon.doc-ic { width: 15px; height: 15px; flex: 0 0 auto; color: var(--muted); }
.doc-item .icon.doc-ic { color: var(--accent); }
.folder-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-count { margin-left: auto; color: var(--muted); font-size: 11px; }
.folder-children { display: flex; flex-direction: column; gap: 2px; }
.doc-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .12s; padding-right: 4px; }
.folder-row:hover .doc-actions, .doc-row:hover .doc-actions { opacity: 1; }
.doc-mini {
  background: none; border: 0; cursor: pointer; line-height: 0;
  padding: 4px; border-radius: 6px; color: var(--muted);
}
.doc-mini .icon { width: 14px; height: 14px; }
.doc-mini:hover { background: var(--panel); color: var(--accent); }

.client-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; max-width: 260px;
}
/* The `display` above overrides the default [hidden] rule — restore it so the
   chip is truly gone unless a specific client is selected (on load / "Összes"). */
.client-chip[hidden] { display: none; }
.client-chip .icon { width: 13px; height: 13px; }
.client-chip .acc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.client-chip .acc-x { opacity: .8; font-size: 14px; }
.client-chip:hover { filter: brightness(1.08); }
.client-chip:hover .acc-x { opacity: 1; }

/* ---- Cross-chat memory popup ---- */
.memory-modal {
  width: min(560px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 16px 18px; margin: 8vh auto;
}
.memory-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.memory-title { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-serif); font-weight: 600; font-size: 17px; }
.memory-title .icon { width: 18px; height: 18px; color: var(--accent); }
.memory-share { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.memory-share input { width: 16px; height: 16px; accent-color: var(--accent); }
.memory-hint { font-size: 12px; color: var(--muted); margin: 6px 0 12px; line-height: 1.5; }
.memory-add { display: flex; gap: 8px; margin-bottom: 12px; }
.memory-add input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font-size: 13px;
}
.memory-add .primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.memory-add .primary:hover { filter: brightness(1.08); }
.memory-list { display: flex; flex-direction: column; gap: 4px; }
.memory-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--panel-2); border-radius: 8px;
}
.memory-text { flex: 1; font-size: 13px; line-height: 1.45; }
.memory-row .doc-mini { opacity: .6; }
.memory-row:hover .doc-mini { opacity: 1; }

/* One-line note above the composer (e.g. "wait — a response is streaming"). */
.composer-hint {
  max-height: 0; overflow: hidden; opacity: 0;
  font-size: 12px; color: var(--muted);
  text-align: center; transition: max-height .2s, opacity .2s, padding .2s;
}
.composer-hint.show { max-height: 40px; opacity: 1; padding: 4px 0; }

/* Nudge used when an action isn't allowed yet (send-while-streaming, quota). */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake { animation: shake .32s cubic-bezier(.36,.07,.19,.97) both; }

/* Version history + redline diff */
.doc-versions-box { max-height: 40vh; overflow-y: auto; padding: 6px 0; border-top: 1px solid var(--border); }
.ver-row { padding: 8px 10px; border: 1px solid var(--border); margin: 6px 0; background: var(--panel); }
.ver-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.ver-preview { font-family: var(--font-serif, Georgia, serif); font-size: 13px; color: var(--text); margin: 4px 0; }
.ver-diff { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; margin-top: 4px; }
.ver-add { color: var(--conf-fg, #14624f); background: rgba(20,98,79,.07); padding: 0 4px; }
.ver-del { color: var(--error-fg, #a23030); background: rgba(162,48,48,.06); padding: 0 4px; text-decoration: line-through; }

/* Subscription tiers / pricing */
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.plan-card { border: 1px solid var(--border); padding: 10px; background: var(--panel); }
.plan-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.plan-price { font-size: 11px; color: var(--muted); }
.plan-lim { font-size: 12.5px; color: var(--accent); margin-top: 3px; font-weight: 600; }
.plan-feat { font-size: 11.5px; color: var(--muted); margin: 4px 0 8px; line-height: 1.4; }
.plan-current-badge { font-size: 11px; color: var(--accent); font-weight: 700; }

/* Deadline calculator */
.deadline-calc { padding: 8px 4px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.deadline-calc .dc-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.deadline-calc .dc-row label { font-size: 12px; color: var(--muted); width: 78px; flex: none; }
.deadline-calc input, .deadline-calc select { flex: 1; padding: 5px 7px; background: var(--panel); color: var(--text); border: 1px solid var(--border); font: inherit; font-size: 12.5px; }
.deadline-calc .primary-btn { width: 100%; margin-top: 6px; }
.dc-result { margin-top: 8px; font-size: 13px; }
.dc-out b { font-family: var(--font-serif, Georgia, serif); color: var(--accent); font-size: 15px; }
.dc-note { color: var(--warn-fg, #8b6914); font-size: 11px; }
.dc-save { margin-top: 6px; }

/* Explain-this-clause box */
.doc-explain-box { border-top: 1px solid var(--border); padding: 8px 0; max-height: 40vh; overflow-y: auto; }
.explain-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--accent); font-family: var(--font-serif, Georgia, serif); }
.explain-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
.explain-body { font-size: 14px; line-height: 1.55; margin: 6px 0; }
.explain-srcs { border-top: 1px dashed var(--border); padding-top: 6px; }
.explain-src { font-size: 12px; color: var(--muted); margin: 4px 0; }
.explain-src b a { color: var(--accent); }

/* Matter / case overview modal */
.matter-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(10,14,19,.45); display: grid; place-items: center; padding: 24px; }
.matter-modal { background: var(--panel); border: 1px solid var(--border); max-width: 900px; width: 100%; max-height: 80vh; overflow-y: auto; padding: 22px; box-shadow: 0 30px 90px rgba(40,40,60,.35); }
.matter-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.matter-head h3 { font-family: var(--font-serif, Georgia, serif); font-size: 22px; color: var(--strong, #0b0e13); }
.matter-close { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
.matter-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .matter-cols { grid-template-columns: 1fr; } }
.matter-col h4 { font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.matter-col ul { list-style: none; margin: 0; padding: 0; }
.matter-col li { font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.matter-col a, .link-btn { color: var(--accent); background: none; border: 0; cursor: pointer; font: inherit; text-align: left; padding: 0; }

.dc-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.dc-chip { font-size: 11px; padding: 3px 8px; background: var(--bg); border: 1px solid var(--border); color: var(--accent); cursor: pointer; }
.dc-chip:hover { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }

/* Advanced settings rows */
.adv-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 13px; }
.adv-row select { flex: 0 0 58%; padding: 6px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border); font: inherit; font-size: 12.5px; }

/* SSO login buttons */
.sso-buttons { margin-top: 12px; }
.sso-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; }
.sso-btn { display: block; text-align: center; padding: 10px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; margin: 6px 0; font-size: 13px; background: var(--panel); }
.sso-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Law-change news feed (sidebar section) */
.news-badge { background: var(--accent); color: #0b1020; border-radius: 999px;
  font-size: 11px; font-weight: 700; padding: 0 6px; margin-left: 6px; }
.news-list { display: flex; flex-direction: column; gap: 6px; }
.news-row { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--panel); }
.news-row.news-mine { border-color: var(--accent); }
.news-row.news-hot { box-shadow: inset 3px 0 0 var(--accent); }
.news-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.news-ref { font-weight: 600; }
.news-jur { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.news-type { font-size: 11px; color: var(--muted); }
.news-flag { font-size: 11px; color: var(--accent); margin-left: auto; }
.news-sum { font-size: 12px; color: var(--text); margin-top: 3px; }
.news-secs { color: var(--muted); }
.news-when { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Per-sentence grounding (Sources panel) */
.src-chip.ground-mid { background: #5a4a1a; color: #ffe9a8; }
.ground-uns { margin: 4px 0 0; padding-left: 18px; }
.ground-uns li { font-size: 12px; color: var(--muted); margin: 2px 0; }

/* Related case law (precedents) panel */
.caselaw-panel { margin-top: 8px; border: 1px solid var(--line, var(--border)); border-left: 3px solid var(--accent); border-radius: 8px; padding: 8px 10px; background: var(--panel); }
.caselaw-head { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.caselaw-count { background: var(--accent-2, #3a4a8c); color: #dbe4ff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.caselaw-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.caselaw-ref { font-weight: 600; font-size: 12px; color: var(--accent); text-decoration: none; }
.caselaw-ref:hover { text-decoration: underline; }
.caselaw-snip { font-size: 12px; color: var(--muted); margin-top: 2px; }
.caselaw-note { font-size: 11px; color: var(--muted); margin-top: 6px; font-style: italic; }

/* Team / firm management (settings) */
.team-create, .team-invite { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.team-create input, .team-invite input { flex: 1; min-width: 140px; }
.team-name-row { margin: 6px 0; }
.team-members { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.team-member { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tm-email { flex: 1; }
.tm-role { font-size: 11px; border-radius: 999px; padding: 1px 8px; background: var(--panel); border: 1px solid var(--border); }
.tm-owner { color: var(--accent); border-color: var(--accent); }
.tm-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.tm-del:hover { color: #e06c6c; }

/* citation-graph precedents (§-precise badge) */
.caselaw-precise { font-size: 10px; background: var(--accent); color: #0b1020; border-radius: 999px; padding: 0 6px; margin-left: 6px; font-weight: 700; }
