:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #13141a;
  --border: #22252e;
  --text: #e6e8ee;
  --muted: #8b8f9b;
  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-dim: #92400e;
  --danger: #ef4444;
  --ok: #22c55e;
}
* { box-sizing: border-box; }
/* Screen-reader-only / SEO content — hidden from sighted users but crawled by Google. */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Microsoft JhengHei", sans-serif;
  /* iOS Safari: prevent the page from being wider than the viewport on reload */
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;                 /* stricter than 'hidden', no extra scroll context */
  -webkit-text-size-adjust: 100%;
}
body > * { max-width: 100vw; }       /* defence in depth — no top-level child can leak */
body { display: flex; flex-direction: column; overflow: hidden; }
img, video { max-width: 100%; }

/* ============== top bar ============== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: .5rem; }
.brand .logo { font-size: 1.4rem; }
.brand .title { font-weight: 600; font-size: 1.05rem; }

.topbar-right { display: flex; align-items: center; gap: .9rem; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.lang-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 0.25rem 0.7rem; font-size: .8rem; cursor: pointer;
}
.lang-btn.active { background: var(--accent); color: #000; }

.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: #444; }
.dot.live { background: var(--danger); box-shadow: 0 0 8px var(--danger); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

/* ============== layout ============== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1rem;
  padding: 1rem;
  flex: 1 1 auto;          /* fill the body's remaining height after topbar */
  min-height: 0;           /* allow flex children to shrink */
}

/* ============== video side ============== */
.video-side {
  display: flex;
  flex-direction: column;
  align-items: center;     /* center the 16:9 box horizontally inside the column */
  min-width: 0;
  gap: 0.6rem;
}
.video-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  /* Width: smaller of (column width) or (viewport-height-derived width for 16:9). */
  width: min(100%, calc((100vh - 160px) * 16 / 9));
  /* Padding-bottom trick: enforces exact 9/16 = 56.25% height. Works in every browser. */
  height: 0;
  padding-bottom: 56.25%;
}
video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}
.loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .9rem; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.6) 100%);
}
.loading.hidden { display: none; }
.footnote { color: var(--muted); font-size: .8rem; margin-top: .6rem; line-height: 1.4; }

