/* UI « delta » de Gundo, dont les valeurs ont été mesurées sur le front
   d'origine (servi par le dépôt parent) :
   bandeau gauche noir 250px / sélection #ff9900 / compteurs blancs 13px,
   toolbar de détail (teinte du thème mêlée à un gris translucide, cf.
   `.detail-toolbar`) sur 48px,
   bouton save #55aa55,
   libellés de champ #808080 16px, valeurs 24px, séparateurs #eee.

   `--main` est la couleur principale (fond de la page d'accès, barre du haut,
   sélection du bandeau, liserés, jauge de robustesse). Le thème ne change
   qu'elle : le reste de la palette est commun aux quatre thèmes. */

:root {
  --main: #ff9900;
  --blue: #1863a1;
  --green: #55aa55;
  --ink: #000;
  --dim: #808080;
  --faint: #999;
  --line: #eee;
  --side: #000;
  --mono: ui-monospace, SFMono-Regular, "DejaVu Sans Mono",
          Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* Thèmes : la couleur principale seule change. La déclaration porte sur
   `[data-theme]`, donc aussi bien `html` (qui peint la page) que les boutons
   de choix des réglages (qui peignent leur pastille par héritage). L'orange est
   listé comme les autres : sans règle propre, la pastille du bouton `orange`
   hériterait de la `--main` du thème actif et changerait de couleur. */
[data-theme="orange"] { --main: #ff9900; }
[data-theme="azur"] { --main: #3d9bfd; }
[data-theme="menthe"] { --main: #2fbf71; }
[data-theme="violet"] { --main: #b06bff; }

/* `hidden` doit gagner contre nos `display`. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--ink);
  background: var(--main);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor;
      stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ═══════════════════════════════ accès ═══════════════════════════════ */

.gate {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 40px 16px;
}

.gate-head { text-align: center; color: #fff; }
.gate-head h1 {
  margin: 0; font-size: 46px; font-weight: 400; letter-spacing: 1px;
}
.gate-head p { margin: 4px 0 0; font-size: 17px; letter-spacing: 1px; }

.gate-card {
  width: 100%; max-width: 445px;
  background: #fff; padding: 18px; border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

.gate-card input {
  display: block; width: 100%; padding: 12px 14px;
  border: 1px solid #ccc; border-radius: 2px; font-size: 22px;
  background: #fff; outline: 0;
}

/* Identifiant mémorisé en cookie : champ + croix de purge. */
.gate-field { position: relative; margin-bottom: 10px; }
.gate-field input { margin-bottom: 0; padding-right: 46px; }
.gate-clear {
  position: absolute; top: 50%; right: 9px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; color: #9a9a9a;
}
.gate-clear:hover { color: #333; background: #eee; }
.gate-clear:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.gate-clear svg { width: 19px; height: 19px; }
.gate-card input::placeholder { color: #999; }
.gate-card input:focus { border-color: #333; }

.strength { height: 3px; background: #eee; margin: -4px 0 10px; }
.strength i { display: block; height: 100%; width: 0; background: var(--main); transition: width .2s; }

.gate-submit {
  width: 100%; padding: 12px; margin-top: 4px;
  background: #c0c0c0; color: #fff; font-size: 22px; letter-spacing: 1px;
  border-radius: 2px;
}
.gate-submit:hover { background: #b3b3b3; }
.gate-submit:disabled { opacity: .6; cursor: default; }

.gate-signup {
  padding: 12px 34px; background: #c0c0c0; color: #fff;
  font-size: 22px; letter-spacing: 1px; border-radius: 2px;
}
.gate-signup:hover { background: #b3b3b3; }

.gate-foot {
  max-width: 460px; color: rgba(255, 255, 255, .85);
  font-size: 12.5px; text-align: center; line-height: 1.5;
}

.gate-lang {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255, 255, 255, .8); font-size: 13px;
}
.gate-lang button {
  padding: 2px 6px; border-radius: 3px; color: inherit;
}
.gate-lang button:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.gate-lang button.is-on { color: #fff; font-weight: 700; text-decoration: underline; }

.gate-note, .error, .steps {
  margin: 10px 0 0; font-size: 12.5px; line-height: 1.45;
}
.gate-note { color: var(--dim); }
.error { padding: 8px 10px; background: #fdecea; color: #94241a; border: 1px solid #f5c6c0; }
.steps { padding: 8px 10px 8px 26px; background: #f7f7f7; color: var(--faint); list-style: decimal; }
.steps li.done { color: #2e7d32; }
.steps li.now { color: var(--blue); font-weight: 700; }

/* ══════════════════════════ partage de secret ═══════════════════════════ */

.share-gate { gap: 14px; }
.share-card { max-width: 560px; padding: 20px 22px 22px; }
.share-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 400; }
.share-intro { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.share-card label {
  display: block; margin: 12px 0 4px;
  font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
}
.share-card textarea,
.share-card input[type=password],
.share-card select {
  width: 100%; padding: 9px 10px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #fcfcfc; color: var(--ink); font: inherit; font-size: 15px; outline: 0;
}
.share-card textarea { resize: vertical; line-height: 1.45; }
.share-card textarea:focus,
.share-card input[type=password]:focus,
.share-card select:focus {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 99, 161, .13);
}


.share-gen-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 9px; border: 1px dashed #d9d9d9; border-radius: 3px; background: #fafafa;
}
.share-gen-row input[type=text] {
  flex: 1; min-width: 0; padding: 7px 9px; border: 1px solid #d6d6d6; border-radius: 3px;
  font: inherit; font-size: 15px; background: #fff;
}
.share-gen-row input[type=text]:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(24, 99, 161, .13); outline: 0;
}
.share-gen-row .gen-set {
  margin: 0; font-size: 11px; letter-spacing: 0; text-transform: none;
  color: var(--muted); white-space: nowrap; cursor: pointer;
}
.share-gen {
  margin-left: auto; padding: 5px 10px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #fff; font-size: 13px; color: var(--ink);
}
.share-gen:hover { border-color: var(--blue); color: var(--blue); }

.share-secret-row { display: flex; gap: 8px; align-items: flex-start; }
.share-secret-row #read-secret { flex: 1; min-width: 0; }

.share-options { display: flex; gap: 12px; }
.share-options > div { flex: 1; }

.share-hint { margin: 8px 0 0; color: var(--faint); font-size: 11.5px; line-height: 1.45; }

.share-card .gate-submit { margin-top: 16px; }

.share-result { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.share-link { display: flex; gap: 6px; }
.share-link input {
  flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #f6f6f6; font-size: 13px; color: var(--ink); outline: 0;
}
.share-copy {
  flex: none; width: 38px; display: flex; align-items: center; justify-content: center;
  border: 1px solid #d6d6d6; border-radius: 3px; background: #f6f6f6; color: #666;
}
.share-copy:hover { background: #eee; color: var(--ink); }
.share-copy svg { width: 18px; height: 18px; }

#read-secret {
  margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 3px;
  background: #f8f8f8; font-family: inherit; font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

.share-nav {
  display: flex; gap: 10px; align-items: center;
  color: rgba(255, 255, 255, .85); font-size: 13px;
}
.share-nav a { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .5); }
.share-nav a:hover { border-bottom-color: #fff; }

/* lien « partager un secret » sous le formulaire d'accès */
.gate-share {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255, 255, 255, .85); font-size: 13px;
}
.gate-share a {
  color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .5);
}
.gate-share a:hover { border-bottom-color: #fff; }

/* ═══════════════════════════════ l'app ═══════════════════════════════ */

/* Bandeau de gauche pleine hauteur : le topbar n'occupe que le panneau de droite. */
.main { display: flex; height: 100%; background: #fff; }
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; padding: 0 14px; background: var(--main); color: #fff;
  flex: none;
}
.topbar .logo {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
}
/* Icônes en traits (astérisque, tag) : pas de remplissage, sinon le tag
   devient une tache blanche. */
.topbar .logo svg { width: 28px; height: 28px; stroke-width: 2.2; fill: none; stroke: #fff; flex: none; }
.topbar .logo svg:has(use[href="#i-asterisk"]) { stroke-width: 4px; }
.topbar .logo-label {
  font-size: 19px; color: #fff; max-width: 40vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 15px; opacity: .9; }
.topbar-btn { color: #fff; padding: 4px; }
.topbar-btn svg { width: 26px; height: 26px; stroke-width: 2; }
/* Bouton « filtres » : il n'existe qu'en smartphone, où le bandeau de gauche
   devient un tiroir (cf. le média 720px en fin de feuille). */
.topbar-filters { display: none; }

.columns { display: flex; flex: 1; min-height: 0; }

/* ─────────────────────────── bandeau de gauche ──────────────────────── */

.sidebar {
  width: 300px; flex: none; display: flex; flex-direction: column;
  background: var(--side); color: #fff; padding: 12px 0 0;
  overflow: hidden;
}

.filters li, .tag-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 14pt; line-height: 1.25;
  color: #fff; white-space: nowrap;
}
.filters li svg, .side-title svg { width: 19px; height: 19px; flex: none; }
.filters li:hover, .tag-list li:hover { background: #1a1a1a; }
.filters li.is-on, .tag-list li.is-on { color: var(--main); }
.filters li.is-on svg, .tag-list li.is-on svg { color: #fff; }

.filters li .label, .tag-list li .label {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
}
.count {
  flex: none; min-width: 20px; padding: 2px 5px; text-align: center;
  background: #fff; color: #000; font-size: 13px; font-weight: 300;
  border-radius: 1px;
}
.tag-list li { padding-left: 34px; }
.tag-list li.is-on .count { background: var(--main); }

.side-search {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 12px 6px; padding-bottom: 4px; border-bottom: 1px solid #555;
  color: #ccc;
}
.side-search svg { width: 19px; height: 19px; }
.side-search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: #fff;
  font-size: 15px; outline: 0;
}
.side-search input::placeholder { color: #777; }
/* On remplace la croix native (minuscule, non stylable) par la nôtre. */
.side-search input::-webkit-search-cancel-button,
.side-search input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.search-clear {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin: -4px -6px -4px 0;
  color: #9a9a9a; border-radius: 50%;
}
.search-clear:hover { color: #fff; background: #2a2a2a; }
.search-clear:active { background: #3a3a3a; }
.search-clear:focus-visible { outline: 2px solid var(--main); outline-offset: 1px; }
.search-clear svg { width: 18px; height: 18px; }

.side-title {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 12px 2px; font-size: 15px; font-weight: 400; color: #ddd;
}

.side-foot {
  margin-top: auto; padding: 10px 12px; border-top: 1px solid #222;
  color: #666; font-size: 10.5px; line-height: 1.4;
}

/* ─────────────────────────── colonne des cartes ─────────────────────── */

.list-column {
  position: relative; width: 340px; flex: none;
  display: flex; flex-direction: column; min-height: 0;
  background: #fff; border-right: 1px solid #d5d5d5;
  overflow: hidden;
}

.list-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  /* laisse le dernier élément dépasser au-dessus du bouton flottant */
  padding-bottom: 84px;
}

.card-list li {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-size: 16px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-list li:hover { background: #fafafa; }
.card-list li.is-on { background: #eef3f7; box-shadow: inset 3px 0 0 var(--main); }
.card-list li .sub { display: block; margin-top: 2px; color: var(--faint); font-size: 12px; }
.list-empty { padding: 22px 16px; color: var(--faint); font-size: 14px; }

/* Bouton flottant « nouvelle carte » : mêmes teintes que la barre d'actions du
   détail (couleur du thème mêlée au gris translucide), survol un cran plus
   dense — #1863a1 / #14548a restent les replis sans `color-mix`. */
.fab {
  position: absolute; bottom: 18px; right: 18px;
  display: flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; border-radius: 50%;
  color: #fff;
  background: var(--blue);
  background: color-mix(in srgb, var(--main) 55%, #9b9a9a4d);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.fab:hover {
  background: #14548a;
  background: color-mix(in srgb, var(--main) 45%, #9b9a9a4d);
}
.fab svg { width: 30px; height: 30px; stroke-width: 2.4; }

/* ─────────────────────────── détail / éditeur ───────────────────────── */

.detail { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }

/* Barre d'actions du détail : elle suit le thème, mêlé à un gris translucide
   (#9b9a9a4d) — la teinte obtenue est plus claire que `--main` et laisse
   transparaître le panneau. Le bleu #1863a1 mesuré sur le front d'origine reste
   le repli pour les navigateurs sans `color-mix`. */
.detail-toolbar {
  display: flex; justify-content: flex-end; align-items: stretch;
  height: 48px; flex: none; color: #fff;
  background: var(--blue);
  background: color-mix(in srgb, var(--main) 55%, #9b9a9a4d);
}
.detail-toolbar button {
  padding: 0 22px; color: #fff; font-size: 16px; opacity: .95;
}
.detail-toolbar button:hover { background: rgba(0, 0, 0, .12); }
/* Retour détail → liste : seulement en smartphone, quand les deux colonnes
   s'alternent au lieu de cohabiter. */
.toolbar-back { display: none; }
.toolbar-back svg { width: 24px; height: 24px; stroke-width: 2.2; }

.detail-scroll { flex: 1; overflow-y: auto; padding: 16px 26px 40px; }
.placeholder { color: var(--faint); font-size: 15px; }

.detail-title {
  margin: 4px 0 10px; font-size: 30px; font-weight: 400; line-height: 1.15;
  word-break: break-word;
}

.detail-tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  margin-bottom: 12px; color: var(--ink); font-size: 17px; font-weight: 300;
}
.detail-tags svg { width: 20px; height: 20px; color: #bbb; }
.detail-tags .tag { cursor: pointer; }
.detail-tags .tag:hover { color: var(--blue); }

.field {
  padding: 9px 0 11px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 10px;
}
.field-main { flex: 1; min-width: 0; }
.field-label {
  display: block; padding-bottom: 4px; color: var(--dim); font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field-value {
  display: block; font-size: 24px; line-height: 1.25;
  word-break: break-all; user-select: text;
  /* Toute valeur se copie d'un clic : le curseur doit le dire. */
  cursor: pointer;
}
.field-value:hover {
  text-decoration: underline dotted; text-underline-offset: 4px;
  text-decoration-color: #bbb;
}
.field-value:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.field-value.masked { letter-spacing: 2px; }
.field-actions { flex: none; display: flex; gap: 2px; margin-top: 18px; color: #c4c4c4; }
.field-actions button { padding: 2px 4px; color: inherit; }
.field-actions button:hover { color: var(--ink); }
.field-actions svg { width: 20px; height: 20px; }

.notes-block { margin-top: 18px; }
.notes-block .field-label { color: var(--dim); }
.notes-block p { white-space: pre-wrap; font-size: 16px; line-height: 1.5; }

/* ─────────────────────────────── éditeur ────────────────────────────── */

.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-scroll { flex: 1; overflow-y: auto; padding: 16px 26px 26px; }

.edit-title {
  width: 100%; padding: 6px 10px; margin-bottom: 12px;
  border: 1px solid #ccc; border-radius: 2px; font-size: 26px; outline: 0;
}
.edit-title:focus { border-color: var(--blue); }

.tag-editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 4px 0 14px; border-bottom: 1px solid var(--line);
}
.tag-editor .tag-icon { width: 20px; height: 20px; color: #bbb; flex: none; }
.tag-editor ul { display: contents; }
.tag-editor li {
  display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 300;
}
.tag-editor li button { color: #bbb; display: flex; padding: 2px; }
.tag-editor li button:hover { color: #9b0000; }
.tag-editor li button svg { width: 16px; height: 16px; }
#edit-add-tag {
  flex: 1 1 150px; min-width: 130px; max-width: 300px; padding: 4px 8px;
  border: 1px dashed #d5d5d5; border-radius: 3px; background: #fafafa;
  outline: 0; font-size: 14px; color: var(--ink);
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
#edit-add-tag:hover { border-color: #c0c0c0; }
#edit-add-tag:focus {
  border-style: solid; border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 99, 161, .13);
}
#edit-add-tag::placeholder { color: #b5b5b5; font-style: italic; }

.field-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 6px; margin: 0 -6px;
  border-bottom: 1px solid var(--line); border-radius: 3px;
  transition: background-color .12s;
}
/* Bloc entier en surbrillance légère au survol. */
.field-row:hover { background: #f6f6f6; }
.field-row.is-dragging { opacity: .45; }
.field-row.drop-before { box-shadow: inset 0 2px 0 var(--blue); }
.field-row.drop-after { box-shadow: inset 0 -2px 0 var(--blue); }

.row-grip {
  flex: none; margin-top: 7px; color: #cfcfcf; cursor: grab;
  border-radius: 2px; padding: 0 1px;
}
.row-grip:hover { color: #666; background: #ececec; }
.row-grip:active { cursor: grabbing; }
.row-grip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.row-grip svg { width: 14px; height: 20px; }

.row-remove { flex: none; margin-top: 6px; color: #b8b8b8; }
.row-remove:hover { color: #9b0000; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Champs de l'éditeur : ils doivent se voir comme des champs (bord + fond),
   contrairement à la vue lecture où la valeur est du texte. */
.row-label, .row-value {
  width: 100%; border: 1px solid #d6d6d6; border-radius: 3px;
  outline: 0;
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.row-label {
  margin-bottom: 5px; padding: 4px 8px;
  color: #5f5f5f; font-size: 15px; background: #f1f1f1;
}
.row-value {
  padding: 6px 8px; font-size: 20px; background: #fff;
}
.row-label:hover, .row-value:hover { border-color: #c8c8c8; }
.row-label::placeholder, .row-value::placeholder { color: #b5b5b5; }
/* Masque d'un champ secret vide : puces, comme dans la vue lecture. */
.row-value[data-masked]::placeholder { letter-spacing: 2px; font-size: 14px; }
.row-label:focus, .row-value:focus {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 99, 161, .13);
}
/* Valeur + actions sur une même ligne : alignement garanti sur le champ. */
.row-value-line { display: flex; align-items: center; gap: 4px; }
.row-value-line .row-value { flex: 1; min-width: 0; }
.row-actions { flex: none; display: flex; align-items: center; gap: 2px; }
.row-actions button { color: #b0b0b0; padding: 2px; }
.row-actions button:hover { color: var(--ink); }
.row-actions svg { width: 19px; height: 19px; }

.add-field {
  display: block; width: 100%; margin: 8px 0 18px; padding: 10px;
  border: 1px dashed #d0d0d0; color: var(--dim); font-size: 15px;
}
.add-field:hover { border-color: var(--blue); color: var(--blue); }

.edit-notes-label { display: block; margin: 6px 0 4px; color: var(--dim); font-size: 16px; }
#edit-notes {
  width: 100%; padding: 8px 10px; border: 1px solid #dedede; border-radius: 3px;
  background: #fcfcfc; font-size: 15px; line-height: 1.5; outline: 0; resize: vertical;
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
#edit-notes:hover { border-color: #c8c8c8; }
#edit-notes:focus {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 99, 161, .13);
}

.editor-actions { flex: none; display: flex; border-top: 1px solid #ddd; }
.editor-actions button {
  flex: 1; padding: 13px; color: #fff; font-size: 19px; letter-spacing: .5px;
}
.editor-actions .save { background: var(--green); }
.editor-actions .save:hover { background: #4c9c4c; }
.editor-actions .cancel { background: #7f7f7f; }
.editor-actions .cancel:hover { background: #737373; }

/* ───────────────────────── générateur de mot de passe ───────────────── */

.generator {
  position: fixed; z-index: 60; width: 320px;
  background: #333; color: #fff; border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  padding: 6px 8px 8px;
}
.generator::after {
  content: ""; position: absolute; left: var(--arrow, 26px);
  border: 6px solid transparent;
}
.generator.is-below::after { bottom: 100%; border-bottom-color: #333; }
.generator.is-above::after { top: 100%; border-top-color: #333; }
.gen-gear { display: block; margin: 0 auto 2px; color: #999; }
.gen-gear:hover { color: #fff; }
.gen-gear svg { width: 18px; height: 18px; }

.gen-options { background: #fff; color: #000; padding: 6px 8px; margin-bottom: 6px; border-radius: 2px; }
.gen-length { display: block; font-size: 11px; }
.gen-length input {
  width: 52px; margin-left: 4px; padding: 1px 3px; font-size: 13px; font-weight: 700;
  text-align: right; border: 1px solid #bbb;
}
.gen-charsets {
  margin-top: 4px; font-size: 11px;
  display: flex; flex-wrap: wrap; gap: 1px 7px; align-items: center;
}
.gen-charsets label { cursor: pointer; white-space: nowrap; }
.gen-charsets input { margin: 0 3px 0 0; vertical-align: -1px; }
#gen-charset {
  width: 100%; margin-top: 5px; padding: 3px 4px; font-size: 11px; line-height: 1.35;
  border: 1px solid #000; color: #444; resize: none; outline: 0;
}

.gen-main { display: flex; align-items: center; gap: 6px; }
.gen-btn { flex: none; color: #999; padding: 3px; }
.gen-btn:hover { color: #fff; }
.gen-btn svg { width: 22px; height: 22px; }
.gen-value { flex: 1; min-width: 0; }
#gen-value {
  width: 100%; padding: 4px 6px; border: 0; outline: 0;
  font-size: 15px; font-weight: 700; color: #000; background: #fff;
}
.entropy { height: 2px; background: #555; }
.entropy i { display: block; height: 100%; width: 0; background: #e0e0e0; transition: width .15s, background .15s; }

/* ─────────────────────────── tiroir de droite ───────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .18s ease-out;
}
.drawer-backdrop.is-open { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; z-index: 71;
  width: 290px; max-width: 86vw; height: 100%;
  display: flex; flex-direction: column;
  background: #111; color: #fff;
  box-shadow: -8px 0 26px rgba(0, 0, 0, .35);
  transform: translateX(100%);
  transition: transform .22s ease-out;
}
.drawer.is-open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid #2a2a2a;
}
.drawer-user {
  font-size: 15px; color: #fff; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close { color: #999; display: flex; }
.drawer-close:hover { color: #fff; }
.drawer-close svg { width: 22px; height: 22px; }

.drawer-menu { padding: 8px 0; }
.drawer-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; color: #e6e6e6; font-size: 15px; text-align: left;
}
.drawer-menu button:hover { background: #1e1e1e; color: #fff; }
.drawer-menu svg { width: 20px; height: 20px; color: #bbb; }

/* Sous-menu « données » : le chevron pousse à droite, tourne à l'ouverture, et
   les entrées enfants sont en retrait sous le libellé du parent. */
.drawer-menu .drawer-chevron {
  margin-left: auto; width: 16px; height: 16px; color: #777;
  transition: transform .18s ease-out;
}
.drawer-menu button[aria-expanded="true"] .drawer-chevron {
  transform: rotate(180deg); color: #bbb;
}
.drawer-submenu button { padding-left: 38px; font-size: 14.5px; }
.drawer-submenu button:hover { background: #1e1e1e; color: #fff; }
.drawer-submenu svg { width: 18px; height: 18px; color: #999; }

/* ────────────────────────────── réglages ────────────────────────────── */

dialog.settings {
  width: 100%; max-width: 460px; padding: 0; border: 0; border-radius: 4px;
  background: #fff; color: var(--ink);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
  /* Quatre sections à présent : sur un écran court, le bouton de suppression
     sortait sous la ligne de flottaison sans moyen d'y arriver. */
  max-height: 88dvh; overflow-y: auto;
}
dialog.settings::backdrop { background: rgba(0, 0, 0, .45); }
.settings-body { padding: 16px 22px 22px; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 4px;
}
.settings-head h2 { margin: 0; font-size: 20px; font-weight: 400; }
.settings-head button { color: #aaa; display: flex; }
.settings-head button:hover { color: var(--ink); }
.settings-head svg { width: 22px; height: 22px; }

.settings-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; padding-bottom: 0; }
.settings-section h3 {
  margin: 0 0 10px; font-size: 12px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--dim); font-weight: 400;
}

.lang-choice { display: flex; gap: 8px; }
.lang-choice button {
  flex: 1; padding: 9px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #f6f6f6; font-size: 15px;
}
.lang-choice button:hover { border-color: #bbb; }
.lang-choice button.is-on {
  border-color: var(--blue); background: #eef3f7; color: var(--blue); font-weight: 700;
}

.theme-choice { display: flex; gap: 8px; }
.theme-choice button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 4px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #f6f6f6; font-size: 12.5px;
}
.theme-choice button:hover { border-color: #bbb; }
.theme-choice button.is-on {
  border-color: var(--blue); background: #eef3f7; color: var(--blue); font-weight: 700;
}
.theme-choice .swatch {
  width: 26px; height: 26px; border-radius: 50%; background: var(--main);
  border: 1px solid rgba(0, 0, 0, .16);
}

.settings-label {
  display: block; margin: 10px 0 4px;
  font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
}
.settings input[type=password] {
  width: 100%; padding: 9px 10px; border: 1px solid #d6d6d6; border-radius: 3px;
  background: #fcfcfc; font-size: 16px; outline: 0;
}
.settings input[type=password]:focus {
  border-color: var(--blue); background: #fff;
  box-shadow: 0 0 0 3px rgba(24, 99, 161, .13);
}
.settings .strength { margin: 10px 0 0; }
.settings-submit {
  width: 100%; margin-top: 14px; padding: 11px;
  background: var(--blue); color: #fff; font-size: 16px; border-radius: 3px;
}
.settings-submit:hover { background: #14548a; }
.settings-submit:disabled { background: #b9c4cc; cursor: default; }

/* Suppression du compte : la seule action destructrice de l'interface. Rouge,
   jamais la couleur principale — et placée après les règles ci-dessus pour
   l'emporter à spécificité égale. */
.settings-danger { background: #c0392b; color: #fff; }
.settings-danger:hover { background: #a93226; }
.settings-danger:disabled { background: #cfa9a3; cursor: default; }
.settings-hint { margin: 10px 0 0; color: var(--faint); font-size: 11.5px; line-height: 1.45; }
.settings-error {
  margin: 10px 0 0; padding: 8px 10px; border: 1px solid #f5c6c0;
  background: #fdecea; color: #94241a; font-size: 12.5px;
}
.settings .steps { margin-top: 10px; }

/* Deux boutons côte à côte (annuler / action) dans les dialogues d'export et
   d'import : même gabarit que `change passphrase`, mais l'annulation reste
   possible. */
.settings-actions { display: flex; gap: 10px; margin-top: 14px; }
.settings-actions button { flex: 1; padding: 11px; font-size: 16px; border-radius: 3px; }
.settings-actions .settings-submit { margin-top: 0; }
.settings-cancel { background: #7f7f7f; color: #fff; }
.settings-cancel:hover { background: #737373; }

/* ─────────────────────── modale de confirmation ─────────────────────── */

dialog.confirm {
  width: 100%; max-width: 430px; padding: 0; border: 0; border-radius: 4px;
  background: #fff; color: var(--ink);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, .45); }

.confirm .card-band { height: 4px; background: var(--main); }
.confirm-body { padding: 20px 22px 0; }
.confirm-message { margin: 0 0 12px; font-size: 16px; line-height: 1.5; }
.confirm-target {
  margin: 0 0 18px; color: var(--dim); font-size: 14px;
  overflow-wrap: anywhere;
}
.confirm-actions { display: flex; gap: 10px; padding-bottom: 20px; }
.confirm-actions button {
  flex: 1; padding: 11px; font-size: 16px; border-radius: 3px; color: #fff;
}
#confirm-delete-cancel { background: #7f7f7f; }
#confirm-delete-cancel:hover { background: #737373; }
#confirm-delete-ok { background: #c0392b; }
#confirm-delete-ok:hover { background: #a93226; }
#confirm-delete-cancel:focus-visible, #confirm-delete-ok:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}

/* ───────────────────────────────── toast ────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  padding: 9px 18px; background: #333; color: #fff; font-size: 14px;
  border-radius: 3px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); z-index: 80;
}

@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .list-column { width: 240px; }
  .detail-scroll, .editor-scroll { padding: 14px 16px 30px; }
  .field-value { font-size: 20px; }
  /* Trois actions dans une colonne de 280 à 460px : elles se resserrent (et
     s'abrègent au besoin) au lieu de déborder sous la liste des cartes. */
  .detail-toolbar button {
    padding: 0 12px; font-size: 15px;
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
}

/* ══════════════════════════════ smartphone ═══════════════════════════════
   Tout ce qui suit ne s'applique qu'aux téléphones (≤ 720px) : au-dessus, le
   rendu est intact, y compris le palier tablette ci-dessus. Le principe : une
   seule colonne — le bandeau de gauche devient un tiroir, la liste des cartes
   et le détail s'alternent, et les cibles tactiles sont agrandies. */

@media (max-width: 720px) {
  /* Champs à 16px minimum : en dessous, iOS zoome sur le champ au focus. */
  .side-search input,
  .row-label,
  .row-value,
  #edit-add-tag,
  #edit-notes,
  #gen-value,
  #read-pass { font-size: 16px; }
  .row-value { font-size: 18px; }
  .field-value { font-size: 18px; }

  /* ── écran d'accès ── */
  .gate { min-height: 100dvh; padding: 26px 14px; gap: 14px; }
  .gate-head h1 { font-size: 38px; }
  .gate-card { padding: 14px; }
  .gate-submit, .gate-signup { font-size: 20px; }
  .gate-lang button { padding: 8px 10px; }
  .gate-lang, .gate-share { font-size: 14px; }
  .gate-share a { display: inline-block; padding: 6px 0; }
  .gate-foot { font-size: 12px; }

  /* ── coquille de l'app ── */
  .main { height: 100dvh; }
  .topbar { height: 48px; padding: 0 6px; }
  .topbar-filters { display: flex; }
  .topbar-btn { padding: 8px; }
  .who { display: none; } /* l'identifiant reste dans le tiroir de droite */

  /* ── bandeau de gauche : tiroir ouvert par le bouton « filtres » ── */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 71;
    width: 280px; max-width: 84vw;
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-100%);
    transition: transform .22s ease-out;
  }
  /* Ombre seulement quand le tiroir est ouvert : sinon elle resterait peinte
     au bord gauche de l'écran, tiroir hors champ. */
  .sidebar.is-open { transform: translateX(0); box-shadow: 8px 0 26px rgba(0, 0, 0, .35); }
  .filters li, .tag-list li { padding: 12px; font-size: 16px; }
  .tag-list li { padding-left: 34px; }
  .side-search { margin: 10px 12px 8px; }
  .search-clear { width: 34px; height: 34px; }

  /* ── liste des cartes ── */
  .columns { position: relative; }
  .list-column { width: auto; flex: 1; border-right: 0; }
  .card-list li { padding: 15px 16px; }
  .fab { bottom: 16px; right: 16px; width: 56px; height: 56px; }

  /* ── liste et détail s'alternent (classe posée par app.js) ── */
  .detail { display: none; flex: 1; min-height: 0; }
  .main.is-detail .list-column { display: none; }
  .main.is-detail .detail { display: flex; }

  .detail-toolbar { height: 52px; justify-content: space-between; }
  .detail-toolbar button { padding: 0 10px; font-size: 14px; }
  .toolbar-back { display: flex; align-items: center; padding: 0 12px; }
  .detail-scroll, .editor-scroll { padding: 14px 16px 32px; }
  .detail-title { font-size: 24px; }
  .detail-tags { gap: 10px; }
  .field-actions { margin-top: 14px; gap: 4px; }
  .field-actions button { padding: 8px; }
  .field-actions svg { width: 22px; height: 22px; }

  /* ── éditeur ── */
  .edit-title { font-size: 20px; }
  .row-grip, .row-remove { margin-top: 10px; padding: 6px; }
  .row-actions button { padding: 8px; }
  .editor-actions button { padding: 15px; font-size: 17px; }

  /* ── générateur : feuille basse (le JS cesse de le positionner) ── */
  .generator {
    left: 8px; right: 8px; top: auto; bottom: 8px;
    width: auto; max-height: 76dvh; overflow-y: auto;
  }
  .generator::after { display: none; }
  .gen-btn { padding: 8px; }
  .gen-gear { padding: 6px; }

  /* ── tiroir de droite ── */
  .drawer-menu button { padding: 14px 16px; }

  /* ── réglages et confirmation ── */
  dialog.settings, dialog.confirm {
    width: calc(100vw - 16px); max-width: none;
    max-height: 88dvh; overflow-y: auto;
  }
  .settings-body { padding: 14px 16px 18px; }
  .settings-actions { flex-wrap: wrap; }
  .theme-choice, .lang-choice { flex-wrap: wrap; }
  .theme-choice button { min-width: 68px; }
  .settings-submit, #change-passphrase { padding: 13px; }
  .confirm-body { padding: 16px 16px 0; }

  /* ── partage d'un secret ── */
  .share-card { padding: 16px; }
  .share-card input, .share-card textarea, .share-card select { font-size: 16px; }
  .share-copy { width: 44px; }

  /* ── toast ── */
  .toast { bottom: 16px; max-width: calc(100vw - 32px); text-align: center; }
}

/* Téléphones très étroits (320–360px) : les trois actions du détail tiennent
   encore, de justesse — on resserre plutôt que de laisser déborder. */
@media (max-width: 360px) {
  .detail-toolbar button { padding: 0 6px; font-size: 12.5px; }
  .gate-card input { font-size: 19px; }
  .theme-choice button { min-width: 58px; font-size: 11.5px; }
}
