/*
 * IP-Whitelist UI. No JavaScript, no external assets (CSP: style-src 'self').
 * Tokens: primitives → semantic (light/dark) → component.
 */

/* ---------- primitives ---------- */
:root {
  --slate-0: #ffffff;
  --slate-50: #f6f7f9;
  --slate-100: #eef1f5;
  --slate-200: #e2e7ee;
  --slate-300: #cbd3de;
  --slate-500: #5b6676;
  --slate-600: #475263;
  --slate-700: #334155;
  --slate-800: #1c2536;
  --slate-850: #151d2c;
  --slate-900: #0f1626;
  --slate-950: #0b1120;
  --slate-text-dark: #e7ebf2;
  --slate-muted-dark: #9aa6b8;

  --navy-700: #1e3a5f;
  --navy-300: #9cb8dc;

  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-300: #6ee7b7;
  --green-400: #34d399;
  --green-600: #059669;
  --green-700: #047857;
  --green-800: #065f46;
  --green-950: #052e22;

  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-800: #854d0e;
  --amber-950: #2b1d05;

  --red-50: #fef2f2;
  --red-200: #fecaca;
  --red-300: #fca5a5;
  --red-700: #b91c1c;
  --red-800: #991b1b;
  --red-950: #2d0f12;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --dur-fast: 150ms;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

/* ---------- semantic: light ---------- */
:root {
  --bg: var(--slate-50);
  --surface: var(--slate-0);
  --surface-sunken: var(--slate-100);
  --text: var(--slate-900);
  --text-muted: var(--slate-500);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --brand: var(--navy-700);

  --primary: var(--green-700);
  --primary-hover: var(--green-800);
  --on-primary: var(--slate-0);
  --focus: var(--green-600);

  --ok-bg: var(--green-50);
  --ok-fg: var(--green-800);
  --ok-border: var(--green-100);
  --warn-bg: var(--amber-50);
  --warn-fg: var(--amber-800);
  --warn-border: var(--amber-200);
  --danger-bg: var(--red-50);
  --danger-fg: var(--red-800);
  --danger-border: var(--red-200);

  --shadow-card: 0 1px 2px rgba(15, 22, 38, .05), 0 4px 16px rgba(15, 22, 38, .04);
  --shadow-btn: 0 1px 2px rgba(15, 22, 38, .08);
}

/* ---------- semantic: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--slate-950);
    --surface: var(--slate-900);
    --surface-sunken: var(--slate-850);
    --text: var(--slate-text-dark);
    --text-muted: var(--slate-muted-dark);
    --border: var(--slate-800);
    --border-strong: var(--slate-700);
    --brand: var(--navy-300);

    --primary: var(--green-400);
    --primary-hover: var(--green-300);
    --on-primary: var(--slate-950);
    --focus: var(--green-400);

    --ok-bg: var(--green-950);
    --ok-fg: var(--green-300);
    --ok-border: #0b4a37;
    --warn-bg: var(--amber-950);
    --warn-fg: var(--amber-300);
    --warn-border: #4a3509;
    --danger-bg: var(--red-950);
    --danger-fg: var(--red-300);
    --danger-border: #5a1d22;

    --shadow-card: 0 1px 0 rgba(255, 255, 255, .03) inset;
    --shadow-btn: none;
  }
}

/* ---------- component tokens ---------- */
:root {
  --control-h: 48px;
  --control-radius: var(--radius-md);
  --card-pad: var(--space-6);
  --content-narrow: 26rem;
  --content-app: 34rem;
  --segment-active: var(--surface);
}
@media (prefers-color-scheme: dark) {
  :root { --segment-active: var(--slate-700); }
}

/* ---------- base ---------- */
*, *::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: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 var(--space-2); }
h2 { font-size: 1.0625rem; font-weight: 650; margin: 0 0 var(--space-4); }
h3 { font-size: .8125rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: var(--space-6) 0 var(--space-2); }
p { margin: 0 0 var(--space-3); }
a { color: var(--primary); text-underline-offset: 2px; }
code { font-family: var(--font-mono); font-size: .9em; overflow-wrap: anywhere; }
strong { font-weight: 650; }

.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.2em;
}

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

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--content-app); margin: 0 auto; padding: var(--space-2) var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 56px;
}
.topbar form { margin: 0; }
.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.01em;
}
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--brand); color: var(--surface);
}
.brand-mark .icon { width: 18px; height: 18px; }

.nav { display: flex; align-items: center; gap: var(--space-1); }
.nav a, .nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-sm);
  font: inherit; font-size: .9375rem; font-weight: 550; color: var(--text-muted);
  text-decoration: none; background: none; border: 0; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav a:hover, .nav-btn:hover { background: var(--surface-sunken); color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-sunken); }
