:root {
  --ink: #13342c;
  --ink-2: #3c5a52;
  --paper: #f7f1e6;
  --paper-2: #efe6d4;
  --card: #fffdf8;
  --line: #d9cdb6;
  --coral: #a83f24;
  --on-coral: #ffffff;
  --field: #857864;
  --sun: #f2b544;
  --leaf: #2f6b56;
  --focus: #1b5fd1;
  --fs: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f2ead9; --ink-2: #c3b9a5; --paper: #10201c; --paper-2: #162a25;
    --card: #1b302a; --line: #2f4840; --coral: #ff8a66; --leaf: #7fc8a9; --focus: #8fb6ff;
    --on-coral: #10201c; --field: #6b8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #f2ead9; --ink-2: #c3b9a5; --paper: #10201c; --paper-2: #162a25;
  --card: #1b302a; --line: #2f4840; --coral: #ff8a66; --leaf: #7fc8a9; --focus: #8fb6ff;
    --on-coral: #10201c; --field: #6b8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: var(--fs); scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif; line-height: 1.6;
}
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 .5em; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }

.skip { position: absolute; inset-inline-start: 8px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 14px; z-index: 10; transform: translateY(-300%); }
.skip:focus { transform: none; }

.crisis { background: var(--ink); color: var(--paper); font-size: .82rem; padding: 8px 16px; text-align: center; }
.crisis a { font-weight: 700; }

.top {
  display: flex; align-items: center; gap: 20px; padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 5; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: "Fraunces", serif; font-weight: 700; font-size: 1.4rem; text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; font-size: .92rem; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
.tools { display: flex; gap: 6px; }
.tools button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; min-width: 40px; height: 36px; cursor: pointer; }

.hero { padding: clamp(40px, 8vw, 96px) clamp(16px, 4vw, 48px) 48px; max-width: 1100px; margin: 0 auto; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; color: var(--coral); font-weight: 700; margin: 0 0 14px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); max-width: 16ch; }
.lede { font-size: 1.12rem; max-width: 60ch; color: var(--ink-2); }

.setup { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; margin-top: 32px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend, .nation { font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pills button {
  border: 1.5px solid var(--ink); background: transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: .9rem;
}
.pills button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.topics { margin-bottom: 18px; }
.topics button { border-width: 1px; border-color: var(--line); padding: 5px 13px; font-size: .82rem; }
.topics button[aria-pressed="true"] { border-color: var(--ink); }
.nation { display: flex; flex-direction: column; gap: 6px; }
select, input, textarea {
  border: 1.5px solid var(--field); background: var(--card); border-radius: 10px; padding: 9px 12px; width: 100%;
}

.band { padding: 64px clamp(16px, 4vw, 48px); }
.band.alt { background: var(--paper-2); }
.band > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.head h2 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); margin: 0; }
.head p { margin: 6px 0 0; max-width: 60ch; color: var(--ink-2); flex-basis: 100%; }
.head input { max-width: 360px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.sit {
  text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px;
  cursor: pointer; display: flex; flex-direction: column; gap: 10px; min-height: 130px; transition: transform .15s, border-color .15s;
}
.sit:hover { transform: translateY(-2px); border-color: var(--ink); }
.sit[aria-expanded="true"] { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral) inset; }
.sit .t { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.08rem; line-height: 1.25; }
.tag { align-self: flex-start; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--leaf); }
.tag.urgent { color: var(--coral); }
.empty { color: var(--ink-2); }

.result {
  margin-top: 28px; background: var(--card); border-radius: 20px; border: 1.5px solid var(--ink);
  padding: clamp(20px, 4vw, 40px); display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px;
}
.result h3 { font-size: clamp(1.4rem, 3vw, 2rem); }
.result .plain { font-size: 1.1rem; border-left: 4px solid var(--sun); padding-left: 14px; }
.result h4 { margin: 22px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--coral); }
.result ul, .result ol { padding-left: 1.2em; margin: 0; }
.result li { margin-bottom: 6px; }
.say {
  background: var(--ink); color: var(--paper); border-radius: 14px; padding: 18px 20px; font-family: "Fraunces", serif; font-size: 1.12rem; position: relative;
}
.say button { margin-top: 12px; background: var(--sun); color: #13342c; border: 0; border-radius: 999px; padding: 6px 14px; font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 700; cursor: pointer; font-size: .85rem; }
.lawlist { list-style: none; padding: 0 !important; }
.lawlist li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.lawlist a { font-weight: 700; }
.lawlist small { display: block; color: var(--ink-2); }
.nationNote { background: var(--paper-2); border-radius: 12px; padding: 12px 14px; font-size: .92rem; }
.rowbtns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn, .actions button {
  border: 1.5px solid var(--ink); background: transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; text-decoration: none; font-weight: 700; font-size: .9rem;
}
.btn.primary, .actions .primary { background: var(--coral); border-color: var(--coral); color: var(--on-coral); }
.result h4.first { margin-top: 0; }

.letterwrap { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; }
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 22px; }
#letterForm { display: flex; flex-direction: column; gap: 14px; }
#letterForm label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .88rem; }
#letterFields { display: flex; flex-direction: column; gap: 14px; }
.paper pre {
  white-space: pre-wrap; font-family: "Atkinson Hyperlegible", sans-serif; margin: 0 0 16px; font-size: .95rem; max-height: 560px; overflow: auto;
}
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#copied { color: var(--leaf); font-weight: 700; }

