/* =============================================================
   Parliament Workbench: "Record, not catalogue" visual layer.
   Loaded after styles.css. Retunes the shared tokens (so legacy
   pages pick up the new palette) and adds the redesign's
   components. Reference: parliament-redesign.md, section 6.
   ============================================================= */

:root {
    --surface-page: #fbfaf7;
    --surface-card: #ffffff;
    --surface-muted: #f3f1ec;
    --surface-soft: #f8f6f1;

    --ink-1: #14171f;
    --ink-2: #4a5160;
    --ink-3: #6b7280;

    --border-1: #e5e2da;
    --border-2: #cfcbc0;
    --border-strong: #8a8578;

    --accent: #3b2a6b;
    --accent-strong: #2a1d50;
    --accent-soft: #e7e1f5;
    --accent-tint: #f5f2fb;

    --data-yes: #1a7f5a;
    --data-no: #c2410c;
    --data-abstain: #b7950b;
    --data-not-voted: #b4b9c2;

    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --shadow-focus: 0 0 0 3px rgba(59, 42, 107, 0.22);

    --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

    --party-snp: #f5d000;
    --party-lab: #d4213d;
    --party-con: #1f6fd0;
    --party-grn: #2e9e4f;
    --party-ld: #f39a1d;
    --party-ref: #12b6cf;
    --party-alba: #005eb8;
    --party-ssp: #e4003b;
    --party-ind: #7a8088;

    --page-max: 1200px;

    --bs-body-bg: var(--surface-page);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 59, 42, 107;
    --bs-link-hover-color: var(--accent-strong);
    --bs-link-hover-color-rgb: 42, 29, 80;
    --bs-success: var(--accent);
    --bs-success-rgb: 59, 42, 107;
    --bs-primary: var(--accent);
    --bs-primary-rgb: 59, 42, 107;
}

.party-snp { --party: var(--party-snp); }
.party-lab { --party: var(--party-lab); }
.party-con { --party: var(--party-con); }
.party-grn { --party: var(--party-grn); }
.party-ld { --party: var(--party-ld); }
.party-ref { --party: var(--party-ref); }
.party-alba { --party: var(--party-alba); }
.party-ssp { --party: var(--party-ssp); }
.party-ind { --party: var(--party-ind); }

body.pw {
    background: var(--surface-page);
    color: var(--ink-1);
    font-family: var(--font-sans);
    font-feature-settings: "cv11", "ss01";
}

body.pw a { text-underline-offset: 2px; }
body.pw .btn-success,
body.pw .btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-strong);
    --bs-btn-hover-border-color: var(--accent-strong);
    --bs-btn-active-bg: var(--accent-strong);
}
body.pw .text-success { color: var(--accent) !important; }
.tnum, .num { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--border-1);
    backdrop-filter: saturate(1.2) blur(6px);
}
.topbar-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--ink-1);
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover { color: var(--accent); }
.brand-mark {
    width: 4px;
    height: 22px;
    border-radius: 2px;
    background: var(--accent);
}
.primary-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}
.primary-link {
    display: inline-block;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    color: var(--ink-2);
    font-weight: 500;
    font-size: 0.9375rem;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
}
.primary-link::-webkit-details-marker { display: none; }
.primary-link:hover { color: var(--ink-1); background: var(--surface-muted); }
.primary-link.is-active {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
    border-radius: 0;
}
.more-menu { position: relative; }
.more-menu > summary::after { content: " \25BE"; font-size: 0.75em; }
.more-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: -120px;
    width: min(760px, 92vw);
    background: var(--surface-card);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 32px rgba(20, 23, 31, 0.12);
    padding: 18px 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.more-group { display: flex; flex-direction: column; gap: 2px; }
.more-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    margin-bottom: 4px;
}
.more-group a {
    color: var(--ink-1);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 3px 0;
}
.more-group a:hover { color: var(--accent); text-decoration: underline; }
.topbar-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    position: relative;
    flex: 0 1 340px;
}
.topbar-search input {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-md);
    padding: 0 36px 0 12px;
    background: var(--surface-page);
    font-size: 0.9rem;
    color: var(--ink-1);
}
.topbar-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); background: #fff; }
.topbar-search button {
    position: absolute;
    right: 4px;
    border: 0;
    background: transparent;
    color: var(--ink-2);
    width: 30px;
    height: 30px;
}

