:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-soft: #f1f3f4;
  --ink: #202428;
  --muted: #65707a;
  --line: #d8d6ce;
  --strong-line: #b9b6aa;
  --accent: #b35d32;
  --accent-dark: #783b22;
  --shadow: 0 18px 45px rgba(47, 43, 35, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.brand-block {
  min-width: 0;
}

.topbar-side {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 10px;
}

.mode-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.mode-button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 13px;
}

.mode-button.is-active {
  background: #fff4ed;
  color: var(--accent-dark);
}

.mode-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 1.8vw, 2.05rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 8px;
  width: min(600px, 52vw);
}

.metric {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.metric-value {
  display: block;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.1;
}

.metric-label {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 470px);
  gap: 18px;
  padding: 18px;
}

.chamber-panel,
.analysis-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chamber-panel {
  overflow: hidden;
}

.analysis-panel {
  align-self: start;
  max-height: calc(100vh - 148px);
  overflow: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fcfbf8;
}

.search-field {
  flex: 1 1 180px;
  min-width: min(180px, 100%);
}

.theme-field {
  flex: 1 1 220px;
  min-width: min(220px, 100%);
}

.toolbar > .field,
.toolbar > .toggle-field {
  flex: 0 0 auto;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field input,
.field select {
  min-height: 39px;
  width: 100%;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 93, 50, 0.16);
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  color: var(--ink);
  font-weight: 700;
}

.toggle-field input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.segmented {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 39px;
  overflow: hidden;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  background: #fff;
}

.segmented button {
  margin: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.is-active {
  background: var(--accent);
  color: #fff;
}

.seat-scale-note.is-updating .seat-size-key {
  animation: seat-key-pulse 500ms ease;
}

@keyframes seat-key-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.55;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.seat-scale-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0;
  padding: 4px 8px 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.seat-size-key {
  display: inline-flex;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 12px;
}

.seat-size-key-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.topic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.topic-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
}

.topic-legend-item.is-active {
  border-color: var(--accent);
  background: #fff4ed;
}

.topic-legend-item.is-dimmed {
  opacity: 0.4;
}

.topic-chart {
  display: block;
  width: 100%;
  height: 240px;
  margin: 8px 0 16px;
}

.topic-chart-grid {
  stroke: #e7e5df;
  stroke-width: 1;
}

.topic-chart-axis {
  fill: var(--muted);
  font-size: 10px;
}

.topic-chart-line {
  fill: none;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.search-results {
  display: none;
  gap: 6px;
  padding: 10px 14px 0;
  flex-wrap: wrap;
}

.search-results.is-visible {
  display: flex;
}

.result-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.result-button:hover,
.result-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.chamber-wrap {
  position: relative;
  min-height: 610px;
  padding: 6px 12px 16px;
}

#chamberSvg {
  display: block;
  width: 100%;
  min-height: 560px;
}

.grid-arc {
  fill: none;
  stroke: #e7e5df;
  stroke-width: 1.5;
}

.party-arc {
  fill: none;
  stroke-linecap: round;
  opacity: 0.9;
}

.party-label {
  fill: #34383d;
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
}

.seat-name {
  fill: #202428;
  font-weight: 700;
  pointer-events: none;
  stroke: #fff;
  stroke-width: 3px;
  paint-order: stroke fill;
  text-anchor: middle;
  dominant-baseline: middle;
}

.seat-dot {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 1.4;
  transition:
    r 450ms ease,
    opacity 120ms ease,
    stroke-width 120ms ease;
}

.seat-dot:hover,
.seat-dot:focus {
  opacity: 1;
  stroke: #111418;
  stroke-width: 2.2;
  outline: none;
}

.seat-dot.is-selected {
  stroke: #111418;
  stroke-width: 3;
}

.seat-dot.is-muted {
  opacity: 0.18;
}

.seat-halo {
  pointer-events: none;
}

.tribune {
  fill: #ede9df;
  stroke: var(--strong-line);
  stroke-width: 1.4;
}

.tribune-text {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
  text-transform: uppercase;
}

.empty-label {
  fill: var(--muted);
  font-size: 17px;
  text-anchor: middle;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 0 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.tabs,
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fcfbf8;
}

.subtabs {
  flex-wrap: wrap;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.tab,
.subtab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 7px 11px;
}

