/* TOG ID pages (TOG-SPEC-0022 §2, §9): the TOG ecosystem's dark palette, Inter, no third-party resources. */
:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --bg2: #13161c;
  --card: #171a21;
  --line: #262a33;
  --line2: #343a46;
  --accent: #3987e5;
  --accent2: #5aa2ff;
  --teal: #2cc3b0;
  --amber: #f0b44c;
  --red: #ef6b6b;
  --text: #e8ebf1;
  --muted: #a3abb9;
  --on-accent: #07101d;
  --radius: 10px;
  --font: Inter, "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent2); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 10; padding: 8px 12px;
  background: var(--accent2); color: var(--on-accent); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* Two panes: the brand on the left, the form on the right; one column on a phone. */
.shell { display: grid; grid-template-columns: minmax(320px, 40%) 1fr; min-height: 100vh; }
.brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px;
  background: radial-gradient(900px 600px at 20% 15%, rgba(57, 135, 229, 0.18), transparent 60%), var(--bg2);
  border-right: 1px solid var(--line);
}
.brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(163, 168, 179, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(163, 168, 179, 0.06) 1px, transparent 1px);
  background-size: 64px 64px;
}
.brand > * { position: relative; }
.logo { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; font-size: 19px; }
.logo:hover { text-decoration: none; }
.logo img { width: 32px; height: 32px; }
.hero h2 { font-size: 40px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 16px; }
.hero p { color: var(--muted); font-size: 17px; margin: 0; max-width: 34em; }
.brand-foot { color: var(--muted); font-size: 13px; }

.main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.panel { width: 100%; max-width: 440px; }
.panel.wide { max-width: 880px; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.kicker { color: var(--muted); font-size: 13px; margin: 0 0 4px; }

/* Forms */
form { margin: 0; }
.field { margin: 0 0 16px; }
.field label, .label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field label a { font-size: 14px; }
input[type="text"], input[type="password"], input[type="email"], textarea, select {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line2); border-radius: var(--radius);
  font: inherit; font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(90, 162, 255, 0.25); }
input[aria-invalid="true"] { border-color: var(--red); }
.help { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.with-badge { position: relative; }
.with-badge input { padding-right: 104px; }
.with-badge .badge { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.code-input { font-family: var(--mono); font-size: 24px !important; letter-spacing: 0.4em; text-align: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 46px; padding: 10px 16px;
  border-radius: var(--radius); border: 1px solid var(--line2);
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #4a5260; text-decoration: none; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent); }
.btn.primary:hover { background: #78b4ff; border-color: #78b4ff; }
.btn.danger { color: var(--red); }
.btn.small { width: auto; min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn img, .btn svg { width: 20px; height: 20px; flex: none; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack > * + * { margin-top: 12px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent2); font: inherit; font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--red); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.center { text-align: center; }
.muted { color: var(--muted); }
.mt { margin-top: 20px; }

/* Notes */
.note { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font-size: 14px; }
.note.info { border-color: rgba(90, 162, 255, 0.35); background: rgba(57, 135, 229, 0.08); color: #c9dcf6; }
.note.warn { border-color: rgba(240, 180, 76, 0.45); background: rgba(240, 180, 76, 0.08); color: #f3d9a8; }
.note.warn strong { color: var(--amber); }
.note.ok { border-color: rgba(44, 195, 176, 0.45); background: rgba(44, 195, 176, 0.08); color: #b5ece4; }
.alert { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid rgba(239, 107, 107, 0.5); background: rgba(239, 107, 107, 0.1); color: #f6c3c3; font-size: 14px; }
.alert:empty { display: none; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(90, 162, 255, 0.14); color: var(--accent2); white-space: nowrap; }
.badge.ok { background: rgba(44, 195, 176, 0.14); color: var(--teal); }
.badge.bad { background: rgba(239, 107, 107, 0.14); color: var(--red); }
.badge.warn { background: rgba(240, 180, 76, 0.14); color: var(--amber); }

/* Choice cards */
.card { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 16px 18px; }
.card + .card { margin-top: 12px; }
.card.selected { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset; background: rgba(57, 135, 229, 0.07); }
.card h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .btn { margin-top: 14px; }
.card.disabled { opacity: 0.7; }

/* Steps */
.steps { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.steps li { display: inline-flex; align-items: center; gap: 8px; }
.steps li + li::before { content: ""; width: 28px; height: 1px; background: var(--line2); margin-right: 2px; }
.steps .dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line2); font-size: 12px; font-weight: 600; }
.steps [aria-current="step"] { color: var(--text); font-weight: 600; }
.steps [aria-current="step"] .dot { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent); }
.steps .done .dot { color: var(--teal); border-color: var(--teal); }

/* The 24 words */
.words { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; counter-reset: w; }
.words li { display: flex; gap: 8px; align-items: baseline; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); font-family: var(--mono); font-size: 14px; }
.words li::before { counter-increment: w; content: counter(w); color: var(--muted); min-width: 1.6em; font-size: 12px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.codes li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); font-family: var(--mono); font-size: 15px; text-align: center; }

/* TOTP enrolment */
.totp { display: grid; grid-template-columns: 148px 1fr; gap: 16px; align-items: start; margin-top: 12px; }
.qr { width: 148px; height: 148px; padding: 8px; background: #fff; border-radius: 10px; }
.qr svg { display: block; width: 100%; height: 100%; }
.secret { font-family: var(--mono); font-size: 14px; letter-spacing: 0.06em; word-break: normal; overflow-wrap: anywhere; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 8px; background: var(--bg2); }

/* Account and security */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 20px 22px; }
.section h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 18px; margin: 0 0 12px; }
.section > p { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.rows { margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rows li:first-child { border-top: 0; }
.rows .k { color: var(--muted); }
.rows .v { text-align: right; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }

/* Language switcher (docs/i18n.md §2.4): flag + code, open list with flag, code, own name and a check. */
.lang { position: relative; display: inline-block; }
.lang-wrap { display: flex; justify-content: center; margin-top: 28px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 12px;
  border: 1px solid var(--line2); border-radius: 8px; background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
}
.lang-btn:hover { border-color: #4a5260; }
.flag { width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); flex: none; }
.caret { width: 10px; height: 10px; color: var(--muted); }
.lang-menu {
  position: absolute; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(100% + 6px);
  min-width: 220px; margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.lang.down .lang-menu { bottom: auto; top: calc(100% + 6px); left: auto; right: 0; transform: none; }
.lang-menu li {
  display: grid; grid-template-columns: 24px 2.4em 1fr 16px; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.lang-menu li:hover, .lang-menu li.active { background: rgba(90, 162, 255, 0.12); }
.lang-menu li[aria-selected="true"] { color: var(--accent2); }
.lang-menu .code { font-weight: 700; }
.lang-menu .check { visibility: hidden; color: var(--accent2); }
.lang-menu li[aria-selected="true"] .check { visibility: visible; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .brand { padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand .hero, .brand .brand-foot { display: none; }
  .main { align-items: flex-start; padding: 24px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 480px) {
  h1 { font-size: 26px; }
  .words { grid-template-columns: repeat(3, 1fr); }
  .words li { font-size: 13px; padding: 8px 7px; }
  .totp { grid-template-columns: 1fr; }
  .qr { margin: 0 auto; }
  .btn-row { grid-template-columns: 1fr; }
  .rows li { flex-wrap: wrap; }
}

@media print {
  body { background: #fff; color: #000; }
  .brand, .lang-wrap, .btn, .note, .steps, .no-print { display: none !important; }
  .words li { border-color: #999; background: #fff; color: #000; }
  .words li::before { color: #555; }
}
