/* Trade visualisation platform — design tokens & layout.
 *
 * Colour roles come from the validated palette; the sector hues themselves are
 * served by the API (light + dark column) so Python and the browser can never
 * disagree about what colour a sector is.
 *
 * Dark mode is a selected set, not an inverted one: the media query covers the
 * OS setting and the [data-theme] scope covers the in-page toggle, which must
 * win in both directions.
 */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;          /* chart surface */
  --surface-page: #f9f9f7;       /* page plane */
  --surface-raised: #ffffff;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;

  --grid: #e1e0d9;               /* hairline gridline */
  --axis: #c3c2b7;               /* baseline / axis */
  --border: rgba(11, 11, 11, 0.10);
  --ghost: rgba(11, 11, 11, 0.04);

  --delta-good: #006300;
  --delta-bad: #d03b3b;

  --radius: 6px;
  --radius-lg: 10px;
  --gap: 16px;

  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-page: #0d0d0d;
    --surface-raised: #212120;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --ghost: rgba(255, 255, 255, 0.06);
    --delta-good: #0ca30c;
    --delta-bad: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-page: #0d0d0d;
  --surface-raised: #212120;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --ghost: rgba(255, 255, 255, 0.06);
  --delta-good: #0ca30c;
  --delta-bad: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- app shell ---------- */

.app {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 0 20px 18px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0;
}

.nav-group-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--ghost); color: var(--text-primary); }
.nav-item[aria-current="page"] {
  color: var(--text-primary);
  font-weight: 500;
  border-left-color: #2a78d6;
  background: var(--ghost);
}
.nav-item:disabled { opacity: 0.45; cursor: default; }
.nav-item:disabled:hover { background: none; color: var(--text-secondary); }

/* Width: generous but not edge-to-edge. A treemap does use extra width well
 * (more cells clear the direct-label threshold), so the column grows past the
 * usual ~1200px reading measure — but it stops at 2100px and adds roomier side
 * padding on large screens, so the page keeps a margin instead of running into
 * the bezel. */
.main { padding: 24px 28px 56px; width: 100%; max-width: 2100px; }

@media (min-width: 1700px) {
  .main { padding: 32px 48px 72px; }
}

/* Long-form text stays readable regardless of how wide the column gets. */
.page-head p, .note { max-width: 90ch; }

.page-head { margin-bottom: 20px; }
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.page-head p { margin: 0; color: var(--text-secondary); font-size: 13px; }

/* ---------- filter row: one row, above the charts ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: var(--gap);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

select, input[type="search"], button.btn {
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--axis);
  border-radius: var(--radius);
  padding: 6px 9px;
  min-height: 32px;
}
select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid #2a78d6;
  outline-offset: 1px;
}

/* segmented control — flow switch */
.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  font: inherit; font-size: 13px; padding: 6px 13px; min-height: 32px;
  border: none; background: var(--surface-raised); color: var(--text-secondary);
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--axis); }
.segmented button[aria-pressed="true"] {
  background: #2a78d6; color: #fff; font-weight: 500;
}

.spacer { flex: 1; }

/* ---------- cards & stat tiles ---------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

/* On a large screen the chart card gets more internal breathing room too, so the
 * treemap doesn't sit tight against the card edge. */
@media (min-width: 1700px) {
  .card { padding: 24px 26px; }
}
.card + .card { margin-top: var(--gap); }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .sub { color: var(--text-muted); font-size: 12px; }

/* auto-fit with a max keeps four tiles compact on a wide monitor instead of
 * stretching each one to 600px of mostly empty card. */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 340px));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--text-secondary); }
.stat .value {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
  margin-top: 2px; line-height: 1.15;
}
.stat .hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat .delta { font-size: 12px; font-weight: 500; margin-top: 2px; }
.delta.up { color: var(--delta-good); }
.delta.down { color: var(--delta-bad); }

