/* ==========================================================================
   Chest — direction artistique reprise de Score / corentinjgt.fr : fond sombre,
   grandes taches de couleur floues, grain fin, titres en Syne, texte en DM Sans,
   cartes en verre. L'accent est un vert pomme (« sécurité ») qui glisse vers
   l'émeraude ; le dégradé vert + grain est réservé à ce qui est actif.
   Pensé d'abord pour le téléphone, élargi à partir de 720px.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #070d08;
  --surface-1: #101811;
  --surface-2: #162117;
  --glass: rgb(255 255 255 / 0.045);
  --glass-strong: rgb(255 255 255 / 0.085);
  --text-primary: #f2f7f0;
  --text-secondary: #b3c2b0;
  --text-muted: #7f927c;
  --border: rgb(255 255 255 / 0.08);
  --baseline: rgb(255 255 255 / 0.16);
  --danger: #ff6b6b;
  --danger-soft: rgb(255 107 107 / 0.14);
  --warn: #ffc24d;
  --warn-soft: rgb(255 194 77 / 0.14);

  --apple: #a6ec5c;
  --emerald: #34c27a;
  --apple-ink: #c2f58a;
  --on-apple: #0a1a06;
  --apple-soft: rgb(166 236 92 / 0.14);
  --apple-line: rgb(166 236 92 / 0.42);
  --blob-a: rgb(130 220 70 / 0.34);
  --blob-b: rgb(40 190 120 / 0.28);
  --blob-c: rgb(190 240 90 / 0.16);
  --grain-opacity: 0.075;
  --grain-blend: overlay;

  --shadow-1: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 8px 24px -14px rgb(0 0 0 / 0.6);
  --shadow-2: 0 1px 0 rgb(255 255 255 / 0.06) inset, 0 22px 48px -18px rgb(0 0 0 / 0.75);
  --shadow-apple: 0 10px 26px -10px rgb(110 210 70 / 0.7);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f7f0;
  --surface-1: #ffffff;
  --surface-2: #f2f6ef;
  --glass: rgb(255 255 255 / 0.72);
  --glass-strong: rgb(255 255 255 / 0.92);
  --text-primary: #0f1a0e;
  --text-secondary: #43553f;
  --text-muted: #6f8169;
  --border: rgb(15 26 14 / 0.09);
  --baseline: rgb(15 26 14 / 0.18);
  --danger: #d23f3f;
  --danger-soft: rgb(210 63 63 / 0.1);
  --warn: #b77700;
  --warn-soft: rgb(183 119 0 / 0.1);

  --apple: #7fd03a;
  --emerald: #1fa864;
  --apple-ink: #3f8a12;
  --on-apple: #0a1a06;
  --apple-soft: rgb(110 190 50 / 0.13);
  --apple-line: rgb(90 170 40 / 0.4);
  --blob-a: rgb(140 220 80 / 0.28);
  --blob-b: rgb(50 190 120 / 0.18);
  --blob-c: rgb(190 240 100 / 0.2);
  --grain-opacity: 0.045;
  --grain-blend: multiply;

  --shadow-1: 0 1px 2px rgb(15 26 14 / 0.05), 0 6px 18px -10px rgb(15 26 14 / 0.18);
  --shadow-2: 0 2px 6px rgb(15 26 14 / 0.06), 0 18px 36px -16px rgb(15 26 14 / 0.25);
  --shadow-apple: 0 10px 22px -10px rgb(90 170 40 / 0.55);
}

:root {
  --apple-gradient: linear-gradient(135deg, var(--apple), var(--emerald));
  --grain-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.25' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23g)'/%3E%3C/svg%3E");
  --grain-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 -0.25'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)'/%3E%3C/svg%3E");
  --apple-fill: var(--grain-light) 0 0 / 80px 80px, var(--apple-gradient);
  --f-display: 'Syne', system-ui, sans-serif;
  --f-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: linear(0, 0.21 6%, 0.65 15%, 0.96 25%, 1.08 34%, 1.1 40%, 1.05 52%, 0.99 64%, 1);
  --gutter: 16px;
  --bottom-nav: 74px;
  accent-color: var(--apple);
  interpolate-size: allow-keywords;
  scrollbar-color: var(--apple-line) transparent;
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 720px) { :root { --gutter: 28px; --bottom-nav: 0px; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-primary); font-family: var(--f-body); font-weight: 450; line-height: 1.5; }
body { -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden; background: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, .brand-word, .display { font-family: var(--f-display); letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 800; line-height: 1.05; margin: 0 0 6px; text-wrap: balance; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 .ic { width: 18px; height: 18px; color: var(--apple-ink); }
h3 { font-size: 0.95rem; font-weight: 700; margin: 0 0 8px; }
p { text-wrap: pretty; }
a { color: var(--apple-ink); text-underline-offset: 3px; }
.subtitle { color: var(--text-muted); font-size: 0.92rem; font-weight: 500; margin: 0; }
.muted { color: var(--text-muted); }
::selection { background: var(--apple-soft); }
:focus-visible { outline: 2px solid var(--apple); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex-shrink: 0; display: block; }

/* ---------- Fond : taches floues + grain ---------- */
html::before {
  content: '';
  position: fixed;
  inset: -10vmax;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(38vmax 34vmax at 12% 8%, var(--blob-a), transparent 70%),
    radial-gradient(34vmax 30vmax at 92% 30%, var(--blob-b), transparent 70%),
    radial-gradient(30vmax 26vmax at 40% 95%, var(--blob-c), transparent 70%);
  filter: blur(18px);
  animation: blob-drift 26s ease-in-out infinite alternate;
}
@keyframes blob-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2vmax, -2vmax, 0) scale(1.05); }
  100% { transform: translate3d(-2vmax, 1.5vmax, 0) scale(0.98); }
}
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: var(--grain-img);
  background-size: 110px 110px;
  animation: grain-shift 0.9s steps(1) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -2%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Marque ---------- */
.mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--apple-fill); color: var(--on-apple);
  box-shadow: var(--shadow-apple), inset 0 1px 0 rgb(255 255 255 / 0.3);
}
.mark .ic { width: 20px; height: 20px; stroke-width: 2.2; }
.mark-lg { width: 64px; height: 64px; border-radius: 20px; }
.mark-lg .ic { width: 36px; height: 36px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  font-weight: 700; border-radius: var(--radius-m); padding: 12px 18px;
  background: var(--apple-fill); color: var(--on-apple);
  box-shadow: var(--shadow-apple), inset 0 1px 0 rgb(255 255 255 / 0.25);
  transition: transform 0.25s var(--ease-spring), filter 0.2s ease, box-shadow 0.2s ease;
}
.btn .ic { width: 18px; height: 18px; }
@media (hover: hover) { .btn:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.06); } }
.btn:not(:disabled):active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.secondary { background: var(--glass-strong); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border); }
.btn.ghost { background: transparent; color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border); }
.btn.small { padding: 8px 13px; font-size: 0.86rem; border-radius: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-primary);
  transition: background 0.2s ease, transform 0.15s ease;
}
.icon-btn:hover { background: var(--glass-strong); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ic { width: 18px; height: 18px; }

/* ---------- Champs ---------- */
input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
  width: 100%; padding: 12px 14px;
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-m);
  font-size: 1rem; transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
textarea {
  width: 100%; padding: 12px 14px; resize: vertical; min-height: 64px; line-height: 1.45;
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-m);
  font-size: 1rem; font-weight: 450; transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
textarea:focus { outline: none; border-color: var(--apple); box-shadow: 0 0 0 4px var(--apple-soft); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus { outline: none; border-color: var(--apple); box-shadow: 0 0 0 4px var(--apple-soft); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px var(--gutter); }
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  padding: 36px 24px 28px; border-radius: 28px;
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  animation: fade-up 0.6s var(--ease-out) both;
}
.login-card h1 { margin: 6px 0 0; font-size: 2.2rem; }
.login-card .subtitle { margin-bottom: 8px; }
.login-card .btn { width: 100%; }
.field { position: relative; width: 100%; }
.field > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.field > span .ic { width: 18px; height: 18px; }
.field input { padding-left: 42px; }
.error { color: var(--danger); margin: 0; font-size: 0.9rem; }