@media (max-width: 640px) {
  /* Icon-only on small phones; the text stays readable for screen readers. */
  .nav span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav a, .nav-btn { min-width: 44px; justify-content: center; }
}

/* ---------- layout ---------- */
main { flex: 1; width: 100%; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-8); }
main.narrow { max-width: calc(var(--content-narrow) + 2 * var(--space-4)); padding-top: var(--space-8); }
main.app { max-width: calc(var(--content-app) + 2 * var(--space-4)); }
.footer { text-align: center; color: var(--text-muted); font-size: .8125rem; padding: var(--space-4) var(--space-4) var(--space-6); }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--card-pad);
  margin-bottom: var(--space-4);
}
.card > :last-child { margin-bottom: 0; }
.card-head { text-align: center; margin-bottom: var(--space-6); }
.card-head .tile { margin: 0 auto var(--space-4); }
.lead { color: var(--text-muted); margin: 0; }
.center { text-align: center; }

.tile {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text-muted);
  border: 1px solid var(--border);
}
.tile .icon { width: 22px; height: 22px; }
.tile.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-border); }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .hint { margin: 0; }
label { font-weight: 600; font-size: .9375rem; }
input[type=text], input[type=password], input:not([type]) {
  width: 100%; min-height: var(--control-h);
  font: inherit; font-size: 1rem;  /* ≥16px: no zoom on iOS */
  padding: 0 var(--space-4);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--control-radius);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:hover { border-color: var(--text-muted); }
input:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
input.otp {
  min-height: 60px; text-align: center;
  font-family: var(--font-mono); font-size: 1.625rem; letter-spacing: .3em;
}
.hint { color: var(--text-muted); font-size: .875rem; }
.hint .icon { width: 1em; height: 1em; vertical-align: -.125em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-5);
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--control-radius);
  box-shadow: var(--shadow-btn);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-sunken); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-border); box-shadow: none; }
.btn.danger:hover { border-color: var(--danger-fg); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 56px; font-size: 1.0625rem; }
.btn.sm { min-height: 40px; padding: 0 var(--space-3); font-size: .875rem; }
.actions { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-3); }