/* ---------- Context bar ---------- */
.context-bar { border-bottom: 1px solid var(--border-1); background: var(--surface-page); }
.context-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
}
.crumbs { color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink-1); }
.freshness {
    color: var(--ink-2);
    background: var(--surface-muted);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    white-space: nowrap;
}

/* ---------- Page ---------- */
main.page {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 28px 16px 64px;
}
.page-narrow { max-width: 720px; }
.legacy-main { max-width: 1400px; margin: 0 auto; }
.legacy-header { margin: 4px 0 20px; }
.page-title,
.entity-title {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 2.25rem;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--ink-1);
    margin: 0 0 6px;
}
.page-lede, .lede {
    color: var(--ink-2);
    font-size: 1.0625rem;
    max-width: 72ch;
    margin: 0;
}
body.pw .eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

/* ---------- Entity header ---------- */
.entity-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding-bottom: 20px;
    margin-bottom: 8px;
}
.entity-header .avatar { flex: 0 0 auto; }
.entity-head-body { min-width: 0; flex: 1; }
.entity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    color: var(--ink-2);
    font-size: 0.9375rem;
    margin-top: 4px;
}
.entity-meta > * { white-space: nowrap; }
.entity-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-1);
    margin: 8px 0 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: 10px 14px;
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--ink-1); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .tab-count { color: var(--ink-3); font-weight: 400; margin-left: 4px; font-size: 0.875em; }

/* ---------- Sections ---------- */
.section { padding: 24px 0; border-top: 1px solid var(--border-1); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-h {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.375rem;
    margin: 0 0 12px;
    color: var(--ink-1);
}
.section-h small, .section-sub { font-family: var(--font-sans); font-size: 0.875rem; font-weight: 400; color: var(--ink-3); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-head .section-h { margin: 0; }
.see-all { font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.see-all:hover { text-decoration: underline; }
.muted { color: var(--ink-3); }
.note { color: var(--ink-2); font-size: 0.875rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 40px; }
.grid-2 > .section, .grid-main > .section { border-top: 1px solid var(--border-1); }

/* ---------- Facts ---------- */
.facts { display: flex; flex-wrap: wrap; gap: 16px 32px; margin: 4px 0 8px; }
.fact { min-width: 120px; }
.fact-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 600; }
.fact-value { font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.fact-meta { font-size: 0.8125rem; color: var(--ink-2); }
.deflist { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 0.9375rem; }
.deflist dt { color: var(--ink-3); font-weight: 500; }
.deflist dd { margin: 0; }

/* ---------- Meters ---------- */
.meter { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; margin-bottom: 12px; }
.meter-label { font-size: 0.875rem; color: var(--ink-2); }
.meter-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-track { grid-column: 1 / -1; position: relative; height: 6px; background: var(--surface-muted); border-radius: 3px; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.meter-tick { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink-1); }
.meter-note { grid-column: 1 / -1; font-size: 0.75rem; color: var(--ink-3); }

/* ---------- Filters ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 12px;
}
.filters .form-control, .filters .form-select { width: auto; min-width: 140px; height: 38px; font-size: 0.9rem; border-color: var(--border-2); }
.filters .filter-q { flex: 1 1 260px; }
.filters .btn { height: 38px; }
.filter-more > summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; font-weight: 500; list-style: none; padding: 8px 4px; }
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-more[open] { flex-basis: 100%; }
.filter-more .filters { margin-top: 6px; }
.applied-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; font-size: 0.8125rem; }
.applied-label { color: var(--ink-3); }
.applied-chip {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-tint);
    border: 1px solid var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}
.applied-chip:hover { background: var(--accent-soft); }
.view-switch { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-md); overflow: hidden; }
.view-switch a { padding: 6px 12px; font-size: 0.875rem; color: var(--ink-2); text-decoration: none; border-left: 1px solid var(--border-2); }
.view-switch a:first-child { border-left: 0; }
.view-switch a.is-active { background: var(--accent); color: #fff; }

/* ---------- Lists ---------- */
.list-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-1);
    font-size: 0.875rem;
    color: var(--ink-2);
}
.list-count strong { color: var(--ink-1); }
.sort-links { display: flex; gap: 10px; align-items: center; }
.sort-links a { color: var(--ink-2); text-decoration: none; }
.sort-links a.is-active { color: var(--accent); font-weight: 600; }
.record-list { list-style: none; margin: 0; padding: 0; }
.record {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr) auto;
    gap: 4px 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-1);
    align-items: baseline;
}
.record-ref { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink-2); white-space: nowrap; }
.record-ref a { color: inherit; text-decoration: none; }
.record-main { min-width: 0; }
.record-title { font-weight: 600; color: var(--ink-1); text-decoration: none; display: inline; }
a.record-title:hover { color: var(--accent); text-decoration: underline; }
.record-meta { font-size: 0.8125rem; color: var(--ink-2); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.record-side { text-align: right; font-size: 0.8125rem; color: var(--ink-2); white-space: nowrap; }
.record-snippet { font-size: 0.875rem; color: var(--ink-2); margin: 4px 0 0; }
.list-foot { display: flex; justify-content: center; padding: 20px 0 0; }
.empty { padding: 24px 0; color: var(--ink-2); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 600; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border-2); }
.data-table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border-1); vertical-align: top; }
.data-table .num { text-align: right; }
.data-table tr:hover td { background: var(--surface-soft); }

