/* Mise en page et composants « Or et nuit ». Couleurs, polices et durées : css/tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.55 var(--font-text);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { font-family: var(--font-title); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 var(--space); }
h2 { font-size: 1.2rem; margin: calc(var(--space) * 2) 0 calc(var(--space) * 0.75); }
h3 { font-size: 1.05rem; margin: 0 0 6px; }

.muted { color: var(--muted); }
.good { color: var(--gain); }
.bad { color: var(--loss); }
.warn { color: var(--warn); }
.mono, .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 0.92em; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---- squelette ------------------------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  transition: width var(--dur) var(--ease);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 22px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; border-radius: 9px; box-shadow: 0 6px 18px -6px var(--accent); }
.brand-mark.big { width: 44px; height: 44px; border-radius: 12px; }
.brand-name { font-family: var(--font-title); font-size: 1.3rem; font-weight: 600; letter-spacing: 0.01em; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.active { background: var(--accent-soft); color: var(--text); }
.side-link.active .icon { color: var(--accent); }
.side-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.side-collapse {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.side-collapse:hover { background: var(--surface-2); color: var(--text); }

body.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.collapsed .sidebar .label,
body.collapsed .brand-name { display: none; }
body.collapsed .side-link, body.collapsed .side-collapse { justify-content: center; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  backdrop-filter: blur(14px);
}
.page-title { margin: 0; flex: 1; font: 600 0.78rem/1 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }

.main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }
.main.enter { animation: rise var(--dur) var(--ease) both; }

/* Écran de connexion : ni menu ni barre du haut. */
body[data-auth="out"] .sidebar,
body[data-auth="out"] .topbar,
body[data-auth="out"] .tabbar { display: none; }

/* ---- messages -------------------------------------------------------------------------------- */

.notice {
  margin: 16px 32px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise var(--dur) var(--ease) both;
}
.notice.error { border-color: var(--loss); color: var(--loss); background: var(--loss-soft); }

/* ---- cartes et chiffres clés ------------------------------------------------------------------ */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.cards > .card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); }
.card.flush { padding: 0; overflow: hidden; }
.card + .card.stack, .card.stack + .card.stack { margin-top: 14px; }
.cards > .card { animation: rise var(--dur) var(--ease) both; }
.cards > .card:nth-child(2) { animation-delay: 40ms; }
.cards > .card:nth-child(3) { animation-delay: 80ms; }
.cards > .card:nth-child(4) { animation-delay: 120ms; }
.cards > .card:nth-child(n+5) { animation-delay: 160ms; }

.kpi { font-family: var(--font-num); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 4px 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.spacer { flex: 1; }

/* ---- boutons et champs ------------------------------------------------------------------------ */

button, .button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 0.92rem/1 var(--font-text);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
button:hover, .button:hover { filter: brightness(1.06); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
button.ghost, .button.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
button.ghost:hover, .button.ghost:hover { border-color: var(--accent); }
button.danger { background: var(--loss); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; }

input, select, textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  max-width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 160px; font-family: var(--font-num); font-size: 0.9rem; }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.9rem; }

/* ---- tableaux --------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }

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

.setting { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 6px 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: none; }
.setting .key { font-family: var(--font-num); font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.setting .error { color: var(--loss); font-size: 0.88rem; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); background: var(--surface-2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.sensitive { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); background: transparent; }
.badge.on { border-color: color-mix(in srgb, var(--gain) 45%, transparent); color: var(--gain); background: var(--gain-soft); }
.badge.on::before { animation: pulse 2s var(--ease) infinite; }
.badge.off { border-color: color-mix(in srgb, var(--loss) 45%, transparent); color: var(--loss); background: var(--loss-soft); }

.steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
.steps li::before { content: counter(step) ' · '; font-family: var(--font-num); }
.steps li.current { border-color: var(--accent); color: var(--text); background: var(--accent-soft); font-weight: 600; }

/* ---- connexion -------------------------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 400px; padding: 32px; }
.login .brand { padding: 0 0 18px; }
.login h1 { font-size: 1.6rem; }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; margin-top: 18px; padding: 12px; }
body[data-auth="out"] .main { max-width: none; padding: 0; }
body[data-auth="out"] .notice { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); margin: 0; z-index: 9; }

/* ---- graphiques ------------------------------------------------------------------------------- */

