/* ParlAIment design tokens
   ────────────────────────────
   Civic, parliamentary palette. Warm paper + deep ink + a single
   oxblood accent reserved for source-passage highlights. No verdict
   colors — the LLM never expresses an opinion.
*/

:root {
  /* Surfaces */
  --paper:        oklch(0.985 0.005 85);   /* page bg */
  --paper-2:      oklch(0.965 0.006 82);   /* card / inset bg */
  --paper-3:      oklch(0.945 0.008 80);   /* deeper inset, code */
  --rule:         oklch(0.88 0.010 82);    /* hairline dividers */
  --rule-2:       oklch(0.80 0.012 82);    /* slightly heavier rule */

  /* Ink */
  --ink:          oklch(0.20 0.020 260);   /* primary text */
  --ink-2:        oklch(0.42 0.018 260);   /* secondary text */
  --ink-3:        oklch(0.58 0.014 260);   /* tertiary, meta */
  --ink-4:        oklch(0.72 0.010 260);   /* hint / placeholder */

  /* Accent — oxblood, used ONLY to mark highlighted spans in excerpts
     and as the active state of the citation chip. */
  --ox:           oklch(0.42 0.130 25);
  --ox-soft:      oklch(0.92 0.060 30);    /* highlight wash */
  --ox-soft-2:    oklch(0.86 0.080 28);    /* heavier highlight */

  /* Civic blue — sparingly, for links and active nav */
  --navy:         oklch(0.34 0.090 255);
  --navy-soft:    oklch(0.93 0.025 255);

  /* Origin colors (chip backgrounds in source table — muted) */
  --o-press:      oklch(0.93 0.018 60);
  --o-press-fg:   oklch(0.36 0.060 60);
  --o-regional:   oklch(0.93 0.022 145);
  --o-regional-fg:oklch(0.34 0.060 145);
  --o-national:   oklch(0.93 0.024 255);
  --o-national-fg:oklch(0.34 0.060 255);
  --o-eu:         oklch(0.93 0.030 285);
  --o-eu-fg:      oklch(0.34 0.080 285);

  /* Type */
  --f-serif:      "Spectral", "Source Serif 4", Georgia, serif;
  --f-sans:       "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --f-mono:       "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  /* Radii */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-4: 18px;

  /* Density (override via tweak) */
  --pad-y: 14px;
  --pad-x: 16px;
  --gap:   12px;
}

/* Dark mode (toggled by class on root for tweak) */
.pm-dark {
  --paper:        oklch(0.16 0.012 260);
  --paper-2:      oklch(0.20 0.013 260);
  --paper-3:      oklch(0.24 0.014 260);
  --rule:         oklch(0.30 0.015 260);
  --rule-2:       oklch(0.36 0.018 260);

  --ink:          oklch(0.96 0.008 85);
  --ink-2:        oklch(0.80 0.008 85);
  --ink-3:        oklch(0.65 0.010 85);
  --ink-4:        oklch(0.50 0.010 85);

  --ox:           oklch(0.74 0.130 28);
  --ox-soft:      oklch(0.30 0.080 28);
  --ox-soft-2:    oklch(0.36 0.110 28);

  --navy:         oklch(0.72 0.110 255);
  --navy-soft:    oklch(0.26 0.040 255);

  --o-press:      oklch(0.28 0.030 60);
  --o-press-fg:   oklch(0.82 0.050 60);
  --o-regional:   oklch(0.28 0.034 145);
  --o-regional-fg:oklch(0.80 0.050 145);
  --o-national:   oklch(0.28 0.034 255);
  --o-national-fg:oklch(0.80 0.050 255);
  --o-eu:         oklch(0.28 0.040 285);
  --o-eu-fg:      oklch(0.82 0.060 285);
}

.pm-compact { --pad-y: 10px; --pad-x: 12px; --gap: 8px; }
.pm-comfy   { --pad-y: 18px; --pad-x: 20px; --gap: 16px; }

/* ─── Reusable primitives ─────────────────────────────────────── */

