:root {
  --bg: #09090f;
  --bg-2: #101019;
  --card: #15151f;
  --card-2: #1c1c29;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f1f1f7;
  --muted: #9393ab;
  --dim: #63637b;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --green: #4ade80;
  --red: #f87171;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; padding: calc(var(--safe-t) + 8px) 16px 10px; background: rgba(9, 9, 15, 0.72); -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px); border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.top.scrolled { border-bottom-color: var(--line); }
.top-row { display: flex; align-items: center; gap: 11px; }
.logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 4px 16px -6px var(--accent); }
.top-txt { flex: 1; min-width: 0; }
.brand { font-size: 11px; letter-spacing: 0.2em; color: var(--muted); }
.brand b { color: var(--text); }
.pc { font-size: 13px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 4px 16px calc(var(--safe-b) + 40px); }
.title { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0 14px; }

/* install hint */
.install { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-size: 14px; line-height: 1.4; color: var(--muted); margin-bottom: 14px; }
.install b { color: var(--text); }
.in-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(139, 92, 246, 0.16); color: var(--accent); flex-shrink: 0; }
.install .inline { width: 15px; height: 15px; vertical-align: -2px; color: #3b82f6; }
.install .x { font-size: 24px; color: var(--dim); padding: 0 4px; margin-left: auto; }

/* replay card */
.replay { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; margin-bottom: 18px; background: linear-gradient(145deg, #1d1630, #12121c 60%); border: 1px solid rgba(139, 92, 246, 0.22); position: relative; overflow: hidden; }
.replay::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(236, 72, 153, 0.25), transparent 70%); pointer-events: none; }
.replay.off { background: var(--card); border-color: var(--line); }
.replay.off::after { display: none; }
.rp-txt { flex: 1; min-width: 0; }
.rp-state { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.rp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 1.8s ease-in-out infinite; }
.off .rp-dot { background: var(--dim); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: 0.45; } }
.rp-sub { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.save-btn { position: relative; z-index: 1; height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 15px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px -10px var(--accent-2); display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.save-btn svg { width: 18px; height: 18px; }
.save-btn:active { transform: scale(0.96); }
.save-btn[disabled] { opacity: 0.4; box-shadow: none; }

/* filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 6px; padding: 0 16px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 34px; padding: 0 14px; border-radius: 99px; background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); }
.chip.on { background: var(--text); color: var(--bg); border-color: transparent; }

/* list */
.day { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 18px 2px 10px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.clip { text-align: left; display: block; width: 100%; }
.clip:active .thumb { transform: scale(0.97); }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: linear-gradient(135deg, var(--card-2), var(--card)); transition: transform 0.15s; }
.thumb img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.dur, .new { z-index: 2; }
.thumb img.ok { opacity: 1; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); }
.dur { position: absolute; right: 6px; bottom: 6px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 7px; background: rgba(0, 0, 0, 0.65); font-variant-numeric: tabular-nums; }
.new { position: absolute; left: 6px; top: 6px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.c-name { font-size: 14px; font-weight: 600; margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--card-2); color: var(--muted); margin-left: 4px; vertical-align: 1px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); line-height: 1.5; }
.empty .e-ic { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--card); color: var(--accent); }
.empty .e-ic svg { width: 30px; height: 30px; }
.empty h2 { color: var(--text); font-size: 19px; margin: 0 0 6px; }
.empty .btn { margin-top: 16px; height: 42px; padding: 0 18px; border-radius: 12px; background: var(--card-2); font-weight: 600; }

.skel { aspect-ratio: 16/9; border-radius: 14px; background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* player sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet.closing { animation: down 0.22s ease-in forwards; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
.sheet-top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 6px) 12px 8px; }
.sheet-top .icon-btn { background: rgba(255, 255, 255, 0.1); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); }
.player { background: #000; }
.player video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 18px calc(var(--safe-b) + 24px); background: var(--bg); border-radius: 22px 22px 0 0; margin-top: 10px; }
.s-title { font-size: 22px; font-weight: 750; letter-spacing: -0.01em; }
.s-meta { color: var(--muted); font-size: 14px; margin-top: 5px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.act { height: 54px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 650; font-size: 15px; color: var(--text); text-decoration: none; }
.act:active { transform: scale(0.97); }
.act.danger { color: var(--red); }
.hint { font-size: 12.5px; color: var(--dim); line-height: 1.45; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%); z-index: 80; background: rgba(28, 28, 41, 0.96); border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 12px 40px -10px #000; max-width: calc(100% - 32px); animation: tin 0.25s ease; }
.toast.err { color: #fecaca; }
@keyframes tin { from { opacity: 0; transform: translate(-50%, 10px); } }

/* pairing page */
body.pair { display: grid; place-items: center; min-height: 100vh; padding: 24px; text-align: center; }
.pair-box { max-width: 360px; }
.pair-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 12px 40px -12px var(--accent); }
.pair h1 { font-size: 26px; margin: 22px 0 10px; }
.pair p { color: var(--muted); line-height: 1.5; }
.pair b { color: var(--text); }
.pair .dim { color: var(--dim); font-size: 14px; }

/* quality + preparing */
.player { position: relative; }
.prep { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(0, 0, 0, 0.78); font-size: 14px; font-weight: 600; color: #ddd; text-align: center; padding: 0 30px; }
.prep-ring svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.pr-bg { fill: none; stroke: rgba(255, 255, 255, 0.15); stroke-width: 3; }
.pr-fg { fill: none; stroke: url(#none); stroke: var(--accent-2); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset 0.4s; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.seg button { height: 38px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset; }
.act.photos { width: 100%; margin-top: 12px; color: #fff; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