/* ---------- segmented control (radio group) ---------- */
.segmented { border: 0; padding: 0; margin: 0; min-width: 0; }
.segmented legend { font-weight: 600; font-size: .9375rem; padding: 0; margin-bottom: 6px; }
.segments {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; border-radius: var(--control-radius);
  background: var(--surface-sunken); border: 1px solid var(--border);
}
.segments label { position: relative; font-weight: 550; }
.segments input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segments span {
  display: grid; place-items: center; min-height: 44px; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segments input:hover + span { color: var(--text); }
.segments input:checked + span { background: var(--segment-active); color: var(--text); font-weight: 650; box-shadow: 0 1px 3px rgba(15, 22, 38, .12); outline: 1px solid var(--border); }
.segments input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- connection status ---------- */
.conn { display: flex; gap: var(--space-4); align-items: flex-start; margin-bottom: var(--space-5); }
.card > .conn:last-child { margin-bottom: 0; }
.conn-body { min-width: 0; flex: 1; }
.conn-body > * { margin-bottom: var(--space-2); }
.conn-body > :last-child { margin-bottom: 0; }
.eyebrow {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: .8125rem; font-weight: 600; color: var(--text-muted);
}
.ip { font-family: var(--font-mono); font-size: 1.1875rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.name { font-size: 1.1875rem; font-weight: 650; }

/* ---------- pills / tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: .8125rem; font-weight: 600; line-height: 1.4;
  color: var(--text-muted); background: var(--surface-sunken); border: 1px solid var(--border);
}
.pill .icon { width: 14px; height: 14px; }
.pill.ok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-border); }
.pill.sm { padding: 1px 8px; font-size: .75rem; vertical-align: 1px; }
.eyebrow .pill { padding: 0 8px; font-size: .75rem; }
.tag {
  flex: none; padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); border: 1px solid var(--border); font-size: .8125rem;
}

/* ---------- alerts ---------- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4);
  border-radius: var(--radius-md); border: 1px solid; font-size: .9375rem;
}
.alert > .icon, .alert summary > .icon { margin-top: 2px; }
.alert p:last-child { margin-bottom: 0; }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-border); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-border); }
.alert.error { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
details.alert { display: block; }
details.alert summary { display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer; list-style: none; }
details.alert summary::-webkit-details-marker { display: none; }
details.alert summary::after { content: "Mehr"; margin-left: auto; font-size: .8125rem; font-weight: 600; text-decoration: underline; flex: none; }
details.alert[open] summary::after { content: "Weniger"; }
details.alert[open] summary { margin-bottom: var(--space-2); }

/* ---------- disclosure ---------- */
.disclosure { margin-top: var(--space-5); border-top: 1px solid var(--border); padding-top: var(--space-4); font-size: .9375rem; }
.disclosure summary {
  cursor: pointer; font-weight: 600; color: var(--primary);
  min-height: 44px; display: flex; align-items: center;
}
.disclosure p { color: var(--text-muted); }

/* ---------- rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.rows form { margin: 0; }
.row-icon {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px;
  border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--text-muted);
}
.row-icon .icon { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; font-weight: 550; }
.row-main code { font-weight: 600; }
.row-main .hint { margin: 2px 0 0; font-weight: 400; }
.empty { color: var(--text-muted); text-align: center; padding: var(--space-4); margin: 0; background: var(--surface-sunken); border-radius: var(--radius-md); font-size: .9375rem; }

/* ---------- onboarding ---------- */
.progress {
  list-style: none; margin: 0 0 var(--space-5); padding: 0;
  display: flex; justify-content: center; gap: var(--space-2);
  font-size: .8125rem; font-weight: 600; color: var(--text-muted);
}
.progress li { display: flex; align-items: center; gap: 6px; }
.progress li + li::before { content: ""; width: 16px; height: 1px; background: var(--border-strong); margin-right: 2px; }
.progress span {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--border-strong); font-size: .75rem;
}
.progress .current { color: var(--text); }
.progress .current span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.progress .done span { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
@media (max-width: 380px) { .progress li:not(.current) { font-size: 0; gap: 0; } .progress li:not(.current) span { font-size: .75rem; } }

.option { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: var(--space-3); }
.option h2 { display: flex; align-items: center; gap: var(--space-2); font-size: .9375rem; margin-bottom: var(--space-3); }
.option h2 .icon { color: var(--text-muted); }
.option .hint { margin: var(--space-2) 0 0; }
.option .hint:first-of-type:not(:last-child) { margin: 0 0 var(--space-3); }
.qr { display: block; margin: 0 auto; background: #fff; padding: 10px; border-radius: var(--radius-md); border: 1px solid var(--border); max-width: 100%; height: auto; }
.secret {
  display: block; padding: var(--space-3); margin-top: var(--space-2);
  background: var(--surface-sunken); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  font-size: 1.0625rem; letter-spacing: .06em; text-align: center; user-select: all; -webkit-user-select: all;
}
.confirm { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border); }

.codes {
  list-style: none; counter-reset: code; padding: 0; margin: var(--space-4) 0 var(--space-5);
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2);
}
.codes li { counter-increment: code; position: relative; }
.codes li::before {
  content: counter(code); position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: .6875rem; font-weight: 600; color: var(--text-muted);
}
.codes code {
  display: block; padding: 10px 8px 10px 26px; text-align: center;
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9375rem; user-select: all; -webkit-user-select: all;
}
@media (max-width: 360px) { .codes { grid-template-columns: 1fr; } }

/* ---------- guide ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: var(--space-3) 0 var(--space-4); font-size: .9375rem; }
.facts dt { color: var(--text-muted); font-weight: 600; }
.facts dd { margin: 0; min-width: 0; }
@media (max-width: 480px) {
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: var(--space-2); }
}
code.copy { user-select: all; -webkit-user-select: all; padding: 1px 6px; border-radius: 6px; background: var(--surface-sunken); border: 1px solid var(--border); }
pre {
  margin: var(--space-2) 0 var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow-x: auto; font-size: .8125rem; line-height: 1.55;
}
pre code { white-space: pre; overflow-wrap: normal; }
.steps { margin: var(--space-3) 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: var(--space-3); }
.steps li { padding-left: 2px; }
details.guide { border-top: 1px solid var(--border); }
details.guide:last-of-type { border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); }
details.guide summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-height: 48px; cursor: pointer; font-weight: 600; list-style: none;
}
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary::after { content: "+"; font-size: 1.25rem; color: var(--text-muted); }
details.guide[open] summary::after { content: "–"; }
details.guide > :last-child { margin-bottom: var(--space-4); }
.link-card { display: flex; align-items: center; gap: var(--space-3); color: var(--text); text-decoration: none; padding: var(--space-4) var(--space-5); }
.link-card .row-main { display: flex; flex-direction: column; gap: 2px; }
.link-card > .icon { color: var(--text-muted); }
.link-card:hover { border-color: var(--border-strong); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .btn:active { transform: none; }
}

/* ---------- print (recovery codes) ---------- */
@media print {
  .topbar, .footer, .actions, .progress, form { display: none !important; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; color: #000; }
}

/* Visually hidden, still read by screen readers. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
