@font-face {
  font-family: "Josefin Sans";
  src: url("fonts/JosefinSans-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 700;
  font-display: swap;
}

:root {
  --deep: #0c3b2e;
  --primary: #347b6b;
  --primary-ink: #ffffff;
  --soft: #a5d4cb;
  --accent: #7cc5b8;
  --bg: #f1fbf9;
  --surface: #ffffff;
  --surface-2: #e6f4f0;
  --text: #1d2a26;
  --muted: #5d6f69;
  --border: rgba(12, 59, 46, 0.12);
  --shadow: 0 10px 28px rgba(12, 59, 46, 0.08);
  --ok: #2f8a4a;
  --ok-bg: #e2f3e6;
  --warn: #b5560f;
  --warn-bg: #fdeedd;
  --idle: #6b7a76;
  --idle-bg: #eef1f0;
  --danger: #c0341a;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --deep: #d7f0ea;
    --primary: #7cc5b8;
    --primary-ink: #0b2a22;
    --soft: #2c5a50;
    --bg: #0d1a17;
    --surface: #15241f;
    --surface-2: #1c302a;
    --text: #e4efec;
    --muted: #93a8a2;
    --border: rgba(165, 212, 203, 0.14);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    --ok: #7fd394;
    --ok-bg: #1d3b26;
    --warn: #f3a46a;
    --warn-bg: #3d2a17;
    --idle: #a2b2ae;
    --idle-bg: #23302d;
    --danger: #ff8a73;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 96px);
  min-height: 100vh;
}

/* ---------- En-tête ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
}
.brand {
  font-family: "Josefin Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -0.01em;
  color: var(--deep);
  margin: 0;
  flex: 1;
  line-height: 1.1;
}
.brand small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  flex: none;
  color: var(--deep);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Bandeau sauvegarde ---------- */
.banner {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.banner button {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  padding: 6px;
  flex: none;
}

/* ---------- Recherche & filtres ---------- */
.search {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 12px;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 -16px 16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.chip[aria-pressed="true"] {
  background: var(--deep);
  border-color: var(--deep);
  color: var(--bg);
}

/* ---------- Cartes projet ---------- */
.list { display: grid; gap: 12px; }
.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title {
  font-family: "Josefin Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.15;
  margin: 0;
  color: var(--deep);
  flex: 1;
  overflow-wrap: anywhere;
}
.card-sub { color: var(--muted); font-size: 0.86rem; margin: 2px 0 12px; }
.badge {
  flex: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--idle);
  white-space: nowrap;
}
.badge.s-encours { background: var(--warn-bg); color: var(--warn); }
.badge.s-enligne { background: var(--ok-bg); color: var(--ok); }
.badge.s-idee { background: var(--surface-2); color: var(--primary); }

.progress { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--muted); }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.todo { background: var(--warn-bg); color: var(--warn); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

/* ---------- Bouton flottant ---------- */
.fab {
  position: fixed;
  right: max(16px, calc(50vw - 320px + 16px));
  bottom: calc(var(--safe-bottom) + 20px);
  height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  border: 0;
  background: var(--deep);
  color: var(--bg);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 30px rgba(12, 59, 46, 0.3);
}
.fab svg { width: 22px; height: 22px; }

/* ---------- Fiche projet ---------- */
.title-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: "Josefin Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--deep);
  padding: 4px 0;
}
.title-input:focus { outline: none; border-bottom: 2px solid var(--soft); }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 18px; }
.meta-grid .full { grid-column: 1 / -1; }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  font-weight: 600;
  color: var(--deep);
  cursor: pointer;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary .count { margin-left: auto; font-weight: 500; font-size: 0.82rem; color: var(--muted); }
.section > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-left: 6px;
  transition: transform 0.2s;
}
.section[open] > summary::after { transform: rotate(-135deg); }
.section-body { padding: 0 16px 16px; }

label.field { display: grid; gap: 4px; font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 1rem;
  color: var(--text);
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { outline: 2px solid var(--soft); outline-offset: 0; border-color: transparent; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.toggle-row:first-child { border-top: 0; padding-top: 0; }
.toggle-row .grow { flex: 1; min-width: 0; }
.toggle-row .label { font-weight: 500; }
.toggle-row .hint { font-size: 0.8rem; color: var(--muted); }
.stack { display: grid; gap: 8px; margin-top: 8px; }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--idle-bg);
  border: 1px solid var(--border); transition: background 0.2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--soft); outline-offset: 2px; }

