/* Portail familial — design simple, chaleureux, natif sur mobile */
:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --ink: #1c1f22;
  --muted: #6b6f73;
  --line: rgba(28, 31, 34, .08);
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 111, 94, .12);
  --danger: #b5523b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 18px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1d2125;
    --surface-2: #262b30;
    --ink: #eceae6;
    --muted: #9a9fa4;
    --line: rgba(255, 255, 255, .08);
    --accent: #5fb39b;
    --accent-ink: #0e1a16;
    --accent-soft: rgba(95, 179, 155, .16);
    --danger: #e0806a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-user-select: none; user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
.defs { position: absolute; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.4em; font-size: 14px; margin: 12px 0 0; }

/* Boutons et champs */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 50px; padding: 0 18px; border-radius: 14px;
  font-weight: 600; text-decoration: none; color: var(--ink);
  transition: transform .12s ease, opacity .2s ease, background .2s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); margin-top: 14px; }
.btn.ghost { color: var(--accent); margin-top: 6px; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn[disabled] { opacity: .5; }
.stack { display: grid; gap: 10px; margin-top: 12px; }
.field {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 17px; outline: none; transition: border-color .2s, background .2s;
}
.field:focus { border-color: var(--accent); background: var(--surface); }
.field.pin { letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.field.pin::placeholder { letter-spacing: normal; }

/* Connexion */
.auth {
  min-height: 100%; display: grid; place-items: center;
  padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px);
  animation: fade .4s ease;
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-logo { border-radius: 20px; box-shadow: var(--shadow); }
.auth-title { font-size: 28px; letter-spacing: -.02em; margin: 18px 0 4px; }
.auth-card .muted { margin: 0 0 24px; }

/* Coquille */
.shell { min-height: 100%; }
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-t) + 14px) 20px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
}
.kicker { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.top h1 { margin: 0; font-size: 32px; letter-spacing: -.025em; }
main { padding: 6px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); max-width: 640px; margin: 0 auto; }
.pane { animation: rise .32s cubic-bezier(.2, .8, .2, 1); }
.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 4px 8px; font-weight: 600; }

/* Barre d'onglets */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; transition: color .2s; }
.tab svg { width: 25px; height: 25px; transition: transform .25s cubic-bezier(.3, 1.5, .5, 1); }
.tab.active { color: var(--accent); }
.tab.active svg { transform: translateY(-1px) scale(1.06); }

