/* ================= écho — feuille de style ================= */
:root {
  --ciel:      #B9DCD2;
  --papier:    #F2E9D4;
  --papier-clair: #FAF4E4;
  --papier-blanc: #F4EFE0;
  --corail:    #E8956D;
  --ambre:     #F2C879;
  --rouge:     #D65A4A;
  --rose:      #E8A5B5;
  --vert:      #5E9E4E;
  --encre:     #3A2A28;
  --brun:      #6B5445;
  --brun-clair:#8A7358;
  --sable-trait:#B99F6E;

  --micro-corps: var(--corail);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);

  --serif: Georgia, 'Times New Roman', serif;
  --mono:  'Courier New', Courier, monospace;
  --sans:  Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  background: #cbb98f;
  color: var(--encre);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh; /* dvh après vh : prioritaire quand supporté (iOS standalone) */
  overflow: hidden;
  background: var(--ciel);
  display: flex;
  flex-direction: column;
}

/* ================= écrans ================= */
.ecran {
  position: absolute;
  inset: 0;
  bottom: calc(56px + var(--safe-bot)); /* place pour les onglets + safe-area */
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.ecran.est-actif {
  opacity: 1;
  pointer-events: auto;
}

/* ================= topbar ================= */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--safe-top) + 16px) 22px 8px;
}
.logo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--encre);
}
.date-jour {
  font-family: var(--mono);
  font-size: 12px;
  color: #4A5A50;
}

/* ================= écran dictaphone ================= */
.ecran--dictaphone { background: var(--ciel); }

.decor {
  position: absolute;
  inset: 0;
  background: url('../assets/decor-desert.svg') center bottom / cover no-repeat;
  z-index: 0;
}

.dictaphone-corps {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-bottom: 6px;
}

.micro-bouton {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 128px;
  height: 174px;
  display: block;
  transform-origin: center 88%;
  transition: transform .12s ease;
}
.micro-bouton:active { transform: scale(.96); }
.micro-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.micro-corps { transition: fill .3s ease; }

.micro-bouton[data-etat="idle"]       { --micro-corps: var(--corail); }
.micro-bouton[data-etat="rec"]        { --micro-corps: var(--rouge); }
.micro-bouton[data-etat="reflexion"]  { --micro-corps: var(--ambre); }

.micro-bouton[data-etat="rec"] .micro-svg { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
.micro-bouton[data-etat="reflexion"] .micro-svg { animation: souffle 2.2s ease-in-out infinite; }
@keyframes souffle {
  0%, 100% { opacity: 1; }
  50%      { opacity: .78; }
}

.micro-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  text-align: center;
  color: var(--encre);
  margin: 0;
  min-height: 20px;
  padding: 0 24px;
  max-width: 320px;
}
.micro-label.est-chrono { font-family: var(--mono); font-style: normal; font-size: 18px; letter-spacing: 2px; }

/* ================= lecteur Léa ================= */
.lecteur-lea {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 22px 10px;
  padding: 12px 14px;
  background: var(--papier-blanc);
  border: 2.5px solid var(--encre);
  border-radius: 14px;
}
.lea-play {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: none; background: transparent; padding: 0; cursor: pointer;
}
.lea-play svg { width: 100%; height: 100%; display: block; }
.lea-play.est-lecture .icone-play { d: path('M14 12 L20 12 L20 28 L14 28 Z M24 12 L30 12 L30 28 L24 28 Z'); }
.lea-centre { flex: 1; min-width: 0; }
.lea-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--brun);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lea-ondes {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
}
.lea-ondes span {
  display: block;
  width: 3px;
  border-radius: 1.5px;
  background: #C9AB74;
}
.lea-ondes.est-lecture span { animation: onde .9s ease-in-out infinite; }
@keyframes onde {
  0%,100% { transform: scaleY(.6); }
  50%     { transform: scaleY(1); }
}
.lea-aa {
  flex: 0 0 auto;
  width: 40px; height: 30px;
  border: 2px solid var(--encre);
  border-radius: 8px;
  background: var(--rose);
  color: #4A2430;
  font-family: var(--serif);
  font-size: 15px;
  cursor: pointer;
}
.lea-aa:active { transform: scale(.94); }

/* ================= instructions ================= */
.instructions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-bottom: 14px;
}
.instructions span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--brun);
}

/* ================= écran carnet ================= */
.ecran--carnet { background: var(--papier); }
.topbar--carnet { padding-bottom: 12px; }
.export-bouton {
  border: none; background: transparent; padding: 0; cursor: pointer;
  width: 34px; height: 26px;
}
.export-bouton svg { width: 100%; height: 100%; display: block; }
.export-bouton:active { transform: scale(.92); }

.carnet-defilement {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px 24px;
}

.grenier {
  background: var(--papier-clair);
  border: 2px solid var(--encre);
  border-radius: 12px;
  padding: 14px 14px 16px;
}

.jour-titre {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brun-clair);
  margin: 14px 0 8px;
}
.jour-titre:first-child { margin-top: 2px; }

