/* ============ 全局变量 & 主题 ============ */
:root {
  --bg: #eaf3fb;
  --panel: #ffffff;
  --ink: #1c2733;
  --ink-soft: #6a7787;
  --line: #1c2733;
  --accent: #2f7bf6;
  --accent-2: #1b5fd9;
  --red: #ef4b5c;
  --blue: #2f7bf6;
  --green: #22b573;
  --shadow: 4px 4px 0 rgba(28,39,51,0.85);
  --radius: 18px;
  --fs: 15px;
}
[data-theme="dark"] {
  --bg: #12161d;
  --panel: #1c232e;
  --ink: #e8eef6;
  --ink-soft: #9aa7b6;
  --line: #3a4756;
  --accent: #4d8bff;
  --accent-2: #2f6fd6;
  --shadow: 4px 4px 0 rgba(0,0,0,0.6);
}
[data-theme="candy"] {
  --bg: #fdeef6;
  --panel: #ffffff;
  --ink: #4a2540;
  --ink-soft: #a06d90;
  --line: #4a2540;
  --accent: #ff5fa2;
  --accent-2: #e33d86;
  --shadow: 4px 4px 0 rgba(74,37,64,0.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs);
  position: relative;
  min-height: 100vh;
  transition: background .3s, color .3s;
}
.bg-layer {
  position: fixed; inset: 0; z-index: -1; opacity: .5;
  background-repeat: repeat; pointer-events: none; transition: background .4s;
}

kbd {
  background: var(--ink); color: #fff; border-radius: 4px;
  padding: 1px 6px; font-size: 12px;
}

/* ============ 按钮 ============ */
.btn {
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform .08s, box-shadow .08s, background .2s;
  white-space: nowrap;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(2px,2px); box-shadow: 0 0 0 var(--line); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent-2); box-shadow: 2px 2px 0 var(--accent-2); }
.btn-primary:hover { box-shadow: 3px 3px 0 var(--accent-2); }
.btn-danger { background: var(--red); color: #fff; border-color: #c22; box-shadow: 2px 2px 0 #c22; }
.btn-success { background: var(--green); color: #fff; border-color: #158a55; box-shadow: 2px 2px 0 #158a55; }
.btn-sm { padding: 6px 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--line); }
.btn.toggle.active { background: var(--green); color: #fff; border-color: #158a55; }
.link-btn { background: none; border: none; color: var(--red); cursor: pointer; font-size: 13px; font-weight: 600; }

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 26px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  display: grid; place-items: center; font-size: 22px;
  border: 2px solid var(--accent-2); box-shadow: var(--shadow);
}
.brand-text h1 { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.brand-text p { font-size: 11px; color: var(--ink-soft); letter-spacing: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: 110%; width: 340px; z-index: 40;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px; display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-menu h4 { margin-bottom: 8px; }
.dropdown-menu ol { padding-left: 18px; line-height: 1.9; font-size: 13px; color: var(--ink-soft); }
.dropdown-menu b { color: var(--ink); }

/* ============ 容器 ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 8px 26px 60px; }

/* ============ 卡片 ============ */
.card {
  background: var(--panel);
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.card-title { font-weight: 800; font-size: 16px; }

/* ============ OCR 行 ============ */
.ocr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .ocr-row { grid-template-columns: 1fr; } }

.upload-card { position: relative; min-height: 380px; display: grid; place-items: center;
  background-image: radial-gradient(var(--ink-soft) 1px, transparent 1px);
  background-size: 16px 16px; overflow: hidden; }
.upload-inner { text-align: center; }
.upload-icon { position: relative; width: 96px; height: 96px; margin: 0 auto 14px; border-radius: 22px;
  background: var(--accent); display: grid; place-items: center; font-size: 44px;
  border: 3px solid var(--accent-2); box-shadow: var(--shadow); }
.scan-dot { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.25);opacity:.6} }
.upload-title { font-size: 30px; font-weight: 900; font-style: italic; letter-spacing: 2px; }
.upload-sub { color: var(--ink-soft); margin: 8px 0 16px; font-size: 14px; }
.upload-btns { display: flex; gap: 12px; justify-content: center; }
.upload-formats { margin-top: 16px; font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
.upload-card.dragover { background-color: rgba(47,123,246,.08); }

.ocr-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.92); display: grid;
  place-items: center; gap: 14px; z-index: 5; }