/* ---------- legend ---------- */

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--grid);
}
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  background: none; border: none; font-family: inherit; cursor: pointer;
  padding: 2px 4px; border-radius: 4px;
}
.legend-item:hover { background: var(--ghost); color: var(--text-primary); }
.legend-item[aria-pressed="false"] { opacity: 0.4; }
.legend-swatch {
  width: 11px; height: 11px; border-radius: 2px; flex: none;
}
.legend-item .pct { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 9px 11px;
  font-size: 12px;
  max-width: 280px;
  opacity: 0;
  transition: opacity 90ms ease;
}
.tooltip[data-show="true"] { opacity: 1; }
.tooltip .tt-value {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  letter-spacing: -0.01em;
}
.tooltip .tt-name { color: var(--text-secondary); margin-bottom: 1px; }
.tooltip .tt-meta { color: var(--text-muted); margin-top: 3px; font-size: 11px; }
.tooltip .tt-key {
  display: inline-block; width: 12px; height: 2px; border-radius: 1px;
  vertical-align: middle; margin-right: 5px;
}

/* ---------- table view (the relief channel for sub-3:1 fills) ---------- */

.table-toggle {
  background: none; border: none; font: inherit; font-size: 12px;
  color: var(--text-secondary); cursor: pointer; padding: 4px 8px;
  border-radius: 4px; text-decoration: underline; text-underline-offset: 2px;
}
.table-toggle:hover { background: var(--ghost); color: var(--text-primary); }