/* ---------- Pager ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 0.875rem; }
.pager-link {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
    color: var(--ink-1);
    text-decoration: none;
    background: var(--surface-card);
}
a.pager-link:hover { border-color: var(--accent); color: var(--accent); }
.pager-link.is-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager-link.is-disabled { color: var(--ink-3); background: transparent; }
.pager-gap { color: var(--ink-3); padding: 0 4px; }

/* ---------- Chips and marks ---------- */
body.pw .chip { border-radius: var(--radius-sm); }
.chip-ref { font-family: var(--font-mono); font-size: 0.75rem; }
.party-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    vertical-align: 1px;
}
.party-chip::before {
    content: "";
    width: 4px;
    height: 12px;
    border-radius: 1px;
    background: var(--party, var(--party-ind));
}
.party-chip-link { text-decoration: none; }
.party-rule { border-left: 4px solid var(--party, var(--party-ind)); padding-left: 10px; }
.msp-link { color: var(--ink-1); font-weight: 500; text-decoration: none; }
.msp-link:hover { color: var(--accent); text-decoration: underline; }
.vote-mark { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.vote-yes { color: var(--data-yes); }
.vote-no { color: var(--data-no); }
.vote-abstain { color: var(--data-abstain); }
.vote-absent { color: var(--ink-3); font-weight: 500; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 6px; vertical-align: 1px; }
.status-dot.is-live { background: var(--data-yes); }

/* ---------- Result bar ---------- */
.result-bar {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 260px;
    background: var(--surface-muted);
    border-radius: 2px;
    overflow: hidden;
    vertical-align: middle;
}
.result-bar-sm { height: 8px; }
.result-bar-lg { height: 22px; max-width: none; border-radius: 3px; }
.rb-for { background: var(--data-yes); }
.rb-against { background: var(--data-no); }
.rb-abstain { background: repeating-linear-gradient(45deg, var(--data-abstain), var(--data-abstain) 3px, #e7d389 3px, #e7d389 6px); }
.rb-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ink-1); opacity: 0.55; }
.tally { font-variant-numeric: tabular-nums; font-size: 0.8125rem; color: var(--ink-2); white-space: nowrap; }
.tally strong { color: var(--ink-1); }

/* ---------- Avatar ---------- */
.avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-muted);
    color: var(--ink-1);
    font-weight: 600;
    overflow: hidden;
    box-shadow: inset 0 0 0 3px var(--party, var(--party-ind));
    flex: 0 0 auto;
}
.avatar::before { content: attr(data-initials); }
.avatar img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; border-radius: 50%; background: var(--surface-muted); }
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; box-shadow: inset 0 0 0 2px var(--party, var(--party-ind)); }
.avatar-sm img { inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); }
.avatar-md { width: 56px; height: 56px; font-size: 1.05rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.75rem; }