.chart-box { position: relative; margin: 6px 0; }
.chart { width: 100%; height: 220px; display: block; overflow: visible; touch-action: pan-y; }
.chart.bars { height: 120px; }
.chart .zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .dd-zone { fill: var(--loss-soft); }
.chart .guide { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .drawn { animation: draw var(--dur-draw) var(--ease) both; }
.bar.gain { fill: var(--gain); opacity: 0.85; }
.bar.loss { fill: var(--loss); opacity: 0.85; }
.bar:hover { opacity: 1; }
.chart-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  pointer-events: none;
}
.chart-tip {
  position: absolute;
  top: 0;
  transform: translate(-50%, -110%);
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}
.chart-tip strong { font-family: var(--font-num); font-size: 1rem; }
.chart-note { margin: 4px 0 0; font-size: 0.85rem; }
.spark { width: 100%; height: 44px; display: block; margin: 8px 0 4px; }
.spark polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark.up polyline { stroke: var(--gain); }
.spark.down polyline { stroke: var(--loss); }

.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { padding: 6px 14px; background: transparent; color: var(--muted); border: 0; font-family: var(--font-num); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: 6px 0 12px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); }
.facts b { color: var(--text); font-weight: 600; }
.num.big { font-size: 1.25rem; font-weight: 600; }
.row.tight { margin: 4px 0; }
h4 { margin: 18px 0 6px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
.flash { animation: flash 1.2s var(--ease); border-radius: 4px; }

/* ---- fond animé de la connexion ---------------------------------------------------------------- */

.login-wrap { position: relative; overflow: hidden; }
.login-wrap .login { position: relative; z-index: 1; backdrop-filter: blur(10px); background: color-mix(in srgb, var(--surface) 86%, transparent); }
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-bg .blob { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px); opacity: 0.35; animation: aurora 18s ease-in-out infinite alternate; }
.login-bg .a { background: var(--accent); top: -18vmax; right: -12vmax; }
.login-bg .b { background: #6b4fd8; bottom: -22vmax; left: -14vmax; animation-delay: -6s; opacity: 0.22; }
.login-bg .c { background: var(--gain); top: 30%; left: 40%; width: 26vmax; height: 26vmax; animation-delay: -12s; opacity: 0.12; }

.main.static .cards > .card, .main.static.enter { animation: none; }
dl.summary { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; font-weight: 500; }

/* ---- tableaux triables et dépliables ------------------------------------------------------------ */

.th-sort {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sort-icon { width: 14px; height: 14px; opacity: 0.35; transition: opacity var(--dur-fast) var(--ease), transform var(--dur) var(--ease); }
th[aria-sort] { color: var(--accent); }
th[aria-sort] .sort-icon { opacity: 1; }
th[aria-sort="descending"] .sort-icon { transform: scaleY(-1); }
th.num, td.num { text-align: right; font-family: var(--font-num); }
td.empty { text-align: center; padding: 28px; }
tr.expandable { cursor: pointer; }
tr.expandable[aria-expanded="true"] { background: var(--accent-soft); }
tr.expand > td { background: var(--surface-2); padding: 16px 18px; animation: fade var(--dur) var(--ease) both; }
.expand dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.expand dt { color: var(--muted); }
.expand dd { margin: 0; font-family: var(--font-num); }

/* ---- fenêtre de confirmation ---------------------------------------------------------------- */

dialog.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  animation: pop var(--dur) var(--ease) both;
}
dialog.dialog.danger { border-color: color-mix(in srgb, var(--loss) 55%, var(--line)); }
dialog.dialog h2 { margin: 0 0 10px; }
dialog.dialog p { color: var(--muted); margin: 0 0 14px; }
dialog.dialog .typed { width: 100%; font-family: var(--font-num); letter-spacing: 0.15em; text-transform: uppercase; }
dialog::backdrop { background: rgba(5, 6, 10, 0.62); backdrop-filter: blur(4px); animation: fade var(--dur) var(--ease) both; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---- toasts ---------------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.toast > span { flex: 1; }
.toast .icon { color: var(--gain); }
.toast.error { border-color: color-mix(in srgb, var(--loss) 55%, var(--line)); }
.toast.error .icon { color: var(--loss); }
/* Durée de vie : animation sans mouvement, gardée même sous « réduire les animations ». */
.toast:not(.error):not(.leaving) { animation: toast-life var(--toast-life) linear both !important; }
.toast:not(.error)::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  animation: drain var(--toast-life) linear both;
}
.toast.leaving { animation: toast-out var(--dur-fast) var(--ease) both; }
.toast-close { padding: 6px; background: transparent; color: var(--muted); border: 0; }
.toast-close:hover { color: var(--text); filter: none; }
.toast-close .icon { color: inherit; width: 16px; height: 16px; }

/* ---- interrupteurs, curseurs, aides ----------------------------------------------------------- */

.switch { position: relative; display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: var(--accent-text); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.num-field { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.num-input { width: 8.5em; font-family: var(--font-num); text-align: right; }
.slider { width: 180px; accent-color: var(--accent); background: transparent; border: 0; padding: 0; }

.help { position: relative; display: inline-grid; place-items: center; color: var(--muted); cursor: help; vertical-align: middle; }
.help .icon { width: 16px; height: 16px; }
.help:hover, .help:focus { color: var(--accent); outline: none; }
.help::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font: 400 0.82rem/1.4 var(--font-text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  z-index: 15;
}
.help:hover::after, .help:focus::after { opacity: 1; transform: translate(-50%, 0); }

/* ---- squelettes ------------------------------------------------------------------------------ */

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 60%, var(--line)) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-title { width: 240px; height: 28px; margin-bottom: 22px; }
.skeleton-line { height: 12px; width: 60%; margin: 6px 0; }
.skeleton-line.short { width: 35%; }
.skeleton-kpi { height: 30px; width: 50%; margin: 12px 0; }
.skeleton-block { height: 220px; margin-top: 22px; border-radius: var(--radius-lg); }

/* ---- téléphone -------------------------------------------------------------------------------- */

.tabbar { display: none; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; animation: fade var(--dur-fast) var(--ease) both; }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: slide-up var(--dur) var(--ease) both;
}
.sheet-link { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); color: var(--text); font-weight: 500; }
.sheet-link:hover, .sheet-link.active { background: var(--accent-soft); text-decoration: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  .slider { width: 100%; }
  .topbar { padding: 12px 16px; }
  .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .notice { margin: 12px 16px 0; }
  .setting { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }
  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font: 500 0.7rem/1.2 var(--font-text);
  }
  .tab:hover { text-decoration: none; filter: none; }
  .tab.active { color: var(--accent); }
}