[data-theme="dark"] .ocr-overlay { background: rgba(28,35,46,.94); }
.spinner { width: 46px; height: 46px; border: 5px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: 220px; height: 10px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--panel); }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ============ 识别结果 ============ */
.result-card { min-height: 380px; display: flex; flex-direction: column; }
.result-mode { display: flex; gap: 10px; font-size: 12px; color: var(--ink-soft); }
.result-mode label { cursor: pointer; }
.result-body { flex: 1; overflow-y: auto; max-height: 300px; }
.result-empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--ink-soft); gap: 12px; }
.empty-icon { width: 60px; height: 60px; border: 2.5px dashed var(--ink-soft); border-radius: 14px;
  display: grid; place-items: center; font-size: 26px; margin: 0 auto; }
.result-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.result-item { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line);
  border-radius: 10px; padding: 6px 10px; }
.result-item input[type=text] { flex: 1; border: none; background: transparent; color: var(--ink);
  font-size: 14px; font-weight: 600; outline: none; }
.result-item .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; color: #fff; }
.tag-in { background: var(--green); }
.tag-out { background: var(--ink-soft); }
.result-item .del { cursor: pointer; color: var(--red); font-weight: 700; }
.result-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 2px dashed var(--line); }
.result-count { color: var(--ink-soft); font-size: 13px; margin-right: auto; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* ============ 分隔 ============ */
.divider { display: flex; align-items: center; gap: 14px; margin: 34px 0 22px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 3px; background: var(--line); border-radius: 2px; }
.divider-pill { border: 2.5px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 22px; font-weight: 900; font-style: italic; letter-spacing: 2px; box-shadow: var(--shadow); }

/* ============ 工具栏 ============ */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.tool-group { display: flex; gap: 8px; }
.tool-sep { width: 2px; height: 24px; background: var(--line); border-radius: 2px; }

/* ============ 对战区 ============ */
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .teams { grid-template-columns: 1fr; } .vs-box { order: -1; } }
.team-head { font-weight: 800; font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.team-count { color: var(--ink-soft); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-red { background: var(--red); } .dot-blue { background: var(--blue); }
.slots { display: flex; flex-direction: column; gap: 10px; }
.slot { border: 2px dashed var(--ink-soft); border-radius: 12px; padding: 14px; text-align: center;
  color: var(--ink-soft); cursor: pointer; font-size: 14px; transition: .15s; background: var(--panel); }
.slot:hover { border-color: var(--accent); color: var(--accent); }
.slot.filled { border-style: solid; border-color: var(--line); color: var(--ink); font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; box-shadow: 2px 2px 0 var(--line); cursor: default; }
.team-home .slot.filled { border-color: var(--red); box-shadow: 2px 2px 0 var(--red); }
.team-away .slot.filled { border-color: var(--blue); box-shadow: 2px 2px 0 var(--blue); }
.slot .streak { font-size: 11px; background: var(--green); color: #fff; border-radius: 999px; padding: 1px 7px; margin-left: 6px; }
.slot .slot-x { color: var(--red); cursor: pointer; font-weight: 700; }
.slot.filled { cursor: pointer; }
.slot.swap-sel { outline: 3px solid var(--accent); outline-offset: 2px; background: rgba(47,123,246,.1); }
.slot.dragging { opacity: .45; }
.slot.drag-over { outline: 3px dashed var(--accent); outline-offset: 2px; background: rgba(47,123,246,.12); }
.team-btns { display: flex; gap: 10px; margin-top: 12px; }
.team-btns .team-lose, .team-btns .team-win { flex: 1; margin-top: 0; }
.team-win { border: 2.5px solid var(--line); border-radius: 12px; padding: 14px; font-weight: 800;
  font-size: 15px; color: #fff; cursor: pointer; box-shadow: var(--shadow); background: #7ecb9a; }
.team-win:hover { filter: brightness(.96); }
.team-lose { width: 100%; margin-top: 12px; border: 2.5px solid var(--line); border-radius: 12px;
  padding: 14px; font-weight: 800; font-size: 15px; color: #fff; cursor: pointer; box-shadow: var(--shadow); }
.team-lose-home { background: #f0a0a8; } .team-lose-away { background: #a8c4f0; }
.team-lose:hover { filter: brightness(.96); }
.vs-box { text-align: center; padding-top: 34px; }
.vs-text { font-size: 30px; font-weight: 900; font-style: italic; }
.vs-score { color: var(--ink-soft); font-weight: 700; margin-top: 4px; }

/* ============ 暂存区 ============ */
.staging { margin-top: 24px; border-color: var(--accent); }
.staging-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.staging-hint { color: var(--ink-soft); font-size: 13px; flex: 1; min-width: 180px; }
.staging-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.staging-chip { border: 2px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 700;
  background: var(--panel); color: var(--ink); cursor: pointer; box-shadow: 2px 2px 0 var(--line); font-size: 14px; }
.staging-chip:hover { border-color: var(--accent); color: var(--accent); }
.staging-chip .down { color: var(--accent); font-weight: 900; }

/* ============ 休息区 ============ */
.rest { margin-top: 34px; }
.rest-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.rest-count { color: var(--ink-soft); font-weight: 600; }
.rest-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rest-add { display: flex; gap: 10px; margin-bottom: 12px; }
.rest-add input { flex: 1; border: 2px solid var(--line); border-radius: 999px; padding: 9px 16px;
  font-size: 14px; background: var(--panel); color: var(--ink); outline: none; }
.btn-add { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--accent-2);
  background: var(--accent); color: #fff; font-size: 22px; cursor: pointer; box-shadow: 2px 2px 0 var(--accent-2); }
.rest-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rest-list { list-style: none; max-height: 340px; overflow-y: auto; }
.rest-item { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-bottom: 1.5px solid var(--bg); }
.rest-item .grip { cursor: grab; color: var(--ink-soft); }
.rest-item .idx { width: 22px; color: var(--ink-soft); font-weight: 700; text-align: center; }
.rest-item .name { flex: 1; font-weight: 700; }
.rest-item .name[contenteditable] { outline: none; }
.rest-item .rec { color: var(--ink-soft); font-size: 13px; }
.rest-item .rec .w { color: var(--green); } .rest-item .rec .l { color: var(--red); }
.rest-item .del { color: var(--red); cursor: pointer; opacity: 0; transition: .15s; font-weight: 700; }
.rest-item:hover .del { opacity: 1; }
.rest-item.dragging { opacity: .4; }
.rest-item.selected { background: rgba(47,123,246,.08); border-radius: 8px; }

/* ============ 统计 & 记录 ============ */
.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 34px; }
@media (max-width: 820px) { .stats-row { grid-template-columns: 1fr; } }
.stats-meta { color: var(--ink-soft); font-size: 13px; }
.stats-list, .records-list { list-style: none; max-height: 320px; overflow-y: auto; }
.stat-item { display: grid; grid-template-columns: 22px 1fr auto auto auto 120px auto; gap: 10px;
  align-items: center; padding: 9px 4px; border-bottom: 1.5px solid var(--bg); font-size: 14px; }
.stat-item .s-idx { color: var(--ink-soft); font-weight: 700; }
.stat-item .s-name { font-weight: 700; }
.stat-item .s-g { color: var(--ink-soft); }
.stat-item .s-w { color: var(--green); font-weight: 700; }
.stat-item .s-l { color: var(--red); font-weight: 700; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--green); }
.s-rate { font-weight: 700; text-align: right; }
.records-empty { text-align: center; color: var(--ink-soft); padding: 40px 0; border: 2px dashed var(--line); border-radius: 12px; }
.record-item { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1.5px solid var(--bg); font-size: 14px; }
.record-item .r-idx { color: var(--ink-soft); font-weight: 700; }
.record-item .r-win { color: var(--green); font-weight: 700; }
.record-item .r-lose { color: var(--red); text-decoration: line-through; }
.record-item .r-time { margin-left: auto; color: var(--ink-soft); font-size: 12px; }
.rec-count { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 13px; }

/* ============ 弹窗 ============ */
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-box { position: relative; background: var(--panel); border: 2.5px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 20px; width: 420px; max-width: 92vw; max-height: 80vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 17px; margin-bottom: 14px; }
.modal-x { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.modal-hint { color: var(--ink-soft); font-size: 13px; margin-bottom: 8px; }
.modal-box textarea { width: 100%; border: 2px solid var(--line); border-radius: 10px; padding: 10px;
  font-size: 14px; font-family: inherit; background: var(--panel); color: var(--ink); resize: vertical; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.pick-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pick-item { border: 2px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.pick-item:hover { background: var(--accent); color: #fff; }
.pick-empty { text-align: center; color: var(--ink-soft); padding: 30px 0; }

/* ============ Toast ============ */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 24px; border-radius: 999px; z-index: 90;
  font-weight: 600; box-shadow: var(--shadow); animation: toastIn .25s; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }
