:root {
  --bg: #15121c;
  --bg2: #1f1a29;
  --bg3: #2a2436;
  --line: #3a3348;
  --text: #f3eff8;
  --muted: #a69fb4;
  --like: #3ccf8e;
  --dislike: #ef5a6f;
  --want: #f4c04e;
  --skip: #8d8a99;
  --accent: #f4c04e;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
a { color: var(--accent); }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; }

/* ---------- вхід і вибір користувача ---------- */
.login, .who { max-width: 360px; margin: 0 auto; padding: 18vh 24px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.logo { font-size: 56px; }
.err { color: var(--dislike); min-height: 1.4em; }
button.primary { background: var(--accent); color: #1a1420; font-weight: 700; padding: 13px 16px; border-radius: 14px; }
.who .people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.who .people button { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 8px; font-size: 18px; font-weight: 600; }
.who .people button span { display: block; font-size: 40px; margin-bottom: 6px; }

/* ---------- каркас ---------- */
.shell { display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin: 0 auto; }
header.top { display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 14px 8px; }
header.top h1 { font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; white-space: nowrap; }
.pill:disabled { opacity: .35; }
main { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.scroll { height: 100%; overflow-y: auto; padding: 4px 14px 24px; -webkit-overflow-scrolling: touch; }
nav.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--bg); padding-bottom: var(--safe-b); }
nav.tabs button { padding: 8px 2px 9px; font-size: 11.5px; color: var(--muted); position: relative; }
nav.tabs button .ic { display: block; font-size: 21px; line-height: 1.2; }
nav.tabs button.on { color: var(--text); }
.badge { position: absolute; top: 3px; left: 50%; margin-left: 8px; background: var(--dislike); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; padding: 1px 5px; font-weight: 700; }
.demo { margin: 0 14px 6px; padding: 6px 10px; border-radius: 10px; background: #3b2f12; color: #f6d68b; font-size: 12.5px; }

/* ---------- свайпи ---------- */
.swipe { height: 100%; display: flex; flex-direction: column; padding: 0 12px 10px; }
.stack { flex: 1; position: relative; min-height: 0; }
.card { position: absolute; inset: 0; border-radius: 22px; overflow: hidden; background: var(--bg3) center/cover no-repeat; box-shadow: 0 10px 30px #0008; touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform; }
.card.back { transform: scale(.95) translateY(10px); filter: brightness(.6); }
.card .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; font-size: 26px; font-weight: 700; color: #ffffff30; background: linear-gradient(150deg, #3c2f52, #1d1826 60%, #4b2433); }
.card .shade { position: absolute; inset: 0; background: linear-gradient(to bottom, #0000 40%, #000c 72%, #000e); }
.card .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px 14px; }
.card h2 { font-size: 25px; line-height: 1.15; }
.card .sub { color: #ddd; font-size: 14px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: #ffffff1f; border-radius: 999px; padding: 3px 9px; font-size: 12.5px; }
.chip.imdb { background: #f5c518; color: #000; font-weight: 700; }
.chip.tmdb { background: #01b4e4; color: #000; font-weight: 700; }
.card .more { margin-top: 10px; font-size: 13.5px; color: #fff; background: #ffffff26; padding: 6px 12px; border-radius: 999px; }
.tag { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: center; }
.tag span { background: #000b; border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; backdrop-filter: blur(6px); }
.stamp { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) rotate(-8deg); border: 4px solid; border-radius: 14px; padding: 8px 14px; font-size: 22px; font-weight: 900; text-transform: uppercase; opacity: 0; text-align: center; background: #000a; pointer-events: none; white-space: nowrap; }
.stamp.liked { color: var(--like); }
.stamp.disliked { color: var(--dislike); }
.stamp.want { color: var(--want); }
.stamp.skip { color: #ddd; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 30px; color: var(--muted); }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.act { border-radius: 16px; padding: 8px 4px 9px; background: var(--bg2); border: 1.5px solid var(--line); font-size: 12px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 76px; justify-content: center; }
.act .ar { font-size: 13px; opacity: .7; }
.act .em { font-size: 22px; line-height: 1; }
.act.disliked { border-color: #ef5a6f80; }
.act.liked { border-color: #3ccf8e80; }
.act.want { border-color: #f4c04e90; background: #2c2516; }
.act.skip { border-color: #8d8a9980; }
.act:active { transform: scale(.96); }

/* ---------- нижній лист із деталями ---------- */
.sheet-bg { position: fixed; inset: 0; background: #000a; z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg2); width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); animation: up .2s; }
.sheet .grab { width: 40px; height: 5px; background: var(--line); border-radius: 3px; margin: -6px auto 12px; }
.sheet .head { display: flex; gap: 14px; }
.sheet .head img, .sheet .head .noimg { width: 96px; height: 144px; border-radius: 12px; object-fit: cover; background: var(--bg3); flex: none; }
.sheet h2 { font-size: 21px; }
.sheet p { margin: 12px 0; }
.sheet .row { margin: 6px 0; font-size: 14.5px; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.links a, .links button { background: var(--bg3); border-radius: 999px; padding: 7px 13px; font-size: 14px; text-decoration: none; color: var(--text); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- підказка ---------- */
.help { position: fixed; inset: 0; z-index: 30; background: #0d0b12f2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; animation: fade .2s; }
.help h2 { margin-bottom: 6px; }
.cross { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto auto auto; gap: 10px; align-items: center; margin: 22px 0; max-width: 380px; width: 100%; }
.cross .c { border-radius: 14px; padding: 10px 6px; font-size: 13.5px; font-weight: 600; border: 2px solid; background: #ffffff08; }
.cross .c b { display: block; font-size: 22px; }
.cross .mid { font-size: 44px; }
.cross .up { grid-column: 2; grid-row: 1; color: var(--want); }
.cross .left { grid-column: 1; grid-row: 2; color: var(--dislike); }
.cross .mid { grid-column: 2; grid-row: 2; }
.cross .right { grid-column: 3; grid-row: 2; color: var(--like); }
.cross .down { grid-column: 2; grid-row: 3; color: #ccc; }

/* ---------- збіг ---------- */
.match { position: fixed; inset: 0; z-index: 40; background: radial-gradient(circle at 50% 40%, #5a2440, #15121cf5 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 12px; animation: fade .25s; }
.match .big { font-size: 64px; animation: pop .5s; }
.match img { width: 150px; border-radius: 14px; box-shadow: 0 10px 30px #000a; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } }

/* ---------- списки ---------- */
.sec { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.sec h3 { font-size: 16px; }
.sec .muted { font-size: 13px; }
.hint { font-size: 13.5px; color: var(--muted); margin: -2px 0 8px; }
.item { display: flex; gap: 12px; padding: 10px; background: var(--bg2); border-radius: 16px; margin-bottom: 8px; border: 1px solid transparent; }
.item.match-item { border-color: #f4c04e66; background: linear-gradient(120deg, #2f2615, var(--bg2) 60%); }
.item img, .item .noimg { width: 64px; height: 96px; border-radius: 10px; object-fit: cover; background: var(--bg3); flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 650; }
.item .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .row2 { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.mini { background: var(--bg3); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; text-decoration: none; color: var(--text); white-space: nowrap; }
.mini.on { outline: 2px solid var(--accent); }
.new { background: var(--dislike); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 4px; scrollbar-width: none; }
.seg button { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13.5px; white-space: nowrap; }
.seg button.on { background: var(--text); color: var(--bg); }
.nothing { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- налаштування ---------- */
.genres { display: flex; flex-wrap: wrap; gap: 7px; }
.genres button { background: var(--bg2); border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.genres button.love { border-color: var(--like); background: #173326; }
.genres button.never { border-color: var(--dislike); background: #3a1820; text-decoration: line-through; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
label.l { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; }
.people-res { margin-top: 6px; }
.people-res button { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; padding: 8px; border-radius: 12px; }
.people-res button:hover { background: var(--bg2); }
.people-res img, .people-res .noimg { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--bg3); flex: none; }
.chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chosen span { background: var(--bg3); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 14px; }
.chosen span button { padding: 0 6px; color: var(--muted); }
.save-bar { position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(#15121c00, var(--bg) 30%); }
.save-bar button { width: 100%; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 50; animation: fade .2s; white-space: nowrap; }
