/* 体育舞蹈评分系统 WebUI v1 —— 设计 token + 组件库（无构建链，纯手写） */
:root {
  --bg: #f5f3ef;            /* 暖灰底 */
  --card: #ffffff;
  --line: #e5e0d8;
  --txt: #1f2937;
  --muted: #8a8377;
  --acc: #b91c1c;           /* 竞技红 */
  --acc-soft: #fef2f2;
  --gold: #b45309;          /* 赛事金 */
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #a16207;
  --warn-soft: #fefce8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31,41,55,.08), 0 4px 14px rgba(31,41,55,.05);
  /* R40 主题扩展令牌（浅色=原视觉，零回归） */
  --acc-hi: #c4202c;
  --acc-ink: #8a1f1f;
  --acc-tint: #fdf6f5;
  --acc-line: #e7c8c8;
  --gray-soft: #f1ede6;
  --hover: #faf8f4;
  --press: #f3efe8;
  --chip-bg: #f3f1ec;
  --mute-border: #c9c2b6;
  --hint: #b9b2a4;
  --hint2: #a49e92;
  --ink-soft: #6b6455;
  --ink-strong: #37352f;
  --green: #1d7a46;
  --cream: #f7f0e8;
  --cream-line: #e5d9c5;
  --header-bg: rgba(255, 255, 255, .93);
  --scroll-thumb: #cfc8ba;
  --shadow-kp: 0 4px 16px rgba(0, 0, 0, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 15px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .2em 0 .6em; }
h2 { font-size: 1.1rem; margin: 1.1em 0 .5em; }
h3 { font-size: 1rem; margin: .8em 0 .4em; }

/* ---- 顶栏 ---- */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
}
header .brand { font-weight: 700; color: var(--acc); letter-spacing: .5px; }
header nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
header nav a {
  padding: 5px 11px; border-radius: 999px; color: var(--txt); font-size: .92rem;
}
header nav a:hover { background: var(--acc-soft); text-decoration: none; }
.badge { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.badge.off { background: var(--mute-border); }

/* ---- 布局 ---- */
main { max-width: 1080px; margin: 0 auto; padding: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin: 14px 0;
}
.grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3,1fr); } }
.muted { color: var(--muted); font-size: .9rem; }
.err { color: var(--acc); font-size: .9rem; }
.ok-text { color: var(--ok); font-weight: 600; }

/* ---- 表格 ---- */
table { border-collapse: collapse; width: 100%; margin: .5em 0; background: var(--card); }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; font-size: .93rem; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.rank-1 td { background: var(--warn-soft); font-weight: 600; }

/* ---- 按钮 / 表单 ---- */
.btn {
  display: inline-block; border: 1px solid var(--acc); background: var(--acc); color: #fff;
  border-radius: 8px; padding: 7px 16px; font-size: .92rem; cursor: pointer; margin: 2px 2px 2px 0;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--card); color: var(--txt); border-color: var(--line); }
.btn.danger { background: var(--card); color: var(--acc); border-color: var(--acc); }
.btn.big { padding: 12px 22px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--txt); max-width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--acc-soft); border-color: var(--acc); }
label { display: block; margin: 10px 0 4px; font-size: .88rem; color: var(--muted); }

/* ---- 徽章 / 状态 ---- */
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.acc { background: var(--acc-soft); color: var(--acc); }
.tag.gray { background: var(--gray-soft); color: var(--muted); }