/* Code PIN : quatre points et pavé numérique façon coffre-fort */
.pin-dots { display: flex; gap: 14px; margin: 6px 0 4px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--baseline); background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.25s var(--ease-spring);
}
.pin-dots i.on { background: var(--apple); border-color: var(--apple); transform: scale(1.12); box-shadow: 0 0 12px rgb(166 236 92 / 0.55); }
.pin-dots.bad i { border-color: var(--danger); background: var(--danger); box-shadow: none; }
.pin-dots.bad { animation: shake 0.42s ease; }
.pin-dots.ok i { background: var(--emerald); border-color: var(--emerald); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 68px); gap: 12px; margin-top: 6px; }
.keypad button {
  width: 68px; height: 68px; border-radius: 50%; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--border); color: var(--text-primary);
  font-family: var(--f-display); font-size: 1.5rem; font-weight: 700;
  display: grid; place-items: center; touch-action: manipulation;
  box-shadow: var(--shadow-1);
  transition: transform 0.2s var(--ease-spring), background 0.15s ease, border-color 0.15s ease;
}
.keypad button:hover { border-color: var(--apple-line); }
.keypad button:active { transform: scale(0.9); background: var(--apple-soft); border-color: var(--apple); }
.keypad .key-alt { background: transparent; box-shadow: none; color: var(--text-secondary); }
.keypad .key-alt .ic { width: 24px; height: 24px; }
.keypad [data-k="ok"] { background: var(--apple-fill); color: var(--on-apple); border-color: transparent; box-shadow: var(--shadow-apple); }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  isolation: isolate;
}
.topbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--page) 70%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
@supports (animation-timeline: scroll()) {
  .topbar::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: var(--apple-gradient); transform-origin: 0 50%;
    animation: scroll-progress linear both; animation-timeline: scroll(root);
  }
}
@keyframes scroll-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); flex-shrink: 0; }
.brand-word { font-weight: 800; font-size: 1.25rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.quota {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  padding: 6px 10px; border-radius: 10px; background: var(--glass); border: 1px solid var(--border); white-space: nowrap;
}

/* Navigation : pilule en haut sur grand écran, barre en bas sur téléphone. */
.nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; justify-content: space-around; gap: 2px; padding: 6px;
  border-radius: 20px; background: color-mix(in srgb, var(--surface-1) 82%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
}
.nav a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px; border-radius: 14px; text-decoration: none;
  color: var(--text-muted); font-size: 0.7rem; font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.nav a:active { transform: scale(0.94); }
.nav a.active { background: var(--apple-fill); color: var(--on-apple); box-shadow: var(--shadow-apple); }
.nav-badge {
  position: absolute; top: 3px; right: calc(50% - 20px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--warn); color: #241600; font-style: normal; font-size: 0.68rem; font-weight: 800;
  display: grid; place-items: center;
}
.nav a.active .nav-badge { background: var(--on-apple); color: var(--apple); }
@media (min-width: 720px) {
  .nav {
    position: static; margin: 0 auto; box-shadow: none; padding: 4px; gap: 4px;
    border-radius: var(--radius-m); background: var(--glass);
  }
  .nav a { flex-direction: row; gap: 7px; padding: 8px 16px; border-radius: 10px; font-size: 0.9rem; color: var(--text-secondary); }
  .nav a:hover:not(.active) { color: var(--text-primary); background: var(--glass-strong); }
  .nav a .ic { width: 17px; height: 17px; }
  .nav-badge { position: static; margin-left: -2px; }
  .brand { min-width: 150px; }
  .topbar-right { margin-left: 0; min-width: 150px; justify-content: flex-end; }
}
@media (max-width: 719px) { .quota { display: none; } }

/* ---------- Mise en page ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 20px var(--gutter) calc(var(--bottom-nav) + 48px); }
@media (min-width: 720px) { .container { padding-top: 36px; } }
.view { animation: fade-up 0.45s var(--ease-out) both; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--shadow-1); padding: 18px; margin-bottom: 14px;
}
@media (min-width: 720px) { .card { padding: 22px; } }
.card.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.two-cols { display: grid; gap: 24px; margin-top: 28px; }
@media (min-width: 900px) { .two-cols { grid-template-columns: 1fr 1fr; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-nav) + 22px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 0.92rem;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  animation: fade-up 0.35s var(--ease-out) both;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---------- Tuiles de stats ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 720px) { .stat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; } }
.stat {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-m); box-shadow: var(--shadow-1);
  animation: fade-up 0.5s var(--ease-out) both;
}
.stat:nth-child(2) { animation-delay: 0.05s; } .stat:nth-child(3) { animation-delay: 0.1s; } .stat:nth-child(4) { animation-delay: 0.15s; }
.stat-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--apple-soft); color: var(--apple-ink); flex-shrink: 0; }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.74rem; color: var(--text-muted); font-weight: 600; }

/* ---------- Zone de dépôt ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 26px 18px; margin-bottom: 12px; border-radius: var(--radius-l);
  border: 1.5px dashed var(--apple-line); background: color-mix(in srgb, var(--apple-soft) 50%, var(--glass));
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.3s var(--ease-spring);
}
.drop:hover, .drop.over { border-color: var(--apple); background: var(--apple-soft); }
.drop.over { transform: scale(1.01); }
.drop input { display: none; }
.drop-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--apple-fill); color: var(--on-apple); box-shadow: var(--shadow-apple); margin-bottom: 4px; }
.drop-icon .ic { width: 26px; height: 26px; stroke-width: 2; }
.drop strong { font-family: var(--f-display); font-size: 1.05rem; }
.drop-hint { color: var(--text-muted); font-size: 0.86rem; max-width: 460px; }

.queue { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.queue-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--border); font-size: 0.88rem;
  animation: fade-up 0.3s var(--ease-out) both;
}
.queue-item .ic { width: 18px; height: 18px; color: var(--apple-ink); }
.queue-item.error .ic { color: var(--danger); }
.queue-item.wait .ic { color: var(--warn); }
.queue-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.queue-item .state { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }
.queue-item.working .ic { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Recherche ---------- */
.search { position: relative; margin: 18px 0 14px; }
.search > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search > span .ic { width: 18px; height: 18px; }
.search input { padding-left: 42px; }

/* ---------- Transitions entre onglets (View Transitions, comme Score) ---------- */
.topbar { view-transition-name: topbar; }
main.container { view-transition-name: page; }
::view-transition-old(page) { animation: 180ms var(--ease-out) both vt-out-next; }
::view-transition-new(page) { animation: 340ms var(--ease-out) both vt-in-next; }
html[data-dir="prev"]::view-transition-old(page) { animation-name: vt-out-prev; }
html[data-dir="prev"]::view-transition-new(page) { animation-name: vt-in-prev; }
@keyframes vt-out-next { to { opacity: 0; transform: translateX(-24px); filter: blur(2px); } }
@keyframes vt-in-next { from { opacity: 0; transform: translateX(32px); filter: blur(2px); } }
@keyframes vt-out-prev { to { opacity: 0; transform: translateX(24px); filter: blur(2px); } }
@keyframes vt-in-prev { from { opacity: 0; transform: translateX(-32px); filter: blur(2px); } }
.view { animation: none; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stat.clickable { cursor: pointer; transition: transform 0.3s var(--ease-spring), border-color 0.2s ease; }
.stat.clickable:hover { transform: translateY(-2px); border-color: var(--apple-line); }
.link-chip.accent { background: var(--apple-soft); border-color: var(--apple-line); color: var(--apple-ink); }

/* ---------- Pastille-goutte de la navigation (repris de Score) ---------- */
.nav.pill-ready { isolation: isolate; }
@media (min-width: 720px) { .nav.pill-ready { position: relative; inset: auto; } }
.pill-indicator {
  position: absolute; z-index: 0; pointer-events: none;
  background: var(--apple-fill); box-shadow: var(--shadow-apple), inset 0 1px 0 rgb(255 255 255 / 0.25);
  border-radius: 10px; transition: opacity 0.2s ease; will-change: left, width, transform;
}
@media (max-width: 719px) { .pill-indicator { border-radius: 14px; } }
.pill-ready > a, .pill-ready > button { position: relative; z-index: 1; transition: color 0.3s ease; }
.pill-ready > .active { background: transparent !important; box-shadow: none !important; color: var(--on-apple) !important; }

/* ---------- Puces de dossier : remplissage liquide depuis l'endroit touché ---------- */
.folder-chip { position: relative; overflow: hidden; isolation: isolate; }
.folder-chip::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--apple-fill);
  clip-path: circle(0px at var(--tap-x, 50%) var(--tap-y, 50%));
  transition: clip-path 0.55s cubic-bezier(.3, .7, .2, 1);
}
.folder-chip.on { background: var(--glass) !important; color: var(--on-apple); border-color: transparent; box-shadow: var(--shadow-apple); animation: chip-pop 0.4s var(--ease-spring); }
.folder-chip.on::before { clip-path: circle(160% at var(--tap-x, 50%) var(--tap-y, 50%)); }
.folder-chip .ic { width: 0; opacity: 0; transition: width 0.25s var(--ease-out), opacity 0.2s ease; }
.folder-chip.on .ic { width: 14px; opacity: 1; }
@keyframes chip-pop { 40% { transform: scale(1.08); } }

