:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --ink: #1b1d1f;
  --muted: #62686c;
  --line: #d7dadd;
  --soft: #f1f2f2;
  --soft-strong: #e7e9ea;
  --accent: #315e72;
  --accent-soft: #e5eef1;
  --focus: #156fc3;
  --profile: #8a3ffc;
  --profile-soft: #f1eaff;
  --dialog-shadow: rgba(15, 20, 24, 0.26);
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #171a1c;
  --ink: #f0f1f2;
  --muted: #adb3b6;
  --line: #3b4144;
  --soft: #202426;
  --soft-strong: #292e31;
  --accent: #8cb7c8;
  --accent-soft: #20343d;
  --focus: #79b8ff;
  --profile: #c6a7ff;
  --profile-soft: #312445;
  --dialog-shadow: rgba(0, 0, 0, 0.54);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: transparent;
}

body,
button,
select {
  font-family: var(--font);
}

body {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

button,
select {
  color: inherit;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app {
  width: min(700px, 100%);
  height: min(600px, 100vh);
  margin: 0 auto;
  padding: 12px 14px 10px;
  display: grid;
  grid-template-rows: 50px 72px minmax(0, 1fr) 24px;
  gap: 7px;
  overflow: hidden;
  background: var(--bg);
}

.app__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.profile-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--profile);
  border-radius: 5px;
  background: transparent;
  color: var(--profile);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.profile-button:hover,
.profile-button[data-active="true"] {
  background: var(--profile-soft);
}

.app__header h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.035em;
}

.app__header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.info-button {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.info-button:hover {
  background: var(--soft);
}

.party-picker {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 9px;
  align-items: stretch;
  padding: 2px 0 7px;
  border-bottom: 1px solid var(--line);
}

.party-picker__heading h2 {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.25;
}

.party-picker__heading p {
  min-height: 28px;
  margin: 5px 0 0;
  color: #9a463d;
  font-size: 10.5px;
  line-height: 1.25;
}

.party-picker__heading p[data-tone="info"] {
  color: var(--muted);
}

:root[data-theme="dark"] .party-picker__heading p {
  color: #e0a09a;
}

:root[data-theme="dark"] .party-picker__heading p[data-tone="info"] {
  color: var(--muted);
}

.party-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.party-button {
  min-width: 0;
  height: 28px;
  display: grid;
  grid-template-columns: 8px 25px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.party-button:hover {
  background: var(--soft);
}

.party-button[data-selected="true"] {
  border-color: var(--party-color);
  background: var(--soft);
  box-shadow: inset 3px 0 0 var(--party-color);
}

.party-button strong {
  font-size: 11px;
}

.party-button > span:last-child {
  overflow: hidden;
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--party-color);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 207px;
  gap: 12px;
}

.chart-panel {
  min-width: 0;
  min-height: 0;
  margin: 0;
  border-right: 1px solid var(--line);
}

#position-chart {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.chart-grid {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.chart-grid:last-of-type {
  stroke-width: 1.4;
}

.chart-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.chart-label--active {
  fill: var(--accent);
  font-weight: 850;
}

.party-shape {
  fill-opacity: 0.11;
  stroke-width: 2.7;
  stroke-linejoin: round;
}

.party-point {
  stroke: var(--bg);
  stroke-width: 1.5;
}

.profile-shape {
  fill-opacity: 0.08;
  stroke-width: 3.2;
  stroke-dasharray: 8 5;
}

.profile-point {
  stroke-width: 2;
}

.axis-panel {
  min-height: 0;
  padding: 7px 0 0;
}

.axis-controls label,
.values h3 {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.axis-controls {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 7px;
}

.axis-panel select {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
}

#year-select {
  padding-right: 22px;
}

.axis-panel h2 {
  margin: 14px 0 3px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.axis-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.context-button {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 11px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.context-button:hover {
  background: var(--soft);
}

.axis-description {
  min-height: 54px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.scale {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 13px 0 14px;
  padding-top: 12px;
}

.scale::before {
  content: "";
  position: absolute;
  inset: 2px 0 auto;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--soft-strong), var(--accent));
}

.scale > div:last-child {
  text-align: right;
}

.scale span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.scale strong {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.2;
}

.values {
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.values ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.values li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 31px;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--soft);
}

.values li span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 750;
}

.values li i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.values li strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.app__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.info-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 18px 50px var(--dialog-shadow);
}

.info-dialog::backdrop {
  background: rgba(12, 16, 18, 0.48);
}

.info-dialog__frame {
  max-height: calc(100vh - 30px);
  display: flex;
  flex-direction: column;
}

.info-dialog__frame > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px 10px;
  border-bottom: 1px solid var(--line);
}

.info-dialog__frame h2 {
  margin: 0;
  font-size: 20px;
}

.info-dialog__frame header button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.info-dialog__body {
  padding: 13px 15px 15px;
  overflow-y: auto;
}

.info-dialog__body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.info-dialog__body dl {
  display: grid;
  gap: 5px;
  margin: 13px 0 0;
}

.info-dialog__body dl div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}

.info-dialog__body dt {
  font-weight: 800;
}

.info-dialog__body dd {
  margin: 0;
  color: var(--muted);
}

.method-info section + section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.method-info h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.method-info section p {
  margin-bottom: 0;
}

.profile-dialog {
  width: min(540px, calc(100% - 28px));
}

.profile-dialog__frame > header > div {
  min-width: 0;
}

.profile-progress {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.profile-dialog__body {
  min-height: 270px;
}

.profile-intro {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.profile-question {
  min-width: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.profile-question legend {
  min-height: 58px;
  padding: 0;
  font-size: 20px;
  font-weight: 820;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.profile-poles {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 17px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
}

.profile-poles span {
  width: 45%;
}

.profile-poles span:last-child {
  text-align: right;
}

.profile-options {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.profile-options::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 20px 7% auto;
  height: 3px;
  background: linear-gradient(90deg, var(--soft-strong), var(--profile));
}

.profile-options label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.profile-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.profile-options span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.profile-options label:hover span {
  border-color: var(--profile);
}

.profile-options input:checked + span {
  border-color: var(--profile);
  background: var(--profile);
  color: #fff;
}

:root[data-theme="dark"] .profile-options input:checked + span {
  color: #17131d;
}

.profile-options input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.profile-status {
  min-height: 18px;
  margin: 12px 0 0 !important;
  color: #9a463d !important;
  font-size: 11.5px !important;
}

:root[data-theme="dark"] .profile-status {
  color: #e0a09a !important;
}

.profile-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 15px 14px;
  border-top: 1px solid var(--line);
}

.profile-dialog__footer > div {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.profile-dialog__footer button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--profile);
  background: var(--profile);
  color: #fff;
}

:root[data-theme="dark"] .primary-button {
  color: #17131d;
}

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.text-button:hover {
  color: var(--ink);
  text-decoration: underline;
}

.context-dialog__body > p:first-child {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.context-dialog__body section {
  margin: 0 0 11px;
}

.context-dialog__body h3 {
  margin: 0 0 3px;
  font-size: 12px;
}

.context-dialog__body section p {
  margin: 0;
}

.context-dialog__body ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.context-dialog__body li {
  font-size: 11.5px;
}

.context-dialog__body a {
  color: var(--accent);
  text-underline-offset: 2px;
}

@media (max-width: 580px) {
  .app {
    padding-inline: 9px;
  }

  .party-picker {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .party-button > span:last-child {
    display: none;
  }

  .party-button {
    grid-template-columns: 8px 1fr;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 174px;
  }
}
