/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #080c15;
  --surface:   #0f1625;
  --surface2:  #161e30;
  --border:    #1e2d45;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --accent-lo: rgba(59,130,246,0.12);
  --green:     #22c55e;
  --green-lo:  rgba(34,197,94,0.12);
  --red:       #ef4444;
  --red-lo:    rgba(239,68,68,0.1);
  --text:      #f0f4fc;
  --muted:     #8094b4;
  --radius:    14px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen management ─────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ── Brand header ──────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 1.1rem 1.75rem;
  font-weight: 600;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.logo-dot {
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent);
}
.back-btn {
  margin-right: auto;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 0.875rem; padding: 0.2rem 0;
  font-family: var(--font);
}
.back-btn:hover { color: var(--text); }

/* ── Landing hero ──────────────────────────────────────────────────────── */
.hero {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 5rem 2rem 4rem;
  gap: 1.75rem;
}
.hero h1 {
  font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f0f4fc 40%, #7ea8f8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 500px;
  line-height: 1.65;
}

/* ── Features strip ────────────────────────────────────────────────────── */
.features {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2.5rem 3.5rem;
  padding: 2rem;
  border-top: 1px solid var(--border);
}
.feature { display: flex; flex-direction: column; gap: 0.2rem; text-align: center; }
.feature strong { font-size: 0.875rem; color: var(--text); font-weight: 600; }
.feature span   { font-size: 0.8rem;   color: var(--muted); }

/* ── Disclaimer ────────────────────────────────────────────────────────── */
.disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 1rem 2rem;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  opacity: 0.7;
}

/* ── Card wrapper (register + success) ────────────────────────────────── */
.card-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}
.card {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card-sub {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-top: -0.75rem;
}

/* ── Form fields ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.45rem; }
label { font-size: 0.875rem; font-weight: 500; }
.opt  { color: var(--muted); font-weight: 400; }

input[type=text],
input[type=password],
input[type=email] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

/* subdomain row */
.subdomain-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.subdomain-row:focus-within { border-color: var(--accent); }
.subdomain-row input {
  border: none;
  border-radius: 0;
  flex: 0 0 auto;
  width: 140px;
}
.domain-suffix {
  flex: 1;
  background: var(--bg);
  border-left: 1px solid var(--border);
  padding: 0 0.9rem;
  display: flex; align-items: center;
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

/* availability badge */
.avail {
  font-size: 0.8rem;
  min-height: 1.1rem;
  transition: color 0.15s;
}
.avail.checking { color: var(--muted); }
.avail.ok       { color: var(--green); }
.avail.bad      { color: var(--red);   }

.hint { font-size: 0.78rem; color: var(--muted); line-height: 1.45; }

/* ── Primary button ────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 0.85rem 1.5rem;
  font-size: 0.975rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* error box */
.error {
  background: var(--red-lo);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 9px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--red);
  line-height: 1.4;
}

/* ── Success screen ────────────────────────────────────────────────────── */
.success-icon {
  width: 48px; height: 48px;
  background: var(--green-lo);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--green);
  font-size: 1.3rem;
  font-weight: 600;
}

/* steps */
.steps { display: flex; flex-direction: column; gap: 0.8rem; }
.step {
  display: flex; gap: 0.8rem; align-items: flex-start;
  font-size: 0.875rem; color: var(--muted); line-height: 1.45;
}
.step strong { color: var(--text); }
.step-n {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--accent-lo);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
}

/* credentials table */
.creds {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.cred-row {
  display: grid;
  grid-template-columns: 82px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cred-row:last-child { border-bottom: none; }
.cred-k  { font-size: 0.775rem; color: var(--muted); font-weight: 500; }
.cred-v  { font-size: 0.875rem; word-break: break-all; }
.mono    { font-family: 'Menlo', 'Consolas', 'Liberation Mono', monospace; }

/* copy button */
.copy-btn {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.copy-btn:hover   { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied  { border-color: var(--green);  color: var(--green);  }

/* Nightscout URL box */
.ns-box {
  background: var(--accent-lo);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.ns-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.ns-box a {
  flex: 1;
  color: var(--accent);
  font-size: 0.875rem;
  text-decoration: none;
  word-break: break-all;
  font-family: monospace;
}
.ns-box a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .card { border-radius: 0; border-left: none; border-right: none; }
  .card-wrap { padding: 0; }
  .brand { padding: 0.9rem 1rem; }
  .hero { padding: 3rem 1.5rem 3rem; }
  .hero h1 { font-size: 2.1rem; }
  .cred-row { grid-template-columns: 76px 1fr auto; }
  .features { gap: 1.5rem 2rem; padding: 1.5rem; }
  .subdomain-row input { width: 110px; }
}