/* ---------- Sous-catégories ---------- */
.sub { border-radius: var(--radius-m); background: color-mix(in srgb, var(--apple-soft) 35%, transparent); border: 1px solid var(--border); }
.sub[open] { border-color: var(--apple-line); }
.sub > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 12px; font-weight: 700; }
.sub > summary::-webkit-details-marker { display: none; }
.sub > summary .y { font-family: var(--f-display); font-size: 0.96rem; }
.sub > summary .n { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; flex: 1; }
.sub-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--apple-soft); color: var(--apple-ink); flex-shrink: 0; }
.sub-icon .ic { width: 16px; height: 16px; }
.sub[open] .sub-icon { background: var(--apple-fill); color: var(--on-apple); }
.sub-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.sub.org { background: color-mix(in srgb, var(--page) 30%, transparent); }

/* ---------- Archives ---------- */
.arch-link {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px dashed var(--baseline); color: var(--text-secondary); font-weight: 600; font-size: 0.86rem; text-align: left;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.arch-link span { flex: 1; }
.arch-link .ic { width: 16px; height: 16px; }
.arch-link:hover { border-color: var(--apple-line); color: var(--apple-ink); background: var(--apple-soft); }
.arch-link:hover .ic:last-child { transform: translateX(3px); }
.arch-link .ic:last-child { transition: transform 0.25s var(--ease-spring); }
.drawer.archives { opacity: 0.92; }
.drawer.archives .cat-icon { color: var(--text-secondary); background: var(--glass-strong); border-color: var(--border); }
.drawer.archives[open] .cat-icon { background: var(--glass-strong); color: var(--text-primary); box-shadow: none; }

/* ---------- Changement de thème : dévoilement en cercle (comme Score) ---------- */
.theme-vt .topbar, .theme-vt main.container { view-transition-name: none !important; }
html.theme-vt::view-transition-old(root), html.theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-vt::view-transition-old(root) { z-index: 1; }
html.theme-vt::view-transition-new(root) { z-index: 2; }

/* ---------- Rail de choix (Archives / Tout le coffre) ---------- */
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-m); background: var(--glass); border: 1px solid var(--border); position: relative; isolation: isolate; }
.segmented button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 0.86rem; color: var(--text-secondary); cursor: pointer; }
.segmented button.active { background: var(--apple-fill); color: var(--on-apple); }

