:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1f2a2e;
  --muted: #5d6a6d;
  --line: #e2ddd1;
  --accent: #1f6f66;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --warm: #c9772b;
  --neg: #a4553b;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a1c; --surface: #1b2427; --ink: #eef1ef; --muted: #9fb0b0; --line: #2c3a3d;
    --accent: #5cc0b0; --accent-ink: #0d1a18; --accent-soft: #1d3a36; --warm: #e0a060; --neg: #d98a6c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 17px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 680px; margin: 0 auto; padding: 32px 16px 64px; }
.hidden { display: none !important; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; }
.intro { margin-top: 8vh; }
.center { text-align: center; }
h1 { font-size: 30px; line-height: 1.35; margin: 4px 0 12px; font-weight: 700; }
h2 { font-size: 22px; line-height: 1.5; margin: 0 0 16px; font-weight: 600; }
h3 { font-size: 17px; margin: 0 0 8px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 14px; margin: 0; }
.lead { color: var(--muted); margin: 0 0 20px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 24px; }
.facts div { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.field-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
#name-form input {
  font: inherit; width: 100%; padding: 12px 14px; margin-bottom: 14px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
}
#name-form input:focus { outline: none; border-color: var(--accent); }
#name-form .error { margin: -6px 0 12px; }
.rules { padding-inline-start: 22px; margin: 0 0 24px; }
.rules li { margin-bottom: 10px; }
.btn { font: inherit; border: 0; cursor: pointer; border-radius: 12px; padding: 13px 26px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.link { background: none; color: var(--accent); padding: 12px 0; margin-top: 8px; display: block; }
.btn:focus-visible, .opt:focus-visible { outline: 3px solid var(--warm); outline-offset: 2px; }

.progress { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.progress span { white-space: nowrap; min-width: 118px; }
.bar { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s ease; }

.question { animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.context { color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.activity { font-size: 21px; font-weight: 600; background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; margin: -4px 0 18px; }
.options { display: grid; gap: 10px; }
.opt {
  font: inherit; text-align: start; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--accent); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt:disabled { cursor: default; }
.scale { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale .opt { text-align: center; font-size: 15px; padding: 14px 6px; line-height: 1.45; }
@media (max-width: 560px) { .scale { grid-template-columns: 1fr; } .scale .opt { text-align: start; padding: 13px 16px; } }
.error { color: var(--neg); margin-top: 12px; }

.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 8px auto 20px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.code { display: flex; gap: 10px; flex-wrap: wrap; }
.code b { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 8px 16px; font-size: 18px; }
.code b.soft { background: var(--accent-soft); color: var(--ink); }
.section-title { margin: 32px 0 14px; font-size: 19px; }
.dims { display: grid; gap: 12px; }
.dim { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.dim header { display: flex; align-items: baseline; gap: 10px; }
.dim .rank { color: var(--muted); font-size: 14px; min-width: 22px; }
.dim h3 { margin: 0; font-size: 18px; }
.dim .tag { font-size: 12px; color: var(--accent); border: 1px solid currentColor; border-radius: 99px; padding: 0 10px; }
.dim .tag.warm { color: var(--warm); }
.dim header .tag:first-of-type { margin-inline-start: auto; }
.dim p { margin: 4px 0 10px; color: var(--muted); font-size: 15px; }
.dim .mixed-note { margin-top: -6px; font-size: 14px; color: var(--ink); background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.stack .sp, .legend .sp { background: var(--accent); }
.stack .p, .legend .p { background: var(--accent); opacity: .5; }
.stack .n, .legend .n { background: var(--line); }
.stack .m, .legend .m { background: var(--neg); opacity: .45; }
.stack .sm, .legend .sm { background: var(--neg); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 8px; border-radius: 3px; display: inline-block; }
.legend .n { background: var(--muted); opacity: .35; }
.stability { margin: 16px 0 0; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.h2h-card { margin-top: 16px; }
.lead.small { font-size: 14px; margin-bottom: 12px; }
.h2h { list-style: none; margin: 0; padding: 0; }
.h2h li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.h2h li:last-child { border-bottom: 0; }
.h2h .score { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.counts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); margin-top: 8px; }
.counts strong { color: var(--ink); font-weight: 600; }
.note { margin-top: 24px; font-size: 15px; }
.note p { color: var(--muted); margin: 0 0 8px; }
.meta { font-size: 12px; direction: ltr; text-align: end; word-break: break-all; }
