@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap");

:root {
  --bg: #0a0c11;
  --surface: #14171f;
  --surface-2: #1c202b;
  --surface-3: #262b38;
  --text: #f3f5f9;
  --text-dim: #8b93a7;
  --text-faint: #565d70;
  --track: #262b38;
  --locked-fill: #1c202b;
  --locked-stroke: #3a3f4d;
  --gold: #ffd166;
  --danger: #ff5c72;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);

  --c-avis: #ff9f1c;
  --c-examens: #a78bfa;
  --c-impr: #2dd4bf;
}

[data-theme="sunset"] {
  --c-avis: #fb5eae;
  --c-examens: #7c83fd;
  --c-impr: #3ddc97;
}

[data-theme="neon"] {
  --c-avis: #ff2ea6;
  --c-examens: #7cf7ff;
  --c-impr: #c6ff3d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at top, #12151d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: "Space Mono", monospace; }

.icon { display: block; flex-shrink: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 860px) {
  #app { max-width: 920px; }
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}
.app-header .store-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.app-header .week-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--surface-3);
  color: var(--text);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.admin-back-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
  padding: 0 12px 0 8px;
  background: var(--surface);
  border: 1px solid var(--surface-3);
  color: var(--text);
  border-radius: 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
}
.admin-back-btn:active { border-color: var(--c-avis); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Main / nav ---------- */
main#view {
  flex: 1;
  padding: 4px 20px 100px;
}
.bottom-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 6px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 12, 17, 0.86);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--surface-3);
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0 2px;
  font-size: 11px;
  border-radius: 12px;
}
.nav-btn.active { color: var(--text); }
.nav-btn.active .icon { color: var(--c-avis); }

/* ---------- Onboarding ---------- */
.onboarding {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, #12151d 0%, var(--bg) 60%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 48px 24px 24px;
}
.onboarding--centered { align-items: center; justify-content: center; }

.rewards-screen { z-index: 60; overflow-y: auto; }
.rewards-head { text-align: center; margin-bottom: 20px; }
.rewards-title {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--c-avis));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}
.rewards-head .sub { margin-bottom: 18px; }
.rewards-head .ob-validate { max-width: 280px; margin: 0 auto; }
.rewards-grid { padding-bottom: 12px; }
.rewards-grid .badge-card { padding-bottom: 16px; }
.claim-btn {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  background: var(--c-avis);
  color: #0a0c11;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
}
.claim-btn:active { transform: scale(0.97); }
.ob-center {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.ob-brand {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--c-avis), var(--c-examens));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}
.onboarding .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 28px; }
.ob-select {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  text-align: center;
  text-align-last: center;
  appearance: none;
  margin-bottom: 16px;
}
.ob-select:focus { outline: none; border-color: var(--c-avis); }
.ob-validate {
  width: 100%;
  background: var(--c-avis);
  color: #0a0c11;
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
}
.ob-validate:disabled { background: var(--surface-3); color: var(--text-faint); }
.ob-validate:not(:disabled):active { transform: scale(0.98); }
.ob-error { color: var(--danger); font-size: 13px; margin: -8px 0 14px; }
.ob-back-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  margin-top: 14px;
  padding: 4px;
}