/* ---- animations ------------------------------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes flash { 0% { background: var(--accent-soft); color: var(--accent); } 100% { background: transparent; } }
@keyframes aurora { from { transform: translate(0, 0) scale(1); } to { transform: translate(-6vmax, 4vmax) scale(1.15); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-life { from { opacity: 1; } to { opacity: 1; } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 60% { box-shadow: 0 0 0 5px transparent; } }

/* icône qui tourne pendant une lecture en cours */
.icon.spin { animation: spin 1s linear infinite; }

/* ---- listes de choix avec recherche (selectBox) ------------------------------------------- */

.select { display: inline-flex; min-width: 12rem; max-width: 100%; vertical-align: middle; }
.select-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  font: inherit; font-weight: 500; text-align: left;
  padding: 9px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.select-trigger:hover { filter: none; border-color: var(--accent); }
.select-trigger:active { transform: none; }
.select-trigger:focus-visible, .select.open .select-trigger { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-value.placeholder { color: var(--muted); font-weight: 400; }
.select-chevron { flex: none; color: var(--muted); transition: transform var(--dur) var(--ease), color var(--dur-fast) var(--ease); }
.select.open .select-chevron { transform: rotate(180deg); color: var(--accent); }

.select-panel {
  position: fixed; z-index: 40;
  margin-top: 6px;
  max-width: calc(100vw - 2 * var(--space));
  background: var(--surface);
  border: 1px solid var(--line); border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
  overflow: hidden;
  transform-origin: top;
  animation: select-in var(--dur-fast) var(--ease) both;
}
.select-panel.up { margin-top: 0; margin-bottom: 6px; border-top: 1px solid var(--line); border-bottom: 2px solid var(--accent); transform-origin: bottom; }
@keyframes select-in { from { opacity: 0; transform: scaleY(0.96); } }

.select-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-2); }
.select-search:focus-within { color: var(--accent); }
.select-search input { flex: 1; min-width: 0; padding: 2px 0; border: 0; background: transparent; box-shadow: none; }
.select-search input:focus { box-shadow: none; }

.select-list { list-style: none; margin: 0; padding: 6px; max-height: min(320px, 50vh); overflow-y: auto; overscroll-behavior: contain; }
.select-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.select-option.active { background: var(--accent-soft); }
.select-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.select-hint { flex: none; font-size: 0.8rem; color: var(--muted); }
.select-check { flex: none; color: var(--accent); visibility: hidden; }
.select-option[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.select-option[aria-selected="true"] .select-check { visibility: visible; }
.select-option[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.select-option[aria-disabled="true"].active { background: none; }
.select-empty { padding: 14px 10px; color: var(--muted); text-align: center; font-style: italic; }

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