/* ---------- Cards (only for objects) ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.obj-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: var(--surface-card);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--ink-1);
}
a.obj-card:hover { border-color: var(--accent); }
.obj-card-body { min-width: 0; }
.obj-card-title { font-weight: 600; line-height: 1.25; }
.obj-card-meta { font-size: 0.8125rem; color: var(--ink-2); }

/* ---------- Journey (bill stages) ---------- */
.journey { display: flex; align-items: flex-start; margin: 16px 0 8px; overflow-x: auto; }
.journey-step { flex: 1 1 0; min-width: 96px; position: relative; padding-top: 18px; font-size: 0.8125rem; }
.journey-step::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-2);
}
.journey-step.is-done::before { background: var(--accent); }
.journey-step::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--border-2);
}
.journey-step.is-done::after { background: var(--accent); border-color: var(--accent); }
.journey-step:last-child::before { right: auto; width: 13px; }
.journey-label { font-weight: 600; color: var(--ink-1); }
.journey-date { color: var(--ink-2); }
.journey-gap { color: var(--ink-3); font-size: 0.75rem; }

/* ---------- Home ---------- */
.home-hero { padding: 24px 0 28px; }
.home-hero .entity-title { font-size: 2.5rem; max-width: 22ch; }
.search-hero { display: flex; gap: 8px; max-width: 680px; margin: 16px 0 10px; }
.search-hero input { height: 52px; font-size: 1.0625rem; border: 1px solid var(--border-2); }
.search-hero input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.search-hero .btn { height: 52px; padding: 0 22px; }
.quick-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.9rem; color: var(--ink-3); }
.quick-links a { text-decoration: none; font-weight: 500; }
.quick-links a:hover { text-decoration: underline; }

/* ---------- Text ---------- */
.prose { font-size: 1rem; line-height: 1.6; max-width: 72ch; }
.prose-sm { font-size: 0.9375rem; line-height: 1.55; max-width: 72ch; color: var(--ink-1); }
blockquote.motion-text {
    border-left: 3px solid var(--accent-soft);
    padding: 4px 0 4px 16px;
    margin: 12px 0;
    color: var(--ink-1);
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.55;
}

/* ---------- Footer and tab bar ---------- */
.site-footer {
    border-top: 1px solid var(--border-1);
    background: var(--surface-card);
    margin-top: 40px;
}
.footer-inner { max-width: var(--page-max); margin: 0 auto; padding: 28px 16px 32px; }
.footer-groups { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }
.footer-note { margin: 24px 0 0; font-size: 0.8125rem; color: var(--ink-3); max-width: 90ch; }
.tabbar { display: none; }

/* ---------- Legacy tidy-ups inside the new frame ---------- */
body.pw-legacy .card { border-color: var(--border-1); border-radius: var(--radius-lg); box-shadow: none; }
body.pw-legacy .navbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .primary-nav .primary-link { padding: 6px 8px; }
    .more-panel { left: auto; right: -80px; grid-template-columns: repeat(2, 1fr); }
    .grid-main, .grid-2 { grid-template-columns: 1fr; }
    .footer-groups { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .topbar-inner { height: 52px; gap: 10px; }
    .primary-nav { display: none; }
    .brand { font-size: 1rem; }
    .topbar-search { flex: 1 1 auto; }
    main.page { padding: 18px 16px 88px; }
    .legacy-main { padding-bottom: 88px !important; }
    .page-title, .entity-title { font-size: 1.75rem; }
    .home-hero .entity-title { font-size: 1.875rem; }
    .entity-header { gap: 14px; }
    .entity-header .avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
    .entity-actions { margin-left: 0; width: 100%; }
    .record { grid-template-columns: 1fr; gap: 2px; padding: 12px 0; }
    .record-side { text-align: left; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; }
    .filters .filter-q, .filters .btn, .filters .filter-wide { grid-column: 1 / -1; }
    .filters .form-control, .filters .form-select { width: 100%; min-width: 0; }
    .footer-groups { grid-template-columns: 1fr 1fr; }
    .tabbar {
        display: flex;
        position: fixed;
        z-index: 1030;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid var(--border-1);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    }
    .tabbar a {
        flex: 1;
        text-align: center;
        padding: 10px 2px;
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--ink-2);
        text-decoration: none;
    }
    .result-bar { max-width: none; }
    .deflist { grid-template-columns: 1fr; gap: 0; }
    .deflist dd { margin-bottom: 8px; }
}

/* ---------- Progress dots (bill rows) ---------- */
.progress-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.progress-dots .pd { width: 14px; height: 6px; border-radius: 3px; background: var(--border-1); }
.progress-dots .pd.is-done { background: var(--accent); }
.progress-dots .pd.is-stopped { background: var(--data-no); }
body.pw .chip-accent { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-soft); }

