/* V1 — TikTok-ish reels (upgraded UX) */
:root{ color-scheme: dark; --bg:#000; --text:#fff; --panel:rgba(0,0,0,.55); --panel2:rgba(0,0,0,.35); --border:rgba(255,255,255,.14); --muted:rgba(255,255,255,.75); }
body.light{ color-scheme: light; --bg:#f7f7f8; --text:#111; --panel:rgba(255,255,255,.72); --panel2:rgba(255,255,255,.55); --border:rgba(0,0,0,.10); --muted:rgba(0,0,0,.65); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background:var(--bg); color:var(--text); overflow:hidden; }

a { color: inherit; text-decoration:none; }

.tt-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 12px;
  background: linear-gradient(to bottom, var(--panel), rgba(0,0,0,0));
  pointer-events: none;
}
.tt-top * { pointer-events: auto; }
.tt-brand { font-weight: 900; }
.tt-pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); color: rgba(255,255,255,.8); }
.tt-top-right { display:flex; gap: 10px; }
.tt-link { font-size: 13px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(0,0,0,.25); }

.tt-view {
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  padding-bottom: 66px;
}

.reel {
  position: relative;
  height: 100vh;
  scroll-snap-align: start;
  background: #050505;
  display:flex;
  align-items:center;
  justify-content:center;
}

.reel::before {
  content:"";
  position:absolute; inset:0;
  background-image: var(--bg);
  background-size: cover;
  background-position: center;
  filter: blur(0px) saturate(1.05);
  transform: scale(1.02);
}
.reel::after {
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(circle at 40% 30%, rgba(0,0,0,.05), rgba(0,0,0,.60) 60%, rgba(0,0,0,.75));
}

.reel-inner {
  position: relative;
  width: min(520px, 92vw);
  aspect-ratio: 9 / 16;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 50px rgba(0,0,0,.55);
  background: var(--panel2);
  display:flex;
  align-items:center;
  justify-content:center;
}

.reel-thumb {
  width:100%; height:100%;
  object-fit: cover;
  display:block;
  opacity: .92;
}
.reel-play {
  position:absolute;
  width: 74px; height: 74px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.30);
  display:flex; align-items:center; justify-content:center;
  font-size: 28px;
  backdrop-filter: blur(8px);
}
.reel-meta {
  position:absolute;
  left: 14px; right: 76px; bottom: 14px;
  display:grid; gap: 6px;
}
.tt-title { font-weight: 900; font-size: 16px; }
.tt-sub { color: rgba(255,255,255,.80); font-size: 13px; }
.tt-tags { color: var(--muted); font-size: 12px; }

.reel-actions {
  position:absolute;
  right: 10px;
  bottom: 14px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  align-items:center;
}
.actbtn {
  width: 48px; height: 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.22);
  color:#fff;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  cursor:pointer;
  backdrop-filter: blur(8px);
}
.actbtn.busy{ opacity:.65; cursor:progress; }
.actbtn.on { border-color: rgba(255,120,170,.42); background: rgba(255,120,170,.14); }
.actcount { font-size: 11px; color: rgba(255,255,255,.80); margin-top: 2px; }