.ladder { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; counter-reset: step; }
.ladder li {
  counter-increment: step; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; position: relative;
}
.ladder li::before {
  content: counter(step); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: var(--paper); font-weight: 700; margin-bottom: 10px;
}
@media (min-width: 900px) {
  .ladder li:nth-child(1) { transform: translateY(56px); }
  .ladder li:nth-child(2) { transform: translateY(42px); }
  .ladder li:nth-child(3) { transform: translateY(28px); }
  .ladder li:nth-child(4) { transform: translateY(14px); }
}
.ladder strong { display: block; font-family: "Fraunces", serif; font-size: 1.05rem; margin-bottom: 4px; }
.ladder p { margin: 0; font-size: .9rem; color: var(--ink-2); }

.gloss { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 0; }
.gloss div { background: var(--card); border-radius: 14px; padding: 14px 16px; border: 1px solid var(--line); }
.gloss dt { font-weight: 700; }
.gloss dd { margin: 4px 0 0; color: var(--ink-2); font-size: .92rem; }

footer { padding: 32px clamp(16px, 4vw, 48px); border-top: 1px solid var(--line); font-size: .88rem; color: var(--ink-2); }
footer p { max-width: 1100px; margin: 0 auto; }

/* ---------- Languages ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.langsel { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 0 4px 0 10px; height: 36px; }
.langsel svg { width: 18px; height: 18px; flex: none; }
.langsel select { border: 0; background: transparent; padding: 4px 6px; width: auto; font-size: .88rem; cursor: pointer; }
.chip { display: inline-block; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 1px 12px; font-size: .9rem; }
.badge { display: inline-block; border: 1px dashed var(--ink-2); border-radius: 999px; padding: 1px 10px; font-size: .78rem; color: var(--ink-2); }
.note, .notice { font-size: .9rem; color: var(--ink-2); }
.notice { background: var(--paper-2); border-radius: 10px; padding: 10px 14px; margin-top: 14px; }
.sayLabel { font-size: .82rem; font-weight: 700; margin: 12px 0 6px; color: var(--ink-2); }
.say.en { background: var(--card); color: var(--ink); border: 1.5px solid var(--ink); font-family: "Atkinson Hyperlegible", sans-serif; font-size: 1rem; }

/* Logical properties so right-to-left layouts mirror correctly */
.top nav { margin-left: 0; margin-inline-start: auto; }
.sit { text-align: start; }
.result .plain { border-left: 0; padding-left: 0; border-inline-start: 4px solid var(--sun); padding-inline-start: 14px; }
.result ul, .result ol { padding-left: 0; padding-inline-start: 1.2em; }
[dir="rtl"] .result ul[dir="ltr"], [dir="rtl"] .result ol[dir="ltr"] { padding-inline-start: 1.2em; }
.lawlist[dir="ltr"], .lawlist { padding-inline-start: 0 !important; }