.tab.is-active,
.subtab.is-active {
  border-color: var(--accent);
  background: #fff4ed;
  color: var(--accent-dark);
}

.detail-body {
  padding: 16px;
}

.detail-header {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.person-title-row,
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.person-title-row h2,
.panel-title-row h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.15;
}

.party-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 5px 9px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf7;
  padding: 9px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
}

.section-title,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 9px;
  color: #34383d;
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-heading {
  margin: 0 0 12px;
  font-size: 1.2rem;
  line-height: 1.15;
  text-transform: none;
}

.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 1px solid var(--strong-line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  cursor: help;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-transform: none;
}

.info-tip-bubble {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  bottom: auto;
  width: min(260px, 70vw);
  transform: translateX(-50%);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
  text-align: left;
  text-transform: none;
  white-space: normal;
  z-index: 8;
}

.info-tip:hover .info-tip-bubble,
.info-tip:focus-visible .info-tip-bubble {
  display: block;
}

.info-tip:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.phrase-list {
  display: grid;
  gap: 7px;
}

.phrase-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.phrase-track {
  position: relative;
  min-width: 0;
  min-height: 32px;
  overflow: hidden;
  border: 1px solid #e3e0d8;
  border-radius: 7px;
  background: #fbfaf7;
}

.phrase-bar {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 3px;
  background: rgba(179, 93, 50, 0.16);
}

.phrase-text {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 7px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 650;
}

.phrase-track:has(.phrase-badge) .phrase-text {
  padding-right: 64px;
}

.phrase-detail {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.phrase-badge {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e3e0d8;
  color: #7a4a2a;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.phrase-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 800;
}

.language-dashboard h2 {
  margin-bottom: 12px;
  font-size: 1.2rem;
  line-height: 1.15;
}

.marker-control {
  grid-template-columns: 1fr;
}

.language-bars,
.pronoun-list {
  display: grid;
  gap: 10px;
}

.language-bar-row,
.pronoun-row {
  display: grid;
  gap: 5px;
}

.language-bar-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.language-bar-label span {
  min-width: 0;
  overflow: hidden;
  color: #34383d;
  font-size: 0.82rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-bar-label strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.language-track,
.pronoun-stack {
  height: 11px;
  overflow: hidden;
  border: 1px solid #e3e0d8;
  border-radius: 999px;
  background: #f4f1ea;
}

.language-fill,
.pronoun-stack span {
  display: block;
  height: 100%;
}

.pronoun-stack {
  display: flex;
}

.pronoun-stack.is-empty {
  background: repeating-linear-gradient(
    90deg,
    #f4f1ea 0,
    #f4f1ea 6px,
    #e3e0d8 6px,
    #e3e0d8 7px
  );
}

.pronoun-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.pronoun-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.language-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.language-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.language-table th,
.language-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.language-table th:first-child,
.language-table td:first-child {
  text-align: left;
}

.language-table tbody th {
  max-width: 220px;
  overflow: hidden;
  color: #34383d;
  font-weight: 800;
  text-overflow: ellipsis;
}

.language-table tbody tr:last-child th,
.language-table tbody tr:last-child td {
  border-bottom: 0;
}

.language-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.language-mini-grid .stat {
  min-width: 0;
  padding: 8px;
}

.language-mini-grid .stat strong {
  font-size: 0.88rem;
}

.party-pronoun-card {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf7;
}

.party-pronoun-card .pronoun-legend {
  margin-bottom: 0;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.panel-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.source-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.detail-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(23, 25, 28, 0.28);
}

.detail-dialog::backdrop {
  background: rgba(31, 34, 38, 0.38);
}

.dialog-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fcfbf8;
}

#dialogTitle {
  font-weight: 900;
}

.close-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.close-button:hover,
.close-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.theme-combobox {
  position: relative;
}

.theme-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--shadow);
}

