:root {
  --ink: #17212b;
  --muted: #64707c;
  --line: #dfe4e7;
  --paper: #f4f1ea;
  --white: #fff;
  --position: #db5b38;
  --importance: #214f9b;
  --teal: #157a74;
  --alarm: #8c2c1c;
  --shadow: 0 22px 70px rgba(28, 37, 45, 0.11);
  --thumb: 16px;
  --font-sans: "Noto Sans", "Noto Sans Hebrew", "Noto Sans Arabic",
    "Noto Sans Ethiopic", system-ui, sans-serif;
}

[lang="he"] {
  --font-sans: "Noto Sans Hebrew", "Noto Sans", system-ui, sans-serif;
}

[lang="ar"] {
  --font-sans: "Noto Sans Arabic", "Noto Sans", system-ui, sans-serif;
}

[lang="am"] {
  --font-sans: "Noto Sans Ethiopic", "Noto Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(219, 91, 56, 0.08), transparent 24rem),
    radial-gradient(circle at 94% 88%, rgba(33, 79, 155, 0.08), transparent 26rem),
    var(--paper);
  font-family: var(--font-sans);
  text-align: start;
}

button {
  color: inherit;
  font: inherit;
}

:where(button, input, [tabindex]):focus-visible {
  outline: 3px solid #b84a2d;
  outline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  font-family: var(--font-sans);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto;
}

.site-header,
.site-footer {
  display: flex;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.site-header {
  min-height: 76px;
}

.brand {
  display: flex;
  padding: 0;
  border: 0;
  background: transparent;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.brand strong {
  font-weight: 800;
}

.brand-mark {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
}

.brand-mark i {
  position: absolute;
  top: 4px;
  width: 13px;
  height: 20px;
  border-radius: 10px 10px 3px 3px;
  transform: rotate(45deg);
}

.brand-mark i:first-child {
  inset-inline-start: 3px;
  background: var(--position);
}

.brand-mark i:last-child {
  inset-inline-end: 3px;
  background: var(--importance);
  transform: rotate(-45deg);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  position: relative;
  flex-shrink: 0;
}

.lang-toggle {
  display: flex;
  padding: 7px 11px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.45);
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.lang-toggle:hover,
.lang-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.85);
}

.lang-current {
  overflow: hidden;
  max-width: 11ch;
  text-overflow: ellipsis;
}

.lang-caret {
  width: 9px;
  flex: none;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.lang-toggle[aria-expanded="true"] .lang-caret {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  z-index: 20;
  display: grid;
  min-width: 100%;
  padding: 4px;
  border-radius: 9px;
  margin-top: 6px;
  background: var(--white);
  box-shadow: 0 14px 34px rgba(28, 37, 45, 0.16);
  inset-inline-end: 0;
}

.lang-menu[hidden] {
  display: none;
}

.lang-menu button {
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
}

.lang-menu button:hover {
  background: rgba(23, 33, 43, 0.06);
}

.lang-menu button.is-active {
  color: var(--ink);
  background: rgba(23, 33, 43, 0.09);
}

.icon-button,
.dialog-close {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  place-items: center;
  cursor: pointer;
}

main {
  display: grid;
  width: 100%;
  place-items: center;
}

.screen {
  width: min(1080px, calc(100% - 40px));
  margin: 48px auto;
  animation: enter 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------- welcome ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 720px);
  align-items: center;
  justify-content: center;
}

.hero h1 {
  max-width: 720px;
  margin-bottom: 14px;
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1;
}

.hero h1 em {
  color: var(--position);
  font-style: normal;
}

.hero-copy {
  max-width: 520px;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.hero-visual {
  display: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
}

.orb-a {
  width: 320px;
  height: 320px;
  background: var(--position);
  opacity: 0.9;
}

.orb-b {
  width: 255px;
  height: 255px;
  margin-block-start: 130px;
  margin-inline-start: 165px;
  background: var(--importance);
  opacity: 0.9;
  mix-blend-mode: multiply;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--ink);
  color: var(--white);
  background: var(--ink);
  box-shadow: 0 8px 22px rgba(23, 33, 43, 0.15);
}

.primary-button[disabled] {
  border-color: #b9c0c6;
  background: #b9c0c6;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
}

.text-button {
  padding: 7px 2px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}

/* ---------- utility ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- question ---------- */

.question-screen {
  display: grid;
  width: min(1100px, calc(100% - 40px));
  margin-top: 32px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 16px;
}

