:root {
  --bg: #f6f3ea;
  --surface: #ffffff;
  --text: #1f2a22;
  --muted: #5f6b62;
  --accent: #2e7d4f;
  --accent-text: #ffffff;
  --border: #e3ded0;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121814;
    --surface: #1c241f;
    --text: #e8eee9;
    --muted: #9aa79e;
    --accent: #6fbf87;
    --accent-text: #0e1a12;
    --border: #2b362f;
    --danger: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 4px; }
.muted { color: var(--muted); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 48px; height: 48px; border-radius: 12px; }

/* Tuiles des apps */
.apps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 18px 16px;
  min-height: 132px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.tile:active { transform: scale(0.98); }
.tile .emoji { font-size: 36px; line-height: 1; }
.tile strong { font-size: 18px; }
.tile .badge { position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: 13px; font-weight: 700; line-height: 24px; box-sizing: border-box; }
.tile .badge:empty { display: none; }
/* Point « nouveau » (Sorties) : bien visible, sans chiffre */
.tile .badge.dot { display: block; min-width: 0; width: 18px; height: 18px; padding: 0; top: 12px; right: 12px; background: #e8590c; box-shadow: 0 0 0 3px var(--surface); }
#export { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#export .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile.soon { opacity: 0.55; pointer-events: none; }

/* Formulaires */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin-top: 20px;
}

label { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 6px; }

input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: 0.6; }

.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.link {
  background: none;
  color: var(--accent);
  width: auto;
  min-height: 44px;
  padding: 0;
  margin-top: 12px;
  font-weight: 500;
}

.error { color: var(--danger); font-size: 15px; min-height: 1.4em; margin: 12px 0 0; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

.actions { display: grid; gap: 0; margin-top: 8px; justify-items: center; }
.actions > .button, .actions > button:not(.link) { justify-self: stretch; }

/* Entrée « Nos idées » sur l'accueil : pastille = questions qui attendent une réponse */
.idees-btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -8px; margin-bottom: 8px; padding: 14px 16px; min-height: 56px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; box-shadow: var(--shadow); }
.idees-btn .n { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.idees-btn .qb { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: #b85f0f; color: #fff; font-size: 13px; font-weight: 700; line-height: 24px; text-align: center; }

/* Bandeau d'une ligne (public/shared/bar.js), le même que celui de La Crocotte */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; min-height: 44px; margin: -18px 0 10px; padding: 6px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.bar-back { justify-self: start; display: inline-flex; align-items: center; gap: 1px; min-height: 44px; padding-right: 8px; color: var(--accent); font-size: 16px; font-weight: 600; text-decoration: none; }
.bar .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bar-back .ico { margin-left: -4px; }
.bar-mid { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.bar-end { justify-self: end; display: flex; align-items: center; }
.bar button { width: 44px; min-height: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 11px; background: transparent; color: var(--accent); }
.bar button:disabled { opacity: .3; }
.bar-mid button { color: var(--muted); background: none !important; transform: none !important; }
.bar-mid button:active .ico { opacity: .4; }
.bar-end button .ico { width: 24px; height: 24px; stroke-width: 2; }
.guide-link { text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }

[hidden] { display: none !important; }

/* Toucher façon app : léger enfoncement, pas de sélection de texte sur les boutons. */
button, .tile, .idees-btn, .idea, .button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tile, .idees-btn, .idea { transition: transform .12s ease-out; }
.tile:active, .idees-btn:active, .idea:active { transform: scale(.98); }
/* Commandes : un toucher = un clic, jamais un zoom (deux touchers rapides restent deux clics). */
button, a, .tile, .idees-btn, .idea, .chip, summary, label, input, select { touch-action: manipulation; }
/* Boutons : un léger enfoncement pendant l'appui, rien ne reste après (pas de survol au doigt). */
button, .button { transition: transform .1s ease-out; }
button:not(:disabled):active, .button:active, .bar-back:active { transform: scale(.96); }
.idea:not(:disabled):active, .tile:active { transform: scale(.98); }
@media (prefers-reduced-motion: reduce) { .tile, .idees-btn, .idea, button, .button { transition: none; } button:active, .button:active, .bar-back:active { transform: none !important; } }

/* iPhone : Safari zoome sur un champ écrit en moins de 16 px. Tous les champs en 16 px, le zoom reste possible. */
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }

/* iPad (choix du 25/10, page « Le portail sur iPad ») : au-delà de 960 px de large, les pages prennent la largeur
   au lieu d'une colonne de 560 px ; en dessous (iPhone, Split View, Slide Over), rien ne change. */
@media (min-width: 960px) {
  main:has(.bar), main:has(> .apps) { max-width: 1180px; padding-left: 32px; padding-right: 32px; }
  /* Accueil : trois grandes tuiles */
  main:has(> .apps) { max-width: 960px; padding-top: 48px; }
  main:has(> .apps) .brand img { width: 64px; height: 64px; border-radius: 16px; }
  main:has(> .apps) h1 { font-size: 34px; }
  .apps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 36px 0 28px; }
  .tile { min-height: 230px; border-radius: 24px; gap: 16px; }
  .tile .emoji { font-size: 72px; }
  .tile strong { font-size: 22px; }
  .tile .badge { top: 16px; right: 16px; }
  .tile .badge.dot { top: 18px; right: 18px; }
  .idees-btn { min-height: 68px; font-size: 19px; padding: 0 22px; }
  main:has(> .apps) .actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 28px; margin-top: 24px; }
  main:has(> .apps) .actions > * { margin: 0; width: auto; justify-self: auto; }
  main:has(> .apps) #export { padding: 0 24px; }
  main:has(> .apps) .actions .hint:empty { display: none; }
}
