:root {
  --bg: #0b0b12;
  --bg2: #15151f;
  --bg3: #1f1f2c;
  --line: #2a2a3a;
  --text: #f4f4f8;
  --muted: #9a9ab0;
  --like: #2fd889;
  --nope: #ff4f6d;
  --seen: #5aa7ff;
  --accent1: #ff4f7b;
  --accent2: #ff9a3c;
  --grad: linear-gradient(135deg, var(--accent1), var(--accent2));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; position: relative; overflow: hidden; }

/* ---------- Écrans d'accès ---------- */
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 24px calc(28px + var(--safe-b)); gap: 18px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.logo i { width: 30px; height: 36px; border-radius: 8px; background: var(--grad); display: inline-grid; place-items: center; font-style: normal; font-size: 16px; }
.logo span b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate .logo { font-size: 34px; justify-content: center; }
.gate .logo i { width: 44px; height: 52px; font-size: 24px; border-radius: 12px; }
.gate h2 { margin: 6px 0 0; font-size: 22px; text-align: center; }
.gate p.sub { margin: 0; color: var(--muted); text-align: center; line-height: 1.45; }
.field { width: 100%; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); font-size: 18px; outline: none; }
.field:focus { border-color: var(--accent1); }
.btn { width: 100%; padding: 16px; border-radius: 14px; background: var(--grad); font-weight: 700; font-size: 17px; color: #fff; box-shadow: 0 8px 24px rgba(255, 79, 123, 0.25); }
.btn:disabled { opacity: 0.5; }
.btn.ghost { background: var(--bg3); box-shadow: none; color: var(--text); font-weight: 600; }
.link { color: var(--muted); text-decoration: underline; text-align: center; padding: 8px; }
.err { color: var(--nope); text-align: center; min-height: 1.2em; margin: 0; font-size: 15px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); text-align: left; }
.choice:active { transform: scale(0.98); }
.choice .t { font-weight: 700; font-size: 17px; }
.choice .s { color: var(--muted); font-size: 14px; margin-top: 2px; }
.choice .lock { color: var(--muted); font-size: 14px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--grad); color: #fff; flex: none; }
.row { display: flex; align-items: center; gap: 12px; }