.question-progress {
  display: grid;
  grid-column: 1 / -1;
  margin-bottom: 0;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.back-button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.progress-track {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 10px;
  background: #dcdedb;
}

.progress-track i {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.progress-count {
  display: flex;
  color: var(--muted);
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.progress-estimate {
  white-space: nowrap;
}

/* Four items per page, two by two on the shared 12-col track.
   Inline flow puts the first card at inline-start (right in RTL). */
.question-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: stretch;
  column-gap: 16px;
  row-gap: 14px;
}

.tutorial-screen {
  width: min(1100px, calc(100% - 40px));
  margin-block: 30px;
}

.tutorial-guide {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 14px;
  padding: 22px 24px;
  border: 0;
  border-radius: 0;
  background: #eae9e9;
  align-items: start;
  font-size: 13px;
}

.tutorial-header {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.tutorial-header h1 {
  margin: 0;
  color: #201e1d;
  font-size: 22px;
  line-height: 1.1;
}

.picker-dynamics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.picker-dynamics span {
  display: inline-flex;
  color: #201e1d;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.picker-dynamics b {
  display: inline-grid;
  width: 28px;
  height: 28px;
  color: #f3f2f2;
  background: #201e1d;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
}

.practice-picker {
  grid-column: 1 / span 7;
  min-width: 0;
  width: auto;
}

.tutorial-side {
  grid-column: 8 / span 5;
  min-width: 0;
  align-self: start;
}

.practice-readout {
  min-height: 62px;
}

.practice-picker[data-level="0"] .magnitude-pair {
  color: #3f8f57;
}

.practice-picker[data-level="3"] .magnitude-pair {
  color: #dd6a10;
}

.practice-picker[data-level="4"] .magnitude-pair {
  color: #ec3013;
}

.tutorial-dealbreaker-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.tutorial-actions {
  display: flex;
  grid-column: 1 / -1;
  margin-top: 4px;
  align-items: center;
  justify-content: space-between;
}

.question-tile {
  display: flex;
  grid-column: span 6;
  min-width: 0;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: #eae9e9;
  box-shadow: none;
  flex-direction: column;
}

.question-tile.is-active {
  box-shadow: 0 0 0 2px #201e1d;
}

.domain-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tile-head h2 {
  margin: 0 0 4px;
  font-size: clamp(14px, 1.45vw, 17px);
  letter-spacing: -0.02em;
  line-height: 1.28;
}

.context-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.context-chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  padding: 6px 9px;
  border: 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.chip-separate {
  color: var(--teal);
  background: rgba(21, 122, 116, 0.08);
}

.chip-pending {
  color: #8a6212;
  background: rgba(240, 163, 58, 0.14);
}

/* ---------- magnitude / angle picker ---------- */

.magnitude-picker {
  margin-top: auto;
  padding-top: 4px;
}

.magnitude-pad {
  width: 100%;
  cursor: crosshair;
  touch-action: none;
}

.magnitude-pad:focus-visible {
  outline: 3px solid #201e1d;
  outline-offset: 3px;
}

.magnitude-field {
  display: block;
  width: 100%;
  background: #f8f4f4;
}

.magnitude-redline-band {
  fill: #fff2ef;
  stroke: #ec3013;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.magnitude-redline-band.is-solid {
  stroke-dasharray: none;
}

.magnitude-half-low {
  fill: #eae7e7;
}

.magnitude-half-high {
  fill: #d7d3d3;
}

.magnitude-inner-arc,
.magnitude-baseline {
  fill: none;
  stroke: #201e1d;
  stroke-width: 2;
}

.magnitude-projection {
  stroke: #201e1d;
}

.magnitude-redline-label,
.magnitude-endpoint-label {
  fill: #201e1d;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
}

.magnitude-redline-label {
  fill: #ae1800;
  font-size: 13px;
  letter-spacing: 0.1em;
}

.magnitude-endpoint-label {
  letter-spacing: 0.04em;
}

[dir="rtl"] .magnitude-redline-label,
[dir="rtl"] .magnitude-endpoint-label {
  letter-spacing: normal;
}

.magnitude-readout {
  min-height: 52px;
  padding-top: 7px;
  border-top: 2px solid rgba(32, 30, 29, 0.4);
  margin-top: 6px;
}

.magnitude-readout h3 {
  margin: 0 0 3px;
  color: #656160;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[dir="rtl"] .magnitude-readout h3 {
  letter-spacing: normal;
}

.magnitude-pair {
  display: block;
  color: #9b6b00;
  font-size: clamp(14px, 1.7vw, 19px);
  font-weight: 800;
  line-height: 1.15;
}

.magnitude-picker[data-level="0"] .magnitude-pair {
  color: #3f8f57;
}

.magnitude-picker[data-level="3"] .magnitude-pair {
  color: #dd6a10;
}

.magnitude-picker[data-level="4"] .magnitude-pair {
  color: #ec3013;
}

.magnitude-pair.bump {
  animation: pop 160ms ease;
}

@keyframes pop {
  50% {
    transform: translateY(-2px) scale(1.06);
  }
}

.magnitude-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.magnitude-picker.is-locked .magnitude-pad {
  opacity: 0.45;
}

.importance-legend {
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.importance-legend-head {
  display: flex;
  margin-bottom: 6px;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.importance-legend-head strong {
  font-size: 11px;
}

.importance-legend-head span {
  color: var(--muted);
  font-size: 10px;
}

.importance-legend-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.importance-legend button {
  display: flex;
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  align-items: center;
  gap: 10px;
  text-align: start;
  cursor: pointer;
}

.importance-legend button:hover {
  background: rgba(255, 255, 255, 0.65);
}

.importance-legend button:focus {
  outline: none;
}

.importance-legend button:focus-visible {
  outline: 2px dotted #201e1d;
  outline-offset: 2px;
}

.importance-legend button.is-selected {
  border-color: var(--importance);
  background: var(--white);
}

.importance-legend button > i {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: #3f8f57;
  flex: none;
}

.importance-legend button:nth-child(2) > i {
  background: #78951d;
}

.importance-legend button:nth-child(3) > i {
  background: #b27c00;
}

.importance-legend button:nth-child(4) > i {
  background: #dd6a10;
}

.importance-legend button:nth-child(5) > i {
  background: #ec3013;
}

.importance-legend button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.importance-legend button strong,
.importance-legend button small {
  display: block;
}

.importance-legend button strong {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.importance-legend button small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.legend-dealbreaker-note {
  margin: 8px 0 0;
  color: var(--alarm);
  font-size: 10px;
}

.page-dealbreaker-note {
  display: none;
}

.question-grid[data-layout="compact"] .question-tile {
  padding-block: 12px;
}

.question-grid[data-layout="compact"] .magnitude-pad {
  width: min(100%, 300px);
  margin-inline: auto;
}

.question-grid[data-layout="compact"] .magnitude-readout {
  min-height: 48px;
}

.tile-foot {
  display: flex;
  margin-top: 5px;
  gap: 5px;
  flex-wrap: wrap;
}

.tile-foot button {
  min-height: 34px;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: #fafafa;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.tile-foot button:hover {
  color: var(--ink);
  background: #f1f2f1;
}

.page-foot {
  display: flex;
  grid-column: 1 / -1;
  margin-top: 2px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  margin-inline-start: auto;
  align-items: center;
  gap: 14px;
}

.card-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.card-hint[hidden] {
  display: none;
}

/* ---------- results ---------- */

.results-header {
  margin-bottom: 8px;
}

.results-header h1 {
  margin-bottom: 2px;
  font-size: clamp(26px, 3.8vw, 36px);
  letter-spacing: -0.05em;
}

.results-header p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.typicality {
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.typicality-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.typicality h2 {
  margin: 0;
  font-size: 13px;
}

.typicality-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.typicality-badge.band-common {
  color: #176144;
  background: #e4f4ec;
}

.typicality-badge.band-mixed {
  color: #7a5a12;
  background: #fbf0d9;
}

.typicality-badge.band-unusual {
  color: var(--importance);
  background: #e7efff;
}

.typicality-scale {
  position: relative;
  height: 5px;
  margin: 8px 0 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, #dfe7f6, #d8ece2);
}

.typicality-fill {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--importance), var(--teal));
}

.typicality-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  transform: translate(-50%, -50%);
}

[dir="rtl"] .typicality-marker {
  transform: translate(50%, -50%);
}

.typicality-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.typicality-mix {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

.typicality-caveat {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  align-items: start;
  gap: 12px;
}

.match-list {
  position: relative;
  min-width: 0;
}

.match-table {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.match-row {
  padding: 5px 10px 4px;
  border-block-end: 1px solid rgba(23, 33, 43, 0.07);
}

.match-row:nth-child(even) {
  background: rgba(23, 33, 43, 0.02);
}

.match-row:last-child {
  border-block-end: 0;
}

.match-row.is-open,
.match-row:focus-within {
  background: var(--white);
}

.match-row.has-dealbreaker-conflict {
  box-shadow: inset 3px 0 0 rgba(184, 74, 45, 0.7);
  background: rgba(255, 240, 236, 0.55);
}

[dir="rtl"] .match-row.has-dealbreaker-conflict {
  box-shadow: inset -3px 0 0 rgba(184, 74, 45, 0.7);
}

.match-row-main {
  display: grid;
  grid-template-columns: 18px minmax(90px, 1.05fr) minmax(64px, 1.35fr) 52px minmax(0, auto) auto;
  align-items: center;
  gap: 7px;
}

.rank {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
}

.party-name {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.party-name strong,
.party-name small {
  display: inline;
}

.party-name strong {
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.2;
}

.party-name small {
  margin-top: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.fit-bar {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6e9e9;
}

.fit-bar i {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #49a48d);
}

.fit-score {
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.05;
  text-align: end;
}

.fit-score small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
}

.dealbreaker-mark {
  max-width: 9rem;
  color: var(--alarm);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-align: end;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dealbreaker-mark.is-empty {
  display: none;
}

.match-row-sub {
  display: flex;
  margin-top: 2px;
  padding-inline-start: 28px;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.match-flags {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  flex-wrap: wrap;
}

.match-flags:empty {
  display: none;
}

.coalition-chip {
  display: inline-flex;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

.coalition-chip.aligned {
  color: #176144;
  background: #e4f4ec;
}

.coalition-chip.mixed {
  color: #7a5a12;
  background: #fbf0d9;
}

.coalition-chip.conflict {
  color: var(--alarm);
  background: #ffe7e0;
}

.coalition-chip.unknown {
  color: var(--muted);
  background: #eceeef;
}

.match-reason {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.why-toggle {
  min-height: 28px;
  padding: 2px 6px;
  border: 0;
  border-radius: 3px;
  color: var(--importance);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.match-toggle {
  margin-top: 8px;
}

/* Shared fixed flyout: smaller than the list, elevated as a layer, positioned in JS
   so it stays in the viewport and opens inward (clearing the Why column). */
.why-flyout {
  position: fixed;
  z-index: 40;
  width: min(280px, calc(100vw - 16px));
  max-height: min(36vh, 240px);
  border-radius: 10px;
  background: var(--white);
  box-shadow:
    0 0 0 1px rgba(23, 33, 43, 0.08),
    0 18px 40px rgba(23, 33, 43, 0.2);
  overflow: hidden;
}

.why-flyout[hidden] {
  display: none !important;
}

.why-inner {
  padding: 8px 10px;
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.why-group {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.why-group:first-child {
  margin-top: 0;
}

.why-table,
.why-unused {
  margin: 0;
  padding: 0;
  list-style: none;
}

.why-row {
  display: grid;
  padding: 3px 0;
  border-top: 1px solid rgba(23, 33, 43, 0.07);
  grid-template-columns: 10px minmax(0, 1fr) minmax(76px, 44%);
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.why-row:first-child {
  border-top: 0;
}

.why-mark {
  display: flex;
}

.why-mark svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.why-row.is-up .why-mark {
  color: var(--teal);
}

.why-row.is-down .why-mark {
  color: var(--position);
}

.why-row.is-flat .why-mark {
  color: var(--muted);
}

.why-issue {
  min-width: 0;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.why-row.is-conflict .why-issue {
  color: var(--alarm);
}

.why-stance {
  position: relative;
  min-width: 0;
  height: 14px;
  padding-inline: 5px;
}

.why-track {
  position: absolute;
  inset-inline: 5px;
  top: 50%;
  height: 3px;
  margin-block-start: -1.5px;
  border-radius: 99px;
  background: linear-gradient(to inline-end, #e4ddd4, #d5e0da);
}

.why-tick {
  position: absolute;
  top: 50%;
  inset-inline-start: var(--at);
  box-sizing: border-box;
}

.why-tick-party {
  z-index: 1;
  width: 7px;
  height: 7px;
  border: 1px solid #fff;
  border-radius: 1px;
  background: #2a2f33;
  transform: translate(-50%, -50%);
}

.why-tick-you {
  z-index: 2;
  width: 8px;
  height: 8px;
  border: 1px solid #fff;
  background: var(--tick);
  box-shadow: 0 0 0 1px rgba(23, 33, 43, 0.2);
  transform: translate(-50%, -50%) rotate(45deg);
}

[dir="rtl"] .why-tick-party {
  transform: translate(50%, -50%);
}

[dir="rtl"] .why-tick-you {
  transform: translate(50%, -50%) rotate(45deg);
}

.why-row.is-uncoded .why-track {
  inset-inline-end: 52px;
  opacity: 0.55;
}

.why-uncoded {
  position: absolute;
  inset-inline-end: 0;
  top: 50%;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

.why-thin {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.why-unused li {
  display: flex;
  padding: 4px 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.why-unused small {
  color: var(--muted);
  font-size: 10px;
}

.results-aside {
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.results-aside h2 {
  margin-bottom: 2px;
  font-size: 13px;
}

.metric {
  display: flex;
  padding: 6px 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-block-end: 1px solid rgba(23, 33, 43, 0.06);
}

.metric:last-of-type {
  border-block-end: 0;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.metric strong {
  font-size: 12px;
  text-align: end;
  line-height: 1.3;
}

.coverage-note {
  margin-top: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: #fdf6e8;
  font-size: 10px;
  line-height: 1.45;
}

.coverage-note strong {
  display: block;
  margin-bottom: 6px;
  color: #7a5a12;
  font-size: 12px;
}

.coverage-note ul {
  margin: 0 0 6px;
  padding-inline-start: 16px;
}

.coverage-note span {
  color: var(--muted);
}

.coalition-panel {
  display: grid;
  margin-top: 14px;
  padding: 14px 16px;
  border: 0;
  border-radius: 8px;
  background: rgba(21, 122, 116, 0.06);
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}

.coalition-panel h2 {
  margin-bottom: 2px;
  font-size: 15px;
}

.panel-note {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.coalition-panel p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.coalition-legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.coalition-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coalition-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.coalition-legend .aligned {
  background: #2f8f63;
}

.coalition-legend .mixed {
  background: #d9a13a;
}

.coalition-legend .conflict {
  background: #b8452e;
}

.results-disclaimer {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.result-actions {
  display: flex;
  margin-top: 22px;
  gap: 10px;
}

/* ---------- dialog and footer ---------- */

.info-dialog {
  width: min(560px, calc(100% - 32px));
  padding: 32px;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(23, 33, 43, 0.3);
}

.info-dialog::backdrop {
  background: rgba(23, 33, 43, 0.5);
  backdrop-filter: blur(3px);
}

.dialog-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
}

.info-dialog h2 {
  padding-inline-end: 30px;
  font-size: 25px;
}

.info-dialog p,
.info-dialog li {
  color: var(--muted);
  line-height: 1.6;
}

.site-footer {
  min-height: 64px;
  color: var(--muted);
  justify-content: flex-start;
  gap: 16px;
  font-size: 11px;
}

.site-footer button {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

[dir="rtl"] .typicality-scale {
  background-image: linear-gradient(270deg, #dfe7f6, #d8ece2);
}

[dir="rtl"] .typicality-fill {
  background-image: linear-gradient(270deg, var(--importance), var(--teal));
}

[dir="rtl"] .fit-bar i {
  background-image: linear-gradient(270deg, var(--teal), #49a48d);
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] .brand,
[dir="rtl"] .domain-label,
[dir="rtl"] .panel-note,
[dir="rtl"] .why-group,
[dir="rtl"] .why-head {
  letter-spacing: normal;
}

/* ---------- responsive ---------- */

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

  .orb-a {
    width: 230px;
    height: 230px;
  }

  .orb-b {
    width: 185px;
    height: 185px;
    margin-block-start: 90px;
    margin-inline-start: 125px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .coalition-panel {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .tutorial-header,
  .practice-picker,
  .tutorial-side,
  .tutorial-actions,
  .question-tile {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .site-header,
  .site-footer,
  .screen,
  .question-screen {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    min-height: 62px;
  }

  .header-meta {
    gap: 6px;
  }

  .lang-toggle {
    padding-inline: 8px;
  }

  .lang-current {
    max-width: 9ch;
  }

  .screen {
    margin: 28px auto;
  }

  .hero h1 {
    font-size: 44px;
  }

  .hero-visual {
    min-height: 210px;
  }

  .orb-a {
    width: 175px;
    height: 175px;
  }

  .orb-b {
    width: 140px;
    height: 140px;
    margin-block-start: 70px;
    margin-inline-start: 95px;
  }

  .tile-foot button {
    min-height: 44px;
  }

  .why-toggle {
    min-height: 36px;
  }

  .question-progress {
    grid-template-columns: auto 1fr;
  }

  .progress-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .progress-count {
    justify-self: end;
  }

  .page-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions {
    margin-inline-start: 0;
    justify-content: space-between;
  }

  .match-row-main {
    grid-template-columns: 18px minmax(0, 1fr) 52px auto auto;
    gap: 6px;
  }

  .fit-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .match-row-sub {
    padding-inline-start: 24px;
  }

  .dealbreaker-mark {
    max-width: 6rem;
  }

  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
