:root {
  /* Airmail: envelope paper, postal-ink navy, the red/blue of airmail borders. */
  --paper: #ECF1F8;
  --card: #FFFFFF;
  --ink: #15233F;
  --ink-2: #33415C;
  --muted: #5E6B83;
  --line: #C9D4E4;
  --line-soft: #E1E8F2;
  --accent: #1E4D9B;        /* airmail blue: actions */
  --accent-ink: #FFFFFF;
  --air-red: #CC2F2B;       /* airmail red: stripes only */
  --amber: #B26B00;
  --red: #B42A26;
  --pass-bg: #DDEFE5; --pass-fg: #1C6B45;
  --warn-bg: #FBEBCF; --warn-fg: #7A4A00;
  --fail-bg: #F8DEDC; --fail-fg: #A3231F;
  --info-bg: #E3E9F3; --info-fg: #33476B;
  --air: repeating-linear-gradient(-45deg, var(--air-red) 0 11px, #FFFFFF 11px 18px, var(--accent) 18px 29px, #FFFFFF 29px 36px);
  --serif: 'Archivo Narrow', 'Arial Narrow', system-ui, sans-serif;   /* display: postal-form labels */
  --sans: Archivo, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --pad: clamp(20px, 5.5vw, 80px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body::before { content: ''; display: block; height: 6px; background: var(--air); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
a { color: var(--ink); }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); }
h1, h2, h3 { margin: 0; }
p { margin: 0; }

/* ---- Buttons ---------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { color: var(--paper); background: #0F1A30; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn-ghost:hover { border-color: var(--ink); }
.link-btn { background: none; border: 0; padding: 0; font: 500 14px var(--sans); color: var(--ink); text-decoration: underline; cursor: pointer; min-height: 44px; }

/* ---- Top bar ------------------------------------------------------------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 22px var(--pad); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font: 700 25px var(--serif); color: var(--ink); letter-spacing: -0.01em; }
.brand-dot { fill: var(--accent); }
.topbar nav { display: flex; gap: 28px; }
.topbar nav a { text-decoration: none; font-size: 15px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Home ------------------------------------------------------------------ */
.home { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(32px, 5vw, 72px); padding: clamp(32px, 5vw, 64px) var(--pad) 0; }
.intro { display: flex; flex-direction: column; gap: 26px; }
.intro h1 { font: 700 clamp(44px, 6vw, 80px)/0.98 var(--serif); letter-spacing: -0.015em; max-width: 12em; }
.lede { font-size: 19px; line-height: 1.55; color: var(--ink-2); max-width: 36em; }

.address-card { background: linear-gradient(var(--card), var(--card)) padding-box, var(--air) border-box; border: 9px solid transparent; border-radius: 12px; box-shadow: 0 18px 40px -24px rgba(21, 35, 63, .45); padding: clamp(18px, 3vw, 28px); display: flex; flex-direction: column; gap: 16px; }
.address-card label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.address-row { display: flex; gap: 12px; align-items: stretch; }
.address-row input { flex: 1; min-width: 0; height: 58px; padding: 0 16px; font: 500 clamp(15px, 2vw, 21px) var(--mono); color: var(--ink); background: var(--paper); border: 1px dashed #9FB0CB; border-radius: 8px; }
.address-row .btn { height: 56px; padding: 0 22px; font-size: 16px; }
.address-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.address-links { display: flex; align-items: center; gap: 18px; }
.address-links a { font-weight: 500; font-size: 14px; }
.status { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot-waiting { background: var(--amber); animation: pulse 1.6s infinite; }
.dot-busy { background: var(--accent); animation: pulse .9s infinite; }
.dot-error { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }

.cta-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.cta-row .btn { height: 56px; padding: 0 28px; font-size: 17px; }
.hint { font-size: 14px; color: var(--muted); max-width: 26em; line-height: 1.45; }

.checks { display: flex; flex-direction: column; gap: 14px; padding-top: 30px; }
.checks h2 { font: 700 26px var(--serif); margin-bottom: 4px; }
.check-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.check-card h3 { font-size: 17px; font-weight: 600; }
.check-card p { font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.check-card .tags { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; padding: 36px var(--pad) 48px; margin-top: 48px; border-top: 1px solid var(--line); }
.steps p { display: flex; gap: 16px; align-items: baseline; font-size: 15px; color: var(--ink-2); }
.steps strong { color: var(--ink); }
.step-num { font: 700 38px/1 var(--serif); color: var(--air-red); }

/* ---- Report ------------------------------------------------------------------ */
.report { padding: 40px var(--pad) 64px; display: flex; flex-direction: column; gap: 24px; }
.loading { color: var(--muted); }
.notice { max-width: 640px; margin: 40px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: clamp(24px, 4vw, 40px); display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.notice h1 { font: 700 36px/1.08 var(--serif); }
.notice p { color: var(--ink-2); }
.notice .address-row { width: 100%; }

.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; }
.score-card { display: flex; gap: clamp(20px, 4vw, 44px); align-items: center; padding: clamp(20px, 3vw, 36px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
/* The grade as a rubber-stamp postmark: ring text, grade, cancellation waves.
   Ink colour follows the grade. It lands once, with a stamp "thunk". */
.postmark { display: flex; align-items: center; flex-shrink: 0; color: var(--pm-ink, var(--accent)); }
.postmark-a { --pm-ink: #1C6B45; }
.postmark-b, .postmark-c { --pm-ink: #A55F00; }
.postmark-d, .postmark-e, .postmark-f { --pm-ink: #B42A26; }
.postmark-stamp { width: 216px; height: 216px; transform: rotate(-7deg); opacity: .92; animation: stamp .42s cubic-bezier(.2, .9, .3, 1.25) both; }
.postmark-waves { width: 96px; height: 120px; margin-inline-start: -30px; opacity: .8; animation: stamp-fade .5s .18s both; }
[dir="rtl"] .postmark-waves { transform: scaleX(-1); }
.pm-ring-text { font: 700 12.5px var(--sans); letter-spacing: .16em; fill: currentColor; }
.pm-grade { font: 700 76px var(--serif); fill: currentColor; }
.pm-score { font: 700 17px var(--sans); fill: currentColor; }
@keyframes stamp { from { transform: rotate(-2deg) scale(1.28); opacity: 0; } 70% { opacity: .95; } to { transform: rotate(-7deg) scale(1); opacity: .92; } }
@keyframes stamp-fade { from { opacity: 0; } to { opacity: .8; } }
.score-text { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.score-text h1 { font: 700 clamp(30px, 3.2vw, 44px)/1.04 var(--serif); }
.score-text dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.score-text dt { color: var(--muted); }
.score-text dd { margin: 0; overflow-wrap: anywhere; }
.score-text dd.mono { font-size: 13px; }

.fix-panel { background: var(--ink); color: var(--paper); border-radius: 12px; padding: clamp(20px, 3vw, 32px); display: flex; flex-direction: column; gap: 12px; }
.fix-panel h2 { font: 700 27px var(--serif); }
.fix-panel ol { list-style: none; margin: 0; padding: 0; }
.fix-panel li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 13px 0; border-top: 1px solid #2B3B5C; }
.fix-panel li div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fix-panel li span { font-size: 14px; color: #C3CCDC; overflow-wrap: anywhere; }
.fix-panel .pts { font: 500 16px var(--mono); color: #F2C98A; flex-shrink: 0; }
.fix-panel p { color: #C3CCDC; }

.categories { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.category { display: flex; flex-direction: column; gap: 8px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.category:hover { border-color: var(--ink); color: var(--ink); }
.cat-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cat-name { font-size: 15px; font-weight: 600; }
.cat-value { font: 700 23px var(--serif); }
.cat-points { font: 13px var(--mono); color: var(--muted); }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.badge-pass { background: var(--pass-bg); color: var(--pass-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-fail { background: var(--fail-bg); color: var(--fail-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }

.results-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.results-head h2 { font: 700 34px var(--serif); }
.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px; background: var(--card); border: 1px solid #C9C2B4; border-radius: 999px; font: 500 15px var(--sans); color: var(--ink); cursor: pointer; }
.toggle-track { width: 34px; height: 20px; padding: 2px; border-radius: 999px; background: #C9C2B4; display: flex; transition: background .15s; }
.toggle-knob { width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle[aria-pressed="true"] .toggle-track { background: var(--accent); }
.toggle[aria-pressed="true"] .toggle-knob { transform: translateX(14px); }

.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 20px 22px; }
.panel-head h3 { font-size: 20px; font-weight: 600; }
.panel-sum { font-size: 14px; color: var(--muted); }
.panel-note { padding: 0 22px 18px; font-size: 14px; color: var(--muted); }
.empty-note { display: none; padding: 16px 22px; border-top: 1px solid var(--line-soft); font-size: 14px; color: var(--muted); }

.row { display: flex; gap: 16px; padding: 16px 22px; border-top: 1px solid var(--line-soft); }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.row-title { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.row-title .pts { font: 500 14px var(--mono); color: var(--warn-fg); }
.row p { font-size: 14px; color: var(--ink-2); }
.record { display: block; padding: 8px 10px; background: var(--paper); border-radius: 6px; font: 12.5px/1.5 var(--mono); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }

.rules-head, .rules-row { display: grid; grid-template-columns: minmax(0, 190px) 70px minmax(0, 1fr); gap: 14px; padding: 11px 22px; font-size: 14px; align-items: baseline; }
.rules-head { background: var(--paper); font-size: 12px; font-weight: 600; color: var(--muted); }
.rules-row { border-top: 1px solid var(--line-soft); }
.rules-row .mono { font-size: 13px; overflow-wrap: anywhere; }
.rules-row span:last-child { color: var(--ink-2); }
.num { text-align: end; }
.neg { color: var(--pass-fg); }
.posi { color: var(--warn-fg); }

.lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; padding: 0 22px 14px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.list-target { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.list-status { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.status-clear { color: var(--pass-fg); }
.status-listed { color: var(--fail-fg); }
.status-error { color: var(--info-fg); }

.raw summary { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; cursor: pointer; list-style: none; }
.raw summary::-webkit-details-marker { display: none; }
.raw summary h3 { font-size: 20px; font-weight: 600; }
.summary-hint { font-size: 14px; font-weight: 500; text-decoration: underline; }
.raw[open] .summary-hint { font-size: 0; }
.raw[open] .summary-hint::after { content: attr(data-hide); font-size: 14px; }
.raw pre { margin: 0; padding: 20px 22px; background: var(--ink); color: #DCE4F2; font: 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow: auto; }

/* Show only issues */
.issues-only .row.is-pass, .issues-only .row.is-info,
.issues-only .rules-row.is-pass, .issues-only .list-item.is-pass { display: none; }
.issues-only .panel:not(.has-issues) .empty-note { display: block; }
.issues-only .panel:not(.has-issues) .rules,
.issues-only .panel:not(.has-issues) .lists { display: none; }

/* ---- Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .categories { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero, .results, .home { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .score-card { flex-direction: column; align-items: flex-start; }
  .postmark-stamp { width: 176px; height: 176px; }
  .postmark-waves { width: 76px; height: 96px; }
  .categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .lists { grid-template-columns: minmax(0, 1fr); }
  .rules-head, .rules-row { grid-template-columns: minmax(0, 1fr) 60px; }
  .rules-head span:last-child, .rules-row span:last-child { grid-column: 1 / -1; }
  .address-row { flex-direction: column; }
  .topbar nav a:not(.lang-switch) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Print / Save as PDF ----------------------------------------------------- */
@media print {
  body { background: #fff; }
  .top-actions, .toggle, .topbar nav { display: none !important; }
  .panel, .score-card, .category { break-inside: avoid; }
  .raw pre { max-height: none; }
  .fix-panel { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Grades ------------------------------------------------------------------ */
.grade { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid currentColor; box-shadow: inset 0 0 0 2px var(--card), inset 0 0 0 3px currentColor; font: 700 13px var(--serif); transform: rotate(-9deg); flex-shrink: 0; }
.grade-a { color: #1C6B45; }
.grade-b, .grade-c { color: #A55F00; }
.grade-d, .grade-e, .grade-f { color: #B42A26; }
.cat-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---- Blocklists: meanings, allowlists ----------------------------------------- */
.list-meaning { display: block; font-size: 12.5px; color: var(--fail-fg); }
.list-item.is-pass .list-meaning { color: var(--pass-fg); }
.list-item.is-warn .list-meaning { color: var(--warn-fg); }
.list-group { display: flex; justify-content: space-between; gap: 10px; padding: 14px 22px 4px; font-size: 15px; font-weight: 600; }
.list-group span { font-size: 13px; font-weight: 400; color: var(--muted); }
.tone-pass { color: var(--pass-fg); }
.tone-fail { color: var(--fail-fg); }
.tone-warn { color: var(--warn-fg); }
.tone-info { color: var(--info-fg); }

/* ---- Delivery path (hops) ------------------------------------------------------ */
.path { margin-top: 24px; }
.hops { list-style: none; margin: 0; padding: 0 22px 12px; }
.hop { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.hop-num { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line); font: 600 13px var(--sans); }
.hop-ours .hop-num { background: var(--ink); color: var(--card); border-color: var(--ink); }
.hop-route { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.hop-arrow { color: var(--muted); }
[dir="rtl"] .hop-arrow { display: inline-block; transform: scaleX(-1); }
.hop-tag { padding: 1px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info-fg); font-size: 11.5px; font-weight: 600; }
.hop-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.hop-sub .badge { min-width: 0; height: 22px; font-size: 11.5px; }
.hop-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hop-delay { font: 600 13px var(--mono); color: var(--ink-2); }
.hop-delay.is-slow { color: var(--warn-fg); }
.hop-start .hop-num { font-size: 15px; }

/* ---- Headers table ----------------------------------------------------------------- */
.hdrs { padding: 0 22px 10px; }
.hdr-row { display: grid; grid-template-columns: minmax(0, 170px) 96px 72px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.hdr-name { font-weight: 500; overflow-wrap: anywhere; }
.hdr-imp { font-size: 12px; color: var(--muted); }
.imp-required { color: var(--ink); font-weight: 600; }
.hdr-value { font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.issues-only .hdr-row.is-pass, .issues-only .hdr-row.is-info { display: none; }
.issues-only .list-item.is-info { display: none; }

@media (max-width: 720px) {
  .hop { grid-template-columns: 30px minmax(0, 1fr); }
  .hop-meta { grid-column: 2; flex-direction: row; align-items: center; gap: 12px; }
  .hdr-row { grid-template-columns: minmax(0, 1fr) auto; }
  .hdr-imp { display: none; }
  .hdr-value { grid-column: 1 / -1; }
}

/* ---- Progress tracker and arrival banner -------------------------------------- */
.dot-pass { background: var(--pass-fg); }
.tracker-slot { margin: 18px 0 4px; }
.tracker { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; counter-reset: step; }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: 12.5px; color: var(--muted); }
/* connector line between steps */
.step:not(:first-child)::before { content: ''; position: absolute; top: 21px; inset-inline-end: calc(50% + 26px); width: calc(100% - 52px + 6px); height: 2px; background: var(--line); }
.step.is-done:not(:first-child)::before, .step.is-active:not(:first-child)::before { background: var(--pass-fg); }
.step-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line); color: var(--muted); }
.step.is-done .step-icon { background: var(--pass-bg); border-color: var(--pass-fg); color: var(--pass-fg); }
.step.is-done { color: var(--pass-fg); }
.step.is-active { color: var(--ink); font-weight: 600; }
.step.is-active .step-icon { background: var(--card); border-color: var(--accent); color: var(--accent); }
/* waiting: a ripple around the inbox; analyzing: the magnifier sweeps */
.step-waiting.is-active .step-icon::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: ripple 1.8s ease-out infinite; }
.step-analyzing.is-active .step-icon svg { animation: sweep 1.2s ease-in-out infinite; }
@keyframes ripple { 0% { transform: scale(.85); opacity: .7; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes sweep { 0%, 100% { transform: translate(-2px, 0) rotate(-8deg); } 50% { transform: translate(2px, -1px) rotate(8deg); } }

.arrival { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--pass-bg); color: var(--pass-fg); animation: pop .35s ease-out; }
.arrival[hidden] { display: none; }
.arrival-icon { display: inline-flex; animation: bounce 1s ease-in-out 2; }
.arrival-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.arrival-text strong { font-size: 17px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }
.notice .tracker-slot { margin: 0 0 22px; }
.notice.is-arrived h1 { color: var(--pass-fg); }

/* ---- Blocklist picker (home) and lookup form (report) ------------------------------ */
.rbl-options { margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.rbl-options summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; font-weight: 600; font-size: 15px; }
.rbl-options summary::-webkit-details-marker { display: none; }
.rbl-summary-title { display: inline-flex; align-items: center; gap: 8px; }
.rbl-count { font-size: 13px; font-weight: 500; color: var(--muted); }
.rbl-body { padding: 0 18px 16px; border-top: 1px solid var(--line-soft); }
.rbl-body .hint { margin: 12px 0; font-size: 13.5px; color: var(--muted); }
.rbl-body fieldset { margin: 0 0 14px; padding: 0; border: 0; }
.rbl-body legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.rbl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.rbl-item { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; padding: 5px 0; font-size: 14px; cursor: pointer; }
.rbl-item input { width: 17px; height: 17px; accent-color: var(--accent); }
.rbl-zone { grid-column: 2; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.rbl-note { margin-inline-start: 6px; padding: 0 6px; border-radius: 999px; background: var(--info-bg); color: var(--info-fg); font-size: 11px; font-weight: 600; }
.custom-lists { list-style: none; margin: 0 0 8px; padding: 0; }
.custom-lists li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.custom-lists li .link-btn { margin-inline-start: auto; min-height: 32px; font-size: 13px; }
.custom-add { display: flex; gap: 8px; flex-wrap: wrap; }
.custom-add[hidden] { display: none; }
.custom-add input { flex: 1 1 180px; min-width: 0; height: 40px; padding: 0 12px; font: 14px var(--mono); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.custom-add select { height: 40px; padding: 0 8px; font: 14px var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.custom-add .btn { min-height: 40px; }
.rbl-saved { margin: 4px 0 0; font-size: 13px; color: var(--pass-fg); min-height: 1.2em; }
.lookup { border-top: 1px solid var(--line-soft); margin-top: 6px; }
.lookup-form { padding: 6px 22px 10px; }
[dir="rtl"] .custom-add input { direction: ltr; text-align: right; }

@media (max-width: 720px) {
  .rbl-grid { grid-template-columns: minmax(0, 1fr); }
  .step-label { font-size: 11.5px; }
  .step-icon { width: 38px; height: 38px; }
  .step:not(:first-child)::before { top: 18px; inset-inline-end: calc(50% + 23px); width: calc(100% - 46px + 6px); }
}

/* ---- Admin page -------------------------------------------------------------------- */
.admin { max-width: 1400px; margin: 0 auto; padding: 32px var(--pad) 64px; }
.admin-login { max-width: 460px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; align-self: stretch; }
.login-form label { font-size: 14px; font-weight: 600; }
.login-form input { height: 46px; padding: 0 14px; font: 16px var(--sans); border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.form-error { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--fail-bg); color: var(--fail-fg); font-size: 14px; }
.inline-form { display: inline; margin: 0; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.admin-head h1 { font: 700 clamp(34px, 4.4vw, 52px)/1 var(--serif); }
.admin-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.admin-stats div { min-width: 104px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.admin-stats dt { font-size: 12px; color: var(--muted); }
.admin-stats dd { margin: 2px 0 0; font: 600 22px var(--sans); }
.admin-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-filter input { flex: 1 1 260px; min-width: 0; height: 44px; padding: 0 14px; font: 15px var(--sans); border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.admin-filter select { height: 44px; padding: 0 10px; font: 15px var(--sans); border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.admin-count { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.admin-empty { padding: 24px; color: var(--muted); }
.admin-table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { position: sticky; top: 0; padding: 11px 14px; background: var(--paper); font-size: 12px; font-weight: 600; color: var(--muted); text-align: start; white-space: nowrap; }
.admin-table td { padding: 11px 14px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.admin-table tbody tr:hover { background: var(--paper); }
.admin-table .badge { min-width: 0; }
.admin-table .grade { margin-inline-start: 6px; }
.cell-from { max-width: 240px; overflow-wrap: anywhere; }
.cell-subject { max-width: 320px; overflow-wrap: anywhere; }
.cell-links a { margin-inline-end: 10px; font-weight: 500; }
.admin-id { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.admin-pages { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Language switch and right-to-left (Persian) ---------------------------- */
.lang-switch { font-weight: 600; }
.lang-switch:lang(fa) { font-family: Vazirmatn, Tahoma, sans-serif; }
.top-actions .lang-switch { align-self: center; padding: 0 6px; color: var(--ink); }
:lang(fa) { --serif: Vazirmatn, Tahoma, sans-serif; --sans: Vazirmatn, Tahoma, sans-serif; }
[lang="fa"] h1, [lang="fa"] h2, [lang="fa"] h3, [lang="fa"] .brand { letter-spacing: 0; }
[lang="fa"] .intro h1 { line-height: 1.25; }
/* Addresses, IPs, DNS records and headers always read left to right. */
[dir="rtl"] .mono, [dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] .address-row input { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .record, [dir="rtl"] pre { text-align: left; }
[dir="rtl"] .pts, [dir="rtl"] .cat-points { direction: ltr; unicode-bidi: isolate; }
[lang="fa"] .check-card .tags, [lang="fa"] .hop-delay { font-family: var(--sans); }
[dir="rtl"] .toggle[aria-pressed="true"] .toggle-knob { transform: translateX(-14px); }