@media (max-width: 480px) {
    .brand-tail { display: none; }
    .topbar-search input { padding-right: 32px; }
}
@media (max-width: 700px) {
    .freshness { white-space: normal; border-radius: var(--radius-md); }
}

/* ===== msp.css ===== */
/* MSP directory (/msps) and profile (/msp/{id}). Builds on record.css. */

/* ---------- Directory ---------- */
.msp-grid { list-style: none; margin: 16px 0 0; padding: 0; }
.msp-card { align-items: flex-start; }
.msp-card > a { flex: 0 0 auto; text-decoration: none; }
.msp-card-name { display: block; color: var(--ink-1); text-decoration: none; margin-bottom: 2px; }
.msp-card-name:hover { color: var(--accent); text-decoration: underline; }
.msp-card .obj-card-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.msp-card .obj-card-meta a { color: var(--ink-2); }
.msp-card-role { color: var(--ink-1); }

/* ---------- Profile header ---------- */
.msp-header .entity-meta .msp-seat { white-space: normal; }
.msp-role { margin: 6px 0 0; font-weight: 500; }
.msp-role a { color: var(--ink-1); text-decoration: none; }
.msp-role a:hover { color: var(--accent); text-decoration: underline; }
.msp-previously { margin: 4px 0 0; font-size: 0.875rem; color: var(--ink-2); }

/* ---------- Overview ---------- */
.msp-inline-form { display: inline-flex; gap: 6px; align-items: center; }
.msp-inline-form .form-select { width: auto; border-color: var(--border-2); }
.msp-counts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0; font-size: 0.875rem; }
.msp-counts a { color: var(--ink-2); text-decoration: none; }
.msp-counts a strong { color: var(--ink-1); font-variant-numeric: tabular-nums; }
.msp-counts a:hover { color: var(--accent); }
.msp-phrases { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.msp-phrases li {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    padding: 3px 10px;
    border: 1px solid var(--border-1);
    border-radius: var(--radius-sm);
    background: var(--surface-card);
    font-size: 0.875rem;
}
.msp-phrases a { color: var(--ink-1); text-decoration: none; }
.msp-phrases a:hover { color: var(--accent); text-decoration: underline; }
.msp-phrases .muted { font-size: 0.75rem; }
.msp-speech { padding: 10px 0; border-bottom: 1px solid var(--border-1); }
.msp-speech:first-child { padding-top: 0; }
.msp-speech .record-meta { margin: 0 0 2px; }
.msp-sub { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 12px 0 4px; }
.msp-sub:first-of-type { margin-top: 0; }
.msp-inline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.9375rem; }
.msp-inline-list li { white-space: nowrap; }
.msp-against .record-ref { box-shadow: inset 3px 0 0 var(--data-no); padding-left: 8px; }
.msp-flag { color: var(--data-no); font-weight: 600; }

/* ---------- Tabs and lists ---------- */
.msp-views { display: flex; max-width: 100%; overflow-x: auto; margin: 0 0 12px; scrollbar-width: none; }
.msp-views::-webkit-scrollbar { display: none; }
.msp-views a { white-space: nowrap; }
.msp-views a .tnum { opacity: 0.75; margin-left: 2px; }
.msp-phrase-line { font-size: 0.875rem; margin: 0 0 12px; }
.msp-timeline .record { grid-template-columns: 7.5rem minmax(0, 1fr) auto; padding: 8px 0; }
.msp-timeline .record-main a { color: var(--ink-1); text-decoration: none; }
.msp-timeline .record-main a:hover { color: var(--accent); text-decoration: underline; }
.msp-plain-list { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.msp-plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border-1); }
.msp-plain-list li:last-child { border-bottom: 0; }
.msp-columns { columns: 2 280px; column-gap: 32px; }
.msp-columns li { break-inside: avoid; }
.msp-table-wrap { overflow-x: auto; }
.msp-table-wrap .data-table { min-width: 420px; }

