/* CICO — interface façon iOS.
   Écran principal : photo du chat plein écran, état en très grand, capsule d'action à portée de pouce.
   Pages secondaires : listes groupées comme l'app Réglages. */

:root {
  --in: #4c9a3f;          /* vert de l'icône */
  --out: #e4572e;         /* rouge-orangé de l'icône */
  --in-deep: #1d3819;
  --out-deep: #4d1b0d;
  --cream: #fefaf2;

  --bg: #f2f2f7;
  --cell: #ffffff;
  --label: #000000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .2);
  --fill: rgba(120, 120, 128, .12);
  --tint: #3f8a35;
  --danger: #e5352b;

  --rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --text: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --cell: #1c1c1e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, .6);
    --label-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .55);
    --fill: rgba(120, 120, 128, .24);
    --tint: #62bb52;
    --danger: #ff453a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden]:not(.island) { display: none !important; }
html, body { margin: 0; }
body {
  font: 17px/1.35 var(--text);
  letter-spacing: -.01em;
  background: var(--bg);
  color: var(--label);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--tint); text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* =====================================================================
   Écran principal
   ===================================================================== */
body.stage-page { background: #000; color: #fff; overflow: hidden; overscroll-behavior: none; }

.hud {
  position: fixed; z-index: 5; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-t) + 8px) 16px 0;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.glass {
  background: rgba(40, 40, 40, .28);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .28), inset 0 1px 0 rgba(255, 255, 255, .22);
  color: #fff;
}
.house-pill {
  position: relative; display: flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 21px; max-width: 58vw;
  font: 600 16px var(--rounded); color: #fff;
}
.house-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.house-pill select { position: absolute; inset: 0; opacity: 0; font-size: 16px; }
.house-pill svg.i { width: 14px; height: 14px; stroke-width: 2.6; opacity: .8; }
.hud-actions { display: flex; gap: 8px; }
.round {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #fff;
}
.round svg.i { width: 20px; height: 20px; }

.pager {
  display: flex; height: 100dvh; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.pager::-webkit-scrollbar { display: none; }

.slide {
  position: relative; flex: 0 0 100%; height: 100dvh; scroll-snap-align: center;
  overflow: hidden; isolation: isolate;
  --state: var(--in); --deep: var(--in-deep);
}
.slide.is-out { --state: var(--out); --deep: var(--out-deep); }

.photo { position: absolute; inset: 0; z-index: -2; background: var(--deep); transition: background .5s; }
.photo img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 35%;
  opacity: 0; transition: opacity 1.4s ease;
}
.photo img.shown { opacity: 1; animation: drift 12s ease-out both; }
@keyframes drift { from { transform: scale(1.12); } to { transform: scale(1); } }
.no-photo[hidden] { display: none; }
.photo .initial {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  font: 800 72vw/1 var(--rounded); letter-spacing: -.06em; color: var(--state); opacity: .35;
  transition: color .5s;
}
.add-photo {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  height: 36px; padding: 0 14px; border-radius: 18px; font-size: 15px; font-weight: 600;
}
.add-photo svg.i { width: 18px; height: 18px; }

