:root {
  color-scheme: dark light;
  --bg: #0e0e13;
  --card: #17171f;
  --text: #f3f3f6;
  --muted: #9a9aab;
  --border: #2a2a36;
  --input: #0f0f15;
  --accent: #fe2c55;
  --accent-2: #25f4ee;
  --ok: #3ddc97;
  --err: #ff6b6b;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f4f7;
    --card: #ffffff;
    --text: #16161d;
    --muted: #5d5d6e;
    --border: #e1e1ea;
    --input: #fafafc;
    --ok: #0d8a5a;
    --err: #d0303b;
  }
}

* { box-sizing: border-box; }

/* Sinon un display: flex (bouton .primary) l'emporte sur l'attribut hidden */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(600px 300px at 15% 0%, rgba(37, 244, 238, .12), transparent 70%),
    radial-gradient(600px 300px at 85% 100%, rgba(254, 44, 85, .12), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.card {
  width: 100%;
  max-width: 480px;
  padding: 28px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

header { text-align: center; margin-bottom: 24px; }

.logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}

.logo svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -.01em; }

.lead { margin: 0; color: var(--muted); }

label { display: block; margin-bottom: 8px; font-size: .9rem; font-weight: 600; }

.field { display: flex; gap: 8px; }

input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px; /* évite le zoom automatique sur iPhone */
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 244, 238, .25);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}

.ghost {
  height: 52px;
  padding: 0 16px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.primary {
  width: 100%;
  height: 54px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  transition: transform .1s, opacity .2s;
}

.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .7; cursor: progress; }

.save { color: #0e0e13; background: var(--accent-2); }

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.loading .spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.status { min-height: 1.5em; margin: 16px 0 0; text-align: center; font-size: .95rem; }
.status.info { color: var(--muted); }
.status.success { color: var(--ok); }
.status.error { color: var(--err); }

.help {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .9rem;
}

.help summary { cursor: pointer; color: var(--text); font-weight: 600; }
.help ol { padding-left: 20px; }

footer { max-width: 480px; text-align: center; color: var(--muted); font-size: .8rem; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .primary { transition: none; }
}