/* Listes à cocher */
.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.item:first-child { border-top: 0; }
.item input[type="checkbox"] {
  width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--primary); flex: none;
}
.item .text {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
  resize: none;
  line-height: 1.45;
  font-size: 1rem;
}
.item .text:focus { outline: none; }
.item.done .text { text-decoration: line-through; color: var(--muted); }
.del {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  margin-top: -4px;
}
.del svg { width: 16px; height: 16px; }

.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row .input { flex: 1; }
.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--deep);
  color: var(--bg);
  font-weight: 600;
  flex: none;
}
.btn.ghost { background: var(--surface-2); color: var(--deep); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.block { width: 100%; padding: 14px; }

/* Commandes */
.cmd {
  border-top: 1px solid var(--border);
  padding: 10px 0;
  display: grid;
  gap: 6px;
}
.cmd:first-child { border-top: 0; padding-top: 0; }
.cmd-head { display: flex; gap: 8px; align-items: center; }
.cmd-head .input { flex: 1; padding: 6px 10px; font-size: 0.9rem; background: transparent; border-color: transparent; font-weight: 500; }
.cmd-code { display: flex; gap: 8px; align-items: stretch; }
.cmd-code .input {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  background: var(--surface-2);
}
.copy {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--deep);
  flex: none;
}

/* Contacts */
.contact {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}
.contact:first-child { border-top: 0; padding-top: 0; }
.contact .full { grid-column: 1 / -1; }
.contact-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.contact-actions a {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  text-decoration: none;
  color: var(--deep);
  font-weight: 500;
}
.contact-actions .del { margin-left: auto; }

.updated { text-align: center; font-size: 0.78rem; color: var(--muted); margin: 18px 0; }

/* Réglages */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 1.05rem; color: var(--deep); }
.panel p { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; }
.panel .btn + .btn { margin-top: 8px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 90px);
  transform: translateX(-50%);
  background: var(--deep);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 10;
  max-width: calc(100vw - 32px);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Statuts des features / tests ---------- */
.status {
  flex: none;
  min-width: 78px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--idle-bg);
  color: var(--idle);
  margin-top: 1px;
}
.status.st-doing { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.status.st-done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* ---------- Comptes & formules ---------- */
.account, .plan {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: grid;
  gap: 8px;
}
.account:first-child, .plan:first-child { border-top: 0; padding-top: 0; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row .input { flex: 1; min-width: 0; }
.row .del { align-self: center; margin-top: 0; }
.input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9rem; }
.input.strong { font-weight: 600; }
.input.price { flex: 0 0 38%; }
.input.env { flex: 0 0 auto; width: auto; font-weight: 600; font-size: 0.85rem; padding-right: 6px; }
.input.env-test { background: var(--warn-bg); color: var(--warn); }
.input.env-prod { background: var(--ok-bg); color: var(--ok); }
.copy svg { width: 18px; height: 18px; display: block; }
.copy.active { background: var(--surface-2); }
.sub-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- Lancements ---------- */
.launches {
  background: var(--deep);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 14px 16px 6px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.launches-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 6px;
}
.launch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.launch-row:first-of-type { border-top: 0; }
.launch-days {
  flex: none;
  width: 56px;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.1;
  opacity: 0.85;
}
.launch-days strong {
  display: block;
  font-family: "Josefin Sans", system-ui, sans-serif;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--accent);
}
.launch-days.soon strong { color: #ffd38a; }
.launch-info { display: grid; min-width: 0; }
.launch-info strong { font-size: 1.02rem; }
.launch-info span { font-size: 0.82rem; opacity: 0.75; }
.launches-more { font-size: 0.8rem; opacity: 0.7; padding: 4px 0 8px; }
.pill.launch { background: var(--deep); color: var(--bg); font-weight: 600; }
.pill.launch.soon { background: #ffd38a; color: #5a3a00; }
.launch-hint:empty { display: none; }
.launch-hint { margin-top: -2px; font-size: 0.8rem; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .launches { background: var(--surface-2); color: var(--text); }
  .launch-row { border-top-color: var(--border); }
  .pill.launch { background: var(--accent); color: #0b2a22; }
}