@media (max-width: 700px) {
    .msp-tabs {
        position: sticky;
        top: 52px;
        z-index: 20;
        background: var(--surface-page);
        margin-left: -16px;
        margin-right: -16px;
        padding: 0 16px;
    }
    .msp-header .entity-meta { white-space: normal; }
    .msp-timeline .record { grid-template-columns: 1fr; }
    .msp-against .record-ref { padding-left: 8px; }
    .msp-inline-list li { white-space: normal; }
}

/* ===== org.css ===== */
/* Committees, statutory instruments and cross-party groups (pages/committee*, ssi*, group*). */

.org-remit { margin: 12px 0 0; max-width: 68ch; color: var(--ink-2); }

.org-role-h {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-3);
    margin: 16px 0 8px;
}
.org-role-h:first-child { margin-top: 0; }
.org-role-h .muted { font-weight: 400; }

.org-people {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px 16px;
}
.org-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.org-person .avatar { flex: 0 0 auto; }
.org-person-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.org-person-name { overflow-wrap: anywhere; }
.org-person-meta { font-size: 0.8125rem; color: var(--ink-3); }

.org-balance { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.org-balance > span { white-space: nowrap; }

.org-links { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.org-links li { padding: 4px 0; }
.org-links .muted { font-size: 0.8125rem; white-space: nowrap; }

.org-details > summary { cursor: pointer; list-style: none; }
.org-details > summary::-webkit-details-marker { display: none; }
.org-details > summary .section-h { display: inline; }
.org-details > summary::after { content: " Show"; font-size: 0.875rem; color: var(--accent); font-weight: 500; }
.org-details[open] > summary::after { content: " Hide"; }
.org-details[open] > summary { margin-bottom: 8px; }

/* Rows without a reference column, and narrow lists in a two-column grid. */
.org-earlier .record { grid-template-columns: minmax(0, 1fr) auto; }
.org-compact .record { grid-template-columns: 6.5rem minmax(0, 1fr) auto; }
.org-compact .record-title { font-weight: 500; }

.org-callout {
    border-left: 4px solid var(--border-strong);
    background: var(--surface-muted);
    padding: 10px 14px;
    font-size: 0.9375rem;
    margin: 0 0 16px;
}

.filters .filter-more { flex-basis: 100%; }
.org-date { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--ink-2); }
.filters .filter-wide { max-width: 24rem; }

.org-ssi-title { font-size: 1.75rem; }

@media (max-width: 700px) {
    .org-people { grid-template-columns: 1fr; }
    .org-earlier .record, .org-compact .record { grid-template-columns: 1fr; }
    .filters .filter-more { grid-column: 1 / -1; }
    .filters .filter-wide { max-width: none; }
    .org-date { display: flex; }
    .org-ssi-title { font-size: 1.375rem; }
}

.org-facts dd { overflow-wrap: anywhere; }

/* ===== records.css ===== */
/* Motions, questions and petitions (pages/motion*.php, question*.php, item.php, petition*.php). */

.page-head .view-switch { margin-top: 4px; }
.rec-title { overflow-wrap: anywhere; }
.rec-h1-note { font-family: inherit; font-size: 0.875rem; font-weight: 500; vertical-align: middle; }
.rec-h3 { font-size: 0.875rem; font-weight: 600; margin: 14px 0 6px; display: flex; align-items: center; gap: 6px; }
.rec-inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--ink-2); }
.rec-inline-label .form-control { width: auto; }

.rec-notice {
    border: 1px solid var(--border-2);
    border-left: 3px solid var(--accent);
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin: 0 0 12px;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.rec-notice-unlisted { display: block; border-left-color: var(--ink-3); max-width: 72ch; margin: 16px 0; }

/* Hatched neutral chip for petitions Parliament no longer lists. */
body.pw .rec-chip-unlisted {
    background: repeating-linear-gradient(135deg, var(--surface-muted), var(--surface-muted) 4px, var(--surface-card) 4px, var(--surface-card) 8px);
    color: var(--ink-2);
    border-color: var(--border-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.6875rem;
}
.rec-terms { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.875rem; }

/* Answer */
.rec-answer-meta { color: var(--ink-2); margin-bottom: 8px; }
.rec-answer { overflow-wrap: anywhere; }
.rec-awaiting { font-size: 1rem; }

/* Supporters: one stacked bar by party, then counts, then names. */
.rec-party-split { display: flex; height: 10px; border-radius: 2px; overflow: hidden; background: var(--surface-muted); max-width: 480px; margin: 4px 0 8px; }
.rec-split-seg { background: var(--party, var(--party-ind)); min-width: 3px; border-right: 1px solid var(--surface-page); }
.rec-split-seg:last-child { border-right: 0; }
.rec-party-counts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.875rem; margin: 0 0 8px; }
.rec-details > summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 0.9rem; padding: 4px 0; }
.rec-name-list { list-style: none; padding: 0; margin: 0 0 4px; columns: 3 14rem; column-gap: 24px; font-size: 0.875rem; }
.rec-name-list li { break-inside: avoid; padding: 2px 0; }

