:root {
  --bg: #f6f1e7;
  --card: #ffffff;
  --ink: #2c2a26;
  --muted: #8a8378;
  --line: #e7e0d2;
  --teal: #1f6f6b;
  --teal-soft: #e3f0ee;
  --terra: #b5462f;
  --terra-soft: #f7e7e1;
  --shadow: 0 6px 22px rgba(60, 50, 35, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: .5px;
}
.topbar .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.back {
  background: var(--teal-soft);
  color: var(--teal);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
/* 右上角有常驻「管理员」按钮时，标题区让出位置，避免被压住 */
.topbar.with-float { padding-right: 104px; }
.topbar .song-title {
  text-align: right;
  font-weight: 600;
  font-size: 16px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 16px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .tag {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

/* 登录门禁 */
.lock {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #1f6f6b 0%, #2c2a26 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.lock-box {
  background: #fff;
  border-radius: 20px;
  padding: 30px 26px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.lock-box .logo {
  font-size: 30px;
  margin-bottom: 6px;
}
.lock-box h3 { margin: 4px 0 4px; font-size: 20px; }
.lock-box p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.lock-box input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
}
.lock-box input:focus { border-color: var(--teal); }
.lock-box button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--teal);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.lock-err { color: var(--terra); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* 通用控件 */
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
input.text, select {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
input.text:focus, select:focus { border-color: var(--teal); }

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-ghost { background: var(--teal-soft); color: var(--teal); }
.btn-danger { background: var(--terra-soft); color: var(--terra); }
.btn-tiny {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 10px;
}
.btn:active { transform: translateY(1px); }

/* 歌曲清单 */
.song-grid { display: grid; gap: 12px; }
.song-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: .15s;
}
.song-item:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.song-item .info { flex: 1; min-width: 0; }
.song-item .name { font-size: 17px; font-weight: 600; }
.song-item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
/* 右侧操作区：删除与进入之间留足间距 + 竖分隔线，避免误点 */
.acts {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.act-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  flex-shrink: 0;
}
.act-del {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: .15s;
}
.act-del .ico { font-size: 13px; line-height: 1; }
.act-del:hover,
.act-del:focus-visible {
  background: var(--terra-soft);
  border-color: #ecc9bf;
  color: var(--terra);
  outline: none;
}
.act-del:active { transform: translateY(1px); }

.act-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 0 3px;
  border: none;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: .15s;
}
.song-item:hover .act-go { background: var(--teal); color: #fff; }
.act-go:active { transform: scale(.94); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 14px;
}

/* 视频区 */
.video-box {
  border-radius: 12px;
  overflow: hidden;
  background: #1c1c1c;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}
.video-box video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-meta { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.upload-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 声部 / 成员 */
.section-item {
  padding: 12px 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.s-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.s-top .s-name { font-size: 15px; font-weight: 600; }
.s-top .s-count { font-size: 12px; color: var(--muted); }
.s-top .act-del { margin-left: auto; }
.s-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.m-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f6f1e7;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}
.m-chip .chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.m-chip .chip-x:hover { background: var(--terra-soft); color: var(--terra); }
.s-empty { font-size: 12px; color: var(--muted); }

/* 加成员表单：姓名 / 生日 / 手机 / 按钮 */
.member-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.member-form .field {
  display: flex;
  flex: 1 1 110px;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}
.member-form .field span {
  font-size: 12px;
  color: var(--muted);
}
.member-form .field .text { width: 100%; flex: none; }
.member-form .btn { flex: 0 0 auto; }

.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #fbf8f2;
  border-radius: 10px;
  margin-bottom: 7px;
  font-size: 15px;
}
.member-item .m-name { display: flex; align-items: center; gap: 8px; }
.member-item .m-note { font-size: 12px; color: var(--muted); }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: #2c2a26;
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.admin-float {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 30;
  box-shadow: var(--shadow);
}
.admin-float.on { background: var(--terra); }
.public-tip {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* 曲谱上传提示 / 错误 */
.score-msg {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--terra-soft);
  border: 1px solid #e8c4b8;
  color: #8f3a24;
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-all;
}

/* 曲谱图片九宫格 */
.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.score-cell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #faf7f0;
  aspect-ratio: 3 / 4;
}
.score-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}
.score-thumb { display: block; width: 100%; height: 100%; cursor: zoom-in; }
.score-dl {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--teal);
  font-size: 14px;
  font-weight: 800;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.score-dl:active { transform: scale(.92); }
.score-no {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(31, 111, 107, .92);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.score-fail {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}
.score-acts {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 5px;
  background: linear-gradient(to top, rgba(24, 22, 18, .72), rgba(24, 22, 18, 0));
}
.s-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 7px 0;
  cursor: pointer;
}
.s-btn:disabled { opacity: .42; cursor: default; }
.s-btn.danger { background: rgba(214, 88, 62, .95); color: #fff; }

/* 曲谱查看器 */
body.viewer-open { overflow: hidden; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  flex-direction: column;
  background: rgba(14, 13, 11, .97);
}
.viewer.on { display: flex; }
.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  color: #fff;
}
.viewer-idx {
  font-size: 12.5px;
  opacity: .82;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.v-btn {
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 12px;
  cursor: pointer;
}
.v-btn.dl { background: #C9762B; }
.v-btn.close { background: rgba(255, 255, 255, .24); width: 38px; padding: 9px 0; text-align: center; }
.viewer-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  will-change: transform;
  -webkit-user-drag: none;
  -webkit-touch-callout: default;
}
.viewer-nav {
  display: flex;
  gap: 10px;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
}
.v-nav {
  flex: 1;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 0;
  cursor: pointer;
}
.v-nav:disabled { opacity: .32; cursor: default; }

/* 从已有成员选人（管理员弹窗） */
body.pk-open { overflow: hidden; }
.pk-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(14, 13, 11, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.pk-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
  overflow: hidden;
}
.pk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.pk-title { font-size: 15px; font-weight: 700; }
.pk-title .pk-song { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.pk-close {
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}
.pk-close:hover { color: var(--terra); }
.pk-pad { padding: 12px 14px 0; flex-shrink: 0; }
.pk-list { overflow-y: auto; padding: 10px 14px 4px; max-height: 46vh; }
.pk-item, .pk-sec {
  display: block;
  width: 100%;
  text-align: left;
  background: #fbf8f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: .15s;
}
.pk-item:hover, .pk-sec:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--teal-soft);
}
.pk-item:active, .pk-sec:active:not(:disabled) { transform: translateY(1px); }
.pk-sec:disabled { opacity: .55; cursor: default; }
.pk-name, .pk-secname { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.pk-secname { color: var(--teal); }
.pk-meta, .pk-secmeta { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.pk-sel {
  font-size: 14.5px;
  color: var(--ink);
  padding: 10px 12px;
  background: var(--teal-soft);
  border-radius: 10px;
}
.pk-sel b { color: var(--teal); }
.pk-selnote { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.pk-sub { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.pk-none { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0; }

@media (max-width: 480px) {
  .topbar h1 { font-size: 19px; }
  .song-item { padding: 14px 12px; gap: 8px; }
  .song-item .name { font-size: 16px; }
  .acts { gap: 10px; }
  .act-sep { height: 22px; }
  .act-del { padding: 9px 10px; font-size: 12.5px; gap: 3px; }
  .act-del .ico { display: none; }
  .act-go { width: 38px; height: 38px; font-size: 19px; }
}