.pm {
  font-family: var(--f-sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
.pm * { box-sizing: border-box; }

.pm-serif { font-family: var(--f-serif); font-feature-settings: "onum"; }
.pm-mono  { font-family: var(--f-mono); }

.pm-meta {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.pm-rule { height: 1px; background: var(--rule); width: 100%; }
.pm-rule-v { width: 1px; background: var(--rule); align-self: stretch; }

/* highlight wash inside excerpts */
.pm-hl {
  background: var(--ox-soft);
  box-shadow: 0 0 0 2px var(--ox-soft);
  border-radius: 2px;
  color: inherit;
  padding: 0 1px;
}
.pm-hl-strong {
  background: var(--ox-soft-2);
  box-shadow: 0 0 0 2px var(--ox-soft-2);
  border-radius: 2px;
}

/* numbered citation superscript chip */
.pm-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  margin: 0 2px;
  border-radius: 8px;
  background: var(--ox);
  color: oklch(0.98 0.01 85);
  font-family: var(--f-mono);
  font-size: 10px; font-weight: 500;
  line-height: 1;
  vertical-align: 1px;
  cursor: pointer;
  user-select: none;
}
.pm-cite:hover { filter: brightness(1.08); }

/* origin pill */
.pm-origin {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 7px;
  border-radius: 3px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pm-origin.press     { background: var(--o-press);     color: var(--o-press-fg); }
.pm-origin.regional  { background: var(--o-regional);  color: var(--o-regional-fg); }
.pm-origin.national  { background: var(--o-national);  color: var(--o-national-fg); }
.pm-origin.eu        { background: var(--o-eu);        color: var(--o-eu-fg); }

/* link */
.pm-link {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--navy) 30%, transparent);
}
.pm-link:hover { border-bottom-color: var(--navy); }

/* surface cards */
.pm-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
}

/* Wordmark — small caps serif, parliamentary feel */
.pm-mark {
  font-family: var(--f-serif);
  font-weight: 500;
  letter-spacing: 0.01em;
  font-variant: small-caps;
}
.pm-mark .ai {
  color: var(--ox);
  font-style: italic;
  font-variant: normal;
  font-weight: 600;
}

/* divider with text in middle */
.pm-divider-label {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-3);
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pm-divider-label::before,
.pm-divider-label::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}

/* sources table */
.pm-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.pm-tbl th {
  text-align: left;
  font-family: var(--f-mono);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: bottom;
}
.pm-tbl td {
  padding: 9px 8px 9px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  font-family: var(--f-sans);
  color: var(--ink);
}
.pm-tbl tr:last-child td { border-bottom: 0; }
.pm-tbl td .src-title { color: var(--ink); font-weight: 500; }
.pm-tbl td .src-sub { color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.pm-tbl .rank {
  font-family: var(--f-mono); color: var(--ink-3); font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* tiny icon-button (for chat header) */
.pm-iconbtn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-2);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.pm-iconbtn:hover { background: var(--paper-2); border-color: var(--rule); }

/* primary button */
.pm-btn {
  height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px;
  border-radius: var(--r-2);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-sans);
  font-weight: 500;
  font-size: 13.5px;
  border: 0;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.pm-btn.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--rule-2);
}
.pm-btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-1); }

/* input */
.pm-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 14px;
  outline: none;
}
.pm-input:focus { border-color: var(--ink-3); }

/* ── Mobile chat scrolling area (for IOSDevice viewport) ── */
.pm-screen {
  display: flex; flex-direction: column;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.5;
}
.pm-screen-pad { padding: 0 16px; }

/* status bar spacer (mobile) — accounts for the iOS status bar inside frame */
.pm-statusbar-spacer { height: 54px; flex-shrink: 0; }

/* fake bottom safe area */
.pm-home-spacer { height: 24px; flex-shrink: 0; }

/* generic scroll container that hides scrollbars */
.pm-scroll { overflow-y: auto; }
.pm-scroll::-webkit-scrollbar { width: 0; height: 0; }
.pm-scroll { scrollbar-width: none; }

/* selection */
.pm ::selection { background: var(--ox-soft-2); color: var(--ink); }