/* Cartes et listes */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.hero {
  border-radius: var(--radius); padding: 22px 20px; margin-top: 4px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #1b3a5c));
  color: #fff; box-shadow: var(--shadow);
}
.hero-hello { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.hero-sub { margin: 4px 0 0; opacity: .85; }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.member { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 8px 12px; text-align: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; color: #fff; font-weight: 700; font-size: 21px; }
.member-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-role { font-size: 12px; color: var(--muted); }
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 14px; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row.action:active { background: var(--surface-2); }
.row.danger { color: var(--danger); }
.row .grow { flex: 1; }
.dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.row.danger .dot { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.dot svg { width: 19px; height: 19px; }
.chev { width: 18px; height: 18px; color: var(--muted); }

.vault { text-align: center; padding: 28px 20px 20px; margin-top: 4px; }
.vault h2 { margin: 12px 0 4px; font-size: 22px; }
.vault .muted { margin: 0 0 18px; }
.vault-icon { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.vault-icon svg { width: 32px; height: 32px; }
.tip p { margin: 0 0 12px; }
.tip .fine { margin: 12px 0 0; }
.copy { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.copy code { font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; }
.copy span { color: var(--accent); font-weight: 600; font-size: 14px; }

.empty { text-align: center; padding: 56px 20px; }
.empty-icon { width: 76px; height: 76px; border-radius: 24px; margin: 0 auto; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty-icon svg { width: 36px; height: 36px; }
.empty h2 { margin: 18px 0 6px; }
.empty .muted { max-width: 320px; margin: 0 auto; }

/* Feuille modale */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(var(--safe-b) + 22px); max-height: 88vh; overflow: auto;
  animation: up .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet p { margin: 0 0 14px; }
.sheet .btn + .btn { margin-top: 8px; }
.linkbox { word-break: break-all; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font: 13px ui-monospace, Menlo, monospace; margin-bottom: 12px; -webkit-user-select: all; user-select: all; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.device + .device { border-top: 1px solid var(--line); }
.device .grow { flex: 1; }
.device small { display: block; color: var(--muted); }
.device button { color: var(--danger); font-weight: 600; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: opacity .25s, transform .25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Papiers, admin, visionneuse ---------- */
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.icon-btn.light { background: rgba(255,255,255,.14); color: #fff; }
.text-btn { color: #fff; font-weight: 600; padding: 8px 4px; }
.tab { position: relative; }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.row small, .device small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.dot.red { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.dot.amber { background: rgba(196, 139, 36, .16); color: #b57d14; }
button.member { font: inherit; color: inherit; width: 100%; }
button.member:not([disabled]):active { transform: scale(.97); }
button.member[disabled] { opacity: 1; cursor: default; }
.avatar.small { width: 44px; height: 44px; font-size: 18px; margin: 0; }
.avatar.tiny { width: 30px; height: 30px; font-size: 13px; margin: 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; }
.sheet-head p { margin: 2px 0 0; }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 2px 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg button { height: 40px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.inline { display: flex; gap: 8px; }
.btn.fit { width: auto; margin: 0; padding: 0 18px; }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.danger-soft { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.top-gap { margin-top: 12px; }
.stack.top-gap { margin-top: 18px; }
.stack.narrow { max-width: 320px; margin: 22px auto 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bigpin { font: 700 40px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; text-align: center; padding: 22px; margin: 6px 0 16px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); -webkit-user-select: all; user-select: all; }
.list.flat { box-shadow: none; background: var(--surface-2); margin-bottom: 12px; }
select.field { -webkit-appearance: none; appearance: none; }
.pad { padding: 40px 20px; }
.readonly { text-align: center; margin: 4px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.chips button.on { background: var(--accent); color: var(--accent-ink); }
.preview { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.preview svg { width: 40px; height: 40px; color: var(--muted); }

.person { margin-top: 22px; }
.person-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 10px; }
.person-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; flex: 1; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.doc { text-align: left; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 8px 10px; transition: transform .12s; }
.doc:active { transform: scale(.97); }
.doc-thumb { position: relative; aspect-ratio: 1.45; border-radius: 12px; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb svg { width: 30px; height: 30px; }
.doc.add { box-shadow: none; background: transparent; border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent); }
.doc.add .doc-thumb { background: transparent; color: var(--accent); }
.doc.add .doc-name { text-align: center; color: var(--accent); }
.pdf-tag { position: absolute; top: 6px; right: 6px; font: 700 10px/1 -apple-system, sans-serif; font-style: normal; padding: 4px 6px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; }
.doc-name { font-weight: 600; font-size: 14px; margin: 8px 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; margin-left: 2px; }
.chip.ok, .chip.none { background: var(--surface-2); color: var(--muted); }
.chip.soon { background: rgba(196, 139, 36, .16); color: #b57d14; }
.chip.expired { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.viewer { position: fixed; inset: 0; z-index: 40; background: #0c0d0e; color: #fff; display: flex; flex-direction: column; animation: fade .2s ease; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 12px 10px; background: rgba(12,13,14,.9); }
.viewer-title { flex: 1; min-width: 0; }
.viewer-title b, .viewer-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title small { color: rgba(255,255,255,.65); font-size: 13px; }
.viewer-body { flex: 1; overflow: auto; padding: 12px 12px calc(var(--safe-b) + 16px); display: flex; flex-direction: column; align-items: center; gap: 12px; -webkit-overflow-scrolling: touch; }
.viewer-img { max-width: 100%; height: auto; border-radius: 8px; margin: auto 0; -webkit-user-select: none; user-select: none; touch-action: pinch-zoom; }
.viewer-img.zoom { max-width: none; width: 250%; margin: 0; }
.pdf-page { width: 100%; max-width: 900px; height: auto; background: #fff; border-radius: 4px; }
body.noscroll { overflow: hidden; }
/* Corrections d'alignement (les <button> centrent leur contenu par défaut) */
.doc, button.member { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; }
button.member { align-items: center; }
.doc .chip { align-self: flex-start; }
.two .btn, .sheet .two .btn + .btn { margin-top: 0; }
/* Lecture automatique */
.ocr-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4; }
.ocr-note.busy { background: var(--surface-2); color: var(--muted); }
.ocr-note.busy::before { content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.ocr-note.ok { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ocr-note.warn { background: rgba(196, 139, 36, .14); color: #a0700f; }
.btn.soft#pp-read { margin-top: 10px; }
.pdf-page.zoom { max-width: none; width: 250%; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Import de plusieurs fichiers */
.batch { display: grid; gap: 10px; margin-top: 4px; }
.batch-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.batch-thumb { position: relative; width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--surface); color: var(--muted); }
.batch-thumb img { width: 100%; height: 100%; object-fit: cover; }
.batch-fields { flex: 1; min-width: 0; }
.batch-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-inputs { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 6px; }
.field.sm { height: 40px; padding: 0 10px; font-size: 14px; border-radius: 10px; background: var(--surface); }
.batch-state { margin-top: 6px; }
.batch-state.ok-txt { color: var(--accent); font-weight: 600; }
.batch-state.warn-txt { color: #a0700f; }
.batch-state.err-txt { color: var(--danger); }
.batch-x { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); flex: none; }
.batch-x svg { width: 18px; height: 18px; }
/* Faces (recto / verso) dans la feuille d'ajout */
.faces { display: grid; gap: 10px; margin-bottom: 10px; }
.faces .two { margin-top: 2px; }
.face { border-radius: 14px; background: var(--surface-2); overflow: hidden; }
.face-img { position: relative; display: grid; place-items: center; background: #1b1d1f; max-height: 260px; }
.face-img img { max-width: 100%; max-height: 260px; display: block; }
.face-img.pdf { background: var(--surface); height: 120px; color: var(--muted); }
.face-img.pdf svg { width: 40px; height: 40px; }
.face-tag { position: absolute; left: 8px; top: 8px; font: 700 11px/1 -apple-system, sans-serif; font-style: normal; padding: 5px 8px; border-radius: 7px; background: rgba(0,0,0,.6); color: #fff; }
.face-bar { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 6px 8px; }
.text-btn.dark { color: var(--accent); font-size: 14px; display: inline-flex; align-items: center; gap: 4px; padding: 6px; }
.text-btn.dark svg { width: 16px; height: 16px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.three .btn { min-height: 44px; padding: 0 8px; font-size: 14px; margin: 0; }
.btn.soft { margin-top: 0; }
#pp-faces .btn.soft { min-height: 44px; font-size: 14px; }
.batch-verso { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 6px; }
.batch-verso input { width: 18px; height: 18px; accent-color: var(--accent); }
.batch-row.is-verso { margin-top: -6px; border-top-left-radius: 4px; border-top-right-radius: 4px; }
.batch-acts { display: flex; gap: 8px; margin-top: 2px; }
.batch-state.busy-txt { color: var(--muted); }

/* Outil de recadrage */
.cropper { position: fixed; inset: 0; z-index: 70; background: #0c0d0e; color: #fff; display: flex; flex-direction: column; animation: fade .2s ease; touch-action: none; }
.crop-top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 10px) 14px 10px; }
.crop-top b { font-size: 16px; }
.crop-stage { flex: 1; display: grid; place-items: center; min-height: 0; }
.crop-box { position: relative; }
.crop-box img { width: 100%; height: 100%; display: block; -webkit-user-select: none; user-select: none; pointer-events: none; }
.crop-box svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.crop-poly { fill: rgba(95, 179, 155, .18); stroke: #5fb39b; stroke-width: 4; vector-effect: non-scaling-stroke; }
.crop-h { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; touch-action: none; display: grid; place-items: center; cursor: grab; }
.crop-h::after { content: ''; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid #5fb39b; box-shadow: 0 2px 8px rgba(0,0,0,.5); transition: transform .15s; }
.crop-h.drag::after { transform: scale(1.4); }
.crop-hint { text-align: center; color: rgba(255,255,255,.7); font-size: 14px; margin: 8px 16px; }
.crop-bottom { padding: 8px 16px calc(var(--safe-b) + 16px); }

/* ---------- Bibliothèque d'outils ---------- */
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tool { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: transform .12s; }
.tool:active { transform: scale(.97); }
.tool b { font-size: 16px; margin-top: 8px; }
.tool small { color: var(--muted); font-size: 13px; }
.tool-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #1b3a5c)); color: #fff; }
.tool-icon svg { width: 24px; height: 24px; }
.tool.soon { box-shadow: none; background: transparent; border: 1.5px dashed color-mix(in srgb, var(--muted) 40%, transparent); opacity: .7; }
.tool.soon .tool-icon { background: var(--surface-2); color: var(--muted); }

/* Écran d'outil */
.toolscreen { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; animation: slidein .28s cubic-bezier(.2, .8, .2, 1); }
.tool-top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 14px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.tool-title { flex: 1; min-width: 0; }
.tool-title b { display: block; font-size: 18px; }
.tool-title small { display: block; color: var(--muted); font-size: 13px; min-height: 1em; }
.tool-actions { display: flex; gap: 8px; }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); }
.tool-body { flex: 1; overflow: auto; padding: 4px 16px calc(var(--safe-b) + 120px); -webkit-overflow-scrolling: touch; }
.tool-body > * { max-width: 680px; margin-left: auto; margin-right: auto; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

.notes-seg { margin: 6px auto 12px; }
.searchbox { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; color: var(--muted); }
.searchbox svg { width: 18px; height: 18px; }
.searchbox input { flex: 1; border: 0; background: none; font: inherit; color: var(--ink); outline: none; }
#notes-new { margin-bottom: 8px; }
.notes-list { display: grid; gap: 8px; }
.month { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 4px 2px; }
.month::first-letter { text-transform: uppercase; }
.entry { display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.entry-day { width: 44px; flex: none; text-align: center; }
.entry-day b { display: block; font-size: 24px; line-height: 1; color: var(--accent); }
.entry-day small { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.entry-text { flex: 1; min-width: 0; }
.entry-text b { display: block; margin-bottom: 2px; }
.entry-text span, .note-card span { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.note-card b { display: flex; align-items: center; gap: 6px; }
.note-card small { color: var(--muted); font-size: 12px; }
.pin-ico { width: 16px; height: 16px; color: var(--accent); }

/* Éditeur */
.editor { padding-top: 4px; }
.ed-date { position: relative; display: inline-block; color: var(--accent); font-weight: 600; font-size: 14px; margin: 4px 0 6px; }
.ed-date span { display: inline-block; }
.ed-date span::first-letter { text-transform: uppercase; }
.ed-date input { position: absolute; inset: 0; opacity: 0; width: 100%; }
.ed-title { width: 100%; border: 0; background: none; font: 700 24px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); outline: none; padding: 4px 0; letter-spacing: -.01em; -webkit-user-select: text; user-select: text; }
.ed-body { width: 100%; min-height: 240px; border: 0; background: none; resize: none; font: 18px/1.65 Georgia, "Iowan Old Style", "Times New Roman", serif; color: var(--ink); outline: none; padding: 6px 0; -webkit-user-select: text; user-select: text; }
.ed-title::placeholder, .ed-body::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

/* Micro */
.mic-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 16px calc(var(--safe-b) + 18px); pointer-events: none; background: linear-gradient(to top, var(--bg) 55%, transparent); }
.mic-status { pointer-events: none; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--surface); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.mic { pointer-events: auto; position: relative; width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent); transition: background .2s, transform .12s; }
.mic:active { transform: scale(.94); }
.mic svg { width: 30px; height: 30px; position: relative; }
.mic-ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; transition: transform .08s linear; }
.mic.rec { background: #d1453b; color: #fff; box-shadow: 0 6px 22px rgba(209, 69, 59, .45); }
.mic.rec .mic-ring { border-color: rgba(209, 69, 59, .35); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

a.tool { text-decoration: none; color: inherit; }
.tool-icon.music { background: linear-gradient(135deg, #1d2a38, #0e1620); color: #f0b44a; }

/* Choix du moteur de dictée */
.mic-row { display: flex; align-items: center; gap: 16px; }
.mic-mode { pointer-events: auto; min-width: 64px; height: 32px; padding: 0 10px; border-radius: 16px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 700; box-shadow: var(--shadow); }
.mic-mode.ghost { visibility: hidden; }
.mic-status { max-width: min(92vw, 520px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

body.noscroll .toast { bottom: calc(var(--safe-b) + 130px); }

/* Espace perso */
#members.as-tools { display: block; }
.tabbar.three { grid-template-columns: repeat(3, 1fr); }
#members.as-tools { margin-top: 18px; }
