/* ==========================================================================
   点歌台 · 样式
   全部外置，页面里没有任何内联 style/script —— 这样才能启用严格 CSP

   移动优先：默认样式按手机写，屏幕变宽再用 @media 加强。
   手机上最要紧的三件事：**点击目标够大（≥44px）、输入框不被键盘挡住、
   列表滚动顺滑不跳**。
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0e1014;
  --panel: #151922;
  --panel-2: #171b22;
  --line: #1f2531;
  --line-2: #262c38;
  --text: #e9ecf1;
  --muted: #8b95a7;
  --dim: #5f6b80;
  --accent: #4f8cff;
  --accent-2: #3d7bee;
  --danger: #ff7a7a;
  --warn: #ffd77a;
  --ok: #6ee7a8;

  /* 点击目标最小尺寸 —— 苹果/谷歌的可点性建议值是 44px */
  --tap: 44px;
  --radius: 14px;
  --radius-sm: 10px;

  /* 安全区：刘海屏、底部小白条 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  /* 手机上横向不该出现滚动条 */
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body.page-player { min-height: 100vh; display: flex; align-items: stretch; }

img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { width: 1em; height: 1em; fill: currentColor; display: block; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(14, 16, 20, .9);
}
.topbar .brand { font-weight: 700; }
.topbar .spacer { flex: 1; }

/* ---------- 通用容器 ---------- */
.wrap {
  max-width: 720px; margin: 0 auto;
  padding: 14px calc(14px + var(--sar)) calc(40px + var(--sab)) calc(14px + var(--sal));
}
.wrap.narrow { max-width: 640px; }
.center-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px calc(16px + var(--sar)) calc(24px + var(--sab)) calc(16px + var(--sal));
}
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; flex: 1; min-width: 140px; }

.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.7; white-space: pre-line; }
.hint code, .code, code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px;
  background: #0b0e13; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}
.err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 10px 0 0; }

.notice {
  background: #131a26; border: 1px solid #223047; border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 12px 0; font-size: 13px; color: var(--muted);
}
.notice > strong { display: block; margin-bottom: 6px; color: var(--text); }
.notice p { margin: 6px 0; }
.notice .small { font-size: 12px; }
.notice .code-line {
  display: block; margin: 8px 0; padding: 9px 11px; background: #0b0e13;
  border: 1px solid var(--line); border-radius: 8px; word-break: break-all;
}
.notice .claim-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.notice details { margin-top: 8px; }
.notice details summary { cursor: pointer; }

.diag-out {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.6;
  background: #0b0e13; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin-top: 10px; white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow: auto; color: var(--muted);
}