.pensee {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--encre);
  line-height: 1.5;
  padding: 2px 0;
  position: relative;
}
.pensee .heure { color: var(--sable-trait); flex: 0 0 auto; }
.pensee .texte { flex: 1; word-break: break-word; }
.pensee .supprimer {
  flex: 0 0 auto;
  border: none; background: transparent;
  color: var(--sable-trait);
  font-size: 15px; line-height: 1; cursor: pointer;
  padding: 0 2px;
  opacity: .5;
}
.pensee .supprimer:hover, .pensee .supprimer:active { opacity: 1; color: var(--rouge); }

/* synthèse dépliante */
.synthese-toggle {
  display: block;
  width: 100%;
  text-align: left;
  border: none; background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brun-clair);
  cursor: pointer;
  padding: 8px 0 2px;
}
.synthese-encart {
  display: none;
  margin: 6px 0 4px;
  padding: 12px 14px;
  background: #FAEEDA;
  border: 2px solid var(--encre);
  border-radius: 8px;
}
.synthese-encart.est-ouvert { display: block; }
.synthese-encart p {
  font-family: var(--sans);
  font-size: 12px;
  color: #633806;
  margin: 0 0 4px;
}
.synthese-copier {
  margin-top: 8px;
  border: 1.5px solid var(--encre);
  border-radius: 8px;
  background: var(--ambre);
  color: #412402;
  font-family: var(--sans);
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
}
.synthese-copier:active { transform: scale(.96); }

.grenier-vide {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--brun-clair);
  text-align: center;
  padding: 30px 10px;
}

/* réglages */
.separateur {
  border: none;
  border-top: 2px solid var(--encre);
  margin: 22px 0 18px;
}
.reglage { margin-bottom: 24px; }
.reglage-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--brun);
  margin-bottom: 12px;
}

/* curseur TONE */
.tone-piste {
  position: relative;
  height: 26px;
  margin: 0 10px 6px;
  cursor: pointer;
}
.tone-rail {
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 2.5px;
  background: var(--encre);
  border-radius: 2px;
  transform: translateY(-50%);
}
.tone-cran {
  position: absolute;
  top: 50%;
  width: 2px; height: 12px;
  background: var(--encre);
  transform: translate(-50%, -50%);
}
.tone-cran[data-cran="0"] { left: 0; }
.tone-cran[data-cran="1"] { left: 50%; }
.tone-cran[data-cran="2"] { left: 100%; }
.tone-curseur {
  position: absolute;
  top: 50%;
  width: 18px; height: 18px;
  background: var(--rouge);
  border: 2.5px solid var(--encre);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left .18s ease;
  left: 0;
}
.tone-legendes {
  display: flex;
  justify-content: space-between;
  margin: 0 2px;
}
.tone-legendes span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--brun-clair);
}
.tone-legendes span.est-actif { color: #412402; font-weight: bold; }

/* FACE B */
.faceb-champs {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.faceb-champs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--brun);
  flex: 1;
  min-width: 130px;
}
.faceb-champs input,
.faceb-champs select {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--encre);
  border: 2px solid var(--encre);
  border-radius: 8px;
  background: var(--papier-clair);
  padding: 6px 8px;
}

.carnet-pied {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--brun-clair);
  text-align: center;
  margin: 6px 0 0;
}

/* ================= onglets ================= */
.onglets {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(56px + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  display: flex;
  background: var(--papier-clair);
  border-top: 2.5px solid var(--encre);
  z-index: 5;
}
.onglet {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--brun-clair);
  cursor: pointer;
}
.onglet.est-actif {
  color: var(--encre);
  background: var(--papier-blanc);
  font-weight: bold;
  box-shadow: inset 0 3px 0 var(--rouge);
}

/* ================= popin ================= */
.popin-fond, .confirm-fond {
  position: fixed;
  inset: 0;
  background: rgba(58,42,40,.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}
.popin-fond.est-ouvert, .confirm-fond.est-ouvert { display: flex; }

.popin, .confirm {
  width: 100%;
  max-width: 380px;
  background: var(--papier-clair);
  border: 3px solid var(--encre);
  border-radius: 18px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.popin-entete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 2px solid var(--encre);
}
.popin-entete span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
}
.popin-fermer {
  border: none; background: transparent;
  font-size: 26px; line-height: 1; cursor: pointer;
  color: var(--encre);
}
.popin-corps {
  padding: 18px;
  overflow-y: auto;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--encre);
  white-space: pre-wrap;
}

/* ================= confirmation ================= */
.confirm { max-width: 320px; padding: 20px; }
.confirm-message {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  text-align: center;
  margin: 4px 0 18px;
}
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button {
  flex: 1;
  border: 2px solid var(--encre);
  border-radius: 10px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.confirm-non { background: var(--papier-blanc); color: var(--encre); }
.confirm-oui { background: var(--rouge); color: var(--papier-clair); }

/* ================= toast ================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-bot));
  transform: translateX(-50%) translateY(20px);
  background: var(--encre);
  color: var(--papier-clair);
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 30;
  max-width: 80%;
  text-align: center;
}
.toast.est-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