/* ---------- Ring cluster ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 6px;
}
.ring-cluster { width: 100%; height: 100%; overflow: visible; }
.ring-animate { transition: stroke-dasharray 1.15s cubic-bezier(0.16, 1, 0.3, 1); }
.ring-cluster--mini { width: 40px; height: 40px; }
.ring-wrap { position: relative; width: 230px; height: 230px; }
.ring-wrap--hero { width: 276px; height: 276px; }
.ring-wrap .score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-center .score-value { font-size: 40px; font-weight: 800; }
.score-center .score-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}
.stat-row {
  display: flex;
  gap: 18px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
}
.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-pill .val { font-size: 22px; font-weight: 800; font-family: "Space Mono", monospace; }
.stat-pill .lbl { font-size: 10px; letter-spacing: 0.1em; color: var(--text-dim); text-transform: uppercase; margin-top: 2px; }

/* ---------- Metric cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.metric-list { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.metric-card {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.metric-card .m-icon {
  width: 58px; height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.metric-card .m-body { flex: 1; min-width: 0; }
.metric-card .m-top { display: flex; justify-content: space-between; align-items: baseline; }
.metric-card .m-label { font-size: 13px; color: var(--text-dim); }
.metric-card .m-nums { font-size: 15px; font-weight: 700; font-family: "Space Mono", monospace; }
.m-nums-objectif { color: #b7bfd2; font-weight: 600; }
.metric-card .m-pct { font-size: 13px; font-weight: 700; }
.bar-track {
  height: 8px;
  border-radius: 6px;
  background: var(--track);
  margin-top: 8px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.m-note {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--surface-3);
}
.chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.chip.gold { background: rgba(255, 209, 102, 0.18); color: var(--gold); }
.chip.met { background: rgba(45, 212, 191, 0.14); color: #6ee7d8; }
.chip.miss { background: rgba(255, 92, 114, 0.12); color: #ff8a98; }

.section-title {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 26px 0 10px;
}

.badges-preview { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.badges-preview .badge-mini {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 68px; flex-shrink: 0;
}
.badges-preview .badge-mini span { font-size: 10.5px; color: var(--text-dim); text-align: center; }
.link-row {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-dim); font-size: 13px; margin-top: 10px;
}
.trophy-count { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

/* ---------- Metric detail ---------- */
.detail-hero { display: flex; align-items: center; gap: 18px; padding: 10px 0 8px; }
.detail-hero .big-num { font-size: 46px; font-weight: 800; font-family: "Space Mono", monospace; }
.detail-hero .big-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.detail-hero .ring-wrap { width: 108px; height: 108px; flex-shrink: 0; }
.detail-hero .ring-wrap .score-value { font-size: 20px; }
.detail-extra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}
.detail-extra--split { justify-content: space-around; text-align: center; }
.detail-extra--split div { display: flex; flex-direction: column; gap: 3px; }
.detail-extra--split .mono { font-size: 18px; font-weight: 800; color: var(--text); }
.streak-row { display: flex; gap: 10px; margin-top: 18px; }
.streak-card { flex: 1; text-align: center; padding: 12px; }
.streak-card .n { font-size: 22px; font-weight: 800; }
.streak-card .l { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.avis-list { display: flex; flex-direction: column; gap: 10px; }
.avis-item { display: flex; flex-direction: column; gap: 6px; }
.avis-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.avis-item-auteur { font-weight: 700; font-size: 13.5px; color: var(--text); }
.avis-item-note { color: var(--gold); font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.avis-item-texte { font-size: 13.5px; line-height: 1.5; color: var(--text-dim); margin: 0; white-space: pre-line; }
.avis-item-date { font-size: 11px; color: var(--text-dim); opacity: 0.7; align-self: flex-end; }

.sparkline { display: flex; gap: 4px; align-items: flex-end; height: 56px; margin: 18px 0 4px; border-bottom: 1px solid var(--surface-3); padding-bottom: 2px; }
.sparkline .bar { flex: 1; border-radius: 3px 3px 1px 1px; min-height: 3px; }

table.history { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.history th {
  text-align: left; font-size: 10.5px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 6px; font-weight: 600;
}
table.history td { padding: 10px 6px; font-size: 13.5px; border-top: 1px solid var(--surface-3); }
table.history td.num { font-family: "Space Mono", monospace; }
.best-streak-note { color: var(--text-dim); font-size: 12.5px; margin-top: 14px; }

/* ---------- Trophies ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 6px; }
@media (min-width: 640px) { .badge-grid { grid-template-columns: repeat(3, 1fr); } }
.badge-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.badge-card.locked { opacity: 0.7; }
.badge-img { width: 56px; height: 56px; display: block; border-radius: 14px; }
.badge-img.locked { filter: grayscale(1) brightness(0.55); opacity: 0.75; }
.badge-card .b-name { font-size: 12.5px; font-weight: 700; }
.badge-card .b-desc { font-size: 12.5px; color: #b7bfd2; line-height: 1.4; }
.badge-card.locked .b-desc { color: #8791a8; }
.badge-card .b-progress { font-size: 11.5px; font-weight: 700; font-family: "Space Mono", monospace; }

/* ---------- Settings ---------- */
.settings-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.settings-top h2 { font-size: 20px; }
.setting-block { margin-top: 22px; }
.setting-block .label { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.shape-options, .theme-options { display: flex; gap: 10px; }
.opt-btn {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 11.5px;
}
.opt-btn.active { border-color: var(--c-avis); color: var(--text); }
.opt-btn svg { width: 30px; height: 30px; }
.theme-swatch { display: flex; gap: 4px; }
.theme-swatch i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.danger-btn {
  width: 100%; margin-top: 24px; padding: 14px;
  background: var(--surface); border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm); color: var(--danger); font-weight: 600; font-size: 14px;
}
.about-text { color: var(--text-faint); font-size: 12px; line-height: 1.6; margin-top: 28px; }
.about-text-sm { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin-top: 8px; }
.admin-cutoff-card { text-align: left; }
.admin-cutoff-card code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-family: "Space Mono", monospace;
  font-size: 11px;
}

.empty-hint { color: var(--text-dim); font-size: 13px; padding: 30px 0; text-align: center; }

/* ---------- Admin ---------- */
.admin-list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 26px 0 10px; }
.admin-sort { display: flex; gap: 6px; }
.admin-sort-btn {
  background: var(--surface);
  border: 1px solid var(--surface-3);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
}
.admin-sort-btn.active { background: var(--c-avis); border-color: var(--c-avis); color: #0a0c11; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
}
.admin-row:active { border-color: var(--c-avis); }
.admin-row-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.admin-row-name { font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -0.01em; }
.admin-row-score { font-family: "Space Mono", monospace; font-weight: 800; font-size: 22px; flex-shrink: 0; }
.admin-metrics { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--surface-3); border-bottom: 1px solid var(--surface-3); }
.admin-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16.5px;
  font-weight: 800;
  font-family: "Space Mono", monospace;
}
.admin-metric .icon { flex-shrink: 0; }
.admin-metric--off { color: var(--text-faint); }
.admin-row-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.admin-trophies {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--gold);
  font-family: "Space Mono", monospace;
  white-space: nowrap;
}
.admin-trophies .icon { color: var(--gold); }
