:root {
  --bg: #0e0d12;
  --bg-2: #16141c;
  --card: #1b1922;
  --card-2: #23202c;
  --line: #2e2a38;
  --text: #f4f1ea;
  --muted: #a39fae;
  --faint: #6f6a7c;
  --accent: #ffb547;
  --accent-ink: #261800;
  --p3: #ff6b4a;
  --p2: #5aa9ff;
  --p1: #8b8697;
  --ok: #4fd18b;
  --danger: #ff5d6c;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; line-height: 1.1; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 6px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line);
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
a.btn { text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { height: 52px; width: 100%; font-size: 17px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.ok { background: var(--ok); color: #04210f; border-color: transparent; }
.btn:disabled { opacity: .5; }
.link { color: var(--accent); font-weight: 600; padding: 8px 4px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  font-size: 20px; display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- segmented / tabs / chips ---------- */
.seg, .tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button, .tabs button {
  flex: 1; height: 38px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 15px;
}
.seg button.on, .tabs button.on { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
.count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--line); font-size: 12px; line-height: 20px; color: var(--muted); }
.tabs button.on .count { background: var(--accent); color: var(--accent-ink); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 2px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}
.chips button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.p3 { background: var(--p3); } .dot.p2 { background: var(--p2); } .dot.p1 { background: var(--p1); }

/* ---------- auth ---------- */
#auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: radial-gradient(120% 60% at 50% 0%, #2a1d0a 0%, var(--bg) 60%); }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.brand { text-align: center; }
.brand-mark { font-size: 54px; filter: drop-shadow(0 8px 24px rgba(255,181,71,.35)); }
.brand h1 { font-size: 34px; margin-top: 8px; }
.brand p { color: var(--muted); margin: 8px 0 0; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
label input, .note-input {
  height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  padding: 0 16px; font-size: 17px; color: var(--text); outline: none; font-weight: 500;
}
label input:focus, .note-input:focus { border-color: var(--accent); }
#auth-pin:not(:placeholder-shown) { letter-spacing: .35em; }

/* ---------- main ---------- */
.top {
  position: sticky; top: 0; z-index: 5; padding: calc(14px + var(--safe-t)) 16px 12px;
  background: linear-gradient(var(--bg) 85%, rgba(14,13,18,0));
}
.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.top-row h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw; }
.top-actions { display: flex; gap: 8px; }

#list { padding: 4px 16px calc(110px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin: 0 auto; }
.section-label { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin: 14px 2px 2px; display: flex; align-items: center; gap: 8px; }
.section-label:first-child { margin-top: 2px; }

.card {
  display: flex; gap: 12px; padding: 10px; padding-right: 6px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); align-items: stretch; position: relative;
  text-align: left; width: 100%; transition: transform .1s ease, opacity .2s;
  animation: rise .25s ease both;
}
.card:active { transform: scale(.985); }
.card.watched { opacity: .72; }
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pc, transparent); }
.card[data-p="3"] { --pc: var(--p3); } .card[data-p="2"] { --pc: var(--p2); } .card[data-p="1"] { --pc: var(--p1); }
.card.watched::before { background: var(--ok); }
.poster {
  width: 64px; height: 96px; flex: none; border-radius: 10px; background: var(--card-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--faint); font-size: 26px; overflow: hidden;
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.card-title { font-weight: 700; font-size: 17px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.meta .star { color: var(--accent); font-weight: 700; }
.genre { color: var(--faint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; display: inline-flex; gap: 5px; align-items: center; background: var(--card-2); color: var(--muted); }
.pill.p3 { color: var(--p3); background: rgba(255,107,74,.12); }
.pill.p2 { color: var(--p2); background: rgba(90,169,255,.12); }
.pill.p1 { color: var(--p1); background: rgba(139,134,151,.14); }
.by { font-size: 12px; color: var(--faint); }

.check {
  width: 48px; flex: none; display: grid; place-items: center; align-self: center; height: 48px; border-radius: 50%;
}
.check i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-style: normal; font-size: 15px; color: transparent; transition: all .15s; }
.check:active i { transform: scale(.88); }
.card.watched .check i { background: var(--ok); border-color: var(--ok); color: #04210f; }

.empty { text-align: center; color: var(--muted); padding: 60px 24px; }
.empty .big-emoji { font-size: 48px; margin-bottom: 12px; }
.empty b { color: var(--text); display: block; font-size: 18px; margin-bottom: 4px; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 6;
  height: 56px; padding: 0 26px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 10px 30px rgba(255,181,71,.28), 0 2px 8px rgba(0,0,0,.5);
}
.fab span { font-size: 22px; line-height: 1; }
.fab:active { transform: translateX(-50%) scale(.96); }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; animation: fade .2s ease both; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg-2); border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0; max-height: 88dvh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b); animation: up .28s cubic-bezier(.2,.9,.3,1) both; max-width: 720px; margin: 0 auto;
}
#search-sheet { height: 88dvh; }
.sheet.tall { max-height: 92dvh; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 4px; flex: none; }

.search-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px 10px; flex: none; }
.search-bar input {
  flex: 1; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  padding: 0 14px 0 38px; font-size: 17px; outline: none; color: var(--text);
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar { position: relative; }
.search-icon { position: absolute; left: 30px; color: var(--faint); font-size: 20px; pointer-events: none; }
.results { overflow-y: auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.result {
  display: flex; gap: 12px; padding: 8px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  align-items: center; text-align: left; width: 100%;
}
.result .poster { width: 46px; height: 68px; border-radius: 8px; font-size: 20px; }
.result .card-title { font-size: 16px; }
.result .add-tag { margin-left: auto; flex: none; font-size: 13px; font-weight: 700; color: var(--accent); padding: 0 8px; }
.result .add-tag.on { color: var(--ok); }
.results .hint { text-align: center; padding: 24px 0; }

/* detail */
#detail-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.hero { position: relative; padding: 8px 16px 0; display: flex; gap: 16px; }
.hero-bg { position: absolute; inset: -20px 0 -40px; background: center/cover no-repeat; filter: blur(30px) saturate(1.3); opacity: .35; z-index: 0; pointer-events: none; mask-image: linear-gradient(#000 30%, transparent); -webkit-mask-image: linear-gradient(#000 30%, transparent); }
.hero > *:not(.hero-bg) { position: relative; z-index: 1; }
.hero .poster { width: 110px; height: 165px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 40px; }
.hero-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 4px; }
.hero-info h2 { margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: -0.01em; }
.rating-big { font-size: 15px; color: var(--accent); font-weight: 800; }
.backdrop {
  height: 190px; margin: -13px 0 0; background: center/cover no-repeat; border-radius: 22px 22px 0 0;
  mask-image: linear-gradient(#000 45%, transparent); -webkit-mask-image: linear-gradient(#000 45%, transparent);
}
.hero.over { margin-top: -96px; align-items: flex-end; }
.hero.over .hero-info { padding-top: 0; }
.hero.over h2 { text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.ratings { display: flex; gap: 12px; flex-wrap: wrap; }
.rating-big small { font-weight: 600; color: var(--muted); font-size: 12px; }
.rating-big.dim { color: var(--muted); }
.tagline { margin: 0; color: var(--accent); font-style: italic; font-size: 15px; }
.btn.trailer { align-self: flex-start; height: 40px; }
.providers { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.providers::-webkit-scrollbar { display: none; }
.provider {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.provider img { width: 34px; height: 34px; border-radius: 8px; }
.provider span { display: flex; flex-direction: column; line-height: 1.15; }
.provider b { font-size: 13px; white-space: nowrap; }
.provider small { font-size: 11px; color: var(--muted); }
.rate-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rate-grid button {
  height: 50px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line);
  font-size: 19px; font-weight: 800; color: var(--muted); transition: transform .08s, background .15s;
}
.rate-grid button:active { transform: scale(.92); }
.rate-grid button.on { background: var(--sc); border-color: var(--sc); color: #111; }
.others { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.score-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text);
  padding: 3px 10px 3px 3px; border-radius: 99px; background: var(--card-2);
}
.score-chip b { min-width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; background: var(--sc); color: #111; font-size: 13px; }
.score-chip.sm { font-size: 12px; padding: 2px 8px 2px 2px; }
.score-chip.sm b { min-width: 20px; height: 20px; font-size: 12px; }
.rate-cta { color: var(--accent); font-weight: 700; padding: 4px 0; }
.pick.rate .poster { width: 110px; height: 165px; }
.pick.rate .others { justify-content: center; }
.credit { text-align: center; font-size: 11px; color: var(--faint); margin: 6px 0 0; }
.detail-section { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.plot { color: #d8d4cc; margin: 0; font-size: 15px; line-height: 1.5; }
.kv { font-size: 14px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }
.prio-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.prio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.prio button {
  height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted);
}
.prio button small { font-weight: 500; font-size: 11px; color: var(--faint); }
.prio button[data-p="3"].on { border-color: var(--p3); color: var(--p3); background: rgba(255,107,74,.1); }
.prio button[data-p="2"].on { border-color: var(--p2); color: var(--p2); background: rgba(90,169,255,.1); }
.prio button[data-p="1"].on { border-color: var(--p1); color: var(--text); background: rgba(139,134,151,.12); }
.actions { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 20px; }
.actions-row { display: flex; gap: 10px; }
.actions-row .btn { flex: 1; }
.note-input { width: 100%; height: 46px; font-size: 15px; }
.skeleton { background: linear-gradient(90deg, var(--card) 0, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }

/* menu */
.menu { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.menu-info { padding: 8px 4px 12px; }
.menu-title { font-size: 22px; font-weight: 700; margin-top: 2px; }
.menu-item { display: flex; gap: 12px; align-items: center; height: 54px; padding: 0 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-align: left; font-weight: 600; }
.menu-item.danger { color: var(--danger); }

/* pick */
.pick { text-align: center; padding: 8px 20px 24px; }
.pick .poster { width: 150px; height: 225px; margin: 8px auto 14px; border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.6); font-size: 48px; animation: spin-in .5s cubic-bezier(.2,.9,.3,1.3) both; }
.pick h2 { margin: 0 0 4px; font-size: 24px; }
.pick .meta { justify-content: center; margin-bottom: 18px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100vw - 32px); animation: pop .2s ease both; display: flex; gap: 14px; align-items: center;
}
.toast button { color: #b06a00; font-weight: 800; }

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin-in { from { opacity: 0; transform: rotate(-8deg) scale(.7); } }

@media (min-width: 720px) {
  .top { max-width: 720px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