/* ---------- Chronologie des archives ---------- */
.chrono-cats { margin-bottom: 14px; }
.chrono {
  position: relative; height: 430px; overflow: hidden; touch-action: pan-y; user-select: none; cursor: grab;
  border-radius: var(--radius-l); border: 1px solid var(--border); background:
    radial-gradient(60% 80% at 50% 110%, var(--apple-soft), transparent 70%), var(--glass);
  box-shadow: var(--shadow-1); outline: none;
}
.chrono:focus-visible { border-color: var(--apple-line); }
.chrono.dragging { cursor: grabbing; }
.chrono-year {
  position: absolute; left: 0; right: 0; top: 18px; text-align: center; pointer-events: none; z-index: 0;
  font-family: var(--f-display); font-weight: 800; font-size: clamp(110px, 22vw, 220px); line-height: 1; letter-spacing: -0.04em;
  color: transparent; -webkit-text-stroke: 1.5px var(--apple-line); opacity: 0.55; will-change: transform;
}
.chrono-year .y-in { display: inline-block; animation: year-in 0.6s var(--ease-out) both; }
.chrono-year .y-in.up { --from: 60px; }
.chrono-year .y-in.down { --from: -60px; }
@keyframes year-in { from { opacity: 0; transform: translateX(var(--from, 0)) scale(0.96); filter: blur(4px); } }
.chrono-track { position: absolute; left: 0; top: 96px; height: 230px; z-index: 2; will-change: transform; }
.chrono-card {
  position: absolute; top: 0; height: 210px; display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 16px; border-radius: var(--radius-l); cursor: pointer; color: var(--text-primary);
  background: color-mix(in srgb, var(--surface-1) 88%, transparent); border: 1px solid var(--border);
  box-shadow: var(--shadow-2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transform-origin: 50% 50%; will-change: transform, opacity; transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.chrono-card.focus { border-color: var(--apple-line); box-shadow: var(--shadow-2), 0 0 0 1px var(--apple-line), 0 18px 40px -18px rgb(110 210 70 / 0.5); }
.chrono-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chrono-card .cat-icon { width: 40px; height: 40px; }
.chrono-card.focus .cat-icon { background: var(--apple-fill); color: var(--on-apple); border-color: transparent; }
.chrono-card-date { text-align: right; line-height: 1.05; }
.chrono-card-date b { display: block; font-family: var(--f-display); font-size: 1.6rem; }
.chrono-card-date span { font-size: 0.74rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.chrono-card strong { font-family: var(--f-display); font-size: 0.98rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chrono-card-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: auto; }
.chrono-card .tag { align-self: flex-start; }
.chrono-ruler { position: absolute; left: 0; right: 0; bottom: 26px; height: 60px; z-index: 1; pointer-events: none; }
.chrono-ruler::before { content: ''; position: absolute; left: 0; right: 0; top: 14px; height: 1px; background: linear-gradient(90deg, transparent, var(--baseline) 15%, var(--baseline) 85%, transparent); }
.chrono-ruler-inner { position: absolute; left: 0; top: 0; height: 100%; will-change: transform; }
.tick { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; cursor: pointer; padding: 0 6px; }
.tick i { width: 2px; height: 14px; border-radius: 2px; background: var(--baseline); margin-top: 7px; transition: background 0.2s ease, height 0.3s var(--ease-spring); }
.tick em { font-style: normal; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; transition: color 0.2s ease; }
.tick.year i { height: 22px; width: 3px; background: var(--apple-line); margin-top: 3px; }
.tick.year em { font-family: var(--f-display); font-size: 0.9rem; color: var(--text-secondary); }
.tick.on i { background: var(--apple); height: 26px; margin-top: 1px; box-shadow: 0 0 10px rgb(166 236 92 / 0.6); }
.tick.on em { color: var(--apple-ink); }
.chrono-center { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); z-index: 3; pointer-events: none; }
.chrono-date {
  display: inline-block; padding: 6px 14px; border-radius: 10px; white-space: nowrap;
  background: var(--apple-fill); color: var(--on-apple); font-weight: 800; font-size: 0.86rem; box-shadow: var(--shadow-apple);
}
.chrono-date.bump { animation: bump 0.35s var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.08); } }
.chrono-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; width: 40px; height: 40px; background: color-mix(in srgb, var(--surface-1) 80%, transparent); }
.chrono-nav.prev { left: 12px; }
.chrono-nav.prev .ic { transform: rotate(180deg); }
.chrono-nav.next { right: 12px; }
.chrono-empty { position: absolute; left: 50vw; width: 280px; transform: translateX(-50%); top: 30px; }
.chrono-progress { height: 3px; margin-top: 10px; border-radius: 3px; background: var(--border); overflow: hidden; }
.chrono-progress span { display: block; height: 100%; background: var(--apple-gradient); border-radius: 3px; transition: width 0.35s var(--ease-out); }
@media (max-width: 599px) {
  .chrono { height: 400px; }
  .chrono-nav { display: none; }
  .chrono-card { height: 200px; padding: 14px; }
  .chrono-card strong { -webkit-line-clamp: 2; }
}

