:root {
  --bg: #0f1317;
  --panel: #171d23;
  --line: #2a343d;
  --fg: #e8eef4;
  --muted: #94a3b1;
  --accent: #4da3ff;
  --error: #ff6b6b;
  --ok: #55d18e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 600; }

.badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

main { max-width: 520px; margin: 0 auto; padding: 20px 16px 8px; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.hint { color: var(--muted); margin: 0 0 16px; }
.hint.small { font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=tel], input[type=text] {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
}

button.primary {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  font-weight: 600;
  color: #06101c;
  background: var(--accent);
  border: none;
}

button.primary:disabled { opacity: .5; }

button.secondary {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 8px 0;
  font-size: 14px;
}

.row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

.error { color: var(--error); margin: 12px 0 0; }

/* --- OTP field: one real input, segmented display on top ---------------- */

.otp-wrap { position: relative; }

.otp-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  pointer-events: none;
}

.otp-boxes span {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.otp-boxes span.active { border-color: var(--accent); }
.otp-boxes span.filled { border-color: var(--muted); }

/* The real input sits transparently over the boxes so autofill, paste
   and the on-screen keyboard all target a single field. */
.otp-wrap input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 58px;
  padding: 0;
  color: transparent;
  background: transparent;
  border: none;
  caret-color: transparent;
  font-size: 26px;
  letter-spacing: 2em;
  text-indent: 1em;
}

.otp-wrap input:focus { outline: none; }

/* --- SMS-Hilfetext -------------------------------------------------------
   Bewusst grösser und kontrastreicher als der übrige Fliesstext: er wird
   von Personen gelesen, die gerade zum ersten Mal einen Einmalcode
   bekommen, oft auf einem kleinen Bildschirm. */

.help {
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  font-size: 17px;
  line-height: 1.6;
}

.help h2 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
}

.help p { margin: 0 0 10px; color: var(--fg); }
.help p:last-child { margin-bottom: 0; }

.help ol {
  margin: 0 0 12px;
  padding-left: 24px;
}

.help ol li { margin-bottom: 10px; }
.help ol li:last-child { margin-bottom: 0; }

.help strong { color: var(--accent); }

/* Der Ausweg, wenn die Rückfrage weggetippt wurde - ruhiger gesetzt,
   damit er die Hauptanleitung nicht überlagert. */
.help .fallback {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
}

.help .fallback strong { color: var(--muted); }

/* --- cards --------------------------------------------------------------- */

.card {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.card dl { display: grid; grid-template-columns: 40% 60%; gap: 4px 8px; margin: 0; font-size: 14px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; word-break: break-all; }

.card ul { margin: 0; padding-left: 18px; font-size: 14px; }
.card ul li { margin-bottom: 6px; }

.card.install { border-color: var(--accent); }
.card.install ol { margin: 0 0 8px; padding-left: 20px; }

/* --- debug panel --------------------------------------------------------- */

.debug {
  max-width: 520px;
  margin: 24px auto 40px;
  padding: 0 16px;
}

#debug-panel {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b0f13;
  padding: 8px;
}

#debug-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
#debug-table td { padding: 3px 6px; vertical-align: top; border-bottom: 1px solid #161d24; }
#debug-table td.t { color: var(--muted); white-space: nowrap; }
#debug-table td.s { color: var(--ok); white-space: nowrap; }
#debug-table td.p { color: var(--muted); white-space: nowrap; }
#debug-table td.d { color: var(--fg); word-break: break-all; }
#debug-table tr.warning td.s { color: #ffcc66; }
#debug-table tr.error td.s { color: var(--error); }