table.data {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px;
}
table.data th, table.data td {
  text-align: right; padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
table.data th:first-child, table.data td:first-child {
  text-align: left; font-variant-numeric: normal;
}
table.data th {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom-color: var(--axis);
}
table.data tbody tr:hover { background: var(--ghost); }
table.data .swatch {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 7px; vertical-align: baseline;
}

.table-wrap { overflow-x: auto; }

/* ---------- states ---------- */

.chart-host { position: relative; }
/* Refetch keeps the frame: hold the previous render, dimmed. */
.chart-host[data-loading="true"] { opacity: 0.45; transition: opacity 120ms; }

.empty, .error {
  padding: 40px 20px; text-align: center; color: var(--text-muted);
  font-size: 13px;
}
.error { color: var(--delta-bad); }

.note {
  font-size: 12px; color: var(--text-muted);
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--grid);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* treemap cells get their own gap via SVG geometry, not CSS */
svg { display: block; }
svg text { user-select: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 12px; gap: 2px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 12px 0 8px; }
  .nav-group-label { display: none; }
  .nav-item { width: auto; padding: 6px 12px; border-left: none; border-bottom: 2px solid transparent; }
  .nav-item[aria-current="page"] { border-left-color: transparent; border-bottom-color: #2a78d6; }
  .main { padding: 16px; }
}

/* ---------- AI assistant chat ---------- */
.chat-log {
  min-height: 320px; max-height: 60vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 6px 2px;
}
.chat-welcome { color: var(--text-muted); padding: 40px 20px; text-align: center; }
.chat-row { display: flex; flex-direction: column; }
.chat-user { align-items: flex-end; }
.chat-assistant { align-items: flex-start; }
.chat-bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.55; overflow-wrap: break-word;
}
.chat-user .chat-bubble {
  background: var(--accent, #3987e5); color: #fff;
  border-bottom-right-radius: 4px; white-space: pre-wrap;
}
.chat-assistant .chat-bubble {
  background: var(--ghost); color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul { margin: 4px 0 8px; padding-left: 20px; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble h3, .chat-bubble h4, .chat-bubble h5 { margin: 10px 0 6px; }
.chat-bubble code {
  background: var(--surface-1); padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px;
}
.chat-bubble .table-wrap { margin: 8px 0; }
.chat-tools { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.chat-status { font-size: 12px; color: var(--text-muted); font-style: italic; }
.chat-input-row {
  display: flex; gap: 10px; margin-top: 14px; align-items: flex-end;
}
.chat-input-row textarea {
  flex: 1; resize: vertical; min-height: 44px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font: inherit; font-size: 13.5px;
}
.chat-input-row textarea:focus { outline: 2px solid var(--accent, #3987e5); }
.chat-send {
  background: var(--accent, #3987e5); color: #fff; border: 0;
  border-radius: var(--radius); padding: 11px 22px; font: inherit;
  font-size: 13.5px; cursor: pointer;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }
#agent-banner {
  background: color-mix(in srgb, var(--accent, #3987e5) 8%, var(--surface-1));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: 13px;
  color: var(--text-secondary);
}
#agent-banner code {
  background: var(--surface-1); padding: 1px 5px; border-radius: 4px;
}

/* ---------- AI assistant floating widget ---------- */
#agent-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 70;
  width: 54px; height: 54px; border-radius: 50%; border: 0;
  background: var(--accent, #3987e5); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22), 0 2px 5px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease;
}
#agent-fab:hover { transform: scale(1.07); }
#agent-fab[aria-expanded="true"] { transform: scale(0.94); }
#agent-panel {
  position: fixed; right: 26px; bottom: 92px; z-index: 70;
  width: min(460px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 130px));
  display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 16px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24), 0 3px 9px rgba(0, 0, 0, 0.12);
}
#agent-panel[hidden] { display: none; }
.agent-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px; gap: 8px;
}
.agent-panel-head h2 { margin: 0; font-size: 15px; }
.agent-panel-head .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.agent-panel-actions { display: flex; gap: 6px; flex-shrink: 0; }
#agent-panel .chat-log { flex: 1; min-height: 0; max-height: none; }
#agent-panel .note { margin: 8px 0 0; font-size: 10.5px; }

/* ---------- BoL bar lists & origin stacks ---------- */
.barlist-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.barlist-label {
  flex: 0 0 190px; font-size: 12.5px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.barlist-track { flex: 1; height: 14px; background: var(--ghost); border-radius: 4px; }
.barlist-track i {
  display: block; height: 100%; border-radius: 4px;
  background: var(--accent, #3987e5); min-width: 2px;
}
.barlist-value {
  flex: 0 0 70px; text-align: right; font-size: 12px;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.stack-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.stack-label { flex: 0 0 44px; font-size: 12.5px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; }
.stack-track { flex: 1; height: 22px; display: flex; border-radius: 5px;
  overflow: hidden; background: var(--ghost); }
.stack-track i { display: block; height: 100%; margin-right: 1px; }
.card-grid-3 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.stack-label-wide { flex: 0 0 185px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--text-primary); }


/* The brand block doubles as the way back to the Vestigia portal: the parent
   name sits above the section name, so a reader deep in the platform can see
   what this is part of. */
.brand { display: block; text-decoration: none; color: inherit; }
.brand .parent {
  display: block;
  font-family: Georgia, "Songti SC", serif;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.brand:hover .parent { color: var(--text-primary); }


/* A data caveat, not a decoration: this marks totals that are understated
   because the year is missing months. It has to read as a caution at a glance
   without turning the whole subtitle into an alarm. */
.sub.warn { color: #b45309; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .sub.warn { color: #fbbf24; }
}
:root[data-theme="dark"] .sub.warn { color: #fbbf24; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.theme-toggle {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 14px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--text-muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* ------------------------------------------------- assistant drawer -------
   Replaces the corner bubble. A grounded answer is often a wide table plus
   several paragraphs; 460x640 floating above a button could not hold one
   without scrolling in small steps.

   The trigger sits top-left with the page title — where a reader looks to
   begin something — and the panel is a full-height drawer on the right.
*/

#agent-fab {
  position: static;
  width: auto; height: 34px;
  padding: 0 14px 0 11px;
  border-radius: 9px;
  gap: 7px;
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 600;
  box-shadow: none;
  transform: none;
}
#agent-fab::after {
  content: attr(data-label);
  white-space: nowrap;
}
#agent-fab svg { width: 17px; height: 17px; }
#agent-fab:hover { transform: none; filter: brightness(1.06); }
#agent-fab[aria-expanded="true"] { transform: none; }

/* The drawer. Fixed to the viewport edge so it is full height regardless of
   how far the page has scrolled. */
#agent-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  left: auto;
  z-index: 70;
  width: clamp(480px, 34vw, 620px);
  height: 100vh;
  max-height: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .10);
  padding: 18px 20px 16px;
}

/* Give the drawer its room instead of covering the charts, so an answer can
   be read against the figure that prompted it. */
@media (min-width: 1100px) {
  body.agent-open .app { padding-right: clamp(480px, 34vw, 620px); }
  .app { transition: padding-right .2s ease; }
}

#agent-panel .chat-log {
  flex: 1;
  min-height: 0;
  max-height: none;
  /* Wider than the bubble allowed, so a table of a dozen rows fits without
     wrapping every cell. */
  font-size: 13.5px;
}
#agent-panel .chat-log table { width: 100%; font-size: 12px; }
#agent-panel #agent-input { min-height: 54px; }

.agent-panel-head { margin-bottom: 12px; }

@media (max-width: 1099px) {
  /* Not enough width for both; the drawer overlays and the page stays put. */
  #agent-panel { width: min(520px, 100vw); }
}


/* The header carries the assistant trigger opposite its title: a page-level
   action, not a banner above the page. Inserted as the first child it pushed
   the h1 down, which read as a bar rather than a control. */
.page-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 4px 16px;
}
/* The slot is the header's first child in source order but belongs top-right,
   so it is placed explicitly rather than reordered with flex `order`, which
   would leave the reading order wrong for a screen reader. */
#agent-slot { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
.page-head h1 { grid-column: 1; grid-row: 1; }
.page-head p { grid-column: 1; grid-row: 2; }


/* The trigger is a bolt and nothing else. A bubble with the words "AI 问答"
   described a chat assistant; this queries the platform's own data, and the
   tooltip says so for anyone who needs it spelled out. */
#agent-fab {
  width: 34px;
  padding: 0;
  gap: 0;
  justify-content: center;
}
#agent-fab::after { content: none; }
#agent-fab svg { width: 17px; height: 17px; }


