@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazirmatn;
  src: url("/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #efe6d8;
  --bg-2: #f7f1e7;
  --panel: rgba(255, 250, 244, 0.84);
  --ink: #1c1712;
  --muted: #655c53;
  --line: rgba(48, 36, 24, 0.1);
  --accent: #8d4630;
  --accent-soft: rgba(141, 70, 48, 0.12);
  --button: #241c16;
  --button-text: #f6f0e6;
  --chip: rgba(255, 252, 247, 0.72);
  --negative: #8d3b3b;
  --positive: #1d6b48;
  --neutral: #3d5270;
  --shadow: 0 24px 60px rgba(72, 46, 22, 0.08);
  --track: rgba(48, 36, 24, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e;
    --bg-2: #1c1814;
    --panel: rgba(34, 28, 23, 0.9);
    --ink: #f4eee4;
    --muted: #b7ab9d;
    --line: rgba(244, 238, 228, 0.12);
    --accent: #e2a88a;
    --accent-soft: rgba(226, 168, 138, 0.16);
    --button: #f3eadf;
    --button-text: #1c1712;
    --chip: rgba(255, 248, 238, 0.05);
    --negative: #e07a7a;
    --positive: #7dcea5;
    --neutral: #9eb4d4;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    --track: rgba(244, 238, 228, 0.1);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html.restoring body { visibility: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(141, 70, 48, 0.16), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(61, 82, 112, 0.14), transparent 46%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

button, input { font: inherit; }

a { color: inherit; }

.wrap {
  width: min(740px, calc(100% - 32px));
  margin-inline: auto;
  padding-block: 28px 72px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 22px 22px;
  backdrop-filter: blur(10px);
}

.panel + .panel { margin-top: 16px; }

.ornament {
  width: 46px;
  height: 4px;
  border-radius: 99px;
  margin-bottom: 16px;
  background: linear-gradient(to left, var(--accent), transparent);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3.4vw, 2.25rem);
  line-height: 1.55;
  font-weight: 700;
  text-wrap: balance;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.lede, .total {
  margin: 14px 0 0;
  color: var(--muted);
}

.repeat {
  margin: 10px 0 0;
  font-size: 1.02rem;
}

.toast, .form-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
}

.toast {
  background: color-mix(in srgb, var(--positive) 14%, transparent);
  color: var(--positive);
}

.form-error {
  background: color-mix(in srgb, var(--negative) 12%, transparent);
  color: var(--negative);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--chip);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.choice:hover { transform: translateY(-1px); }

.choice:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.choice input {
  position: absolute;
  inset-inline-start: 16px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dot-ui {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ink) 35%, transparent);
  display: grid;
  place-items: center;
}

.dot-ui::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.16s ease;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:has(input:checked) .dot-ui {
  border-color: var(--accent);
}

.choice:has(input:checked) .dot-ui::after { transform: scale(1); }

.choice-label { font-size: 1.05rem; font-weight: 500; }

.actions { margin-top: 18px; }

button, .button {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

button:hover, .button:hover { filter: brightness(1.08); }

.form:not(:has(input:checked)) button { opacity: 0.5; }

.fine {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.stack {
  display: flex;
  height: 14px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.stack span { display: block; min-width: 8px; }
.stack .negative { background: var(--negative); }
.stack .positive { background: var(--positive); }
.stack .neutral { background: var(--neutral); }
.stack.is-empty span { flex: 1; min-width: 0; background: var(--track); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stat {
  padding: 14px 12px 12px;
  border-radius: 18px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--tone, var(--line));
}

.stat.negative { --tone: var(--negative); }
.stat.positive { --tone: var(--positive); }
.stat.neutral { --tone: var(--neutral); }

.stat-label, .stat-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-value {
  margin: 4px 0;
  color: var(--tone);
  font-size: clamp(1.55rem, 4vw, 2.3rem);
  font-weight: 700;
  line-height: 1.15;
}

.group + .group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.group-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.05rem;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tone);
}

.group.negative { --tone: var(--negative); }
.group.positive { --tone: var(--positive); }
.group.neutral { --tone: var(--neutral); }

.group-meta {
  color: var(--muted);
  font-weight: 600;
}

.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.option-meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track {
  height: 7px;
  margin-top: 6px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--tone);
  animation: fill 0.7s ease forwards;
}

@keyframes fill { to { width: var(--w); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .choice, .choice .dot-ui::after { transition: none; }
  .track span { animation: none; width: var(--w); }
}

@media (max-width: 640px) {
  .panel { padding: 22px 16px 16px; border-radius: 22px; }
  .stats { gap: 8px; }
  .stat { padding: 12px 10px; }
}