.tt-nav {
  position: fixed; left:0; right:0; bottom: 0; z-index: 25;
  display:grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.10);
}
.tt-navbtn {
  padding: 14px 10px;
  text-align:center;
  font-weight: 700;
  color: rgba(255,255,255,.85);
}
.tt-navbtn.active { color: #fff; }
.tt-toast {
  position: fixed;
  left: 12px; right: 12px; bottom: 78px;
  display:grid; gap: 8px;
  z-index: 30;
}
.toast {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  color: rgba(255,255,255,.92);
}
.toast.bad { border-color: rgba(255,120,120,.35); }

.sheet {
  height: 100vh;
  padding: 76px 12px 88px;
  display:grid; gap: 12px;
  background: #000;
}
.card {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.04);
}
.h { margin:0; font-weight: 900; font-size: 18px; }
.muted { color: var(--muted); }
.field { display:grid; gap: 6px; margin-top: 10px; }
label { font-size: 12px; color: var(--muted); }
input, textarea, select {
  width:100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: #fff;
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
.row { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color:#fff;
  padding: 9px 12px;
  border-radius: 999px;
  cursor:pointer;
}
.btn.primary { border-color: rgba(120,170,255,.35); background: rgba(120,170,255,.12); }
.media iframe { width:100%; height: 64vh; border:0; border-radius: 14px; background:#000; }


/* Action sheet (modal) */
.tt-backdrop{
  position:fixed; inset:0; z-index: 200;
  background: rgba(0,0,0,.55);
  display:flex; align-items:flex-end; justify-content:center;
  padding: 12px;
}
body.light .tt-backdrop{ background: rgba(0,0,0,.25); }

.tt-sheet{
  width: min(520px, 100%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow:hidden;
}
.tt-sheet-hd{
  display:flex; align-items:center; justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.tt-sheet-title{ font-weight: 900; }
.tt-sheet-bd{ padding: 10px; display:grid; gap: 8px; }
.tt-sheet-act{
  width:100%;
  text-align:left;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.tt-sheet-act:hover{ background: rgba(127,127,127,.10); }
.tt-sheet-act.danger{ border-color: rgba(255,120,120,.35); }
.tt-sheet-act .sub{ display:block; font-size:12px; opacity:.78; margin-top:2px; }

/* Chip label */
.tt-chip{
  position:absolute; top: 82px; left: 12px;
  font-size:12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  z-index: 3;
}
body.light .tt-chip{ border-color: rgba(0,0,0,.14); background: rgba(255,255,255,.55); }

/* Like burst */
@keyframes burst { 0%{ transform: scale(1); } 35%{ transform: scale(1.18); } 100%{ transform: scale(1); } }
.actbtn.burst{ animation: burst .28s ease; }


/* --- Player modal (V1 reels) --- */
.player-open{ overflow:hidden; }
.player-modal{
  position:fixed; inset:0;
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
  opacity:0; pointer-events:none;
  transition: opacity .18s ease;
}
.player-modal.show{ opacity:1; pointer-events:auto; }
.player-backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(6px);
}
.player-sheet{
  position:relative;
  width:min(900px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow:auto;
  border-radius:18px;
  background: rgba(20,24,32,.92);
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  padding:14px;
}
.player-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.player-title{ font-weight:800; font-size:18px; }
.player-sheet .media iframe{
  width:100%;
  aspect-ratio: 16 / 9;
  border:0;
  border-radius:14px;
  background: rgba(0,0,0,.25);
}


/* --- PATCH: V1 UI safe-area + clickability (20251223K3) --- */
:root{
  --tt-nav-safe: 84px; /* space for bottom nav */
}
@supports (padding: env(safe-area-inset-bottom)){
  :root{ --tt-nav-safe: calc(84px + env(safe-area-inset-bottom)); }
}

/* overlays must not eat clicks */
.reel::before,
.reel::after{
  pointer-events: none !important;
}

/* keep interactive UI above thumb/overlays */
.reel-play,
.reel-meta,
.reel-actions,
.tt-chip{
  z-index: 5;
}

/* move bottom UI above fixed nav */
.reel-meta{ bottom: calc(14px + var(--tt-nav-safe)) !important; }
.reel-actions{ bottom: calc(14px + var(--tt-nav-safe)) !important; }

/* the play button should be clickable but not block the whole reel */
.reel-play{ pointer-events: auto !important; cursor: pointer; }

/* ensure action buttons never get visually clipped on narrow heights */
@media (max-height: 700px){
  :root{ --tt-nav-safe: 96px; }
  .reel-actions{ gap: 8px; }
  .actbtn{ width: 44px; height: 44px; }
}
/* --- /PATCH --- */

/* --- PATCH: V1 mobile polish + safe areas (20251223K4) --- */
:root{
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

/* Top bar: keep everything reachable on small screens */
.tt-top{
  padding-top: calc(10px + var(--safe-top)) !important;
}
.tt-top-right{
  max-width: 70vw;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tt-top-right::-webkit-scrollbar{ display:none; }

/* Slightly tighter chips on tiny screens */
@media (max-width: 420px){
  .tt-link{ padding: 6px 8px; font-size: 12px; }
  .tt-pill{ display:none; }
}

/* Bottom nav respects gesture bar / safe-area */
.tt-nav{
  padding-bottom: var(--safe-bot);
}
.tt-navbtn{ padding-bottom: calc(14px + var(--safe-bot)); }

/* Toasts & sheets sit above nav/safe area */
.tt-toast{ bottom: calc(78px + var(--safe-bot)) !important; }
.tt-backdrop{ padding-bottom: calc(12px + var(--safe-bot)); padding-top: calc(12px + var(--safe-top)); }
.tt-sheet{ max-height: calc(86vh - var(--safe-top)); overflow:auto; }
/* --- /PATCH --- */