/* ---------- Réorganisation par consigne ---------- */
.reorg {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; margin: 0 0 12px;
  border-radius: var(--radius-m); background: var(--glass); border: 1px solid var(--apple-line);
}
.reorg-icon { color: var(--apple-ink); }
.reorg-icon .ic { width: 18px; height: 18px; }
.reorg input { border: 0; background: transparent; box-shadow: none !important; padding: 8px 4px; }
.reorg-plan {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; padding: 14px 16px;
  border-radius: var(--radius-l); background: var(--glass); border: 1px solid var(--apple-line); box-shadow: var(--shadow-2);
  animation: fade-up 0.35s var(--ease-out) both;
}
.reorg-summary { display: flex; gap: 8px; margin: 0; font-weight: 600; }
.reorg-summary .ic { color: var(--apple-ink); margin-top: 2px; }
.reorg-ops { display: flex; flex-direction: column; gap: 6px; }
.reorg-op { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--page) 35%, transparent); border: 1px solid var(--border); font-size: 0.9rem; cursor: pointer; }
.reorg-op input { margin-top: 3px; accent-color: var(--apple); }
.reorg-op strong { display: block; font-weight: 650; }
.reorg-op small { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.reorg-ops { max-height: 50vh; overflow-y: auto; }
.reorg-op.rule { border-color: var(--apple-line); background: var(--apple-soft); }

.organize-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; }
.organize-row small { font-size: 0.8rem; }

/* ---------- Étape avant analyse ---------- */
.staging {
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; padding: 16px;
  border-radius: var(--radius-l); background: var(--glass); border: 1px solid var(--apple-line); box-shadow: var(--shadow-2);
  animation: fade-up 0.35s var(--ease-out) both;
}
.staging-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--f-display); }
.staging-head h3 .ic { color: var(--apple-ink); }
.staging-head small, .staging-all { color: var(--text-muted); font-size: 0.82rem; }
.staging-all { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.staging-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.staged { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--radius-m); background: color-mix(in srgb, var(--page) 35%, transparent); border: 1px solid var(--border); animation: fade-up 0.3s var(--ease-out) both; }
.staged-top { display: flex; align-items: center; gap: 10px; }
.staged-top .ic { color: var(--apple-ink); }
.staged-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.staged-top .muted { font-size: 0.78rem; white-space: nowrap; }
.staged-top .icon-btn { width: 30px; height: 30px; }
.staged textarea { min-height: 40px; font-size: 0.9rem; padding: 8px 12px; }
.staging-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Titres de section, dossiers, Sheets ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-head h2 { margin: 0; }
.drawer.folder .cat-icon { color: var(--apple-ink); background: var(--apple-soft); border-color: var(--apple-line); }
.folder-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 4px 2px; }
.folder-empty { color: var(--text-muted); font-size: 0.86rem; padding: 6px 8px; }
.folder-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.folder-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.2s var(--ease-spring);
}
.folder-chip .ic { width: 14px; height: 14px; }
.folder-chip.on { background: var(--apple-fill); color: var(--on-apple); border-color: transparent; }
.folder-chip:active { transform: scale(0.95); }
.sheet-status { display: flex; flex-direction: column; gap: 6px; }
.sheet-status .fact { font-size: 0.86rem; }
.sheet-status .ok { color: var(--apple-ink); }
.sheet-status .ko { color: var(--danger); }