.theme-option,
.theme-option-label {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.theme-option:hover,
.theme-option:focus-visible,
.theme-option.is-active {
  background: #fff4ed;
  outline: none;
}

.theme-option small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.theme-group-label {
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.theme-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff8f3;
}

.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 6px 5px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.theme-chip button {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.theme-context-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.excerpt-list {
  display: grid;
  gap: 8px;
}

.excerpt-card {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf7;
  color: inherit;
  padding: 10px;
  text-align: left;
}

.excerpt-speaker {
  justify-self: start;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.excerpt-speaker:hover,
.excerpt-speaker:focus-visible {
  text-decoration: underline;
}

.excerpt-card blockquote {
  margin: 0;
  border-left: 3px solid var(--line);
  padding-left: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.excerpt-link {
  justify-self: start;
  font-size: 0.8rem;
  color: var(--accent);
}

.theme-chart {
  width: 100%;
  height: 150px;
}

.ownership-list {
  display: grid;
  gap: 8px;
}

.ownership-row {
  display: grid;
  gap: 4px;
}

.ownership-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border: 1px solid #e3e0d8;
  border-radius: 999px;
  background: #f4f1ea;
}

.ownership-fill {
  position: absolute;
  top: 0;
  bottom: 0;
}

.theme-note {
  margin: 0 0 12px;
}

.access-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.quota-chip,
.session-label {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.quota-chip[hidden],
.session-label[hidden] {
  display: none !important;
}

.quota-chip.is-low {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.gate-dialog {
  width: min(460px, calc(100vw - 28px));
}

.gate-body {
  display: grid;
  gap: 12px;
  padding: 16px 14px 18px;
}

.gate-body p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.gate-error {
  margin: 0;
  color: #9b1c2c;
  font-size: 0.84rem;
}

.gate-submit {
  justify-self: start;
  padding: 8px 14px;
  border: 1px solid var(--accent-dark);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.gate-submit:hover,
.gate-submit:focus-visible {
  background: var(--accent-dark);
  outline: none;
}

.gate-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 1080px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-side {
    align-items: start;
    width: 100%;
  }

  .summary-strip {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .analysis-panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar,
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chamber-wrap {
    min-height: 430px;
  }

  #chamberSvg {
    min-height: 390px;
  }

  .summary-strip,
  .stat-grid,
  .language-mini-grid,
  .two-column,
  .panel-control {
    grid-template-columns: 1fr;
  }

  .phrase-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.page-body {
  line-height: 1.55;
}

.page-header,
.page-main,
.page-footer {
  width: min(820px, calc(100vw - 28px));
  margin: 0 auto;
}

.page-header {
  padding: 28px 0 12px;
}

.page-header h1 {
  margin-bottom: 10px;
  font-size: 1.8rem;
}

.page-back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--accent-dark);
  font-size: 0.9rem;
  text-decoration: none;
}

.page-back:hover,
.page-back:focus-visible {
  text-decoration: underline;
}

.page-lead {
  color: var(--muted);
  font-size: 1.02rem;
}

.page-main {
  display: grid;
  gap: 14px;
  padding-bottom: 20px;
}

.page-card {
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.page-card h2 {
  margin-bottom: 10px;
  font-size: 1.15rem;
}

.page-card p:last-child,
.page-card ul:last-child,
.page-card ol:last-child {
  margin-bottom: 0;
}

.page-card li + li {
  margin-top: 6px;
}

.page-card a,
.page-footer a {
  color: var(--accent-dark);
}

.account-card {
  border-color: var(--strong-line);
  background: #fbfaf7;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.account-actions[hidden] {
  display: none;
}

.page-button {
  padding: 8px 14px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.page-button:hover,
.page-button:focus-visible {
  border-color: var(--accent);
}

.page-button.is-danger {
  border-color: #b3261e;
  color: #b3261e;
}

.page-button.is-danger:hover,
.page-button.is-danger:focus-visible {
  background: #b3261e;
  color: #fff;
}

.page-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.terms-table {
  width: 100%;
  margin-bottom: 12px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.terms-table th,
.terms-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.terms-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.page-footer {
  padding: 18px 0 36px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 720px) {
  .page-card {
    padding: 14px;
  }

  .terms-table,
  .terms-table tbody,
  .terms-table tr,
  .terms-table td {
    display: block;
  }

  .terms-table thead {
    display: none;
  }

  .terms-table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .terms-table td {
    padding: 2px 0;
    border: 0;
  }
}

/* ------------------------------------------------------------ dashboard v3 */

body:not([data-mode="scientific"]) .scientific-only {
  display: none;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.account-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2d9b68;
}

.account-chip[hidden] {
  display: none;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: end;
  gap: 10px;
}

.period-control {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.period-control .field select {
  min-width: 210px;
}

.period-custom {
  display: flex;
  gap: 8px;
}

.period-custom[hidden] {
  display: none;
}

.period-custom input {
  min-width: 150px;
}

.summary-period {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 4px 28px 24px;
  color: var(--muted);
  font-size: 0.8rem;
}

.app-footer nav {
  display: flex;
  gap: 16px;
}

.app-footer a,
.source-note a,
.gate-body a {
  color: var(--accent-dark);
}

.fiche-block {
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.fiche-block > .section-title {
  margin-top: 14px;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.sub-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 8px;
  color: #34383d;
  font-size: 0.82rem;
  font-weight: 800;
}

.lead-sentence {
  margin-bottom: 6px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.rank-sentence {
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.chip-row,
.theme-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.chip-row-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.theme-pill small {
  color: var(--muted);
  font-weight: 600;
}

.theme-pill:hover,
.theme-pill:focus-visible,
.domain-title:hover,
.domain-title:focus-visible,
.group-card:hover,
.group-card:focus-visible,
.phrase-track.is-action:hover,
.phrase-track.is-action:focus-visible {
  border-color: var(--accent);
  outline: none;
}

button.party-pill {
  background: #fff;
  cursor: pointer;
}

.phrase-track.is-action {
  display: block;
  width: 100%;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.welcome-card {
  margin-bottom: 8px;
  padding: 14px 16px;
  border: 1px solid #ecd3c3;
  border-radius: var(--radius);
  background: #fff8f3;
}

.welcome-card h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.welcome-card ul {
  margin: 0 0 10px;
  padding-left: 18px;
  line-height: 1.45;
  font-size: 0.88rem;
}

.welcome-card li + li {
  margin-top: 4px;
}

.domain-list {
  display: grid;
  gap: 10px;
}

.domain-card {
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf7;
}

.domain-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 2px 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: left;
}

.domain-title small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.theme-option-domain {
  font-weight: 800;
}

.theme-option-child {
  padding-left: 22px;
}

.back-link {
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 700;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.group-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.group-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.74rem;
}

.locked-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #ecd3c3;
  border-radius: var(--radius);
  background: #fff8f3;
}

.locked-card p {
  margin: 0;
}

.loading-note::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* votes */

.vote-list {
  display: grid;
  gap: 8px;
}

.vote-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf7;
}

.vote-row p {
  margin: 0;
}

.vote-head,
.vote-positions,
.vote-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.vote-foot {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
}

.vote-foot a {
  color: var(--accent-dark);
  font-weight: 700;
}

.vote-date {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.vote-title {
  font-size: 0.86rem;
  line-height: 1.4;
}

.vote-dossier {
  color: var(--muted);
  font-size: 0.78rem;
}

.vote-result,
.vote-key,
.deviates-flag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
}

.vote-result.is-adopted {
  background: #e3f3ea;
  color: #1e6b45;
}

.vote-result.is-rejected {
  background: #f6e3e6;
  color: #8d2436;
}

.vote-key {
  background: var(--panel-soft);
  color: var(--muted);
}

.deviates-flag {
  background: #fff1d6;
  color: #7a5200;
}

.vote-group {
  color: var(--muted);
  font-size: 0.78rem;
}

.pos-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  vertical-align: 1px;
}

.pos-pour {
  background: #dff1e6;
  color: #1e6b45;
}

.pos-contre {
  background: #f6e0e4;
  color: #8d2436;
}

.pos-abstention {
  background: #eceef2;
  color: #4a5361;
}

.pos-non-votant,
.pos-absent,
.pos-none {
  background: #f4f1ea;
  color: var(--muted);
}

.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.group-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.group-chip .swatch {
  width: 9px;
  height: 9px;
}

.more-block summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.more-block[open] summary {
  margin-bottom: 8px;
}

.more-block .vote-row + .vote-row {
  margin-top: 8px;
}

/* estimated stances */

.stance-list {
  display: grid;
  gap: 8px;
}

.stance-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.stance-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 0.86rem;
}

.stance-head small {
  width: 100%;
  color: var(--muted);
  font-size: 0.76rem;
}

.stance-level {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 800;
}

.level-favorable,
.level-plutot-favorable {
  background: #dff1e6;
  color: #1e6b45;
}

.level-defavorable,
.level-plutot-defavorable {
  background: #f6e0e4;
  color: #8d2436;
}

.level-partage,
.level-non-exprime {
  background: #eceef2;
  color: #4a5361;
}

.stance-quote {
  margin: 0;
  padding-left: 8px;
  border-left: 3px solid var(--line);
  font-size: 0.84rem;
  line-height: 1.45;
}

.stance-quote p {
  margin: 0 0 4px;
}

.stance-quote footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.stance-quote footer a {
  color: var(--accent-dark);
}

.method-tag {
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.estimate-note {
  margin-top: 6px;
  font-style: italic;
}

/* gate, account, toast */

.gate-why {
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--panel-soft);
  font-size: 0.86rem;
}

.gate-honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.gate-body[hidden],
.gate-turnstile[hidden],
.gate-dev[hidden],
.gate-error[hidden] {
  display: none;
}

.gate-check-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.gate-dev {
  padding: 8px 10px;
  border: 1px dashed var(--strong-line);
  border-radius: 7px;
  font-size: 0.82rem;
}

.gate-dev a {
  display: block;
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gate-secondary {
  padding: 8px 12px;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.gate-secondary:disabled {
  cursor: default;
  opacity: 0.6;
}

.gate-secondary.is-danger {
  border-color: #c9a0a8;
  color: #8d2436;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #202428;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.toast[data-kind="success"] {
  background: #1e6b45;
}

.toast[data-kind="error"] {
  background: #8d2436;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 1080px) {
  .topbar-controls {
    justify-content: start;
  }

  .summary-period {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .group-grid {
    grid-template-columns: 1fr;
  }

  .period-control .field select,
  .period-custom input {
    min-width: 0;
  }

  .app-footer {
    padding: 4px 12px 20px;
  }
}

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

.admin-body .page-header,
.admin-body .page-main,
.admin-body .page-footer {
  width: min(1180px, calc(100vw - 28px));
}

.admin-title-row,
.admin-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-title-row h1 {
  margin-bottom: 10px;
}

.admin-session {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-session .source-note {
  margin: 0;
}

.admin-session[hidden],
.admin-content[hidden],
.admin-login[hidden],
.admin-body [hidden] {
  display: none;
}

.admin-content {
  display: grid;
  gap: 14px;
}

.admin-login-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-login-form .field {
  flex: 1 1 260px;
}

.admin-login-form .page-button {
  min-height: 39px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.admin-stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.admin-stat p {
  margin: 0;
}

.admin-stat-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-stat-value {
  margin: 4px 0 2px;
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.admin-stat-detail {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-filters .field {
  min-width: 150px;
}

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

.admin-table td.is-number,
.admin-table th.is-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-table td {
  vertical-align: middle;
}

.admin-table tr.is-blocked td {
  color: var(--muted);
}

.admin-email {
  font-weight: 700;
  word-break: break-all;
}

.admin-places span {
  display: block;
  white-space: nowrap;
}

.admin-pill {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid #b7d3c2;
  border-radius: 999px;
  background: #eef7f1;
  color: #1e6b45;
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-pill.is-blocked {
  border-color: #e3b9c0;
  background: #fbeff1;
  color: #8d2436;
}

.admin-pill.is-admin {
  border-color: var(--strong-line);
  background: #fff4ed;
  color: var(--accent-dark);
}

.admin-action {
  padding: 5px 11px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.admin-bar-cell {
  width: 30%;
}

.admin-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.admin-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.admin-daily {
  position: relative;
}

.admin-daily-max {
  margin-bottom: 6px;
  text-align: right;
}

.admin-daily-cols {
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  gap: 3px;
  align-items: end;
}

.admin-daily-track {
  display: flex;
  align-items: end;
  height: 140px;
  border-bottom: 1px solid var(--strong-line);
}

.admin-daily-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.admin-daily-col:hover .admin-daily-bar {
  background: var(--accent-dark);
}

.admin-daily-label {
  display: block;
  min-height: 1.3em;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.admin-geo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.admin-geo h3 {
  margin-bottom: 6px;
  font-size: 0.98rem;
}