/* Ranked bar list (signatures by country). */
.rec-bars { list-style: none; padding: 0; margin: 0; max-width: 640px; }
.rec-bars li { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 0.875rem; }
.rec-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-bar-track { height: 8px; background: var(--surface-muted); border-radius: 2px; overflow: hidden; }
.rec-bar-fill { display: block; height: 100%; background: var(--accent); }
.rec-bar-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Comment thread. */
.rec-comments { list-style: none; padding: 0; margin: 0; max-width: 72ch; }
.rec-comment { padding: 12px 0; border-bottom: 1px solid var(--border-1); }
.rec-comment-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.875rem; }
.rec-comment-body { font-size: 0.9375rem; line-height: 1.55; margin-top: 4px; overflow-wrap: anywhere; }

.rec-related { list-style: none; padding: 0; margin: 0; font-size: 0.875rem; }
.rec-related li { padding: 6px 0; border-bottom: 1px solid var(--border-1); }
.rec-related .muted { display: block; font-size: 0.8125rem; }

@media (max-width: 767px) {
    .rec-bars li { grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: 8px; }
    .rec-name-list { columns: 2 9rem; }
    .rec-inline-label { width: 100%; }
    .rec-inline-label .form-control { flex: 1; }
}

/* "More filters" spans the row in the mobile two-column filter grid. */
.rec-filters .filter-more { grid-column: 1 / -1; }
.rec-filters .filter-more .filters { flex-wrap: wrap; }

/* ===== votes.css ===== */
/* Votes, vote page, home and Business hub (pages/votes.php, vote.php, home.php, business.php). */