/* ---- 大屏（深色 1920 基准；单屏锁定，无滚动） ---- */
body.screen { background: #10131a; color: #e8e6e1; overflow: hidden; height: 100vh; }
body.screen header { background: #10131add; border-color: #262c38; }
body.screen header .muted { color: #9aa3b2; }
body.screen main { max-width: 1600px; height: calc(100vh - 58px); overflow: hidden; padding-bottom: 0; }
body.screen h1 { font-size: 3.2vw; color: #f3c969; margin: 1.2vw 0; }
body.screen h2 { font-size: 2.2vw; color: #d7dbe3; }
body.screen table { font-size: 1.7vw; background: transparent; }
body.screen th { color: #9aa3b2; }
body.screen td, body.screen th { border-color: #262c38; padding: 0.9vw 1.2vw; }
body.screen tr.rank-1 td { background: #3a2e12; color: #f3c969; }
body.screen .screen-section { display: none; height: 100%; overflow: hidden; }
body.screen .screen-section.active { display: block; animation: fade .5s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- 裁判移动端 ---- */
body.judge-sheet table { font-size: 1.05rem; }
body.judge-sheet td { padding: 12px 8px; }
body.judge-sheet select, body.judge-sheet input[type=number] { width: 92px; font-size: 1.15rem; padding: 10px; }
body.judge-sheet .btn.big { width: 100%; margin-top: 14px; }

/* ---- 三档响应式：手机 <720 / 平板 720-1080 / 桌面 >1080 ---- */

/* 平板：720~1080 —— 双列网格生效、排版微缩、保留桌面结构 */
@media (min-width: 720px) {
  .grid.c2 { grid-template-columns: 1fr 1fr; }
  .grid.c3 { grid-template-columns: 1fr 1fr; }   /* 平板 c3 降两列 */
  main { padding: 20px; max-width: 100%; }
  h1 { font-size: 1.5rem; }
}
@media (min-width: 1080px) {
  .grid.c3 { grid-template-columns: repeat(3, 1fr); }
  main { max-width: 1180px; }
  table { font-size: .95rem; }
}

/* 手机：<720 —— 单列、触控目标加大、表格横向滚动、导航横滑 */
@media (max-width: 719px) {
  main { padding: 10px; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.02rem; }
  header { padding: 8px 10px; gap: 8px; flex-wrap: wrap; row-gap: 4px; }
  header .brand { font-size: .95rem; white-space: nowrap; }
  header nav {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  header nav::-webkit-scrollbar { height: 4px; }
  header nav::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 2px; }
  header nav a { white-space: nowrap; padding: 8px 12px; }   /* 触控目标 ≥40px */
  header nav span { white-space: nowrap; }                    /* N3：角色/代码标签不逐字换行 */
  .card { padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* R34：移动端表格自适应收窄换行，不再强制 520px 横滑 */
  table { width: 100%; font-size: .86rem; }
  th, td { padding: 6px 6px; overflow-wrap: anywhere; }
  .card.table-fit table { min-width: 0; }
  /* 裁判×舞种进度矩阵：唯一保留横滑的例外（dense tabular） */
  #matrix { min-width: 420px; }
  /* R34：次要信息列窄屏隐藏（防连场面板/赛事列表等） */
  .hm { display: none !important; }
  /* 触控目标与防 iOS 聚焦缩放 */
  .btn { padding: 10px 16px; font-size: .95rem; }
  .btn.big { padding: 14px 20px; font-size: 1.1rem; width: 100%; }
  input, select, textarea { font-size: 16px; padding: 10px 12px; width: 100%; max-width: 420px; }
  label { margin-top: 12px; }
  .grid { gap: 10px; }
  /* 长按钮组换行不挤压 */
  .card p .btn { margin-bottom: 6px; }
}

/* 吸顶表头：垂直滚动长表时表头跟随（配合 .card 滚动容器） */
th { position: sticky; top: 0; background: var(--card); z-index: 2; }
body.screen th { position: static; }

@media print {
  header, .btn, #net-badge, nav { display: none !important; }
  main { max-width: none; }
  .card { border: none; box-shadow: none; }
}

/* ---- 操作手册（/manual） ---- */
.manual-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: .8rem; }
.manual-nav a { background: var(--cream); border: 1px solid var(--cream-line); border-radius: 8px; padding: 8px 14px; font-weight: 600; color: var(--acc-ink); }
.manual-lifecycle .lc-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: .6rem 0; }
.manual-lifecycle .lc-flow span { background: var(--cream); border: 1px solid var(--cream-line); border-radius: 6px; padding: 4px 10px; font-weight: 600; white-space: nowrap; }
.manual-lifecycle .lc-flow i { color: var(--acc); font-style: normal; font-weight: 700; }
.step { margin: 1.4rem 0; padding: 1rem 1.2rem; background: var(--card, #fff); border: 1px solid var(--cream-line); border-radius: 10px; }
.step h3 { margin-top: 0; }
.step img { display: block; max-width: 100%; height: auto; max-height: 78vh; border: 1px solid var(--line); border-radius: 8px; margin: .6rem 0 .2rem; background: var(--card); }
.step code { background: var(--cream); padding: 2px 6px; border-radius: 4px; }
.manual-note { border-left: 4px solid var(--acc); padding: .8rem 1rem; margin: .8rem 0; }
@media (max-width: 719px) { .step { padding: .8rem .7rem; } }
@media print {
  .step { break-inside: avoid; }
  .manual-nav { display: none; }
  .step img { max-height: none; }
}

/* ---- 裁判评分表：移动优先点选交互 ---- */
.judge-sheet .rank-list, .judge-sheet .mark-list, .judge-sheet .score-list { margin: .6rem 0 0; max-width: 640px; }
.judge-sheet .rank-row, .judge-sheet .mark-row, .judge-sheet .score-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.judge-sheet .row-num { font-size: 1.35rem; font-weight: 800; letter-spacing: 1px; min-width: 3.2em; }
.judge-sheet .rank-hint, .judge-sheet .mark-hint { color: var(--hint); font-size: .85rem; margin-left: auto; }
.judge-sheet .rank-badge {
  width: 42px; height: 42px; border-radius: 50%; border: 2px dashed var(--mute-border); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 800; color: var(--acc);
}
.judge-sheet .rank-row.assigned { border-color: var(--acc); background: var(--acc-tint); }
.judge-sheet .rank-row.assigned .rank-badge { border: none; background: var(--acc); color: #fff; }
.judge-sheet .mark-box {
  width: 28px; height: 28px; border: 2px solid var(--mute-border); border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900;
}
.judge-sheet .mark-row.checked { border-color: var(--acc); background: var(--acc-tint); }
.judge-sheet .mark-row.checked .mark-box { background: var(--acc); border-color: var(--acc); }
.judge-sheet .mark-row.checked .mark-box::after { content: "✓"; }
.judge-sheet .mark-row input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.judge-sheet .score-row { justify-content: space-between; }
.judge-sheet .score-row input[type=number] { width: 120px; font-size: 1.2rem; padding: 12px; text-align: center; }
.judge-sheet .submit-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  background: var(--card, #fff); padding: 12px 2px; border-top: 2px solid var(--cream-line); margin-top: 12px;
}
.judge-sheet .submit-bar .btn { flex: 1; margin: 0; }
.judge-sheet .submit-bar #progress { white-space: nowrap; }
.judge-sheet .submit-bar #msg { font-size: .85rem; }
.judge-sheet .mode-toggle { display: flex; gap: 8px; align-items: center; margin: .6rem 0; flex-wrap: wrap; }
.judge-sheet .mt-btn { border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; padding: 8px 12px; font-weight: 700; color: var(--ink-soft); }
.judge-sheet .mt-btn.active { background: var(--acc); border-color: var(--acc); color: #fff; }
.judge-sheet .mt-btn.ghost { margin-left: auto; color: var(--acc-ink); background: var(--acc-tint); border-color: var(--acc-line); font-weight: 600; }
.judge-sheet .rank-row.selected { outline: 2px solid var(--acc); outline-offset: -1px; }
.judge-sheet .rank-keypad {
  position: sticky; bottom: 66px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; margin: 4px 0 8px; box-shadow: 0 4px 16px rgba(0,0,0,.08); z-index: 4;
}
.judge-sheet .kp-title { font-size: .88rem; margin-bottom: 8px; }
.judge-sheet .kp-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.judge-sheet .kp-key { min-height: 42px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card); font-size: 1.1rem; font-weight: 800; color: var(--ink-strong); }
.judge-sheet .kp-key.taken { opacity: .22; pointer-events: none; }
.judge-sheet .kp-key.own { background: var(--acc); border-color: var(--acc); color: #fff; }
.judge-sheet .rank-row.off, .judge-sheet .mark-row.off, .judge-sheet .score-row.off {
  opacity: 1; cursor: not-allowed; background: var(--off-bg); border-color: var(--off-line);
}
.judge-sheet .rank-row.off .row-num, .judge-sheet .mark-row.off .row-num, .judge-sheet .score-row.off .row-num { color: var(--hint2); }

/* ---- R32 可用性整改 ---- */
#roster-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 16px; }
#roster-box label { display: flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸ "; color: var(--acc); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: .6rem; }
.judge-sheet .rank-row.off .rank-hint, .judge-sheet .mark-row.off .mark-hint, .judge-sheet .score-row.off .mark-hint { color: var(--acc); font-weight: 700; }
.lookup-row { gap: 10px; padding-right: 2px; }
.lookup-row input { min-width: 0; }

/* ---- 检录/播报台（staff） ---- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: .5rem 0; }
.chip {
  min-width: 52px; padding: 9px 10px; border-radius: 8px; font-weight: 800; font-size: 1rem;
  border: 1px solid var(--line-strong); background: var(--chip-bg); color: var(--ink-soft);
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.st-event h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-event .tag { white-space: nowrap; }
.ann-btn.announced { background: var(--green); border-color: var(--green); }

/* ---- 赛程：状态筛选 + 比赛顺序（防连场） ---- */
.status-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.sf-btn { border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; padding: 6px 14px; font-weight: 600; color: var(--ink-soft); }
.sf-btn.active { background: var(--acc); border-color: var(--acc); color: #fff; }
.run-order-list { list-style: none; padding: 0; margin: .6rem 0 0; max-width: 760px; }
.ro-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); flex-wrap: wrap;
}
.ro-item.ro-conflict { border-color: var(--acc-line); background: var(--acc-tint); }
.ro-pos { width: 28px; height: 28px; border-radius: 50%; background: var(--ink-strong); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; flex: 0 0 auto; }
.ro-btns { margin-left: auto; display: flex; gap: 6px; }
.ro-btns .btn { padding: 4px 10px; }
.lookup-row { display: flex; gap: 10px; margin-bottom: .5rem; }
.lookup-row input { flex: 1; font-size: 1.05rem; padding: 10px; }
.lk-head { font-size: 1.05rem; margin-bottom: .4rem; }

/* ================================================================
   R36 可用性打磨层：交互反馈 / 视觉质感 / 移动端信息密度
   ================================================================ */

/* ---- 设计令牌升级 ---- */
:root {
  --acc-deep: #991b1b;
  --line-strong: #d8d2c6;
  --radius-sm: 8px;
  --shadow-lift: 0 2px 6px rgba(31,41,55,.1), 0 10px 28px rgba(31,41,55,.08);
}

/* ---- 按钮：渐变主色 + 按压反馈 ---- */
.btn {
  background: linear-gradient(180deg, var(--acc-hi), var(--acc));
  border-color: var(--acc-deep);
  box-shadow: 0 1px 2px rgba(153,27,27,.25);
  transition: transform .06s ease, filter .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.07); box-shadow: 0 2px 6px rgba(153,27,27,.28); text-decoration: none; }
.btn:active { transform: translateY(1px); filter: brightness(.94); box-shadow: none; }
.btn.secondary, .btn.danger { background: var(--card); box-shadow: 0 1px 2px rgba(31,41,55,.08); }
.btn.secondary:hover { background: var(--hover); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--acc-soft); }
.btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--acc); outline-offset: 2px; text-decoration: none;
}

/* ---- 卡片：更精致的分层阴影 + 悬停微升（仅可交互列表） ---- */
.card { transition: box-shadow .2s ease; }
a .card:hover, .st-event:hover { box-shadow: var(--shadow-lift); }

/* ---- 触控反馈（触屏设备按压态） ---- */
@media (hover: none) {
  .btn:active { transform: scale(.97); }
  .chip:active { transform: scale(.94); }
  .rank-row:active, .mark-row:not(.off):active, .score-row:active { background: var(--press); }
  .kp-key:active { background: var(--acc-soft); border-color: var(--acc); }
}

/* ---- 表单聚焦更清晰 ---- */
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(185,28,28,.12);
}

/* ---- 导航激活态 ---- */
header nav a { font-weight: 500; transition: background .15s ease; }

/* ---- 生命周期工具条（控制台） ---- */
.lifecycle-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.lifecycle-bar .btn { padding: 6px 14px; font-size: .88rem; }

/* ---- 名次键盘：按压反馈 ---- */
.judge-sheet .kp-key { transition: background .12s ease, border-color .12s ease; }
.judge-sheet .kp-key:active { background: var(--acc-soft); border-color: var(--acc); }

/* ---- 检录芯片：过渡与按压 ---- */
.chip { transition: transform .06s ease, background .15s ease, color .15s ease, border-color .15s ease; }

/* ---- details 展开过渡 ---- */
#roster-box, details.card > p { animation: fade .25s ease; }

/* ---- 移动端信息密度收紧（≤719） ---- */
@media (max-width: 719px) {
  main { padding: 10px 10px 16px; }
  h1 { font-size: 1.15rem; margin: .15em 0 .45em; letter-spacing: 0; }
  h2 { font-size: .98rem; margin: .9em 0 .4em; }
  .card { padding: 10px 12px; margin: 9px 0; border-radius: 10px; }
  .tag { font-size: .74rem; padding: 1.5px 8px; }
  .muted, .err { font-size: .8rem; }
  th, td { padding: 6px 5px; }
  /* h1 与后续内容的间距收紧，信息密度提升 */
  h1 .tag, h1 .muted { font-size: .78rem; }
  .card h2 { margin: 0 0 .45em; }
  .card > p { margin: .35em 0; }
  /* 工作台/检录台卡片：标题与元信息同排更紧凑 */
  .st-event h3 { font-size: .95rem; margin: 0 0 6px; }
  /* 裁判评分行更紧凑 */
  .judge-sheet .rank-row, .judge-sheet .mark-row, .judge-sheet .score-row { padding: 9px 10px; gap: 10px; margin-bottom: 8px; border-radius: 10px; }
  .judge-sheet .row-num { min-width: 2.6em; font-size: 1.2rem; }
  .judge-sheet .rank-badge { width: 36px; height: 36px; font-size: 1.1rem; }
  .judge-sheet .mode-toggle { margin: .4rem 0; gap: 6px; }
  .judge-sheet .mt-btn { padding: 7px 10px; font-size: .85rem; }
  .judge-sheet .submit-bar { padding: 9px 2px; gap: 8px; }
  /* 查询卡间距 */
  .lookup-row { gap: 6px; }
  /* 吸顶工具条不遮内容 */
  .lifecycle-bar .btn { padding: 6px 12px; }
}
@media (max-width: 400px) {
  .judge-sheet .row-num { min-width: 2.2em; }
  .judge-sheet .rank-badge { width: 30px; height: 30px; font-size: 1rem; }
}

/* ===== R38：检录台已完成场次手风琴 + 搜索定位高亮 ===== */
.done-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.done-head h3 { margin: 0; flex: 1 1 100%; }
.done-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.done-body { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.st-event.flash { animation: stflash 1.6s ease; }
@keyframes stflash {
  0% { box-shadow: 0 0 0 3px rgba(185, 28, 28, .55); }
  100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); }
}
@media (max-width: 719px) {
  .done-actions { width: 100%; }
  .done-actions .btn { flex: 1; }
}

/* ===== R39：h1 头部标签不拆字换行 ===== */
h1 .tag, h1 .muted { white-space: nowrap; display: inline-block; }


/* ================================================================
   R40 主题系统：深色/浅色双主题 + 手机/平板/桌面三档适配
   机制：html[data-theme="light"|"dark"]，由 base.html 初始脚本按
   localStorage 优先、系统偏好兜底物化；切换按钮 #theme-toggle 循环两态。
   浅色令牌 = :root 默认（与 R39 前视觉零差异）；深色在此覆盖。
   ================================================================ */
html[data-theme="dark"] {
  --bg: #131519;
  --card: #1c1f26;
  --line: #2c313a;
  --line-strong: #3a404c;
  --txt: #e6e4df;
  --muted: #98a0ad;
  --acc: #ef4444;
  --acc-deep: #b91c1c;
  --acc-hi: #f05252;
  --acc-soft: rgba(239, 68, 68, .16);
  --acc-ink: #fca5a5;
  --acc-tint: rgba(239, 68, 68, .10);
  --acc-line: rgba(239, 68, 68, .35);
  --gold: #f3c969;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .13);
  --gray-soft: #262b33;
  --hover: #232830;
  --press: #262c36;
  --chip-bg: #232830;
  --mute-border: #4a5160;
  --hint: #6f7887;
  --hint2: #8b94a3;
  --ink-soft: #c3c9d3;
  --ink-strong: #e6e4df;
  --green: #34d399;
  --cream: #262b33;
  --cream-line: #3a404c;
  --header-bg: rgba(28, 31, 38, .92);
  --scroll-thumb: #3a404c;
  --off-bg: #22262e;
  --off-line: #343a44;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .42);
  --shadow-kp: 0 4px 16px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root {
  --off-bg: #e9e6df;
  --off-line: #d4cfc4;
}

/* ---- 主题切换按钮 ---- */
.theme-toggle {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--txt);
  border-radius: 999px; width: 34px; height: 34px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; line-height: 1; padding: 0; flex: 0 0 auto;
  transition: border-color .15s ease, background .15s ease, transform .06s ease;
}
.theme-toggle:hover { border-color: var(--acc); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle::after { content: "\1F319\FE0F"; }   /* 🌙 */
html[data-theme="dark"] .theme-toggle::after { content: "\2600\FE0F"; }  /* ☀️ */
body.screen .theme-toggle { display: none; }   /* 大屏固定深色 */

/* 深色下的细节修正 */
html[data-theme="dark"] .btn.secondary,
html[data-theme="dark"] .btn.danger { background: var(--card); }
html[data-theme="dark"] .btn.secondary:hover { background: var(--hover); }
html[data-theme="dark"] .step img { background: #fff; }   /* 手册截图为浅色底，保持白衬 */
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: #22262e; border-color: var(--line-strong); color: var(--txt);
}
html[data-theme="dark"] tbody tr:hover { background: var(--hover); }

/* ---- 平板（720~1079）补充优化：布局利用率与触控平衡 ---- */
@media (min-width: 720px) and (max-width: 1079px) {
  header { padding: 10px 16px; }
  .judge-sheet .rank-list, .judge-sheet .mark-list, .judge-sheet .score-list { max-width: none; }
  .judge-sheet .rank-row, .judge-sheet .mark-row, .judge-sheet .score-row { padding: 11px 14px; }
  .done-actions { flex: 0 0 auto; }
  .done-head h3 { flex: 1 1 auto; }
  #roster-box { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ================================================================
   R42 动效与便携手感层：入场编排 / 手风琴平滑 / 状态 pop / toast /
   返回顶部 / 主题过渡；全部尊重 prefers-reduced-motion
   ================================================================ */

/* ---- 卡片与标题入场（轻量上浮，前 6 个元素级联延迟） ---- */
@media (prefers-reduced-motion: no-preference) {
  main > h1, main > h2, main > .card, main > p, main > form {
    animation: r42in .34s cubic-bezier(.22, .8, .36, 1) both;
  }
  main > .card:nth-of-type(2) { animation-delay: .04s; }
  main > .card:nth-of-type(3) { animation-delay: .08s; }
  main > .card:nth-of-type(4) { animation-delay: .12s; }
  main > .card:nth-of-type(5) { animation-delay: .16s; }
  main > .card:nth-of-type(6) { animation-delay: .2s; }
  @keyframes r42in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
  /* 检录芯片翻转入册 */
  .chip { animation: chipIn .22s ease both; }
  @keyframes chipIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
}

/* ---- 计数徽章/芯片状态变化 pop（配合 JS 重启动画） ---- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }
.st-event .tag.pop, .chip.pop { animation: pop .28s ease; }

/* ---- 手风琴平滑展开（grid-rows 技巧；.done-body 由 hidden 改 .acc-body 结构） ---- */
.done-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s cubic-bezier(.22,.8,.36,1), opacity .25s ease; opacity: 0; overflow: hidden; }
.done-body.open { grid-template-rows: 1fr; opacity: 1; }
.done-body > div { min-height: 0; }

/* ---- 主题切换颜色过渡（切换瞬间加 html.theme-anim，防首载闪烁） ---- */
html.theme-anim body, html.theme-anim .card, html.theme-anim header,
html.theme-anim input, html.theme-anim select, html.theme-anim textarea,
html.theme-anim table, html.theme-anim th, html.theme-anim td, html.theme-anim .chip {
  transition: background-color .28s ease, color .28s ease, border-color .28s ease !important;
}

/* ---- Toast（替代高频 alert；底部居中，自动消退） ---- */
#toast-wrap { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; max-width: min(92vw, 480px); }
.toast { background: #262a32; color: #f0efec; border-radius: 10px; padding: 10px 18px; font-size: .92rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: toastIn .28s cubic-bezier(.22,.8,.36,1) both; }
.toast.ok { background: #17472e; color: #d9f5e6; }
.toast.err { background: #5c1d1d; color: #fde3e3; }
.toast.gone { animation: toastOut .3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---- 返回顶部 FAB（长列表页滚动超两屏出现） ---- */
#back-top {
  position: fixed; right: 18px; bottom: 22px; z-index: 60;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--txt); cursor: pointer; font-size: 1.1rem;
  box-shadow: var(--shadow); display: none; align-items: center; justify-content: center;
  transition: transform .12s ease, box-shadow .2s ease;
}
#back-top.show { display: inline-flex; animation: r42in .25s ease both; }
#back-top:active { transform: scale(.92); }

/* ---- 减少动效偏好：全部动画退场 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- R42：控制台花名册批量工具行 ---- */
.roster-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.roster-tools .btn { padding: 5px 12px; font-size: .85rem; }

/* ================================================================
   R43 P2 快赢交互：公开成绩页场次锚点快跳条
   ================================================================ */
.anchor-bar { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
.anchor-chip { padding:4px 10px; border:1px solid var(--line-strong); border-radius:999px; font-size:.82rem; color:var(--txt); }
.anchor-chip:hover { border-color:var(--acc); color:var(--acc); text-decoration:none; }
[id^="ev-"] { scroll-margin-top: 70px; }   /* 锚点落点避开 sticky header */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---- R46：提交栏长消息不挤压按钮 ---- */
.judge-sheet .submit-bar .btn { white-space: nowrap; }
.judge-sheet .submit-bar #msg, .judge-sheet .submit-bar #progress { min-width: 0; }

/* ================================================================
   R45 检录台大场次分区导航：场次索引抽屉（fixed 覆盖，不推挤内容；
   z-index 70 高于 sticky header(20)、低于 toast(90)；深浅主题全走变量色）
   ================================================================ */
.st-event { scroll-margin-top: 70px; }   /* 抽屉/搜索锚点落点避开 sticky header */
.scene-index-drawer {
  position: fixed; top: 62px; right: 14px; z-index: 70;
  width: min(540px, calc(100vw - 28px));
  max-height: 70vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--card);
  background: color-mix(in srgb, var(--card) 94%, transparent);   /* 半透明抽屉面 */
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lift);
}
.si-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px 8px 14px; border-bottom: 1px dashed var(--line); flex: 0 0 auto;
}
.si-head strong { font-size: .95rem; color: var(--ink-strong); }
.si-close {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink-soft);
  border-radius: 8px; width: 28px; height: 28px; padding: 0; flex: 0 0 auto;
  font-size: .95rem; line-height: 1; cursor: pointer;
}
.si-close:hover { background: var(--hover); border-color: var(--acc); color: var(--acc); }
.si-body { overflow-y: auto; padding: 10px 14px 14px; overscroll-behavior: contain; }
.si-group + .si-group { margin-top: 12px; }
.si-group-title { font-size: .88rem; font-weight: 700; color: var(--ink-soft); margin: 0 0 6px; }
.si-group-title .si-count { font-weight: 500; font-size: .8rem; color: var(--muted); margin-left: 4px; }
.si-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.si-chip { padding: 3px 10px; font-size: .85rem; cursor: pointer; }   /* 芯片复用 .sf-btn 风格 */
.si-chip:hover { border-color: var(--acc); color: var(--acc); }
.si-empty { margin: 0; font-size: .85rem; color: var(--muted); }
@media (max-width: 719px) {
  .scene-index-drawer { top: 58px; right: 10px; }
}

/* ---------- R52 工具箱门户首页 ---------- */
.portal-hero {
  text-align: center;
  padding: clamp(28px, 6vw, 56px) 12px 20px;
}
.portal-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  letter-spacing: .04em;
  color: var(--acc);
}
.portal-hero p { margin: 0 auto; max-width: 720px; color: var(--muted); line-height: 1.7; }
.portal-shelf-title {
  max-width: 980px; margin: 18px auto 12px;
  font-size: 1.02rem; color: var(--ink-soft); letter-spacing: .06em;
}
.pc-ico { display: block; font-size: 1.7rem; margin-bottom: 8px; }
.portal-card.is-placeholder {
  border-style: dashed; background: transparent; box-shadow: none;
}
.portal-card.is-placeholder h3 { color: var(--ink-soft); }
.portal-card.is-placeholder .pc-ico { filter: grayscale(.4); opacity: .75; }
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 26px;
}
.portal-card { display: block; text-decoration: none; color: var(--txt); }
.portal-card h3 { margin: 0 0 8px; color: var(--txt); }
.portal-card p { margin: 0 0 14px; color: var(--muted); font-size: .93rem; line-height: 1.65; }
.portal-cta { font-weight: 700; color: var(--acc); }
.portal-card:hover { border-color: var(--acc); box-shadow: var(--shadow); transform: translateY(-2px); }
.portal-card:hover .portal-cta { text-decoration: underline; }
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
  padding: 18px 12px 42px;
}
body.portal main { max-width: 1040px; }
@media (prefers-reduced-motion: no-preference) {
  .portal-card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
}
.portal-actions { display: flex; align-items: center; gap: 16px; }
.portal-card h3 a { color: inherit; text-decoration: none; }
.portal-card h3 a:hover { color: var(--acc); }
.portal-doc { color: var(--muted); font-size: .9rem; }
.portal-doc:hover { color: var(--acc); }

.portal-stat { margin: 12px 0 0; font-size: .85rem; color: var(--muted); }
.beian-line {
  margin: 8px 0 0; font-size: .84rem; color: var(--muted);
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.beian-line a { color: var(--muted); text-decoration: none; }
.beian-line a:hover { color: var(--acc); }
body.screen .site-footer { display: none; }