/* ---------- Tiroirs : catégorie → année → documents ---------- */
.drawers { display: flex; flex-direction: column; gap: 10px; }
.drawer {
  --hue: 100;
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--shadow-1); overflow: hidden;
  animation: fade-up 0.45s var(--ease-out) both;
  transition: border-color 0.2s ease;
}
.drawer[open] { border-color: var(--apple-line); }
.drawer > summary, .year > summary { list-style: none; cursor: pointer; }
.drawer > summary::-webkit-details-marker, .year > summary::-webkit-details-marker { display: none; }
.drawer > summary { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.drawer > summary:hover { background: var(--glass); }
.cat-icon {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center;
  color: hsl(var(--hue) 70% 72%);
  background: hsl(var(--hue) 60% 50% / 0.14);
  border: 1px solid hsl(var(--hue) 60% 60% / 0.22);
  transition: transform 0.45s var(--ease-spring);
}
:root[data-theme="light"] .cat-icon { color: hsl(var(--hue) 60% 32%); background: hsl(var(--hue) 60% 50% / 0.12); }
.drawer[open] .cat-icon { background: var(--apple-fill); color: var(--on-apple); border-color: transparent; box-shadow: var(--shadow-apple); }
.drawer > summary:hover .cat-icon { transform: rotate(-6deg) scale(1.06); }
.cat-icon .ic { width: 23px; height: 23px; }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title strong { display: block; font-family: var(--f-display); font-size: 1.02rem; font-weight: 700; }
.drawer-title span { font-size: 0.8rem; color: var(--text-muted); }
.count {
  min-width: 30px; height: 26px; padding: 0 9px; border-radius: 8px; display: grid; place-items: center;
  background: var(--glass-strong); border: 1px solid var(--border); font-weight: 700; font-size: 0.82rem; font-variant-numeric: tabular-nums;
}
.chev { color: var(--text-muted); transition: transform 0.35s var(--ease-out); }
.chev .ic { width: 18px; height: 18px; }
details[open] > summary .chev { transform: rotate(90deg); }

/* Ouverture animée des tiroirs (navigateurs récents ; ailleurs, ouverture directe). */
details::details-content {
  block-size: 0; overflow-y: clip;
  transition: block-size 0.4s var(--ease-out), content-visibility 0.4s allow-discrete;
}
details[open]::details-content { block-size: auto; }

.drawer-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.year { border-radius: var(--radius-m); background: color-mix(in srgb, var(--page) 35%, transparent); border: 1px solid var(--border); }
.year > summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-weight: 700; }
.year > summary .y { font-family: var(--f-display); font-size: 0.98rem; }
.year > summary .n { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; flex: 1; }
.docs { display: flex; flex-direction: column; padding: 0 6px 6px; }
.doc-row {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 10px 8px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer;
  transition: background 0.15s ease;
}
.doc-row:hover { background: var(--glass-strong); }
.doc-row + .doc-row { border-top: 1px solid var(--border); }
.doc-date { text-align: center; line-height: 1.05; }
.doc-date b { display: block; font-family: var(--f-display); font-size: 1.15rem; }
.doc-date span { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.doc-main { min-width: 0; }
.doc-main strong { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-main span { display: block; font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 8px; white-space: nowrap;
  font-size: 0.72rem; font-weight: 700; background: var(--apple-soft); color: var(--apple-ink);
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.neutral { background: var(--glass-strong); color: var(--text-secondary); }
.tag .ic { width: 13px; height: 13px; }
.drawer.pending .cat-icon { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--radius-l); }
.empty .ic { width: 34px; height: 34px; margin: 0 auto 8px; color: var(--apple-ink); }

/* ---------- Fiche document & visionneuse ---------- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgb(3 8 4 / 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade 0.2s ease both;
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 26px 26px 0 0;
  padding: 26px 20px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -20px 50px -20px rgb(0 0 0 / 0.6);
  animation: sheet-up 0.4s var(--ease-out) both;
}
@media (min-width: 720px) {
  .sheet-overlay { align-items: center; }
  .sheet { border-radius: 26px; padding: 30px 28px; }
}
.sheet-close { position: absolute; top: 14px; right: 14px; }
.sheet-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; padding-right: 44px; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; display: block; }
.sheet-head .cat-icon { background: var(--apple-fill); color: var(--on-apple); border-color: transparent; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.sheet p.summary { color: var(--text-secondary); margin: 0 0 16px; }
.facts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.facts h3 { display: flex; align-items: center; gap: 7px; margin: 12px 0 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-family: var(--f-body); }
.facts h3 .ic { width: 15px; height: 15px; }
.fact { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--border); font-size: 0.92rem; }
.fact small { display: block; color: var(--text-muted); font-size: 0.8rem; }
.fact .p { color: var(--text-muted); font-size: 0.78rem; font-weight: 700; white-space: nowrap; align-self: center; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.viewer { width: min(1000px, 100%); height: min(92vh, 100%); display: flex; flex-direction: column; background: var(--surface-1); border-radius: 22px; overflow: hidden; border: 1px solid var(--border); margin: auto; animation: sheet-up 0.35s var(--ease-out) both; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); }
.viewer-bar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; min-height: 0; display: flex; background: #fff; }
.viewer-body iframe, .viewer-body img { flex: 1; width: 100%; height: 100%; border: 0; object-fit: contain; }
#viewer { padding: 12px; align-items: center; }

/* Contexte de l'utilisateur sur un document */
.context-box {
  display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; padding: 12px;
  border-radius: var(--radius-m); background: var(--apple-soft); border: 1px solid var(--apple-line);
}
.context-box label { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; font-weight: 700; font-size: 0.9rem; }
.context-box label .ic { width: 17px; height: 17px; color: var(--apple-ink); }
.context-box label small { grid-column: 1 / -1; color: var(--text-muted); font-weight: 500; font-size: 0.78rem; }
.context-box textarea { background: var(--surface-1); }
.context-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Échéances ---------- */
.priorities { display: grid; gap: 10px; margin-bottom: 8px; }
@media (min-width: 900px) { .priorities { grid-template-columns: repeat(3, 1fr); } }
.priority {
  position: relative; padding: 18px 18px 16px 18px; border-radius: var(--radius-l);
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  animation: fade-up 0.45s var(--ease-out) both;
}
.priority .num {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px;
  background: var(--apple-fill); color: var(--on-apple); font-family: var(--f-display); font-weight: 800; box-shadow: var(--shadow-apple);
}
.priority strong { display: block; font-family: var(--f-display); font-size: 1rem; margin-bottom: 4px; }
.priority p { margin: 0 0 8px; color: var(--text-secondary); font-size: 0.9rem; }
.priority { display: flex; flex-direction: column; }
.priority-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 5px; margin: 2px 4px 0 0; padding: 4px 10px; border-radius: 9px; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--border); font-size: 0.78rem; font-weight: 600; color: var(--text-primary);
}
.link-chip:hover { border-color: var(--apple-line); color: var(--apple-ink); }
.link-chip .ic { width: 13px; height: 13px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: linear-gradient(var(--apple), transparent); }
.event { position: relative; padding: 12px 14px; border-radius: var(--radius-m); background: var(--glass); border: 1px solid var(--border); }
.event::before { content: ''; position: absolute; left: -18px; top: 17px; width: 12px; height: 12px; border-radius: 50%; background: var(--page); border: 2px solid var(--apple); }
.event.soon::before { border-color: var(--warn); background: var(--warn); }
.event.past::before { border-color: var(--danger); background: var(--danger); }
.event.now::before { border-color: var(--apple); background: var(--apple); box-shadow: 0 0 10px rgb(166 236 92 / 0.6); }
.now-line::before { background: linear-gradient(var(--apple), transparent); }
.event.info { opacity: 0.72; }
.event.info::before { border-color: var(--baseline); }
.event.later::before { border-style: dashed; }
.past-line::before { background: linear-gradient(var(--danger), transparent); }
.event-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.event-date { font-family: var(--f-display); font-weight: 700; }
.event p { margin: 4px 0 0; font-size: 0.86rem; color: var(--text-secondary); }
.event .action { color: var(--apple-ink); font-weight: 600; }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius-m); background: var(--glass); border: 1px solid var(--border); }
.alert-item > .ic { color: var(--warn); margin-top: 2px; }
.alert-item.danger > .ic { color: var(--danger); }
.alert-item.info > .ic { color: var(--apple-ink); }
.alert-item strong { display: block; font-size: 0.92rem; }
.alert-item p { margin: 2px 0 0; font-size: 0.84rem; color: var(--text-secondary); }

