:root { color-scheme: dark light; }
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 70% 20%, #102330 0%, #0a0a14 60%, #050509 100%);
  color: #e7e7ee;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}
html.light, html.light body {
  background: radial-gradient(circle at 70% 20%, #eaf3fb 0%, #f4f5fa 60%, #ffffff 100%);
  color: #1c1f2a;
}
.wrap {
  max-width: 560px; margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 20px max(48px, env(safe-area-inset-bottom));
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 6px; }
.logo span { background: linear-gradient(90deg,#22d3ee,#7af0a3); -webkit-background-clip: text; background-clip: text; color: transparent; }
html.light .logo { color: #1c1f2a; }
.sub { color: #9aa0b4; font-size: 14px; margin-bottom: 22px; line-height: 1.55; }
html.light .sub { color: #5a6178; }
.card {
  background: rgba(20,20,30,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 24px;
}
html.light .card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}

/* step rail */
.step-rail { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; flex-wrap: wrap; }
.step-dot {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px; color: #9aa0b4;
}
.step-dot span {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.step-dot.active { color: #22d3ee; border-color: rgba(34,211,238,0.4); background: rgba(34,211,238,0.08); }
.step-dot.active span { background: #22d3ee; color: #07101a; }
.step-dot.done span { background: #22c55e; color: #04130b; }
.step-dot.done { color: #c8cad6; }
html.light .step-dot { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); color: #5a6178; }

/* tabs */
.tabs { display: flex; gap: 6px; padding: 4px; background: rgba(255,255,255,0.04); border-radius: 12px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px 12px; border: 0; background: transparent; color: #9aa0b4;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: rgba(122,92,255,0.18); color: #fff; }
.tab:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
html.light .tabs { background: rgba(0,0,0,0.04); }
html.light .tab { color: #5a6178; }
html.light .tab.active { background: #fff; color: #1c1f2a; }

label { display: block; font-size: 13px; color: #b5b8c7; margin: 16px 0 6px; }
html.light label { color: #424961; }
input[type=text], input[type=password], textarea {
  width: 100%;
  background: rgba(0,0,0,0.35); color: #fff;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
html.light input[type=text], html.light input[type=password], html.light textarea {
  background: rgba(255,255,255,0.95); color: #1c1f2a; border-color: rgba(0,0,0,0.1);
}
textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, SF Mono, Menlo, monospace; font-size: 12px; line-height: 1.5; }
input:focus-visible, textarea:focus-visible {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34,211,238,0.18);
}

.pw-row { position: relative; }
.pw-row .eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #9aa0b4; cursor: pointer; padding: 6px; }
.strength { height: 6px; background: #1c1c2a; border-radius: 4px; margin-top: 8px; overflow: hidden; }
html.light .strength { background: rgba(0,0,0,0.08); }
.strength > div { height: 100%; width: 0%; transition: width .25s, background .25s; }

.meta { font-size: 12px; color: #9aa0b4; margin-top: 6px; min-height: 16px; line-height: 1.5; }
.field-msg { font-size: 12px; margin: 6px 0 0; min-height: 14px; color: #9aa0b4; }
.field-msg.ok { color: #7af0a3; }
.field-msg.err-msg { color: #ff8a8a; }

.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-top: 8px; }
.avatars .a { aspect-ratio: 1/1; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s, border-color .15s; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.avatars .a.sel { border-color: #22d3ee; transform: scale(1.06); }
.avatars .a:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.upload-row .preview { width: 48px; height: 48px; border-radius: 50%; background: #1c1c2a; background-size: cover; background-position: center; }
.upload-row button { background: rgba(255,255,255,0.06); color: #e7e7ee; border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
html.light .upload-row button { background: rgba(0,0,0,0.04); color: #1c1f2a; border-color: rgba(0,0,0,0.08); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 13px; color: #c8cad6; line-height: 1.5; cursor: pointer; }
.check input { margin-top: 3px; flex-shrink: 0; }
html.light .check { color: #424961; }

.btn {
  width: 100%; margin-top: 18px; padding: 13px 16px;
  border: 0; border-radius: 12px;
  background: linear-gradient(90deg,#22d3ee,#7af0a3);
  color: #0a0a14; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .08s, opacity .15s, box-shadow .15s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(34,211,238,0.18); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: rgba(255,255,255,0.06); color: #e7e7ee; }
.btn-ghost:hover { background: rgba(255,255,255,0.12); box-shadow: none; }
html.light .btn-ghost { background: rgba(0,0,0,0.05); color: #1c1f2a; }

.err { color: #ff8a8a; font-size: 13px; margin-top: 10px; min-height: 18px; }
.alt { text-align: center; margin-top: 18px; font-size: 13px; color: #9aa0b4; }
.alt a { color: #22d3ee; text-decoration: none; }
.alt a:hover { text-decoration: underline; }
.alt a:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; border-radius: 3px; }

/* drop zone */
.drop {
  margin-top: 8px; padding: 18px;
  border: 1px dashed rgba(255,255,255,0.18); border-radius: 12px;
  text-align: center; color: #9aa0b4; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.drop.over { background: rgba(122,92,255,0.08); border-color: #a78bfa; color: #fff; }
.drop.loaded { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.4); color: #c8cad6; border-style: solid; }
.drop:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
.paste-toggle { margin-top: 10px; }
.paste-toggle summary { cursor: pointer; color: #9aa0b4; font-size: 12px; padding: 6px 0; user-select: none; }
.paste-toggle summary:hover { color: #c8cad6; }

/* recovery codes */
.recovery-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 6px; padding: 14px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}
.rec-code {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  font-family: ui-monospace, SF Mono, Menlo, monospace;
  font-size: 13px;
}
.rec-code .rec-num {
  color: #9aa0b4; font-size: 11px; font-weight: 600; flex-shrink: 0;
  background: rgba(255,255,255,0.04); padding: 2px 6px; border-radius: 4px;
}
.rec-code code { color: #22d3ee; flex: 1; word-break: break-all; }
html.light .recovery-grid { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); }
html.light .rec-code { background: #fff; border-color: rgba(0,0,0,0.06); }
html.light .rec-code code { color: #0e7490; }
@media (max-width: 480px) { .recovery-grid { grid-template-columns: 1fr; } }

/* save card */
.save-card .blob-out {
  width: 100%; min-height: 130px; resize: vertical;
  background: rgba(0,0,0,0.45); color: #d8e0ff;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SF Mono, Menlo, monospace;
  font-size: 12px; line-height: 1.5; word-break: break-all;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.row2 .btn { margin-top: 0; }
.warn { background: rgba(255,180,80,0.08); border: 1px solid rgba(255,180,80,0.25); color: #ffd99e; padding: 12px; border-radius: 10px; font-size: 13px; margin-top: 14px; line-height: 1.5; }
html.light .warn { background: rgba(255,180,80,0.12); color: #92400e; border-color: rgba(255,180,80,0.4); }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
