:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #16191d;
  --muted: #5d6673;
  --accent: #1f5fd0;
  --accent-soft: #e8effb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --border: #333a45;
    --text: #e8eaed;
    --muted: #9aa4b2;
    --accent: #6ea0ff;
    --accent-soft: #23304a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 10px 10px 28px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- barre haute ---------- */

.bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.breadcrumb {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 34px;
}

.settings-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.settings-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- réglages ---------- */

.settings {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
}

.settings-hint { margin: 0 0 10px; color: var(--muted); font-size: .8rem; }

.apply {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

.toggle {
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
}

.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Un niveau désactivé reste visible mais en retrait. */
.card.off .label, .card.off .meta { opacity: .45; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}

.crumb.current { background: var(--accent-soft); border-color: var(--accent); cursor: default; }
.crumb .rank { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.crumb-sep { color: var(--muted); }

/* ---------- cartes ---------- */

.deck { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: box-shadow .15s;
}

/* Carte saisie : soulevée et transportée par `transform` pendant le geste. */
.card.dragging {
  position: relative;
  z-index: 5;
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(16, 24, 40, .22);
  transition: none;
}

body.is-dragging { user-select: none; -webkit-user-select: none; }

/* Poignée : cible tactile de 44 px. `touch-action: none` empêche le
   défilement de la page de confisquer le geste. */
.drag-handle {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 3px;
  width: 44px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

.drag-handle:active { cursor: grabbing; }

.rank-number { font-weight: 700; font-size: .95rem; line-height: 1; font-variant-numeric: tabular-nums; }

/* Points de préhension : le signe usuel d'un élément déplaçable. */
.grip {
  width: 10px;
  height: 7px;
  opacity: .55;
  background-image: radial-gradient(currentColor 42%, transparent 46%);
  background-size: 4px 3.5px;
}

.label { font-weight: 600; font-size: .92rem; line-height: 1.3; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .76rem; line-height: 1.3; overflow-wrap: anywhere; }

.open {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

/* ---------- états ---------- */

.status {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
}

.status.error { border-color: #d4534d; color: #d4534d; }

.field-pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  color: var(--text);
  font-size: .8rem;
}

select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
}

.empty { color: var(--muted); font-size: .85rem; padding: 10px 0; }

.more { margin-top: 12px; text-align: center; }

.more button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}

/* Le dictionnaire des champs n'a ni poignée ni bouton : une seule colonne. */
.card.schema-row { grid-template-columns: minmax(0, 1fr); padding: 8px 10px; }