/* ---------- Questions ---------- */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.suggestions button {
  padding: 8px 14px; border-radius: 12px; cursor: pointer; font-size: 0.86rem; font-weight: 600;
  background: var(--glass); border: 1px solid var(--border); color: var(--text-secondary);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.25s var(--ease-spring);
}
.suggestions button:hover { border-color: var(--apple-line); color: var(--apple-ink); }
.suggestions button:active { transform: scale(0.96); }
.chat { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.msg-q {
  align-self: flex-end; max-width: 82%; padding: 11px 16px; border-radius: 18px 18px 6px 18px;
  background: var(--apple-fill); color: var(--on-apple); font-weight: 600; box-shadow: var(--shadow-apple);
  animation: fade-up 0.3s var(--ease-out) both;
}
.msg-a {
  max-width: 94%; padding: 16px 18px; border-radius: 18px 18px 18px 6px;
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  animation: fade-up 0.35s var(--ease-out) both;
}
.msg-a .answer { white-space: pre-wrap; }
.msg-a sup { color: var(--apple-ink); font-weight: 800; margin-left: 1px; }
.sources { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; font-size: 0.86rem; }
.source blockquote { margin: 5px 0 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--apple-line); color: var(--text-secondary); font-style: italic; }
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--text-muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--apple); animation: dot 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.ask {
  position: sticky; bottom: calc(var(--bottom-nav) + 14px + env(safe-area-inset-bottom)); display: flex; gap: 8px;
  padding: 6px; border-radius: 18px; background: color-mix(in srgb, var(--surface-1) 85%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.ask input { border: 0; background: transparent; box-shadow: none !important; }
.ask .btn { padding: 10px 14px; }

/* ---------- Réglages ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form h2 { margin: 6px 0 0; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; }
.form small { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; }
.form .btn { align-self: flex-start; }
.code { display: block; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--page) 50%, transparent); border: 1px solid var(--border); word-break: break-all; font-size: 0.82rem; }

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

.ic.inline-ic { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; }