/* ---------- List rows ---------- */
.vt-record .record-side { min-width: 180px; }
.vt-result { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.vt-margin { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.vt-bar { margin: 5px 0 2px; display: flex; justify-content: flex-end; }
.vt-bar .result-bar { width: 180px; }
.vt-rebels { color: var(--data-no); font-weight: 500; }
.vt-compact .record { grid-template-columns: 6rem minmax(0, 1fr) auto; }
.vt-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 0; }
.vt-sub-h { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 18px 0 4px; }

/* ---------- Vote page ---------- */
.vt-outcome { padding: 4px 0 20px; }
.vt-outcome-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 10px; }
.vt-outcome-words { font-family: var(--font-serif); font-size: 1.375rem; font-weight: 600; }
.vt-outcome-nums { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 10px; font-size: 0.9375rem; color: var(--ink-2); }
.vt-num strong { font-size: 1.375rem; color: var(--ink-1); font-variant-numeric: tabular-nums; margin-right: 4px; }
.vt-num-for strong { color: var(--data-yes); }
.vt-num-against strong { color: var(--data-no); }
.vt-text { padding-top: 12px; }
.vt-text blockquote.motion-text { margin-top: 0; }
.vt-more-text > summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 0.9rem; }
.vt-more-text[open] > summary { margin-bottom: 8px; }
.vt-find { margin: 4px 0 20px; padding: 12px; background: var(--accent-tint); border: 1px solid var(--accent-soft); border-radius: var(--radius-md); }
.vt-split th[scope="row"] { font-weight: 500; white-space: nowrap; }
.vt-split-barcol { width: 40%; }
.vt-split-bar { display: flex; height: 12px; width: 100%; background: transparent; border-radius: 2px; overflow: hidden; }
.vt-split-bar > span { display: block; height: 100%; }
.vt-absent { background: var(--data-not-voted); opacity: 0.6; }
.vt-side { border-top: 1px solid var(--border-1); padding: 6px 0; }
.vt-side > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.vt-side > summary::-webkit-details-marker { display: none; }
.vt-side > summary::before { content: "\25B8"; color: var(--ink-3); font-size: 0.8em; transition: transform 0.15s; }
.vt-side[open] > summary::before { transform: rotate(90deg); }
.vt-side-h { font-family: var(--font-serif); font-size: 1.125rem; font-weight: 600; margin: 0; }
.vt-side-yes .vt-side-h { color: var(--data-yes); }
.vt-side-no .vt-side-h { color: var(--data-no); }
.vt-group { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 4px 12px; padding: 6px 0 6px 18px; }
.vt-group-party { font-size: 0.8125rem; white-space: nowrap; }
.vt-names, .vt-rebels-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 0.9rem; }
.vt-rebels-ul { flex-direction: column; }
.vt-aside .vt-group { grid-template-columns: 1fr; padding-left: 0; }
.vt-rebel-list > summary { cursor: pointer; color: var(--ink-2); font-size: 0.875rem; margin-bottom: 4px; }
.vt-context { list-style: none; padding: 0; margin: 0 0 8px; font-size: 0.9375rem; }
.vt-context li { padding: 5px 0; border-bottom: 1px solid var(--border-1); }
.vt-mini { list-style: none; margin: 0; padding: 0; font-size: 0.875rem; }
.vt-mini li { padding: 8px 0; border-bottom: 1px solid var(--border-1); }
.vt-mini .chip-ref { color: var(--ink-3); margin-left: 4px; }
.vt-mini-res { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.vt-mini-res .result-bar { width: 120px; flex: 0 0 120px; }

/* ---------- Home ---------- */
.vt-home { margin-top: 4px; }
.vt-seatbar { position: relative; display: flex; height: 26px; border-radius: 3px; overflow: hidden; background: var(--surface-muted); }
.vt-seat { display: block; height: 100%; background: var(--party, var(--party-ind)); border-right: 1px solid rgba(255, 255, 255, 0.7); }
.vt-seat:last-of-type { border-right: 0; }
.vt-seat:hover { filter: brightness(0.9); }
.vt-seat-majority { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink-1); opacity: 0.6; pointer-events: none; }
.vt-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; padding: 0; font-size: 0.875rem; }
.vt-legend strong { font-variant-numeric: tabular-nums; }
.vt-bill { padding: 10px 0; border-bottom: 1px solid var(--border-1); }
.vt-plain { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.vt-plain li { padding: 4px 0; }
.vt-changes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 32px; font-size: 0.9rem; }
.vt-changes li { padding: 6px 0; border-bottom: 1px solid var(--border-1); }
.vt-change-date { display: block; font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Business programme ---------- */
.vt-days { list-style: none; margin: 0; padding: 0; }
.vt-day { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--border-1); }
.vt-day-date { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vt-dow { color: var(--accent); }
.vt-day-items { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.vt-day-items li { padding: 1px 0; }
.vt-time { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); margin-right: 4px; }

/* ---------- Business hub ---------- */
.vt-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0 40px; }
.vt-hub-card { padding: 24px 0; border-top: 1px solid var(--border-1); }
.vt-hub-card .section-h a { color: inherit; text-decoration: none; }
.vt-hub-card .section-h a:hover { color: var(--accent); text-decoration: underline; }
.vt-hub-list { list-style: none; margin: 0 0 10px; padding: 0; }
.vt-hub-list li { padding: 7px 0; border-bottom: 1px solid var(--border-1); font-size: 0.9rem; }
.vt-hub-title { font-weight: 500; color: var(--ink-1); text-decoration: none; }
a.vt-hub-title:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 700px) {
    .vt-record .record-side { min-width: 0; }
    .vt-result, .vt-bar { justify-content: flex-start; }
    .vt-bar .result-bar { width: 100%; max-width: 280px; }
    .vt-compact .record { grid-template-columns: 1fr; }
    .vt-split-barcol { display: none; }
    .vt-split td, .vt-split th { padding-right: 6px; }
    .vt-group { grid-template-columns: 1fr; padding-left: 4px; }
    .vt-day { grid-template-columns: 1fr; }
    .vt-hub { grid-template-columns: 1fr; }
    .vt-changes { grid-template-columns: 1fr; }
    .vt-find { padding: 10px; }
    .vt-outcome-words { font-size: 1.25rem; }
}
.vt-outcome-carried { color: var(--data-yes); }
.vt-outcome-defeated { color: var(--data-no); }