.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--danger); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- 卡片 / 表单 ---------- */
.card {
  width: 100%; max-width: 460px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 20px;
}
.wrap .card { max-width: none; margin-bottom: 16px; }
.card.tight { padding: 14px 16px; }
.card h1 { font-size: 20px; margin: 0 0 8px; }
.card h2 { font-size: 16px; margin: 0 0 8px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
select, textarea {
  width: 100%; padding: 12px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: #0e1014; color: var(--text);
  outline: none; transition: border-color .15s, background .15s;
  /* 手机上字号 <16px 会让 iOS 自动放大页面，很难受 */
  font-size: 16px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #10141c; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input[type="number"] { width: 100%; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; min-height: var(--tap); }
.row2 { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row2 > * { flex: 1 1 150px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }

button {
  cursor: pointer; border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 12px 16px; transition: .15s;
  /* 触摸目标够大 */
  min-height: var(--tap);
  touch-action: manipulation;
}
button:disabled { opacity: .5; cursor: default; }
button.primary, .link-btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  font-weight: 600; width: 100%; margin-top: 16px;
}
button.primary:hover, .link-btn.primary:hover { background: var(--accent-2); }
button.mini {
  background: var(--panel); border-color: var(--line-2); color: var(--muted);
  font-size: 12.5px; padding: 8px 13px; width: auto; margin: 0; min-height: 36px;
}
button.mini:hover { color: var(--text); border-color: var(--accent); }
button.mini.danger:hover { color: var(--danger); border-color: #5a2a2a; }
.link-btn { display: inline-block; text-align: center; text-decoration: none; }

/* ---------- 管理端顶部导航 ---------- */
.admin-nav {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin: 0 0 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.admin-nav .nav-links { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.admin-nav .nav-links .mini { text-decoration: none; }
.admin-nav .mini.active { color: var(--text); border-color: var(--accent); background: #17203a; }
@media (max-width: 620px) {
  .admin-nav { padding: 9px 11px; gap: 8px; }
  .admin-nav .nav-links { margin-left: 0; width: 100%; }
  .admin-nav .nav-links .mini { flex: 1 1 auto; text-align: center; }
}

.code { display: block; white-space: pre; overflow-x: auto; padding: 12px; margin: 10px 0 0; line-height: 1.7; }

.card .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 5px 0; }
.card .kv span { color: var(--muted); }
.card .kv b { font-weight: 500; text-align: right; }
.card .kv b.ok { color: var(--ok); }
.card .kv b.warn { color: var(--warn); }
.card .kv b.bad { color: var(--danger); }

/* ==========================================================================
   点歌页（访客）—— 绝大多数人用手机打开，所以一切按手机来设计
   ========================================================================== */
.guest-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding-top: var(--sat);
}
.guest-head .logo { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; }
.me { display: flex; align-items: center; gap: 6px; flex: none; }
/* 昵称框：比通用输入框更小巧的胶囊样式（选择器权重已足够，不用 !important） */
.guest-head .name-input {
  width: 112px; padding: 9px 11px; font-size: 15px;
  border-radius: 999px; text-align: center;
}

/* 「我点的歌现在什么情况」提示条 */
.my-turn {
  background: #14243a; border: 1px solid #2b4870; color: #b9d4ff;
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px;
  margin-bottom: 12px;
}
.my-turn[hidden] { display: none; }
.my-turn.playing { background: #133024; border-color: #245c40; color: #9ff0c4; }
.my-turn.waiting { background: #14243a; border-color: #2b4870; color: #b9d4ff; }

/* 正在播放 */
.now {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #17202f, #12151c);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 11px 13px; margin-bottom: 12px;
}
.now.idle { background: linear-gradient(90deg, #151a24, #12151c); border-color: var(--line); }
.now .cover-s {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
  flex: none; background: #222;
}
.now-body { min-width: 0; flex: 1; }
.now-title { font-size: 14.5px; font-weight: 600; }
.now-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.now-msg { font-size: 12px; color: var(--accent); margin-top: 3px; }

/* 搜索框 —— 手机上要够高、字号 ≥16px 免得 iOS 自动放大 */
.search { position: relative; }
/* 选择器带上 .search，权重就够压过通用 input 规则了，不需要 !important */
.search input[type="search"],
.search input[type="text"] {
  width: 100%;
  padding: 14px 44px 14px 15px;
  border-radius: 12px;
  font-size: 16px;
}
.search .search-spin {
  display: none; position: absolute; right: 14px; top: 50%;
  width: 17px; height: 17px; margin-top: -8.5px;
  border: 2px solid #33405a; border-top-color: var(--accent);
  border-radius: 50%; animation: sr-spin .7s linear infinite;
}
.search.searching .search-spin { display: block; }
@keyframes sr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .search .search-spin { animation: none; border-top-color: var(--accent); opacity: .6; }
}

/* 切换标签 —— 手机上做成等宽一排，好点 */
.tabs {
  display: flex; gap: 6px; margin: 13px 0 10px;
  /* 不被横向裁掉 */
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 1 0; min-width: 88px; text-align: center;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--muted);
  font-size: 14px; padding: 10px 12px;
}
.tab.active { background: #1d2735; color: var(--text); border-color: #33405a; font-weight: 600; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--accent); color: #fff; border-radius: 99px;
  font-size: 11px; line-height: 17px; text-align: center;
}

/* 列表 */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
  /* 手机上整行要能轻松点到 */
  min-height: 62px;
}
.row.pickable { cursor: pointer; }
.row.pickable:active { transform: scale(.985); background: #1a1f2b; }
.row.playing { background: #152238; border-color: #2b4468; }
.row.done { opacity: .8; }
.row.taken { opacity: .45; cursor: not-allowed; }
.row img.cv {
  width: 46px; height: 46px; border-radius: 9px; object-fit: cover;
  flex: none; background: #222;
}
.cv-ph {
  width: 46px; height: 46px; border-radius: 9px; flex: none;
  background: #1b212c; display: flex; align-items: center; justify-content: center;
}
.cv-ph.num { font-size: 13px; color: var(--dim); }
.row .info { flex: 1; min-width: 0; }
.row .t {
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .s {
  font-size: 12.5px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .msg { font-size: 12px; color: var(--accent); margin-top: 4px; }
.tag-add, .tag-mine {
  flex: none; font-size: 11.5px; padding: 5px 10px; border-radius: 99px;
  border: 1px solid #2b4468; color: #9dbcf5; background: #152238;
}
.tag-mine { border-color: #37507a; color: #9dbcf5; }

.empty { text-align: center; padding: 30px 10px; }
.empty-big { font-size: 15px; color: var(--muted); }
.empty-small { font-size: 12.5px; color: #4a5263; margin-top: 6px; }

/* ---------- 弹窗 / 提示 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(6, 8, 12, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px calc(16px + var(--sar)) calc(20px + var(--sab)) calc(16px + var(--sal));
  z-index: 50;
}
.mask[hidden] { display: none; }
.modal {
  width: 100%; max-width: 420px; background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 18px;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal .btns { display: flex; gap: 10px; margin-top: 16px; }
.modal .btns button { flex: 1; margin: 0; }
.btn-cancel { background: #222833; color: var(--muted); }
.btn-ok { background: var(--accent); color: #fff; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--sab));
  transform: translate(-50%, 12px);
  background: #202634; border: 1px solid var(--line-2); color: var(--text);
  border-radius: 11px; padding: 11px 17px; font-size: 13.5px;
  max-width: min(88vw, 420px); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   播放端（后台）
   ========================================================================== */
.stage {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px calc(20px + var(--sar)) calc(26px + var(--sab)) calc(20px + var(--sal));
  text-align: center;
  background:
    radial-gradient(760px 420px at 50% 0%, rgba(79, 140, 255, .10), transparent 70%),
    var(--bg);
}

/* 封面 + 背后的光晕（有歌时亮起来，没歌时敛下去） */
.cover-wrap { position: relative; flex: none; }
.stage .cover {
  position: relative; z-index: 1;
  width: clamp(150px, 26vh, 300px); height: clamp(150px, 26vh, 300px);
  border-radius: 18px; object-fit: cover; background: #1a1f2a;
  border: 1px solid var(--line-2);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .5);
  transition: transform .35s ease, box-shadow .35s ease, opacity .35s ease;
}
.cover-glow {
  position: absolute; inset: 8% 6% -6%; z-index: 0;
  border-radius: 24px; filter: blur(30px); opacity: 0;
  background: var(--accent); transition: opacity .5s ease;
}
.stage:not(.idle) .cover-glow { opacity: .24; }
.stage:not(.idle) .cover { transform: translateY(-2px); box-shadow: 0 22px 56px rgba(0, 0, 0, .6); }
.stage.idle .cover { opacity: .78; }

.stage h1 {
  font-size: clamp(20px, 3.1vw, 34px);
  margin: 24px 0 6px; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.stage .artist { color: var(--muted); font-size: clamp(13px, 1.3vw, 16px); margin-bottom: 4px; }
.stage .who { color: var(--accent); font-size: clamp(13px, 1.3vw, 15px); }
.stage .msg {
  margin-top: 12px; font-size: clamp(14px, 1.5vw, 19px); color: var(--warn);
  max-width: 80%;
}
.stage-hint { color: var(--muted); font-size: 12.5px; min-height: 19px; margin: 12px 0 0; max-width: 90%; }

/* 控制按钮 */
.controls { display: flex; align-items: center; gap: clamp(12px, 2.4vw, 22px); margin-top: 26px; }
.controls button {
  width: 52px; height: 52px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
  font-size: 22px;
}
.controls button svg { width: 22px; height: 22px; }
.controls button:hover { background: #243044; border-color: #3a4a63; }
.controls button:active { transform: scale(.94); }
.controls button.main {
  width: 70px; height: 70px; font-size: 30px;
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 8px 26px rgba(79, 140, 255, .34);
}
.controls button.main:hover { background: var(--accent-2); }
.controls button.main svg { width: 30px; height: 30px; }

/* 播放键的两个图标：默认显示「播放」，正在播时显示「暂停」 */
#btnPlay .ic-pause { display: none; }
#btnPlay.is-playing .ic-play { display: none; }
#btnPlay.is-playing .ic-pause { display: block; }
/* 静音续播时给个明显的提示色，让人知道「点了才出声」 */
#btnPlay.is-silent { background: var(--warn); border-color: var(--warn); color: #201a08; }

.progress {
  display: flex; align-items: center; gap: 12px;
  margin-top: 22px; width: min(560px, 92%);
  font-size: 12.5px; color: var(--muted);
}
.progress .bar {
  flex: 1; height: 7px; border-radius: 99px; background: #232a36;
  overflow: hidden; cursor: pointer; position: relative;
  /* 手机上用手指点，给一个更大的可触区 */
  padding: 0; touch-action: none;
}
.progress .bar::before {
  content: ''; position: absolute; inset: -12px 0;   /* 扩大触摸范围，视觉不变 */
}
.progress .bar i {
  display: block; height: 100%; width: 0; background: var(--accent);
  border-radius: 99px; transition: width .2s linear; position: relative; z-index: 1;
}
.progress .bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 队列侧栏 */
.side {
  width: 340px; flex: none; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: #0f1218;
  max-height: 100vh; overflow: hidden;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 15px 11px; border-bottom: 1px solid var(--line);
}
.side-head h2 { font-size: 14.5px; margin: 0; flex: 1; display: flex; align-items: center; gap: 7px; }
.qcount {
  display: inline-block; min-width: 20px; padding: 0 6px;
  background: #1d2735; color: var(--muted); border-radius: 99px;
  font-size: 11.5px; line-height: 18px; text-align: center;
}
.qhint { color: var(--dim); font-size: 12px; padding: 9px 15px 0; }
#queue { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.qitem {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 15px; border-bottom: 1px solid #161b24; cursor: pointer;
  min-height: 60px;
}
.qitem:hover { background: #1a2130; border-bottom-color: transparent; }
.qitem:active { background: #1d2536; }
.qitem .n { width: 20px; text-align: center; color: var(--dim); font-size: 13px; flex: none; }
.qitem img.cv { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: #222; }
.qitem .info { flex: 1; min-width: 0; }
.qitem .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qitem .s {
  font-size: 12px; color: #6c7688; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qitem .x {
  flex: none; width: 34px; height: 34px; min-height: 34px; padding: 0;
  background: transparent; border: 0; color: var(--dim); font-size: 15px;
  border-radius: 8px;
}
.qitem .x:hover { color: var(--danger); background: #2a1a1a; }
.qempty { color: var(--dim); font-size: 13px; text-align: center; padding: 30px 0; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; gap: 8px; border-top: 1px solid #1c2331; }
.side-foot .mini { text-decoration: none; text-align: center; }

/* 自动播放解锁横幅 */
.unlock-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px; padding: 11px 15px;
  background: #1b2333; border: 1px solid #2b3a55; border-radius: 12px;
  max-width: 92%;
}
.unlock-bar[hidden] { display: none; }
.unlock-bar .unlock-text { font-size: 13px; color: var(--muted); }
.unlock-bar .mini {
  flex: none; background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
.unlock-bar .mini:hover { background: var(--accent-2); color: #fff; }

/* ---------- 窄屏：播放端改成上下排列，队列在下面 ---------- */
@media (max-width: 860px) {
  body.page-player { flex-direction: column; overflow: auto; }
  .stage {
    min-height: auto;
    padding: 22px calc(16px + var(--sar)) 26px calc(16px + var(--sal));
  }
  .stage .cover { width: clamp(140px, 40vw, 220px); height: clamp(140px, 40vw, 220px); }
  .side {
    width: auto; max-height: none; border-left: 0; border-top: 1px solid var(--line);
  }
  #queue { max-height: 46vh; }
  .controls { gap: 14px; margin-top: 22px; }
  .controls button { width: 50px; height: 50px; }
  .controls button.main { width: 66px; height: 66px; }
}

/* ---------- 更窄：手机上点歌页的细节 ---------- */
@media (max-width: 420px) {
  body { font-size: 14.5px; }
  .wrap { padding: 12px 12px calc(34px + var(--sab)); }
  .guest-head .logo { font-size: 17px; }
  .name-input { width: 96px; }
  .row { padding: 9px 10px; gap: 10px; min-height: 58px; }
  .row img.cv, .cv-ph { width: 42px; height: 42px; }
  .tab { padding: 9px 8px; font-size: 13.5px; min-width: 76px; }
  .stage h1 { margin-top: 18px; }
  .progress { width: 100%; }
}

/* 屏幕很矮（横屏手机）时，封面别占满 */
@media (max-height: 560px) and (min-width: 861px) {
  .stage .cover { width: clamp(110px, 22vh, 180px); height: clamp(110px, 22vh, 180px); }
  .stage h1 { margin-top: 14px; }
  .controls { margin-top: 16px; }
}