/* ---- chat history ---------------------------------------------------- */
/* Occupies the same box as the chat log, so opening the list swaps the view
 * instead of floating over a half-visible conversation. */
.chat-history { flex: 1 1 auto; overflow-y: auto; padding: 6px 0; }
.chat-history-empty {
  padding: 24px 16px; color: var(--text-muted);
  font-size: 13px; text-align: center; line-height: 1.6;
}
.chat-session {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  padding: 10px 14px; border: 0; border-bottom: 1px solid var(--grid);
  background: transparent; text-align: left; cursor: pointer;
  font: inherit; color: var(--text-primary);
}
.chat-session:hover { background: var(--surface-raised); }
.chat-session[aria-current="true"] {
  box-shadow: inset 3px 0 0 var(--rail-accent, #f5b800);
}
.chat-session-title {
  flex: 1 1 auto; font-size: 13px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-session-meta {
  flex: 0 0 auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap;
}
.chat-session-del {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 5px;
  border-radius: 3px;
}
.chat-session-del:hover { color: #d03b3b; background: var(--grid); }
.chat-history-foot {
  padding: 10px 14px; font-size: 11.5px; color: var(--text-muted);
}

/* ---- data-source attribution (shared design with the trade platform) --- */
.src-foot {
  margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--grid);
  font-size: 11px; line-height: 1.5; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline;
}
.src-foot .src-label { font-weight: 700; letter-spacing: .02em; }
.src-foot a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px dotted var(--text-muted); }
.src-foot a:hover { color: var(--text-primary); }
.src-foot .src-lic { padding: 0 5px; border-radius: 3px; background: var(--grid); }
.src-foot .src-all { margin-left: auto; font: inherit; font-size: 11px; background: none; border: 0; color: var(--text-secondary); cursor: pointer; text-decoration: underline dotted; }
.src-foot .src-all:hover { color: var(--text-primary); }
#sources-panel {
  position: fixed; top: 0; right: 0; width: min(560px, 100vw); height: 100vh; overflow: auto; z-index: 60;
  background: var(--surface-raised); border-left: 1px solid var(--grid); box-shadow: -8px 0 24px rgba(0,0,0,.18);
  padding: 16px 20px 32px; font-size: 13px; line-height: 1.55; color: var(--text-primary);
}
.src-panel-head { display: flex; justify-content: space-between; align-items: center; }
.src-panel-head h2 { margin: 0; font-size: 17px; }
.src-panel-intro { color: var(--text-secondary); }
#sources-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 6px; }
.src-rec { padding: 10px 0; border-top: 1px solid var(--grid); }
.src-rec h4 { margin: 0 0 6px; font-size: 14px; }
.src-rec h4 a { color: var(--text-primary); text-decoration: none; }
.src-rec dl { display: grid; grid-template-columns: 7em 1fr; gap: 3px 10px; margin: 0; }
.src-rec dt { color: var(--text-muted); }
.src-rec dd { margin: 0; }
.src-panel-foot { color: var(--text-muted); font-size: 11px; margin-top: 16px; }
