:root{
  --bg:#0b0c10;
  --card:#14161d;
  --text:#e9eef5;
  --muted:#9aa4b2;
  --line:#2a2f3a;
  --brand:#6ae5ff;
  --bad:#ff5a6a;

  /* Mobile layout variables */
  --topbar-h: 56px;          /* fallback */
  --app-vh: 1vh;             /* will be improved with dvh if supported */
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-text-size-adjust:100%;
}

a{color:inherit;text-decoration:none}
a:hover{opacity:.9}

/* Desktop container */
.wrap{max-width:980px;margin:0 auto;padding:16px}

/* Top bar */
.topbar{
  position:sticky;
  top:0;
  background:rgba(11,12,16,.86);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
  z-index:10;
}
.brand{font-weight:700;color:var(--brand)}
.nav{display:flex;gap:14px;align-items:center}
.topbar .wrap{display:flex;justify-content:space-between;align-items:center}

/* Flash */
.flash{
  padding:10px 12px;
  border:1px solid var(--line);
  background:var(--card);
  border-radius:12px;
  margin:12px 0;
}
.flash.ok{border-color:rgba(106,229,255,.35)}
.flash.err{border-color:rgba(255,90,106,.35)}

/* Cards / UI */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  margin:14px 0;
}
.btn{
  border:1px solid var(--line);
  background:#0f1118;
  color:var(--text);
  padding:9px 12px;
  border-radius:12px;
  cursor:pointer;
}
.btn.primary{border-color:rgba(106,229,255,.35)}
.btn.danger{border-color:rgba(255,90,106,.35)}
.btn:disabled{opacity:.6;cursor:not-allowed}

.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
.field{display:flex;flex-direction:column;gap:6px;margin:10px 0}
.input,textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#0f1118;
  color:var(--text);
}
textarea{min-height:90px;resize:vertical}
.small{font-size:12px;color:var(--muted)}

.videoWrap{position:relative;background:#000}
video{
  width:100%;
  max-height:72vh; /* desktop default */
  display:block;
  background:#000;
}

.actions{display:flex;gap:10px;align-items:center}
.count{color:var(--muted);font-size:13px}
.hr{height:1px;background:var(--line);margin:14px 0}

.comments{padding:12px 14px;border-top:1px solid var(--line)}
.comment{padding:10px 0;border-bottom:1px solid rgba(42,47,58,.6)}
.comment:last-child{border-bottom:0}
.comment .who{font-size:13px;color:var(--muted)}
.comment .body{margin-top:4px;white-space:pre-wrap}

.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (max-width:760px){
  .grid2{grid-template-columns:1fr}
  .nav{gap:10px}
}

/* Tap-to-unmute overlay */
.unmuteHint{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  padding:10px 14px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.25);
  background:rgba(0,0,0,.55);
  color:#fff;
  font-size:13px;
  z-index:5;
  user-select:none;
}
.unmuteHint.hidden{display:none}

/* ---------------------------
   Reels / Swipe Mode (Mobile)
   ---------------------------
   Expected markup:
   <div class="reels">
     <section class="reel">
       <div class="videoWrap"> <video class="reel-video">...</video> </div>
       <div class="reelMeta">...</div>
     </section>
   </div>
*/
.reels{width:100%}

/* Use new viewport units when available (fixes iPhone Safari 100vh issue) */
@supports (height: 100dvh){
  :root{ --app-vh: 1dvh; }
}
@supports (height: 100svh){
  :root{ --app-vh: 1svh; }
}

@media (max-width:760px){
  /* Remove desktop padding so reels are edge-to-edge */
  .wrap{max-width:980px;padding:0}

  /* iPhone safe-area */
  body{
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Reels container: full viewport minus topbar */
  .reels{
    height: calc((100 * var(--app-vh)) - var(--topbar-h));
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Make each reel a full slide */
  .reel{
    height: calc((100 * var(--app-vh)) - var(--topbar-h));
    margin:0;
    border-radius:0;
    border-left:0;
    border-right:0;
    scroll-snap-align: start;
    display:flex;
    flex-direction:column;
  }

  /* If you still use .card on reels, support it too */
  .reels .card.reel{
    height: calc((100 * var(--app-vh)) - var(--topbar-h));
    margin:0;
    border-radius:0;
    border-left:0;
    border-right:0;
    scroll-snap-align: start;
    display:flex;
    flex-direction:column;
  }

  .reel .videoWrap,
  .reels .card.reel .videoWrap{
    flex:1;
    min-height:0;
    background:#000;
  }

  /* Full-bleed video */
  .reel video,
  .reel .reel-video,
  .reels .card.reel video,
  .reels .card.reel .reel-video{
    width:100%;
    height:100%;
    max-height:none;
    object-fit:cover;
    background:#000;
  }

  /* Meta area under video */
  .reelMeta{
    padding:12px 14px;
    border-top:1px solid var(--line);
  }
}

/* Optional: respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .reels{scroll-behavior:auto}
}
