:root {
  color-scheme: light;
  --ink: #173042;
  --muted: #60727c;
  --paper: #fbfdfc;
  --mist: #eff8f4;
  --line: #d8e6e1;
  --navy: #123a52;
  --teal: #2f7f6e;
  --teal-dark: #246858;
  --sun: #f4b942;
  --coral: #e66f51;
  --white: #fff;
  --shadow: 0 18px 48px rgba(18, 58, 82, .12);
  --radius: 24px;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .14em;
}
.eyebrow.light { color: #a7d9cd; }
.muted { color: var(--muted); line-height: 1.55; }
.hint { margin: -5px 0 4px; color: var(--muted); font-size: .84rem; line-height: 1.4; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }

.button {
  min-height: 46px;
  padding: 11px 19px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 750;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: var(--white); background: var(--teal); box-shadow: 0 8px 20px rgba(47, 127, 110, .2); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--ink); background: #eef4f2; border-color: var(--line); }
.button.ghost-light { color: var(--white); background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); text-decoration: none; }
.button.wide { width: 100%; margin-top: 5px; }

label { font-size: .9rem; font-weight: 720; }
input, textarea {
  width: 100%;
  border: 1px solid #bfd1cb;
  border-radius: 12px;
  color: var(--ink);
  background: var(--white);
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(47,127,110,.12); }
textarea { resize: vertical; }
.form-message { min-height: 20px; margin: 3px 0 0; font-size: .9rem; }
.form-message.error { color: #a33f32; }
.form-message.success { color: var(--teal-dark); }

/* Accès */
.gate-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(244,185,66,.24), transparent 30%),
    radial-gradient(circle at 92% 88%, rgba(47,127,110,.22), transparent 32%),
    #eff8f4;
}
.gate-card {
  width: min(100%, 430px);
  padding: 40px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 28px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  overflow: hidden;
  border: 3px solid var(--navy);
  border-radius: 20px 20px 20px 7px;
  background: var(--sun);
  box-shadow: 0 8px 18px rgba(18, 58, 82, .15);
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gate-card h1 { margin: 0; font-size: clamp(2rem, 9vw, 3rem); letter-spacing: -.04em; }
.gate-intro { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }
.gate-card input { font-size: 1.08rem; }
#access-code { text-align: center; font-size: 1.7rem; letter-spacing: .35em; }
.quiet-link { display: block; margin-top: 25px; color: var(--muted); text-align: center; font-size: .9rem; }

/* Mode enfant */
.child-page {
  overflow: hidden;
  min-height: 100svh;
  background:
    radial-gradient(circle at 17% 22%, rgba(244,185,66,.18), transparent 20%),
    radial-gradient(circle at 82% 72%, rgba(47,127,110,.16), transparent 24%),
    var(--mist);
}
.child-header {
  position: fixed;
  z-index: 5;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 14px max(22px, env(safe-area-inset-left));
}
.child-brand { color: var(--navy); font-size: .92rem; font-weight: 800; letter-spacing: -.01em; }
.parent-lock {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #6e847e;
  background: rgba(255,255,255,.66);
  text-decoration: none;
}
.child-stage { min-height: 100svh; }
.state-panel {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 35px;
  text-align: center;
}
.child-prompt {
  margin: 0 0 clamp(24px, 5vh, 50px);
  color: var(--navy);
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -.045em;
}
.mic-button {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(170px, 40vw, 245px);
  height: clamp(170px, 40vw, 245px);
  border: 0;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #378d79, #246858);
  box-shadow: 0 24px 60px rgba(47,127,110,.34), inset 0 1px rgba(255,255,255,.3);
  transition: transform .15s ease, box-shadow .2s ease;
}
.mic-button:active { transform: scale(.96); }
.mic-button.listening { background: linear-gradient(145deg, #ee8064, #cf543d); box-shadow: 0 24px 70px rgba(230,111,81,.43); }
.mic-button.processing { animation: breathe 1s ease-in-out infinite; }
.mic-ring {
  position: absolute;
  inset: -14px;
  border: 3px solid rgba(47,127,110,.2);
  border-radius: 50%;
}
.listening .mic-ring { border-color: rgba(230,111,81,.28); animation: pulse-ring 1.2s ease-out infinite; }
.mic-icon {
  position: relative;
  width: 42%;
  height: 52%;
  border: clamp(7px, 1.4vw, 11px) solid white;
  border-radius: 32px;
}
.mic-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -34%;
  width: 80%;
  height: 52%;
  border: clamp(6px, 1.2vw, 9px) solid white;
  border-top: 0;
  border-radius: 0 0 40px 40px;
  transform: translateX(-50%);
}
.mic-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -48%;
  width: 11px;
  height: 28px;
  border-radius: 8px;
  background: white;
  transform: translateX(-50%);
}
.child-status { margin: clamp(28px, 5vh, 48px) 0 0; color: var(--teal-dark); font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 750; }
.compatibility-note { max-width: 420px; color: #8a5548; font-size: .9rem; }
.success-panel { position: relative; background: rgba(255,255,255,.25); }
.animal-visual {
  display: grid;
  place-items: center;
  width: min(72vw, 510px);
  height: min(48vh, 430px);
  overflow: hidden;
  border: 10px solid white;
  border-radius: clamp(28px, 5vw, 54px);
  background: linear-gradient(145deg, #f9e4a9, #f8c87b);
  box-shadow: 0 22px 65px rgba(18,58,82,.17);
  animation: reveal .5s cubic-bezier(.2,.9,.3,1.2);
}
.animal-visual img { width: 100%; height: 100%; object-fit: cover; }
.animal-emoji { font-size: clamp(7rem, 22vw, 12rem); filter: drop-shadow(0 12px 12px rgba(77,56,20,.18)); }
.bravo { margin: 26px 0 3px; color: var(--coral); font-size: clamp(1.2rem, 4vw, 1.65rem); font-weight: 850; }
.animal-name { margin: 0; color: var(--navy); font-size: clamp(2.5rem, 9vw, 5.6rem); letter-spacing: .04em; }
.success-actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.round-action { width: 50px; height: 50px; border: 1px solid var(--line); border-radius: 50%; background: white; }
.confetti { position: absolute; pointer-events: none; inset: 0; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -18px;
  left: var(--x);
  width: 10px;
  height: 17px;
  border-radius: 3px;
  animation: confetti-fall 1.8s var(--delay) ease-out both;
}

/* Espace parents */
.admin-page { background: #f3f7f5; }
.admin-header {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 30px max(5vw, 24px);
  color: white;
  background:
    radial-gradient(circle at 85% 20%, rgba(244,185,66,.22), transparent 26%),
    var(--navy);
}
.admin-header h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -.035em; }
.header-actions { display: flex; gap: 10px; }
.admin-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto 70px; }
.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 25px;
  padding: 40px 3px 24px;
}
.intro-row h2 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.035em; }
.intro-row .muted { max-width: 660px; margin-bottom: 0; }
.tabs { display: flex; gap: 8px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab {
  white-space: nowrap;
  padding: 13px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}
.tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.tab-panel { padding-top: 25px; }
.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 23px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}
.summary-strip div { display: flex; align-items: baseline; gap: 8px; padding: 18px 22px; }
.summary-strip div + div { border-left: 1px solid var(--line); }
.summary-strip strong { color: var(--navy); font-size: 1.5rem; }
.summary-strip span { color: var(--muted); font-size: .86rem; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.word-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 7px 22px rgba(18,58,82,.05); }
.word-card.disabled { opacity: .62; }
.word-card-visual { position: relative; display: grid; place-items: center; height: 180px; overflow: hidden; background: linear-gradient(145deg, #edf6f2, #d8ece4); }
.word-card-visual img { width: 100%; height: 100%; object-fit: cover; }
.word-card-visual > span:not(.status-pill) { font-size: 5.5rem; }
.status-pill { position: absolute; top: 12px; right: 12px; padding: 5px 9px; border-radius: 30px; color: var(--teal-dark); background: rgba(255,255,255,.88); font-size: .7rem; font-weight: 800; }
.word-card-body { padding: 18px; }
.category-label { margin: 0; color: var(--teal); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.word-card h3 { margin: 5px 0 8px; font-size: 1.45rem; }
.variant-preview { min-height: 38px; margin: 0 0 13px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.text-button { padding: 0; border: 0; color: var(--teal-dark); background: transparent; font-weight: 760; }
.loading-card, .empty-state { padding: 35px; border: 1px dashed #b9cec7; border-radius: 18px; color: var(--muted); text-align: center; background: rgba(255,255,255,.6); }
.panel-card { padding: clamp(22px, 4vw, 34px); border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 7px 22px rgba(18,58,82,.04); }
.panel-card h3 { margin: 0 0 8px; font-size: 1.35rem; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.panel-heading .muted { margin-bottom: 0; }
.history-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid #edf2f0; }
.history-row:first-child { border-top: 0; }
.history-row div { display: flex; flex-direction: column; gap: 3px; }
.history-row div span, .history-row time { color: var(--muted); font-size: .82rem; }
.history-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 850; }
.history-icon.good { color: white; background: var(--teal); }
.history-icon.neutral { color: var(--muted); background: #edf1f0; }
.settings-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; align-items: start; }
.range-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; color: var(--muted); font-size: .76rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid #edf2f0; }
.switch-row.compact { border: 0; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--teal); }

.word-dialog { width: min(680px, calc(100% - 24px)); max-height: 92vh; padding: 0; border: 0; border-radius: 24px; box-shadow: 0 28px 90px rgba(11,39,53,.28); }
.word-dialog::backdrop { background: rgba(10,30,41,.54); backdrop-filter: blur(3px); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; padding: clamp(22px, 5vw, 36px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.dialog-heading h2 { margin: 0; font-size: 1.8rem; letter-spacing: -.03em; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--muted); background: #eef4f2; font-size: 1.6rem; }
.two-columns { display: grid; grid-template-columns: 1fr 100px; gap: 14px; }
.image-upload-area { display: flex; align-items: center; gap: 18px; padding: 15px; border: 1px dashed #b4cac3; border-radius: 15px; background: #f7faf9; }
.mini-visual { display: grid; place-items: center; width: 92px; height: 78px; overflow: hidden; border-radius: 12px; background: #e5f1ed; font-size: 2.8rem; }
.mini-visual img { width: 100%; height: 100%; object-fit: cover; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@keyframes pulse-ring {
  from { transform: scale(.96); opacity: 1; }
  to { transform: scale(1.22); opacity: 0; }
}
@keyframes breathe {
  50% { transform: scale(.96); }
}
@keyframes reveal {
  from { opacity: 0; transform: scale(.72) rotate(-3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes confetti-fall {
  from { opacity: 0; transform: translateY(0) rotate(0); }
  10% { opacity: 1; }
  to { opacity: 0; transform: translateY(75vh) rotate(var(--spin)); }
}

@media (max-width: 720px) {
  .admin-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; padding-inline: 10px; font-size: .85rem; }
  .intro-row { align-items: stretch; flex-direction: column; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-strip div + div { border-left: 0; border-top: 1px solid var(--line); }
  .settings-grid { grid-template-columns: 1fr; }
  .panel-heading { flex-direction: column; }
  .history-row { grid-template-columns: 34px 1fr; }
  .history-row time { grid-column: 2; }
}

@media (max-width: 470px) {
  .gate-card { padding: 29px 23px; }
  .child-prompt { margin-bottom: 28px; }
  .animal-visual { width: 88vw; height: min(45vh, 390px); }
  .word-grid { grid-template-columns: 1fr; }
  .two-columns { grid-template-columns: 1fr 88px; }
  .image-upload-area { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
