:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f1f0e9;
  --ink: #17201d;
  --muted: #66706b;
  --line: #d5d9d5;
  --riksdag: #2f6178;
  --government: #8d5b2f;
  --positive: #2f6e4d;
  --warning: #9a562a;
  --focus: #1675a1;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a18;
  --surface: #222724;
  --surface-soft: #2b302d;
  --ink: #f1f2ee;
  --muted: #b4bbb6;
  --line: #454d48;
  --riksdag: #82bbd1;
  --government: #d6a06e;
  --positive: #77bf97;
  --warning: #e7a06f;
  --focus: #85cff0;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 2px;
}

.tool {
  width: min(700px, 100vw);
  height: min(600px, 100vh);
  margin: 0 auto;
  padding: 13px 16px 12px;
  overflow: hidden;
}

.tool-header {
  height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.kicker,
.step-owner,
.section-heading span,
#detail-owner {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.info-button,
.dialog-header button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-family: Georgia, serif;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
}

.process { padding-top: 10px; }

.section-heading {
  height: 27px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.section-heading h2 {
  font-size: 14px;
  letter-spacing: -0.01em;
}

.process-row {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr;
  align-items: center;
}

.step {
  position: relative;
  height: 112px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.step:hover,
.review-step:hover { transform: translateY(-1px); }

.step.is-active,
.review-step.is-active {
  border-color: var(--riksdag);
  box-shadow: inset 0 0 0 1px var(--riksdag);
}

.step:first-child.is-active { border-color: var(--government); box-shadow: inset 0 0 0 1px var(--government); }
.step:nth-of-type(3).is-active { border-color: var(--government); box-shadow: inset 0 0 0 1px var(--government); }

.step-number {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.step strong { font-size: 20px; line-height: 1; }
.step-copy { color: var(--muted); font-size: 12px; line-height: 1.25; }
.flow-arrow { color: var(--muted); font-size: 23px; text-align: center; }

.review-step {
  position: relative;
  width: 100%;
  height: 52px;
  margin-top: 8px;
  display: grid;
  grid-template-columns: 34px 22px auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.review-step .step-number { position: static; }
.review-step strong { display: block; margin-top: 1px; font-size: 14px; }
.return-arrow { color: var(--riksdag); font-size: 25px; }
.review-copy { justify-self: end; color: var(--muted); font-size: 12px; }

.step-detail {
  height: 60px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}

.step-detail p { font-size: 13px; line-height: 1.35; }

.parliamentarism {
  height: 218px;
  display: grid;
  grid-template-columns: 235px 1fr;
  gap: 14px;
  padding-top: 13px;
}

.parliamentarism-copy {
  padding: 12px 13px;
  border-left: 4px solid var(--riksdag);
  background: var(--surface-soft);
}

.parliamentarism-copy h2 {
  margin: 2px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
}

.parliamentarism-copy p { font-size: 13px; line-height: 1.4; }

.confidence-card {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.scenario-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 6px;
  background: var(--surface-soft);
}

.scenario-switch button {
  min-height: 31px;
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.scenario-switch button.is-selected {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--ink) 12%, transparent);
}

.confidence-result {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 10px 9px 8px 13px;
  border-left: 3px solid var(--positive);
}

.confidence-result.is-warning { border-left-color: var(--warning); }
.confidence-result strong { font-size: 14px; line-height: 1.25; }
.confidence-result p { color: var(--muted); font-size: 12px; line-height: 1.35; }

.threshold {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.threshold b { color: var(--ink); font-size: 12px; }

.info-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 70px #0006;
}

.info-dialog::backdrop { background: #0b1110a6; }

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

.dialog-header h2 { font-family: Georgia, serif; font-size: 22px; }
.dialog-header button { border: 0; font-family: inherit; font-size: 24px; }
.info-dialog > p { margin: 14px 16px; font-size: 14px; line-height: 1.5; }
.info-dialog .sources { color: var(--muted); font-size: 12px; }
.info-dialog a { color: var(--riksdag); }

@media (max-width: 560px), (max-height: 540px) {
  html, body { overflow: auto; }
  .tool { height: auto; min-height: 100%; overflow: visible; }
  .process-row { grid-template-columns: 1fr; gap: 6px; }
  .flow-arrow { transform: rotate(90deg); line-height: 18px; }
  .step { height: 88px; }
  .parliamentarism { height: auto; grid-template-columns: 1fr; padding-bottom: 14px; }
  .review-copy { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