/* le voile : sombre en bas pour la lisibilité, teinté par l'état */
.scrim { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.scrim::before, .scrim::after { content: ""; position: absolute; inset: 0; transition: opacity .5s; }
.scrim::before {
  background:
    linear-gradient(to bottom, rgba(0,0,0,.45), transparent 22%),
    linear-gradient(to top, rgba(0,0,0,.82) 0%, rgba(0,0,0,.5) 34%, transparent 62%);
}
.scrim::after {
  background: linear-gradient(to top, var(--state) 0%, transparent 55%);
  opacity: .55; mix-blend-mode: soft-light;
}

.content {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 20px calc(var(--safe-b) + 34px);
}
.lead { margin: 0; font: 600 22px/1.2 var(--rounded); color: rgba(255,255,255,.85); }
.state {
  margin: 0 0 0 -4px; font: 800 clamp(5rem, 26vw, 10rem)/.92 var(--rounded);
  letter-spacing: -.055em; color: #fff;
  text-shadow: 0 2px 30px rgba(0,0,0,.25);
}
.state.flip { animation: flip .55s cubic-bezier(.2, .9, .25, 1.15); }
@keyframes flip {
  0% { transform: translateY(40%); opacity: 0; filter: blur(8px); }
  100% { transform: none; opacity: 1; filter: none; }
}
.meta { margin: 10px 0 22px; min-height: 1.35em; font-size: 16px; color: rgba(255,255,255,.75); }

.action {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; height: 78px; border: none; border-radius: 39px; cursor: pointer;
  font: 700 21px var(--rounded); letter-spacing: -.01em; color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,0) 55%), var(--target);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 0 0 .5px rgba(255,255,255,.25),
              0 14px 34px -8px var(--target);
  transition: transform .15s cubic-bezier(.3, .7, .4, 1.4), filter .2s;
}
.is-in .action { --target: var(--in); }
.is-out .action { --target: var(--out); }
.action svg.i { width: 26px; height: 26px; stroke-width: 2.2; }
.action:active { transform: scale(.96); }
.action:disabled { filter: saturate(.4) brightness(.85); }
.action.loading::after {
  content: ""; position: absolute; right: 26px; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dots {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 12px); z-index: 4;
  display: flex; justify-content: center; gap: 7px; pointer-events: none;
}
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.4); transition: background .2s, width .2s; }
.dots i.on { background: #fff; width: 18px; border-radius: 4px; }

.empty-stage { height: 100dvh; display: grid; place-items: center; text-align: center; padding: 24px; }
.empty-stage p { color: rgba(255,255,255,.7); }

/* « Dynamic Island » : confirmation + annulation */
.island {
  position: fixed; z-index: 20; left: 50%; top: calc(var(--safe-t) + 6px);
  display: flex; align-items: center; gap: 14px;
  min-height: 52px; padding: 8px 8px 8px 20px; width: max-content; min-width: 62vw; max-width: calc(100vw - 24px);
  border-radius: 26px; background: #000; color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 .5px rgba(255,255,255,.12);
  font-size: 15px; font-weight: 600;
  transform: translate(-50%, 0) scale(1); transform-origin: top center; opacity: 1;
  transition: transform .45s cubic-bezier(.2, .9, .25, 1.2), opacity .25s;
}
.island[hidden] { display: flex; transform: translate(-50%, -10px) scale(.4, .5); opacity: 0; pointer-events: none; }
.island #toast-msg { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.island-undo {
  border: none; border-radius: 18px; height: 36px; padding: 0 14px; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; font-weight: 700; font-size: 15px;
}
.island-undo[hidden] { display: none; }
.island .ok { color: var(--in); }

/* feuille de confirmation (localisation) */
dialog.sheet {
  width: calc(100% - 16px); max-width: 440px; margin: auto auto calc(var(--safe-b) + 8px);
  border: none; border-radius: 30px; padding: 26px 18px 18px; text-align: center;
  background: rgba(28, 28, 30, .94); color: #fff;
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.2);
}
dialog.sheet[open] { animation: sheet-up .4s cubic-bezier(.2, .9, .25, 1.05); }
dialog.sheet::backdrop { background: rgba(0,0,0,.35); }
@keyframes sheet-up { from { transform: translateY(110%); } }
.sheet-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: rgba(255,255,255,.12); }
.sheet-icon svg.i { width: 28px; height: 28px; }
.sheet h2 { margin: 0 0 6px; font: 700 20px var(--rounded); }
.sheet p { margin: 0 0 20px; color: rgba(255,255,255,.7); font-size: 15px; }
.sheet .stack-btns { display: flex; flex-direction: column; gap: 8px; }
.sheet .pill-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }

/* =====================================================================
   Pages secondaires (style Réglages iOS)
   ===================================================================== */
.navbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; min-height: 44px;
  padding: var(--safe-t) 8px 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
}
.nav-back { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px; font-size: 17px; }
.nav-back svg.i { width: 24px; height: 24px; stroke-width: 2.4; }
.sheet-page main { max-width: 640px; margin: 0 auto; padding: 0 0 calc(var(--safe-b) + 40px); }
.large-title { margin: 4px 20px 18px; font: 800 34px/1.1 var(--rounded); letter-spacing: -.03em; }

.group { margin: 0 16px 30px; }
.group-title { margin: 0 16px 7px; font-size: 13px; font-weight: 400; color: var(--label-2); }
.group-body { background: var(--cell); border-radius: 22px; overflow: hidden; }
.group-foot { margin: 7px 16px 0; font-size: 13px; color: var(--label-2); }

