:root {
  --bg: #0b0c0f;
  --panel: #15171c;
  --panel2: #1b1e25;
  --border: #2a2d36;
  --text: #e8e9ec;
  --muted: #9aa0ab;
  --title: #f59e0b;
  --accent: #5eead4;
  --accent2: #7dd3fc;
  --done: #4b5563;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}
h1, h2, h3, dt { color: var(--title); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
.layout { display: flex; min-height: 100%; flex-direction: column; }
@media (min-width: 768px) {
  .layout { flex-direction: row; }
}
.sidebar {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
@media (min-width: 768px) {
  .sidebar {
    width: 15rem;
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }
}
.brand { padding: 1.25rem; }
.kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.brand h1 {
  margin: 0.25rem 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand p { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--muted); }
.nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0 0.75rem 0.75rem;
}
@media (min-width: 768px) {
  .nav { flex-direction: column; overflow: visible; padding: 0 0.75rem 1.5rem; }
}
.nav a {
  white-space: nowrap;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.active { background: var(--panel2); color: var(--accent); }
.main { flex: 1; padding: 1.5rem 1rem; }
@media (min-width: 768px) { .main { padding: 2rem; } }
.wrap { margin: 0 auto; max-width: 64rem; }
.wrap-wide { margin: 0 auto; max-width: 72rem; }
.wrap-xl { margin: 0 auto; max-width: 87.5rem; }
.space > * + * { margin-top: 1.25rem; }
.page-head { margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; }
.page-head h2 { margin: 0; font-size: 1.25rem; }
.page-head p { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--muted); }
.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 1rem;
  padding: 1.25rem;
}
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tone-now { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.tone-soon { background: color-mix(in srgb, var(--accent2) 15%, transparent); color: var(--accent2); }
.tone-recur { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.tone-muted { background: var(--panel2); color: var(--muted); }
.tone-ok { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.tone-warn { background: rgba(251, 113, 133, 0.15); color: #fb7185; }
.btn {
  border: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg);
}
.btn:hover { opacity: 0.9; }
.btn-ghost {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger { background: transparent; color: #fb7185; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; font-size: 0.75rem; color: var(--accent); }
.linkish.muted { color: var(--muted); }
.linkish.rose { color: #fb7185; }
.linkish.sky { color: var(--accent2); }
.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.field { display: grid; gap: 0.25rem; font-size: 0.875rem; }
.field > span { color: var(--title); }
.grid2 { display: grid; gap: 0.75rem; }
.grid3 { display: grid; gap: 1rem; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr 1fr; }
}
.span2 { grid-column: 1 / -1; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.xs { font-size: 0.75rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.stat { font-size: 1.5rem; font-weight: 600; }
.progress { height: 0.5rem; overflow: hidden; border-radius: 999px; border: 1px solid var(--border); background: var(--panel2); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th { font-weight: 500; color: var(--muted); padding-bottom: 0.5rem; }
td { border-top: 1px solid var(--border); padding: 0.75rem 0.35rem; vertical-align: top; }
.todo-check {
  appearance: none;
  width: 18px; height: 18px; min-width: 18px; margin-top: 2px;
  border: 1.5px solid var(--border); border-radius: 5px;
  background: var(--panel2); display: grid; place-content: center; cursor: pointer;
}
.todo-check::after {
  content: ""; width: 10px; height: 10px; border-radius: 2px;
  background: var(--accent); transform: scale(0);
}
.todo-check:checked::after { transform: scale(1); }
.done { color: var(--done); text-decoration: line-through; }
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.5); padding: 1rem;
}
.sheet { width: 100%; max-width: 24rem; }
.dl { display: grid; gap: 0.75rem; font-size: 0.875rem; }
@media (min-width: 640px) { .dl { grid-template-columns: 1fr 1fr; } }
.copy dt { margin: 0 0 0.2rem; font-size: 0.75rem; }
.copy dd { margin: 0; color: var(--text); }
.secret { filter: blur(4px); cursor: pointer; }
.secret.show { filter: none; }
.line-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 80px 110px 80px auto;
}
.doc-grid { display: grid; gap: 1.25rem; }
@media (min-width: 1280px) {
  .doc-grid { grid-template-columns: 1fr 1fr; }
}
.preview-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: #e4e4e7;
}
.preview-scale { transform-origin: top left; transform: scale(0.72); width: 138.9%; }
.print-doc {
  margin: 0 auto;
  width: 210mm;
  max-width: 100%;
  background: #fff;
  color: #18181b;
  padding: 2.5rem 3rem;
  font-size: 13px;
  line-height: 1.6;
}
.print-doc h1, .print-doc h2, .print-doc dt { color: #18181b; }
.print-doc table { border-collapse: separate; border-spacing: 0; }
.print-doc th { border-bottom: 1px solid #d4d4d8; color: #71717a; }
.print-doc td { border-top: 0; border-bottom: 1px solid #e4e4e7; color: #18181b; }
.week { display: grid; gap: 0.5rem; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day { min-height: 8rem; border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.5rem; background: var(--panel2); }
.sheet-tabs { display: flex; gap: 0.35rem; overflow-x: auto; padding-bottom: 0.5rem; }
.sheet-table { overflow: auto; max-height: 70vh; }
.sheet-table table { min-width: 720px; }
.sheet-table input { min-width: 5rem; }
.lead { font-size: 2.25rem; font-weight: 600; letter-spacing: -0.03em; }
iframe.studio { height: 78vh; width: 100%; border: 1px solid var(--border); border-radius: 1rem; background: #000; }
.right { text-align: right; }
.grow { flex: 1; }
@media print {
  @page { size: A4; margin: 14mm; }
  .sidebar, .print-hide { display: none !important; }
  body { background: #fff; color: #111; }
  .main { padding: 0; }
  .print-doc { width: auto; max-width: none; padding: 0; }
}

/* =====================================================================
   ADN Pilot — adaptations iPhone / Mac (app installée) et synchronisation
   ===================================================================== */
:root { color-scheme: dark; --tabbar-h: 3.6rem; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
.boot { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.card { overflow-x: auto; }
.nav-foot { display: none; padding: 0 1.5rem 1.5rem; }
.tabbar { display: none; }

/* ---- Mac / grand écran : barre latérale fixe ---- */
@media (min-width: 768px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
  .nav { flex: 1; }
  .nav-foot { display: block; }
  .sidebar .brand { padding-top: max(1.25rem, env(safe-area-inset-top)); }
}

/* ---- iPhone ---- */
@media (max-width: 767px) {
  .sidebar {
    position: sticky; top: 0; z-index: 40;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
  }
  .brand { padding: 0.6rem 1rem 0.55rem; display: flex; align-items: baseline; gap: 0.6rem; }
  .brand h1 { margin: 0; font-size: 1rem; }
  .brand p:not(.kicker) { display: none; }
  .sidebar .nav { display: none; }
  .menu-open .sidebar .nav {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem;
    padding: 0.25rem 0.75rem 0.9rem; max-height: calc(100vh - 9rem); overflow-y: auto;
  }
  .menu-open .sidebar .nav a { background: var(--panel2); padding: 0.8rem 0.75rem; white-space: normal; }
  .menu-open .nav-foot { display: block; padding: 0 1rem 1rem; }
  .menu-open .main { display: none; }

  .main { padding: 1rem 0.875rem calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom)); }
  .layout > .main:first-child { padding-top: max(1rem, env(safe-area-inset-top)); }
  .page-head h2 { font-size: 1.15rem; }
  .lead { font-size: 1.75rem; }
  .card { padding: 1rem; border-radius: 0.9rem; }

  .input, select.input, textarea.input, input, select, textarea { font-size: 16px; }
  .btn { padding: 0.65rem 0.9rem; }
  .linkish { padding: 0.25rem 0; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
    background: none; border: 0; padding: 0.25rem 0; cursor: pointer;
    color: var(--muted); text-decoration: none; font-size: 0.66rem; font-weight: 500;
  }
  .tabbar .active { color: var(--accent); }

  .line-grid { grid-template-columns: 1fr 1fr; }
  .line-grid > :first-child { grid-column: 1 / -1; }
  .week { grid-template-columns: repeat(7, minmax(8.5rem, 1fr)); overflow-x: auto; padding-bottom: 0.25rem; scroll-snap-type: x mandatory; }
  .day { scroll-snap-align: start; }
  .preview-scale { transform: none; width: auto; zoom: 0.44; }
  .modal { align-items: end; padding: 0 0 env(safe-area-inset-bottom); }
  .modal .sheet { max-width: none; border-radius: 1.1rem 1.1rem 0 0; padding-bottom: 1.5rem; }
  iframe.studio { height: 60vh; }
}

/* ---- pastille de synchronisation ---- */
.sync-pill {
  position: fixed; z-index: 60; right: 1rem; bottom: 1rem;
  max-width: calc(100vw - 2rem);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.4rem 0.8rem; font-size: 0.75rem; font-weight: 600;
  background: var(--panel); color: var(--muted); cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  opacity: 0; transform: translateY(0.5rem); pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.sync-pill.show { opacity: 1; transform: none; pointer-events: auto; }
.sync-pill[data-status="ok"] { color: #34d399; }
.sync-pill[data-status="saving"] { color: var(--accent2); }
.sync-pill[data-status="offline"], .sync-pill[data-status="error"], .sync-pill[data-status="conflict"] { color: #fb7185; }
@media (max-width: 767px) {
  .sync-pill { bottom: calc(var(--tabbar-h) + 0.6rem + env(safe-area-inset-bottom)); right: 50%; transform: translate(50%, 0.5rem); }
  .sync-pill.show { transform: translate(50%, 0); }
}

/* ---- page de connexion ---- */
.login-page { display: grid; place-items: center; min-height: 100%; padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom)); }
.login-box { width: 100%; max-width: 22rem; }
.login-box h1 { margin: 0.2rem 0 0.2rem; color: var(--text); font-size: 1.4rem; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 0.75rem; }
.login-btn { width: 100%; padding: 0.75rem; }
#error { color: #fb7185; min-height: 1.2em; margin: 0; }
.login-page input { font-size: 16px; }

@media print {
  .tabbar, .sync-pill, .nav-foot { display: none !important; }
}
/* listes : case à cocher et texte sur la même ligne */
.card ul { list-style: none; padding-left: 0; margin: 0.5rem 0 0; }
li.row > label.row { flex-wrap: nowrap; align-items: flex-start; gap: 0.75rem; }
/* ajout de tâche : titre sur toute la largeur, date + bouton dessous */
form[data-form="add-todo"] input[name="title"] { flex: 1 1 100%; }
@media (min-width: 768px) { form[data-form="add-todo"] input[name="title"] { flex: 1 1 auto; } }
/* planning : rendez-vous */
.ev { margin-top: 0.4rem; padding: 0.3rem 0.45rem; border-left: 3px solid var(--accent2); border-radius: 0.35rem; background: var(--panel); font-size: 0.75rem; line-height: 1.35; overflow-wrap: anywhere; }
.ev-time { font-weight: 600; color: var(--text); }
.ev-loc { display: block; color: var(--muted); font-size: 0.68rem; }
.day.today { border-color: var(--accent); }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 999px; display: inline-block; }
@media (max-width: 767px) {
  /* planning iPhone : jours les uns sous les autres */
  .week-nav { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem; }
  .week-nav .btn { padding: 0.6rem 0.3rem; font-size: 0.8rem; }
  .week-nav .week-refresh { grid-column: 1 / -1; }
  .week { grid-template-columns: 1fr; overflow: visible; scroll-snap-type: none; gap: 0.4rem; }
  .day { min-height: 0; padding: 0.6rem 0.75rem; }
  .day > p:nth-child(1), .day > p:nth-child(2) { display: inline; margin: 0; }
  .day > p:nth-child(2) { margin-left: 0.35rem; font-weight: 600; }
  .ev { font-size: 0.85rem; }
}
.ev-link { display: inline-block; margin-top: 0.2rem; font-size: 0.7rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.ev-link:hover { text-decoration: underline; }
