:root {
  --bg: #f6f3ee; --card: #fff; --ink: #1f1d1a; --muted: #6f6a62; --line: #e2ddd4;
  --accent: #8a3b12; --accent-ink: #fff; --danger: #b3261e; --ok: #2f6b3a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
/* L'attribut hidden doit toujours masquer, même si une classe fixe display */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.brand span { color: var(--muted); font-weight: 400; }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: .9em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login { max-width: 380px; margin: 10vh auto 0; display: grid; gap: 14px; }
h1 { margin: 0 0 8px; font-size: 1.4rem; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
label small { font-weight: 400; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
input, textarea, select { font: inherit; font-size: 16px; /* évite le zoom iOS */
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox], input[type=color], input[type=range] { width: auto; padding: 0; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 700; padding: 0 6px; }

.entry-form { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-small { min-height: 34px; padding: 4px 12px; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost.active { background: var(--accent); color: var(--accent-ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); margin-left: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.alert { background: #fde8e6; color: var(--danger); padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.notice { background: #e6f2e8; color: var(--ok); padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: .85rem; margin: 0; } .pad { padding: 16px; }

.search { display: flex; gap: 8px; }
.list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; gap: 12px; padding: 12px; color: inherit; text-decoration: none; align-items: flex-start; }
.list a:hover { background: #faf8f4; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; background: #eee; }
.entry { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-width: 0; }
.entry em { color: var(--muted); font-size: .9em; }
.entry .def { flex-basis: 100%; color: var(--muted); font-size: .92em; }
.ipa { font-family: "Doulos SIL", "Charis SIL", "Gentium Plus", "Lucida Grande", "Segoe UI", sans-serif; }

/* Clavier phonétique */
.ipa-wrap { display: flex; gap: 8px; }
.ipa-wrap .btn { flex: none; }
.ipa-kb { background: #efebe4; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px;
  margin-top: -8px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.ipa-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ipa-label { font-size: .72rem; color: var(--muted); width: 100%; text-transform: uppercase; letter-spacing: .04em; }
.ipa-key { min-width: 40px; height: 42px; padding: 0 8px; font-size: 20px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); cursor: pointer; font-family: "Doulos SIL", "Charis SIL", "Lucida Grande", sans-serif; }
.ipa-key:active { background: var(--accent); color: #fff; }
.ipa-key.wide { flex: 1; font-size: 14px; }
.ipa-ctrl .ipa-key { font-size: 16px; }

/* Synonymes */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }
.chip { background: #efe4da; color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: .88rem; }

/* Illustration */
.tabs { display: flex; gap: 6px; }
.tab { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.draw-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#drawCanvas { width: 100%; height: auto; aspect-ratio: 3 / 2; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; touch-action: none; cursor: crosshair; display: block; }
.current { display: flex; align-items: center; gap: 12px; }
.current img { max-width: 160px; max-height: 120px; border: 1px solid var(--line); border-radius: 6px; }

/* Choix de la langue (drapeaux du site adecec.net) */
.langs { display: inline-flex; gap: 6px; align-items: center; }
.lang { display: inline-flex; padding: 2px; border-radius: 4px; border: 2px solid transparent; opacity: .45; transition: opacity .15s; }
.lang:hover, .lang:focus-visible { opacity: 1; }
.lang.active { opacity: 1; border-color: var(--accent); }
.img-flag { width: 30px; height: 20px; object-fit: cover; display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }

/* Clavier phonétique : bouton de dépliage et écoute */
.ipa-toggle { gap: 6px; white-space: nowrap; }
.ipa-toggle .chev { font-size: .8em; }
@media (max-width: 480px) { .ipa-toggle-label { display: none; } }
.ipa-listen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.ipa-hint { color: var(--muted); font-size: .88rem; }

/* Choix de la voix */
.ipa-voice { width: auto; padding: 4px 8px; font-size: 14px; }
