:root {
  --bg: #f3effa;
  --card: #ffffff;
  --ink: #2a2240;
  --ink-soft: #746b94;
  --accent: #8b5cf6;
  --accent2: #c026d3;
  --accent-soft: #ece2fd;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --border: #e4dcf5;
  --radius: 16px;
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 10% 0%, rgba(139,92,246,0.10), transparent 55%),
                     radial-gradient(circle at 95% 15%, rgba(192,38,211,0.08), transparent 45%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 60px;
}

.app { max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }

.top-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.top-nav .right { display: flex; gap: 8px; align-items: center; }
.top-nav a, .top-nav select, .top-nav button {
  color: var(--ink-soft); font-size: 0.85rem; text-decoration: none;
  border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; background: var(--card);
}

header.hero {
  background: var(--grad);
  box-shadow: 0 10px 30px -10px rgba(139,92,246,0.5);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
}
header.hero h1 { margin: 0 0 4px; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
header.hero .subtitle { opacity: 0.9; font-size: 0.95rem; }

section, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
section h2 { margin: 0 0 12px; font-size: 1.1rem; }

.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.level-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; position: relative; }
.level-card.locked { opacity: 0.45; }
.level-card h3 { margin: 0 0 4px; font-size: 1rem; }
.level-card p { margin: 0 0 10px; font-size: 0.85rem; color: var(--ink-soft); }
.level-card .badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }

button {
  font-family: inherit; cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 0.95rem; font-weight: 600;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 12px -4px rgba(139,92,246,0.6); }
.btn-ghost { background: var(--accent-soft); color: var(--accent); }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
button:disabled { opacity: 0.5; cursor: default; }

/* Clavier visuel */
.finger-banner {
  display: flex; align-items: center; gap: 18px; justify-content: center;
  background: var(--grad); color: #fff; border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 16px; min-height: 70px;
}
.finger-banner .swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; flex-shrink: 0; }
.finger-banner .txt { text-align: left; }
.finger-banner .hand { font-size: 1.2rem; font-weight: 800; }
.finger-banner .finger { font-size: 0.9rem; opacity: 0.9; }
.big-char {
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 16px; background: rgba(255,255,255,0.22);
  border: 3px solid #fff; font-size: 2.2rem; font-weight: 800; flex-shrink: 0;
  animation: bigcharpop 0.25s ease;
}
.big-char.special { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; }
@keyframes bigcharpop { 0% { transform: scale(0.5); opacity: 0.3; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

.keyboard { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-bottom: 16px; }
.kb-row { display: flex; gap: 6px; }
.kb-key {
  width: 52px; height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; color: #fff; border: 3px solid transparent;
  text-transform: lowercase; transition: transform 0.1s ease;
}
.kb-key.target { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 0 4px rgba(255,255,255,0.4); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px rgba(255,255,255,0.4); } 50% { box-shadow: 0 0 0 8px rgba(255,255,255,0.15); } }
.kb-key.dim { opacity: 0.3; }

.typing-zone { font-size: 1.6rem; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; text-align: center; padding: 16px; line-height: 1.6; word-wrap: break-word; }
.typing-zone .done { color: var(--green); }
.typing-zone .err { color: var(--red); background: var(--red-soft); border-radius: 4px; }
.typing-zone .cur { background: var(--accent-soft); color: var(--accent); border-radius: 4px; }
.typing-zone .pending { color: var(--ink-soft); }

.stat-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-box { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; flex: 1; min-width: 100px; text-align: center; }
.stat-box .label { font-size: 0.72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-box .value { font-size: 1.5rem; font-weight: 800; color: var(--accent); }

.weak-list { display: flex; flex-direction: column; gap: 8px; }
.weak-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.weak-row .key-chip { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.weak-row .info { flex: 1; font-size: 0.85rem; color: var(--ink-soft); }
.weak-row .rate { font-weight: 700; color: var(--red); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 4px; }
input[type="text"], input[type="password"], select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: inherit; font-size: 0.95rem; background: #fff; color: var(--ink);
}

.empty-note { color: var(--ink-soft); font-size: 0.9rem; font-style: italic; text-align: center; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; z-index: 100;
}
.toast.show { opacity: 1; }

.tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.tabs button { background: var(--card); border: 1px solid var(--border); color: var(--ink-soft); }
.tabs button.active { background: var(--grad); color: #fff; border-color: transparent; }

@media (max-width: 560px) {
  .kb-key { width: 30px; height: 40px; font-size: 0.85rem; border-radius: 6px; }
  .kb-row { gap: 3px; }
  .typing-zone { font-size: 1.2rem; }
}