/* Arabic-script languages: no letter-spacing or uppercase (it breaks joined letters), dedicated fonts */
[dir="rtl"] .eyebrow, [dir="rtl"] .tag, [dir="rtl"] .result h4, [dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { letter-spacing: 0; text-transform: none; }
html[lang="ar"] body, html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] .sit .t, html[lang="ar"] .say, html[lang="ar"] .brand {
  font-family: "Noto Naskh Arabic", "Atkinson Hyperlegible", system-ui, sans-serif;
}
html[lang="ur"] body, html[lang="ur"] h1, html[lang="ur"] h2, html[lang="ur"] h3, html[lang="ur"] .sit .t, html[lang="ur"] .say, html[lang="ur"] .brand {
  font-family: "Noto Nastaliq Urdu", "Atkinson Hyperlegible", system-ui, sans-serif;
}
html[lang="ur"] body { line-height: 2.1; }
html[lang="ur"] h1, html[lang="ur"] h2, html[lang="ur"] h3, html[lang="ur"] .sit .t { line-height: 1.9; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { line-height: 1.45; }
[dir="rtl"] [lang="en"], [dir="rtl"] .say.en { font-family: "Atkinson Hyperlegible", system-ui, sans-serif; line-height: 1.6; }
.brand { font-family: "Fraunces", serif !important; }

/* ---------- Static pages (A to Z, topic pages, About, Privacy…) ---------- */
.doc { max-width: 780px; margin: 0 auto; padding: 40px 16px 72px; }
.doc h1 { font-size: clamp(2rem, 5vw, 3rem); margin-top: 10px; }
.doc h2 { font-size: 1.45rem; margin: 2em 0 .6em; }
.doc h3 { font-size: 1.1rem; margin: 1.4em 0 .4em; font-family: "Atkinson Hyperlegible", sans-serif; }
.doc ul, .doc ol { padding-inline-start: 1.3em; }
.doc li { margin-bottom: 6px; }
.doc .lede { color: var(--ink-2); font-size: 1.15rem; }
.doc .plain { border-inline-start: 4px solid var(--sun); padding-inline-start: 14px; color: var(--ink); }
.doc .say { margin: 0; }
.doc .lawlist { list-style: none; padding: 0; display: grid; gap: 8px; }
.doc .er-list { padding: 0; }
.crumbs { font-size: .88rem; color: var(--ink-2); }
.cta { margin: 22px 0 6px; }
.nations dt { font-weight: 700; margin-top: 12px; }
.nations dd { margin: 4px 0 0; color: var(--ink-2); }
.easyblock { margin-top: 2.5em; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 8px 22px 18px; }
.reviewed { margin-top: 3em; font-size: .9rem; color: var(--ink-2); }
.az { list-style: none; padding: 0 !important; display: grid; gap: 10px; }
.az li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 0; }
.az a { font-weight: 700; display: block; }
.az span { font-size: .9rem; color: var(--ink-2); }
mark.todo { background: #ffe08a; color: #3a2a00; padding: 0 4px; border-radius: 4px; }
.footlinks { display: flex; flex-wrap: wrap; gap: 8px 20px; max-width: 1100px; margin: 14px auto 0; }

/* ---------- Sign-up ---------- */
.signup { margin: 24px 0 8px; }
.signup form { display: flex; flex-direction: column; gap: 10px; }
.signup label { font-weight: 700; }
.signup fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.signup legend { font-weight: 400; color: var(--ink-2); font-size: .92rem; padding: 0 6px; }
.signup .hint { margin: -4px 0 4px; font-size: .88rem; color: var(--ink-2); }
.signup .consent { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 6px 0; }
.signup .consent input { width: 22px; height: 22px; flex: none; margin-top: 3px; accent-color: var(--leaf); }
.signup button { align-self: flex-start; }
.formStatus { min-height: 1.4em; margin: 0; font-weight: 700; }
.formStatus.error { color: var(--coral); }
.signup [aria-invalid="true"] { border-color: var(--coral); }
.done h2 { margin-top: 0; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.updates { text-align: center; }
.updates .btn { display: inline-block; margin-top: 8px; }

/* ---------- Easy Read ---------- */
.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.erBtn { display: flex; align-items: center; gap: 6px; padding: 0 14px; font-weight: 700; font-size: .88rem; }
.erBtn svg { width: 18px; height: 18px; }
.tools button.erBtn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

html.easy { font-size: calc(var(--fs) * 1.15); }
html.easy body { line-height: 1.7; }
.easy .eyebrow, .easy .sit .tag { display: none; }
.easy .hero h1 { font-size: clamp(2rem, 5vw, 3rem); max-width: 22ch; }
.easy .lede { font-size: 1.2rem; max-width: 40ch; }
.easy .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.easy .sit { flex-direction: row; align-items: center; gap: 16px; min-height: 96px; }
.easy .sit .ico { width: 52px; height: 52px; flex: none; padding: 10px; border-radius: 14px; background: var(--paper-2); color: var(--leaf); }
.easy .sit .t { font-family: "Atkinson Hyperlegible", sans-serif; font-size: 1.1rem; }
.easy .result { grid-template-columns: 1fr; max-width: 760px; }
.er-head { display: flex; align-items: center; gap: 18px; margin-bottom: 8px; }
.er-head .ico { width: 72px; height: 72px; flex: none; padding: 14px; border-radius: 18px; background: var(--sun); color: #13342c; }
.er-head h3 { margin: 0; font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 700; }
.er h4 { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin-top: 28px; }
.er-list { list-style: none; padding: 0 !important; margin: 0; }
.er-list li { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 1.1rem; margin: 0; }
.er-list .ico { width: 56px; height: 56px; flex: none; padding: 11px; border-radius: 14px; background: var(--paper-2); color: var(--ink); }
.er-list strong { color: var(--ink); background: linear-gradient(transparent 62%, color-mix(in srgb, var(--sun) 55%, transparent) 62%); }
.er .say { font-family: "Atkinson Hyperlegible", sans-serif; }
.erlaw { margin-top: 26px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.erlaw summary { cursor: pointer; font-weight: 700; }
.erlaw .lawlist { margin-top: 12px; }

@media (max-width: 860px) {
  .result, .letterwrap { grid-template-columns: 1fr; }
  .ladder { grid-template-columns: 1fr; }
  .top nav { order: 3; width: 100%; margin-inline-start: 0; }
  .tools { margin-inline-start: auto; flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .tools { order: 2; width: 100%; margin-inline-start: 0; }
  .langsel { flex: 1; }
  .langsel select { width: 100%; }
}

@media print {
  body * { visibility: hidden; }
  #letterOut, #letterOut * { visibility: visible; }
  #letterOut { position: absolute; inset: 0; max-height: none; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