/* ---------- En-tête & navigation ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + var(--safe-t)) 16px 8px; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip b { color: var(--text); }
nav.tabs { display: flex; border-top: 1px solid var(--line); background: rgba(11, 11, 18, 0.96); padding-bottom: var(--safe-b); }
nav.tabs button { flex: 1; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); position: relative; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--text); }
nav.tabs button.on svg { color: var(--accent1); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent1); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 8px; padding: 2px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex: none; }
.seg button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 700; }
.genre-select { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 13px; appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a9ab0'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.genre-select.on { border-color: var(--accent1); color: var(--text); }

/* ---------- Âge conseillé ---------- */
.age-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 8px; }
.age { display: inline-block; padding: 4px 9px; border-radius: 7px; font-size: 13px; font-weight: 800; letter-spacing: 0.01em; color: #fff; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.age.small { padding: 2px 7px; font-size: 11px; box-shadow: none; }
.age.all { background: #1fa463; }
.age.kid { background: #2f7de1; }
.age.teen { background: #e08a12; }
.age.mature { background: #e0531f; }
.age.adult { background: #d11f3c; }
.age.unk { background: rgba(255,255,255,0.16); color: #d8d8e4; font-weight: 600; }
.why { font-size: 13px; color: #ffd8c2; font-weight: 600; }
.why::before { content: '· '; color: var(--muted); }

/* ---------- Bande-annonce ---------- */
.trailer { position: absolute; top: 14px; right: 14px; z-index: 5; width: 74px; height: 74px; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 6px 18px rgba(0,0,0,0.55), 0 0 0 2px rgba(255,255,255,0.2); cursor: pointer; touch-action: manipulation; transition: width 0.25s ease, height 0.25s ease; }
.trailer img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.trailer .play { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: rgba(255,0,0,0.9); color: #fff; font-size: 13px; display: grid; place-items: center; padding-left: 2px; pointer-events: none; }
.trailer .tl { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 0 4px; background: rgba(0,0,0,0.7); font-size: 9px; font-weight: 700; text-align: center; letter-spacing: 0.02em; pointer-events: none; }
.trailer.big { left: 10px; right: 10px; width: auto; height: auto; aspect-ratio: 16 / 9; z-index: 20; cursor: default; }
.trailer iframe { width: 100%; height: 100%; border: 0; display: block; }
.trailer .tclose { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,0.75); color: #fff; font-size: 15px; display: grid; place-items: center; }

/* ---------- Pile de cartes ---------- */
.deck { flex: 1; min-height: 0; position: relative; margin: 0 14px; }
.card { position: absolute; inset: 0; border-radius: 22px; overflow: hidden; background: var(--bg3); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55); touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform; transform-origin: 50% 90%; }
.card img.poster { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.card .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(5,5,10,0.75) 68%, rgba(5,5,10,0.97) 100%); pointer-events: none; }
.card .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 18px 16px; }
.card h3 { margin: 0; font-size: 26px; line-height: 1.1; letter-spacing: -0.01em; text-shadow: 0 2px 10px rgba(0,0,0,0.6); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; font-size: 14px; color: #d8d8e4; }
.tag { padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,0.14); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.tag.tv { background: rgba(90, 167, 255, 0.28); }
.tag.movie { background: rgba(255, 154, 60, 0.28); }
.star { color: #ffd34d; font-weight: 700; }
.genres { color: var(--muted); font-size: 13px; margin-top: 6px; }
.overview { margin: 10px 0 0; font-size: 14px; line-height: 1.45; color: #d6d6e2; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card.open .overview { -webkit-line-clamp: 14; }
.card.open .shade { background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(5,5,10,0.85) 35%, rgba(5,5,10,0.98) 100%); }
.more { color: var(--muted); font-size: 12px; margin-top: 6px; }
.providers { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.providers img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.providers .lbl { font-size: 12px; color: var(--muted); margin-right: 2px; }
.providers .none { font-size: 12px; color: var(--muted); }
.prov-detail { margin-top: 10px; font-size: 13px; color: var(--muted); display: none; }
.card.open .prov-detail { display: block; }
.prov-detail div { margin-top: 4px; }
.likedby { position: absolute; top: 14px; left: 14px; padding: 7px 11px; border-radius: 999px; background: rgba(11,11,18,0.78); backdrop-filter: blur(6px); font-size: 13px; font-weight: 600; }
.likedby b { color: var(--accent1); }
.stamp { position: absolute; z-index: 6; top: 34px; padding: 6px 14px; border: 4px solid; border-radius: 12px; font-size: 30px; font-weight: 900; letter-spacing: 0.04em; opacity: 0; pointer-events: none; text-transform: uppercase; }
.stamp.like { left: 22px; color: var(--like); border-color: var(--like); transform: rotate(-14deg); }
.stamp.nope { right: 22px; color: var(--nope); border-color: var(--nope); transform: rotate(14deg); }
.stamp.seen { left: 50%; top: auto; bottom: 46%; color: var(--seen); border-color: var(--seen); transform: translateX(-50%); font-size: 26px; }

.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 24px; color: var(--muted); }
.empty .big { font-size: 46px; }
.empty h3 { color: var(--text); margin: 0; font-size: 20px; }
.empty p { margin: 0; line-height: 1.45; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent1); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Boutons d'action ---------- */
.actions { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 0 12px; }
.act { width: 58px; height: 58px; border-radius: 50%; background: var(--bg2); border: 1px solid var(--line); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,0.4); transition: transform 0.12s; }
.act:active { transform: scale(0.9); }
.act svg { width: 28px; height: 28px; }
.act.small { width: 46px; height: 46px; }
.act.small svg { width: 22px; height: 22px; }
.act.big { width: 68px; height: 68px; }
.act.big svg { width: 34px; height: 34px; }
.act.nope { color: var(--nope); }
.act.like { color: var(--like); }
.act.seen { color: var(--seen); }
.act.undo { color: #ffd34d; }
.act:disabled { opacity: 0.35; }

/* ---------- Matchs ---------- */
.page { flex: 1; overflow-y: auto; padding: 4px 16px 24px; }
.page h2 { margin: 6px 0 14px; font-size: 24px; }
.page .hint { color: var(--muted); margin: -6px 0 16px; line-height: 1.45; font-size: 15px; }
.mlist { display: flex; flex-direction: column; gap: 12px; }
.mitem { display: flex; gap: 12px; padding: 10px; border-radius: 16px; background: var(--bg2); border: 1px solid var(--line); }
.mitem.watched { opacity: 0.55; }
.mitem img.p { width: 78px; height: 117px; object-fit: cover; border-radius: 10px; flex: none; background: var(--bg3); }
.mitem .b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mitem h4 { margin: 2px 0 0; font-size: 17px; line-height: 1.2; }
.mitem .meta { margin-top: 6px; font-size: 13px; color: var(--muted); }
.mitem .providers img { width: 26px; height: 26px; border-radius: 7px; }
.mitem .foot { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.mini { padding: 6px 10px; border-radius: 999px; background: var(--bg3); font-size: 12px; color: var(--muted); }
.mini.on { background: rgba(47, 216, 137, 0.18); color: var(--like); }
.mini a { color: inherit; }

/* ---------- Groupe ---------- */
.section { margin-bottom: 22px; }
.section h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member .s { color: var(--muted); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.credits { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 30px; text-align: center; }

/* ---------- Animation de match ---------- */
.match-overlay { position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 35%, rgba(255,79,123,0.45), rgba(11,11,18,0.96) 65%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; animation: fadein 0.25s ease-out; overflow: hidden; }
.match-overlay h2 { margin: 0; font-size: 42px; font-weight: 900; letter-spacing: -0.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop 0.6s cubic-bezier(.2,1.6,.4,1); text-align: center; }
.match-overlay p { margin: 0; color: #e6e6ee; text-align: center; font-size: 17px; line-height: 1.4; }
.match-overlay img { width: 190px; height: 285px; object-fit: cover; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 0 4px rgba(255,255,255,0.08); animation: pop 0.7s cubic-bezier(.2,1.4,.4,1); }
.match-overlay .btn { max-width: 320px; }
.heart { position: absolute; bottom: -40px; font-size: 26px; animation: rise linear forwards; pointer-events: none; }
@keyframes fadein { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes rise { to { transform: translateY(-115vh) rotate(25deg); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--bg3); border: 1px solid var(--line); padding: 12px 16px; border-radius: 14px; font-size: 14px; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; animation: up 0.2s ease-out; }
.sheet h3 { margin: 0 0 4px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

@media (min-height: 760px) { .card h3 { font-size: 28px; } }

/* ---------- Pastilles de filtre ---------- */
.pill { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--text); color: var(--bg); font-weight: 700; border-color: var(--text); }
.pill.lock { color: #ffd8a8; border-color: rgba(224, 138, 18, 0.5); background: rgba(224, 138, 18, 0.12); }
.fits { margin-top: 6px; font-size: 13px; font-weight: 700; color: #7ff0b8; }

/* ---------- Nos matchs ---------- */
.btn.tonight { margin: 0 0 16px; }
.subhead { margin: 28px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.mitem .who { margin-top: 4px; font-size: 13px; font-weight: 600; color: #ffb3c6; }

/* ---------- Feuilles de réglage ---------- */
.small-hint { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.lbl2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--bg3); border: 1px solid var(--line); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent1); margin: 0; }
.seg.wide { width: 100%; }
.seg.wide button { flex: 1; padding: 9px 6px; }
.sheet { max-height: 92dvh; overflow-y: auto; }
.sheet .err { min-height: 0; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); font-size: 15px; line-height: 1.4; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent1); margin: 0; flex: none; }
.limit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.limit-row select { font-size: 15px; padding: 9px 30px 9px 12px; }
.provs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.prov { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px; background: var(--bg3); border: 2px solid transparent; font-size: 12px; text-align: center; line-height: 1.2; color: var(--muted); }
.prov img { width: 44px; height: 44px; border-radius: 10px; opacity: 0.6; }
.prov.on { border-color: var(--like); color: var(--text); background: rgba(47, 216, 137, 0.12); }
.prov.on img { opacity: 1; }
details summary { color: var(--muted); padding: 8px 0; cursor: pointer; }

/* ---------- Ce soir ---------- */
.tonight-ov { justify-content: flex-start; overflow-y: auto; padding-top: calc(28px + var(--safe-t)); padding-bottom: calc(28px + var(--safe-b)); gap: 12px; }
.tonight-ov h2 { line-height: 1.15; }
.tonight-card { position: relative; width: 210px; flex: none; }
.tonight-card img { width: 210px; height: 315px; }
.tonight-card .trailer img { width: 100%; height: 100%; box-shadow: none; border-radius: 0; animation: none; }
.tonight-card .trailer.big { position: fixed; left: 12px; right: 12px; top: 30%; }
.row2 { display: flex; gap: 10px; width: 100%; max-width: 360px; }
.row2 .btn { flex: 1; }

/* ---------- Écran d'accueil ---------- */
.install { display: flex; align-items: center; gap: 10px; margin: 0 14px 10px; padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); font-size: 13px; line-height: 1.4; color: var(--muted); }
.install b { color: var(--text); font-size: 14px; }
.install .x { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--bg3); color: var(--muted); }
.ios-share { display: inline-block; padding: 0 5px; border-radius: 5px; background: var(--bg3); color: #5aa7ff; font-weight: 800; }
.match-overlay .providers img { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; animation: none; }
.match-overlay .providers { justify-content: center; }
