*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  /* subtle grid */
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}
body::before { /* fade the grid so it stays in the background */
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, rgba(14,17,22,.55), rgba(14,17,22,.94) 70%);
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: var(--space-4); top: var(--space-4); background: var(--paper); color: var(--paper-ink); padding: var(--space-2) var(--space-3); z-index: 10; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: rgba(14,17,22,.85);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.topbar__mark { color: var(--accent); }
.topbar__lang { margin-left: auto; display: flex; gap: 2px; }
.lang {
  font: inherit; color: var(--muted); background: transparent;
  border: 1px solid var(--line-strong); padding: 4px 10px; min-height: 32px; cursor: pointer;
}
.lang.is-active { color: var(--bg); background: var(--text); border-color: var(--text); }
.lang:disabled { opacity: .45; cursor: not-allowed; }

.progress {
  list-style: none; margin: 0 auto; padding: 0;
  display: flex; gap: 6px; align-items: center;
}
.progress li { width: 22px; height: 2px; background: var(--line-strong); }
.progress li.is-done { background: var(--muted); }
.progress li.is-current { background: var(--accent); height: 3px; }

/* ---------- Main stage ---------- */
.stage {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-8);
  outline: none;
}

.footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; color: var(--muted);
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-5);
  font-family: var(--font-mono); font-size: .8125rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  color: var(--bg); background: var(--text);
  border: 1px solid var(--text); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; background: var(--text); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--bg-raised); color: var(--text); border-color: var(--muted); }
.btn--danger { background: var(--paper); border-color: var(--paper); color: var(--paper-ink); }

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .topbar { padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
  .topbar__brand span:last-child { display: none; }
  .progress { order: 3; width: 100%; justify-content: center; }
  .progress li { flex: 1; max-width: 28px; }
  .stage { padding: var(--space-6) var(--space-4) var(--space-7); }
  .btn { width: 100%; }
}

/* Headings receive focus programmatically on each screen change; no visible ring needed there. */
[tabindex="-1"]:focus { outline: none; }
