/* ==========================================================
   精进群工具箱测试 — 单页样式
   顶部时钟 + 内嵌播放器（待机封面）+ 场次列表 + 底部备注
   ========================================================== */

:root {
  --bg-0: #0b0e17;
  --bg-1: #121627;
  --card: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1f8;
  --muted: #9aa3b8;
  --accent: #7c6cff;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #7c6cff 0%, #22d3ee 100%);
  --ok: #34d399;
  --danger: #ff6b81;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 属性必须始终生效（防止被 display:flex 等规则覆盖） */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(124, 108, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  line-height: 1.6;
  user-select: none;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 页面主列 ---------- */
.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 22px 16px 70px;
  text-align: center;
}

#site-title {
  font-size: clamp(16px, 3vw, 19px);
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, #b9c2ff 45%, #7ce7ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#clock {
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  text-shadow: 0 6px 30px rgba(124, 108, 255, 0.35);
}

#date-line { color: var(--muted); font-size: 13.5px; }

/* ---------- 内嵌播放器 ---------- */
#player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 16px 0 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

/* 双播放器：前台播放/后台预载，切换零间隙不闪黑 */
#video, #video2 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  pointer-events: none; /* 不允许任何手动控制 */
}
#video2 { opacity: 0; }
.v-front { opacity: 1 !important; }
.v-back { opacity: 0 !important; }

/* ---------- 播放器待机层（纯色底 + 动态文字） ---------- */
#player-standby {
  position: absolute;
  inset: 0;
  background: #f0e148; /* 与莲花图标同色 */
  color: #483414;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  transition: opacity 0.4s ease;
}
#player-wrap.playing #player-standby { opacity: 0; pointer-events: none; }

#player-standby img {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(72, 52, 20, 0.28);
  margin-bottom: 6px;
}
#sb-label { font-size: 14px; font-weight: 600; opacity: 0.85; }
#sb-name { font-size: 17px; font-weight: 700; }
#sb-time {
  font-size: clamp(40px, 8vw, 56px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  line-height: 1.15;
}
#sb-countdown { font-size: 14px; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* ---------- 播放器外观栏（纯展示） ---------- */
#vbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 12px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none; /* 外观展示，不可操作 */
}
#player-wrap.playing #vbar { opacity: 1; }

#vbar svg { width: 18px; height: 18px; color: #fff; flex: none; }
#vb-track {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
#vb-fill {
  height: 100%;
  width: 0;
  background: var(--accent-grad);
}
#vb-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- 场景图层（音频+图片模式；默认隐藏） ---------- */
#bg-scene, #bg-b {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#bg-scene.show, #bg-b.show { opacity: 1; }

/* ---------- 画面动态：Ken Burns 缓推 + 亮度呼吸（四层同步，保持对齐） ---------- */
#bg-scene, #bg-b, #strip-a, #strip-b {
  animation: kenburns 46s ease-in-out infinite alternate,
             layer-shimmer 7s ease-in-out infinite;
}
@keyframes kenburns {
  from { transform: scale(1) translate(0, 0); }
  to   { transform: scale(1.055) translate(-0.8%, -0.6%); }
}
@keyframes layer-shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.05); }
}
#strip-a, #strip-b {
  position: absolute;
  left: 0;
  top: 70%;            /* 与原视频字幕区域一致（y 70%~100%，含计数器与二维码） */
  width: 100%;
  height: 30%;
  object-fit: fill;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
#strip-a.show, #strip-b.show { opacity: 1; }

/* 光芒呼吸动画（模拟原视频的放射光芒闪烁） */
#glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 226, 140, 0.42) 0%, rgba(255, 226, 140, 0.12) 34%, rgba(255, 226, 140, 0) 60%),
    conic-gradient(from 0deg at 50% 40%,
      rgba(255, 240, 190, 0.10) 0deg, rgba(255, 240, 190, 0) 12deg,
      rgba(255, 240, 190, 0.10) 30deg, rgba(255, 240, 190, 0) 45deg,
      rgba(255, 240, 190, 0.08) 70deg, rgba(255, 240, 190, 0) 90deg,
      rgba(255, 240, 190, 0.10) 130deg, rgba(255, 240, 190, 0) 150deg,
      rgba(255, 240, 190, 0.08) 200deg, rgba(255, 240, 190, 0) 225deg,
      rgba(255, 240, 190, 0.10) 280deg, rgba(255, 240, 190, 0) 310deg,
      rgba(255, 240, 190, 0.08) 330deg, rgba(255, 240, 190, 0) 360deg);
  mix-blend-mode: screen;
  animation: glow-breathe 5.5s ease-in-out infinite, glow-spin 70s linear infinite;
}
@keyframes glow-breathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@keyframes glow-spin {
  to { transform: rotate(360deg); }
}

/* 音频模式下视频元素仅作声音载体：透明但保持渲染（iOS 对 display:none 的视频可能暂停） */
#player-wrap.audio-mode #video, #player-wrap.audio-mode #video2 { opacity: 0; pointer-events: none; }
#player-wrap:not(.audio-mode) #bg-scene,
#player-wrap:not(.audio-mode) #strip-a,
#player-wrap:not(.audio-mode) #strip-b,
#player-wrap:not(.audio-mode) #glow { display: none; }