/* ============== feed button overlay ============== */
.feed-overlay {
  position: absolute; bottom: 0.5rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  z-index: 5;
}
.feed-btn {
  display: inline-flex; align-items: center; gap: .55rem;
  background: var(--accent); color: #1a1a1a;
  border: 0; border-radius: 999px;
  padding: 0.9rem 1.8rem;
  font-size: 1.05rem; font-weight: 700;
  box-shadow: 0 6px 24px rgba(249,115,22,.45), 0 2px 6px rgba(0,0,0,.4);
  cursor: pointer; transition: transform .1s, background .2s, box-shadow .2s;
}
.feed-btn:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.feed-btn:active:not(:disabled) { transform: translateY(0); }
.feed-btn:disabled {
  background: var(--accent-dim); color: #d6d8de;
  cursor: not-allowed; box-shadow: none; opacity: .85;
}
.btn-icon { font-size: 1.25rem; }
.btn-cd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; opacity: .9; }
.feed-msg {
  background: rgba(0,0,0,.65); color: #fff;
  padding: .35rem .8rem; border-radius: 999px;
  font-size: .8rem; backdrop-filter: blur(4px);
  display: none;
  max-width: 90vw; text-align: center;
}
.feed-msg.show { display: block; }
.feed-msg.success { color: #bbf7d0; }
.feed-msg.error { color: #fca5a5; }

/* Tiny site-stamp at the bottom-right of the video. */
.cam-watermark {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.7rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
  z-index: 6;
}

/* ============== chat side ============== */
.chat-side {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 200px;
}
.chat-head {
  padding: .6rem .9rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9rem;
  display: flex; justify-content: space-between; align-items: center;
}
.online-count {
  background: var(--border); padding: .1rem .55rem;
  border-radius: 999px; font-size: .75rem; font-weight: 400; color: var(--muted);
}
.chat-msgs {
  flex: 1 1 0;
  min-height: 0;                /* allow shrink below content size — keeps the chat input row visible */
  overflow-y: auto;
  padding: .55rem .8rem;
  display: flex; flex-direction: column; gap: .4rem;
  font-size: .87rem; line-height: 1.4;
}
.msg .ts { color: #555; font-size: .7rem; margin-right: .4rem; font-variant-numeric: tabular-nums; }
.msg .nick { font-weight: 700; margin-right: .35rem; }
.msg .nick::after { content: ":"; color: var(--muted); margin-left: 1px; }
.msg.system .nick { font-weight: 500; font-style: italic; }
.msg.system .text { color: var(--muted); }

/* Clickable URLs inside chat messages */
.msg-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  cursor: pointer;
}
.msg-link:hover { color: var(--accent-hover); }
.msg.system .msg-link { color: #c4b5fd; }
.msg.system .msg-link:hover { color: #e9d5ff; }

.chat-nick, .chat-input {
  display: flex; gap: .4rem;
  padding: .5rem .55rem;
  border-top: 1px solid var(--border);
}
.chat-nick input, .chat-input input {
  flex: 1; background: #0b0c10; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: .45rem .65rem; font-size: .9rem; min-width: 0;
}
.chat-nick input:focus, .chat-input input:focus { outline: 0; border-color: var(--accent); }
.chat-nick button, .chat-input button {
  background: var(--accent); color: #000; border: 0;
  padding: 0 .9rem; border-radius: 6px; cursor: pointer;
  font-weight: 600;
}
.chat-nick button:hover, .chat-input button:hover { background: var(--accent-hover); }

/* ============== Donate button ============== */
.donate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  border: 0;
  background: linear-gradient(135deg, #f97316 0%, #f472b6 50%, #a78bfa 100%);
  background-size: 200% 200%;
  background-position: 0% 50%;
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(244, 114, 182, 0.25);
  transition: background-position .35s ease, transform .1s, box-shadow .15s;
}
.donate-btn:hover { background-position: 100% 50%; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(244,114,182,.35); }
.donate-btn:active { transform: translateY(0); }
.donate-icon { font-size: 1.05rem; }

/* Donate modal special bits */
.donate-card { max-width: 480px; }
.donate-payme {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.donate-qr {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  padding: 0.5rem;
  border: 1px solid var(--border);
}
.donate-link-btn {
  display: inline-block;
  background: var(--accent);
  color: #1a1a1a !important;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background .2s;
}
.donate-link-btn:hover { background: var(--accent-hover); }
.donate-paypal {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  min-height: 50px;
  /* PayPal's hosted button injects its own iframe inside — keep it light-themed
     so it doesn't inherit our dark background and become unreadable. */
  color-scheme: light;
}
.donate-paypal iframe { width: 100% !important; }

/* Instagram icon in About modal */
.modal-header-text { flex: 1; min-width: 0; }
.modal-ig {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color .2s, border-color .2s, background .2s;
  font-size: 0.78rem;
  white-space: nowrap;
}
.modal-ig:hover { color: #f472b6; border-color: #f472b6; background: rgba(244,114,182,.08); }
.modal-ig-handle { font-weight: 500; }

/* ============== About-TanTan modal ============== */
.brand-clickable {
  cursor: pointer;
  user-select: none;
  transition: opacity .15s;
}
.brand-clickable:hover { opacity: 0.85; }
.brand-clickable:hover .brand-hint { color: var(--accent); }
.brand-hint {
  display: inline-block;
  margin-left: .25rem;
  font-size: .75rem;
  color: var(--muted);
  vertical-align: middle;
  transition: color .15s;
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  animation: modal-fade .18s ease-out;
}
.modal-overlay[hidden] { display: none; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.5rem 1.5rem;
  max-width: 640px;
  width: 100%;
  position: relative;
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
  animation: modal-pop .22s cubic-bezier(.2,.7,.3,1.2);
}
@keyframes modal-pop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-close {
  position: absolute; top: .55rem; right: .7rem;
  background: transparent; border: 0;
  color: var(--muted); font-size: 1.8rem; line-height: 1;
  cursor: pointer; padding: 0 .35rem; border-radius: 6px;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: var(--border); }

.modal-header {
  display: flex; align-items: center; gap: .8rem;
  margin-bottom: .8rem;
}
.modal-cat-icon { font-size: 2.4rem; line-height: 1; }
.modal-name { margin: 0; font-size: 1.35rem; font-weight: 700; }
.modal-sub  { margin: .15rem 0 0; color: var(--muted); font-size: .8rem; }

.modal-section { margin-top: 1rem; }
.modal-h3 {
  margin: 0 0 .5rem;
  font-size: .95rem;
  color: var(--accent);
  font-weight: 600;
}
.modal-para {
  margin: 0 0 .55rem;
  font-size: .9rem;
  line-height: 1.5;
}
.modal-para b { color: #fde68a; font-weight: 600; }

/* Show only the active language site-wide (driven by <html lang="..."> which
   applyI18n() updates whenever the user flips the 繁中 / EN switch). */
html[lang^="zh"] .lang-en { display: none !important; }
html[lang^="en"] .lang-zh { display: none !important; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .5rem;
}
.photo-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform .15s, box-shadow .15s;
  border: 1px solid var(--border);
}
.photo-thumb:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 20px rgba(249,115,22,.25);
}

/* Clickable card inside About modal that opens the Recordings modal */
.rec-trigger {
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.rec-trigger:hover { background: rgba(249,115,22,0.08); border-color: var(--accent); }
.rec-trigger:active { transform: scale(0.99); }
.rec-trigger-icon { font-size: 1.4rem; line-height: 1; }
.rec-trigger-body { flex: 1; min-width: 0; }
.rec-trigger-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.rec-trigger-sub {
  font-size: 0.8rem;
  color: var(--muted);
}
.rec-trigger-arrow { color: var(--muted); font-size: 1.5rem; line-height: 1; }

/* Recordings modal — list of clips, no file size */
.rec-modal-overlay { z-index: 105; }       /* stacks above About (100) but below lightbox (110) */
.rec-list {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rec-list li {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.rec-list li:last-child { border-bottom: 0; }
.rec-list li a {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.rec-list li a:hover { color: var(--accent-hover); text-decoration: underline; }
.rec-list .rec-empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  cursor: default;
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 110;
  cursor: zoom-out;
  animation: modal-fade .15s ease-out;
}
.lightbox[hidden] { display: none; }
.lightbox-img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0,0,0,.6);
}


/* ============== heart effects ============== */
/* Feed-button burst: many hearts fly outward in random directions */
.heart-burst {
  position: absolute;
  font-size: 1.8rem;
  pointer-events: none;
  user-select: none;
  z-index: 20;
  animation: heart-burst-out var(--dur, 1.4s) ease-out forwards;
  will-change: transform, opacity;
}
@keyframes heart-burst-out {
  0%   { transform: translate(-50%, -50%) scale(0.4) rotate(0deg);                                        opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.1) rotate(var(--rot-mid, 10deg));                       opacity: 1; }
  100% { transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -120px))) scale(0.6) rotate(var(--rot, 30deg)); opacity: 0; }
}

/* Broadcast heart (chat ❤ button): one heart floats from bottom-right to top-right of video */
.heart-float {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  font-size: 1.6rem;
  pointer-events: none;
  user-select: none;
  z-index: 15;
  animation: heart-float-up 3.4s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes heart-float-up {
  0%   { transform: translate(0, 0)        scale(0.6) rotate(-8deg);  opacity: 0; }
  10%  { transform: translate(0, -10px)    scale(1.0) rotate(-6deg);  opacity: 1; }
  60%  { transform: translate(var(--drift, -12px), -55vh) scale(1.05) rotate(8deg); opacity: 0.85; }
  100% { transform: translate(0, -80vh)    scale(0.85) rotate(-4deg); opacity: 0; }
}

/* Heart button in chat input row */
.heart-btn {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px;
  padding: 0 .55rem !important;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .1s, background .2s;
}
.heart-btn:hover { background: rgba(244, 114, 182, 0.12) !important; transform: scale(1.08); }
.heart-btn:active { transform: scale(0.92); }

/* ============== mobile ============== */
@media (max-width: 880px) {
  /* Tighter topbar — the bilingual title + lang switch + status was just
     barely overflowing on iPhone, pushing horizontal scroll. */
  .topbar { padding: 0.4rem 0.6rem; gap: 0.4rem; flex-wrap: nowrap; min-width: 0; }
  .brand  { gap: 0.3rem; min-width: 0; }
  .brand .logo  { font-size: 1.15rem; }
  .brand .title { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-hint   { display: none; }                 /* drop the ⓘ chip on phones */
  .topbar-right { gap: 0.5rem; flex-shrink: 0; }
  .lang-btn     { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
  .status       { font-size: 0.75rem; }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);   /* video 16:9 of column width, chat takes the rest */
    padding: 0.6rem;                            /* tighter padding on phones */
    gap: 0.6rem;
  }
  .video-wrap {
    width: 100%;                    /* fill the column on phones */
  }
  .chat-side {
    min-height: 0;
    overflow: hidden;               /* don't push beyond grid cell */
  }
  .chat-msgs { font-size: 0.82rem; }   /* tighter messages on phone */
  .chat-nick, .chat-input { padding: 0.4rem; }
  .donate-btn { font-size: 0.82rem; padding: 0.45rem 0.7rem; border-radius: 0; }
  .modal-ig { padding: 0.2rem 0.4rem; font-size: 0.7rem; }
  .modal-ig-handle { display: none; }    /* show only the IG icon on phone */

  /* feed button on phones: move to TOP-center, ~40% smaller than PC */
  .feed-overlay {
    top: 0.4rem;
    bottom: auto;            /* override PC's bottom anchor */
    gap: 0.25rem;
  }
  .feed-btn {
    /* tight vertical padding so the button is shorter; text/emoji size unchanged */
    padding: 0.18rem 0.9rem;
    font-size: 0.7rem;
    line-height: 1.15;
    gap: 0.35rem;
    box-shadow: 0 3px 12px rgba(249,115,22,.4), 0 1px 3px rgba(0,0,0,.4);
  }
  .feed-btn .btn-icon { font-size: 0.9rem; }
  .feed-btn .btn-cd   { font-size: 0.65rem; }
  .feed-msg { font-size: 0.65rem; padding: 0.25rem 0.55rem; }

  .cam-watermark {
    font-size: 0.55rem;
    padding: 0.08rem 0.3rem;
    right: 0.25rem;
    bottom: 0.25rem;
  }

  .modal-card { padding: 1rem 1.05rem 1.15rem; border-radius: 10px; }
  .modal-name { font-size: 1.15rem; }
  .modal-h3   { font-size: 0.85rem; }
  .modal-para { font-size: 0.82rem; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); gap: .35rem; }

  .footnote { display: none; }
}