.cell {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 16px;
}
.cell + .cell::before, .cell + form > .cell::before, form + .cell::before, form + form > .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep);
}
.group-body > form { margin: 0; }
.cell-label { flex: 1; min-width: 0; }
.cell-sub { display: block; font-size: 13px; color: var(--label-2); }
.cell-value { color: var(--label-2); }
.cell input:not([type=file]), .cell select {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--label);
  font: inherit; font-size: 17px; padding: 6px 0; outline: none;
}
.cell input::placeholder { color: var(--label-3); }
.cell .field-label { width: 7.5em; flex: none; }
.cell input.right { text-align: right; }
.cell-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 16px;
  border: none; background: none; text-align: left; color: var(--tint); cursor: pointer; font-size: 17px;
}
.cell-btn.danger { color: var(--danger); }
.cell-btn:active, a.cell:active { background: var(--fill); }
a.cell { color: var(--label); }
.chev { color: var(--label-3); }
.chev svg.i { width: 16px; height: 16px; stroke-width: 2.6; }
.tag { font-size: 12px; font-weight: 600; color: var(--tint); background: color-mix(in srgb, var(--tint) 14%, transparent); border-radius: 8px; padding: 2px 7px; }

.mini-btn {
  border: none; border-radius: 16px; height: 32px; padding: 0 12px; cursor: pointer; white-space: nowrap;
  background: var(--fill); color: var(--tint); font-size: 15px; font-weight: 600;
}
.mini-btn.danger { color: var(--danger); }
.mini-btn.on { background: var(--tint); color: #fff; }

.pill-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  height: 54px; border: none; border-radius: 27px; cursor: pointer;
  background: var(--tint); color: #fff; font: 700 17px var(--rounded);
}
.pill-btn.secondary { background: var(--fill); color: var(--tint); }
.pill-btn.on-dark { background: rgba(255,255,255,.14); color: #fff; }
.pill-btn.danger { background: var(--fill); color: var(--danger); }
.pill-btn.in { background: var(--in); }
.pill-btn.out { background: var(--out); }

.avatar {
  flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  overflow: hidden; font: 800 22px var(--rounded); color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.is-in { background: var(--in); }
.avatar.is-out { background: var(--out); }
.cat-cell { flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.cat-cell .cat-actions { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; margin: 0; }
.album { width: 100%; }
.album-title { display: flex; align-items: center; gap: 8px; margin: 6px 0 8px; font-weight: 600; font-size: 15px; }
.album-title .cell-sub { margin-left: auto; font-weight: 400; }
.album-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 4px; scroll-padding: 16px; }
.album-row::-webkit-scrollbar { display: none; }
.album-row form { margin: 0; flex: none; }
.thumb {
  position: relative; display: grid; place-items: center; width: 72px; height: 96px; padding: 0;
  border: none; border-radius: 14px; overflow: hidden; background: var(--fill); cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-add { color: var(--tint); }
.thumb-add .plus { font: 300 36px/1 var(--rounded); }
.thumb-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumb-add.busy .plus { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.file-btn { position: relative; overflow: hidden; display: inline-grid; place-items: center; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.notice { margin: 0 16px 20px; padding: 12px 16px; border-radius: 16px; background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); font-weight: 600; }
.error { margin: 0 16px 20px; padding: 12px 16px; border-radius: 16px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 600; }

/* historique */
.ev-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.ev-dot.in { background: var(--in); }
.ev-dot.out { background: var(--out); }
.ev-time { font-variant-numeric: tabular-nums; color: var(--label-2); font-size: 15px; }
.ev-undone { opacity: .45; }
.ev-undone .cell-label strong { text-decoration: line-through; }

/* =====================================================================
   Connexion / invitation
   ===================================================================== */
body.welcome { background: var(--bg); }
.welcome main { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 460px; margin: 0 auto; padding: calc(var(--safe-t) + 24px) 0 calc(var(--safe-b) + 24px); }
.brand { text-align: center; margin-bottom: 30px; }
.brand img { width: 108px; height: 108px; border-radius: 26px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.35); }
.brand h1 { margin: 16px 0 2px; font: 800 38px/1 var(--rounded); letter-spacing: -.04em; }
.brand .c-in { color: var(--in); }
.brand .c-out { color: var(--out); }
.brand p { margin: 18px 0 0; color: var(--label-2); font: 600 17px var(--rounded); }
.welcome .actions { margin: 0 16px; }
.welcome details { margin: 18px 0 0; }
.welcome summary { list-style: none; text-align: center; color: var(--tint); cursor: pointer; padding: 10px; }
.welcome summary::-webkit-details-marker { display: none; }
.welcome details[open] summary { margin-bottom: 14px; }
.hint { margin: 18px 32px 0; text-align: center; font-size: 14px; color: var(--label-2); }

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