#player-state {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 12px;
  backdrop-filter: blur(4px);
}
#player-state.playing {
  color: #fff;
  background: rgba(255, 77, 109, 0.85);
  border-color: transparent;
}
#player-state.playing::before {
  content: "● ";
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- 场次列表 ---------- */
.slots { display: flex; flex-direction: column; gap: 10px; }
.slot {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  text-align: left;
}
.slot-time {
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  min-width: 64px;
}
.slot-name { flex: 1; }
.slot-state {
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

#countdown {
  margin-top: 16px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.hint { margin-top: 12px; font-size: 13px; color: var(--muted); }
.hint.muted { font-size: 12px; margin-top: 6px; }

/* ---------- 到访统计 ---------- */
#visit-count { color: var(--text); font-variant-numeric: tabular-nums; }
#visit-count .cnt {
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  padding: 0 1px;
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 4px 1px 2px;
  border-radius: 50%;
  background: var(--ok);
  animation: live-pulse 1.4s infinite;
  vertical-align: middle;
}
.live-num { color: var(--ok); font-weight: 600; }
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}

/* ---------- 静音提示徽标（播放器内嵌，静音即显示） ---------- */
#unmute-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  white-space: nowrap;
}
#unmute-btn.muted { animation: mute-pulse 1.6s infinite; }
#unmute-btn:not(.muted) { border-color: rgba(52, 211, 153, 0.6); }
#unmute-btn .mute-ic { font-size: 18px; line-height: 1; }
#unmute-btn:hover { background: rgba(0, 0, 0, 0.85); }
@keyframes mute-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 129, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(255, 107, 129, 0); }
}

/* ---------- 加载待启状态：静止背景 + 文字，就绪后整套动画开场 ---------- */
#player-wrap.preload-visual #glow,
#player-wrap.preload-visual #strip-a,
#player-wrap.preload-visual #strip-b,
#player-wrap.preload-visual #vbar { display: none; }
#player-wrap.preload-visual #bg-scene,
#player-wrap.preload-visual #bg-b { animation: none; }

/* ---------- 缓冲提示 ---------- */
#buffering {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 15px;
  pointer-events: none;
}
.dot-flask { display: inline-flex; gap: 7px; font-size: 20px; }

/* ---------- 兜底启动按钮（自动播放被完全禁止时） ---------- */
#start-btn {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  margin: auto;
  width: auto;
  height: auto;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  cursor: pointer;
  backdrop-filter: blur(3px);
}
#start-btn::before {
  content: "";
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: radial-gradient(circle, rgba(124, 108, 255, 0.55), rgba(34, 211, 238, 0.35));
  box-shadow: 0 0 34px rgba(124, 108, 255, 0.65);
  margin-bottom: 14px;
}
#start-btn { grid-template-rows: auto auto; align-content: center; gap: 14px; }
#start-btn:hover { background: rgba(0, 0, 0, 0.7); }
.dot-flask span { animation: dot-bounce 1.2s infinite; }
.dot-flask span:nth-child(2) { animation-delay: 0.15s; }
.dot-flask span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-6px); }
}

/* ---------- 刷新按钮 ---------- */
#refresh-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 25;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(11, 14, 23, 0.6);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: 0.2s;
}
#refresh-btn:hover { color: var(--text); border-color: var(--border-strong); transform: rotate(180deg); }

/* ---------- 全屏按钮（vbar 内，可点） ---------- */
#fs-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  pointer-events: auto; /* vbar 整体不可点，此按钮例外 */
  border-radius: 6px;
}
#fs-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.15); }
#fs-btn svg { width: 18px; height: 18px; }

/* 横屏全屏状态：铺满屏幕 */
#player-wrap:fullscreen {
  aspect-ratio: auto;
  max-width: none;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: none;
  border-radius: 0;
}

/* ---------- 伪全屏（iOS 等不支持元素全屏的设备） ---------- */
body.fs-fake #player-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: auto;
  margin: 0;
  border: none;
  border-radius: 0;
}
/* 竖屏持机时把画面旋转成横屏 */
@media (orientation: portrait) {
  body.fs-fake #video, body.fs-fake #video2 {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

/* ---------- 全屏退出按钮（真/伪全屏都显示） ---------- */
#fs-exit {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 6;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
}
#fs-exit:hover { background: rgba(0, 0, 0, 0.8); }

/* ---------- 底部备注（常显） ---------- */
#note {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(11, 14, 23, 0.88);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  backdrop-filter: blur(6px);
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  width: max-content;
  max-width: min(90vw, 480px);
}
.toast {
  background: rgba(20, 24, 40, 0.95);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.25s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.hide { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ==========================================================
   后台管理页
   ========================================================== */
.admin-body { overflow-y: auto; }
.admin-page { max-width: 720px; margin: 0 auto; padding: 26px 16px 60px; }
.admin-page h1 { font-size: 22px; margin-bottom: 4px; }
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
}
.admin-card h2 { font-size: 16px; margin-bottom: 12px; }
.admin-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.token-row { display: flex; gap: 10px; flex-wrap: wrap; }
.token-row input {
  flex: 1;
  min-width: 240px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}
.token-row input:focus { border-color: var(--accent); }
#token-status { margin-top: 8px; }
.ok-text { color: var(--ok); }
.err-text { color: var(--danger); }
.token-help { margin-top: 10px; }
.token-help ol { padding-left: 20px; margin-top: 6px; }
.token-help code { background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 4px; }

.grace-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}
.grace-row input {
  width: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font);
  padding: 7px 10px;
  outline: none;
}

.session-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.15);
}
.session-head { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.session-head input[type="time"] { width: 110px; }
.session-head input[type="text"] { flex: 1; min-width: 160px; }
.session-head input, .session-row textarea {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
}
.session-head input:focus, .session-row textarea:focus { border-color: var(--accent); }
.session-row textarea { width: 100%; resize: vertical; font-family: Consolas, monospace; font-size: 13px; }

.btn-danger {
  border: 1px solid rgba(255, 107, 129, 0.4);
  color: var(--danger);
  padding: 7px 14px;
}
.btn-danger:hover { background: rgba(255, 107, 129, 0.15); border-color: var(--danger); }
