:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color-scheme: light;
  --background: #f8f9fa;
  --card: #fff;
  --text: #202427;
  --muted: #646b70;
  --line: #d9dee1;
  --input: #fff;
  --accent: #335f50;
  --primary: #293f35;
  --primary-text: #fff;
  --focus: #638b79;
  --error: #a52f28;
  --error-bg: #fff0ee;
  color: var(--text);
  background: var(--background);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #17191b;
  --card: #202326;
  --text: #eef0f1;
  --muted: #a8afb4;
  --line: #474e53;
  --input: #25292d;
  --accent: #b1d2bf;
  --primary: #b1d2bf;
  --primary-text: #17261e;
  --focus: #9dc3ad;
  --error: #ffb1a9;
  --error-bg: #3c2728;
}
/* Match the system before JavaScript initializes, including during load failure. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --background: #17191b; --card: #202326; --text: #eef0f1;
    --muted: #a8afb4; --line: #474e53; --input: #25292d;
    --accent: #b1d2bf; --primary: #b1d2bf; --primary-text: #17261e;
    --focus: #9dc3ad; --error: #ffb1a9; --error-bg: #3c2728;
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; }
main { width: min(100%, 432px); padding: 40px 20px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 4px 26px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; font-size: 18px; font-weight: 600; letter-spacing: -.5px; }
.moon { width: 24px; height: 24px; border-radius: 50%; background: var(--text); position: relative; overflow: hidden; }
.moon::after { content: ""; position: absolute; width: 23px; height: 23px; border-radius: 50%; background: var(--background); left: 9px; top: -5px; }
.appearance { display: flex; align-items: center; gap: 12px; }
.theme-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.theme-button:hover { background: var(--line); }
.sun-icon, [data-theme="dark"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 30px; }
h1 { font-weight: 600; font-size: 25px; letter-spacing: -.7px; margin: 0 0 26px; }
.subtitle { font-size: 13px; line-height: 1.6; color: var(--muted); margin: -12px 0 24px; }
.button { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--input); color: inherit; display: flex; align-items: center; justify-content: center; gap: 10px; }
.button:hover:not(:disabled) { filter: brightness(.95); }
.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; margin-top: 22px; }
.divider { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.field { margin: 0 0 18px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: inherit; padding: 0 12px; font: inherit; font-size: 16px; outline: none; }
input::placeholder { color: var(--muted); opacity: 1; }
input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.text-button { border: 0; padding: 4px 0; background: transparent; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.switch { font-size: 13px; color: var(--muted); text-align: center; margin: 22px 0 0; }
.code-input { display: flex; gap: 8px; }
.code-input input { min-width: 0; letter-spacing: 5px; }
.code-input button { white-space: nowrap; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--accent); padding: 0 10px; font: inherit; font-size: 12px; cursor: pointer; }
small { font-size: 12px; color: var(--muted); display: block; margin-top: 8px; line-height: 1.6; }
.message { font-size: 13px; line-height: 1.6; padding: 12px; border-radius: 8px; overflow-wrap: anywhere; }
.error { background: var(--error-bg); color: var(--error); }
.notice { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
footer { margin: 22px 0 0; text-align: center; color: var(--muted); }
footer p { font-size: 12px; line-height: 1.6; margin: 0 0 8px; }
button:disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }
.success-mark { text-align: center; font-size: 36px; color: var(--accent); margin: 20px; }
#success-copy { font-size: 14px; text-align: center; line-height: 1.7; }
@media (max-width: 480px) {
  main { padding: 28px 18px; }
  .card { padding: 26px 22px; }
}
