:root {
  --bg1: #0c1e35;
  --bg2: #07142a;
  --panel: #102a43;
  --panel2: #17334b;
  --line: #28415b;
  --gold: #e8c77c;
  --white: #e8eff8;
  --muted: #9cb2cc;
  --blue: #9fccf0;
  --warn: #f0a868;
  --ok: #7fd1a8;
}

* { box-sizing: border-box; }

html { background: var(--bg2); scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--white);
  background: linear-gradient(180deg, var(--bg1) 0, var(--bg2) 900px);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

code { color: var(--gold); background: rgba(232, 199, 124, 0.08); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* 首屏 */
.boot {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--bg2);
  transition: opacity .4s;
}
.boot.done { opacity: 0; pointer-events: none; }

/* 顶部 */
.topbar {
  max-width: 1280px; margin: 0 auto; padding: 24px 24px 14px;
  display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center;
}
.brand { display: flex; gap: 14px; align-items: stretch; margin-right: auto; }
.brand .bar { width: 6px; border-radius: 3px; background: var(--gold); }
.brand h1 { margin: 0; color: var(--gold); font-size: 26px; letter-spacing: 1px; }
.brand p { margin: 4px 0 0; font-size: 14px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  min-width: 88px; padding: 6px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); text-align: center;
}
.stat b { display: block; font-size: 20px; color: var(--gold); }
.stat span { font-size: 12px; color: var(--muted); }
.icon-btn { position: relative; }
.dot {
  position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 0 3px var(--bg1);
}

/* 标签页 */
.tabs {
  position: sticky; top: 0; z-index: 20;
  background: rgba(8, 22, 42, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.tabs-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 6px; }
.tab {
  border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent;
  color: var(--muted); padding: 14px 20px 11px; font-size: 16px; display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--white); filter: none !important; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: bold; }
.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; line-height: 20px;
  background: var(--warn); color: #10223a; font-weight: bold; text-align: center;
}

/* 卡片 */
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
.panel { display: grid; gap: 18px; }
.panel > * { min-width: 0; } /* 允许日期条、表格在内部横向滚动，而不是撑宽页面 */
.card {
  background: rgba(16, 42, 67, 0.85); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px 24px;
}
.card h2 { margin: 0 0 8px; font-size: 20px; color: var(--gold); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card > p { margin: 0 0 16px; font-size: 14px; line-height: 1.7; }

/* 表单 */
.field { display: inline-flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.field span { color: var(--muted); }
input[type="date"] {
  background: var(--bg2); color: var(--white); color-scheme: dark;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 15px;
}
.drop {
  display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center;
  min-height: 130px; border: 2px dashed var(--line); border-radius: 12px;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.drop:hover, .drop.over { border-color: var(--gold); background: rgba(232, 199, 124, 0.06); }
.drop strong { color: var(--white); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
button {
  font: inherit; font-size: 15px; padding: 9px 22px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--gold); transition: filter .2s, opacity .2s;
}
button:disabled { opacity: .4; cursor: not-allowed; }
button.gold { background: var(--gold); color: #10223a; font-weight: bold; }
button.ghost { background: transparent; color: var(--gold); }
button:not(:disabled):hover { filter: brightness(1.15); }

/* 缩略图 */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.thumb {
  position: relative; border-radius: 8px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--line); cursor: zoom-in;
}
.thumb-img { display: grid; place-items: center; aspect-ratio: 2.17; background: var(--bg2); }
.thumb-img > * { grid-area: 1 / 1; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.thumb img.loaded { opacity: 1; }
.thumb.working .thumb-img::after {
  content: ""; grid-area: 1 / 1; width: 100%; height: 100%; background: rgba(4, 12, 26, .55);
}
.thumb.working .thumb-img .ld { z-index: 2; }
.thumb .cap {
  display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px;
  font-size: 12px; color: var(--muted);
}
.thumb .cap span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; padding: 0 6px; border-radius: 4px; font-size: 12px; }
.badge.registered { color: var(--ok); background: rgba(127, 209, 168, .12); }
.badge.pending { color: var(--warn); background: rgba(240, 168, 104, .14); }
.badge.unregistered { color: var(--muted); background: rgba(156, 178, 204, .12); }

/* 归档 */
details.day { border-top: 1px solid var(--line); padding: 10px 0; }
details.day:first-of-type { border-top: 0; }
details.day summary { cursor: pointer; font-size: 16px; list-style: none; display: flex; gap: 12px; align-items: center; }
details.day summary::before { content: "▸"; color: var(--gold); transition: transform .2s; }
details.day[open] summary::before { transform: rotate(90deg); }
details.day summary b { color: var(--gold); }

.float { z-index: 1; pointer-events: none; }

/* 排行榜工具栏与表格 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-actions button, .toolbar-actions .btn { padding: 7px 14px; font-size: 14px; }
.btn { display: inline-block; text-decoration: none; border: 1px solid var(--gold); border-radius: 8px; color: var(--gold); }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; cursor: pointer; margin-right: 6px; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.small { font-size: 13px; margin: 0; }
.table-wrap {
  display: grid; place-items: start center; min-height: 240px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(16, 42, 67, .6);
}
.rank-table thead th:first-child { border-top-left-radius: 11px; }
.rank-table thead th:last-child { border-top-right-radius: 11px; }
.table-wrap > * { grid-area: 1 / 1; }
.table-wrap > .ld { align-self: center; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 15px; white-space: nowrap; transition: opacity .25s; }
.rank-table.dim { opacity: .3; }
.rank-table thead th {
  position: sticky; top: var(--tabs-h, 53px); z-index: 5; background: #183653; color: var(--gold);
  font-weight: bold; padding: 12px 10px; text-align: center; cursor: pointer; user-select: none; font-size: 14px;
}
.rank-table thead th:hover { color: #fff3cf; }
.rank-table thead th.sorted::after { content: " ▼"; font-size: 10px; }
.rank-table thead th.sorted.asc::after { content: " ▲"; }
.rank-table td { padding: 11px 10px; text-align: center; border-top: 1px solid var(--line); }
.rank-table td.name { text-align: left; font-weight: bold; color: var(--white); }
.rank-table tbody tr:nth-child(even) { background: rgba(13, 36, 59, .6); }
.rank-table tbody tr:hover { background: rgba(232, 199, 124, .08); }
.rank-table td.rank { color: var(--gold); font-weight: bold; font-size: 16px; }
.rank-table tr.top td.rank span {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold); color: #10223a;
}
.rank-table tr.top td { background: rgba(232, 199, 124, .07); }
.rank-table td.score { color: var(--gold); font-weight: bold; }
.rank-table td.win-mvp { color: var(--blue); }
.rank-table td.loss-mvp { color: #c6b1e1; }
.rank-table tr.short td { color: var(--muted); }
.rank-table tr.short td.name { color: var(--muted); font-weight: normal; }
.rank-table tr.divider td { background: var(--bg2); color: var(--muted); font-size: 13px; text-align: left; padding: 8px 14px; }

/* 录入步骤 */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.stepper li {
  flex: 1; min-width: 160px; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--white);
}
.stepper b {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); color: #10223a;
}
.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 18px; border-radius: 10px; border: 1px solid var(--warn); background: rgba(240, 168, 104, .1); color: var(--warn);
}
.banner button { padding: 7px 18px; }
.empty { margin: 4px 0 0; padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

/* 设置弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(4, 12, 26, .82); padding: 20px;
}
.modal-box {
  width: min(860px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 14px; padding: 20px 24px;
}
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.modal-head h2 { margin: 0; color: var(--gold); font-size: 20px; }
.modal-box > p { font-size: 14px; line-height: 1.7; margin: 8px 0 16px; }
.settings-grid .wide4 { grid-column: 1 / -1; }
.settings-grid .row { display: flex; gap: 8px; }
.settings-grid .row input { flex: 1; min-width: 0; }
.settings-grid .row button { white-space: nowrap; padding: 7px 12px; font-size: 13px; }

/* 模型列表选择 */
.model-picker {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); padding: 12px 14px;
  display: grid; gap: 10px; max-height: 280px; overflow: auto;
}
.model-picker .picker-head { display: flex; gap: 10px; align-items: center; }
.model-picker .picker-head input { flex: 1; }
.model-picker .picker-head .muted { font-size: 13px; white-space: nowrap; }
.model-picker .group-title { font-size: 13px; color: var(--muted); }
.model-picker .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.model-chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--white);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.model-chip:hover { border-color: var(--gold); filter: none !important; }
.model-chip.selected { background: var(--gold); border-color: var(--gold); color: #10223a; font-weight: bold; }
.model-chip .tag { margin-left: 6px; font-size: 11px; color: var(--warn); }
.model-chip.selected .tag { color: #6b3c10; }
.section-title { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-top: 10px; padding-top: 14px; border-top: 1px dashed var(--line); }
.section-title b { color: var(--gold); font-size: 16px; }
.section-title .muted { font-size: 13px; }

/* 卡通海报弹窗 */
.poster-box { width: min(1280px, 100%); }
.poster-body { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; }
.poster-form { display: grid; gap: 14px; align-content: start; }
.poster-form .row { display: flex; gap: 8px; }
.poster-form .row input { flex: 1; }
.poster-form .row button { white-space: nowrap; padding: 7px 12px; font-size: 14px; }
.poster-form .actions { flex-wrap: wrap; justify-content: stretch; }
.poster-form .actions button { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 8px 6px; font-size: 14px; color: var(--muted); background: var(--bg2); transition: background .2s, color .2s; }
.seg input:checked + span { background: var(--gold); color: #10223a; font-weight: bold; }
.poster-preview { display: grid; place-items: center; min-height: 360px; border: 1px dashed var(--line); border-radius: 12px; padding: 12px; gap: 10px; }
/* 海报为 4:3，预先占好位置，弹窗一打开就是出图后的大小 */
.poster-preview::before { content: ""; grid-area: 1 / 1; width: 100%; aspect-ratio: 4 / 3; }
.poster-preview > .ld { grid-area: 1 / 1; }
.poster-preview img { grid-area: 1 / 1; width: 100%; border-radius: 10px; cursor: zoom-in; }
.poster-preview .empty { grid-area: 1 / 1; border: 0; }
.poster-preview .actions { margin: 0; }
.gold-btn { background: var(--gold); color: #10223a; font-weight: bold; padding: 9px 22px; }

.close { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 26px; padding: 0 6px; }

/* 按钮忙碌态 */
button.busy { display: inline-flex; align-items: center; gap: 8px; cursor: progress; }
button.busy:disabled { opacity: .85; }

/* 遮罩 */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(4, 12, 26, .78); backdrop-filter: blur(3px);
}
.overlay-box { text-align: center; display: grid; justify-items: center; }
.overlay-loader { min-height: 210px; display: grid; place-items: center; }
.overlay-box p { color: var(--gold); font-size: 20px; letter-spacing: 1px; margin: 18px 0 0; }
.overlay-box .overlay-timer { color: var(--muted); font-size: 14px; margin-top: 8px; }

.lightbox {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(4, 12, 26, .92); cursor: zoom-out;
}
.lightbox > * { grid-area: 1 / 1; }
.lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 60;
  max-width: min(720px, 92vw); padding: 12px 20px; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--gold); color: var(--white);
  white-space: pre-wrap; font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.toast.error { border-color: #e07070; }

.gold-text { color: var(--gold); }

/* 识别接口设置 */
.settings-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; }
.settings-grid .wide { grid-column: span 2; }
.settings-grid .actions { grid-column: 1 / -1; align-items: center; margin-top: 4px; }
.field.col { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin: 0; }
.field.col span { font-size: 13px; }
input:not([type]), input[type="url"], input[type="password"], input[type="number"], input[list], select {
  width: 100%; background: var(--bg2); color: var(--white); color-scheme: dark;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }
.link-btn { color: var(--gold); text-decoration: none; border-bottom: 1px dashed var(--gold); }
.spacer { flex: 1; }
.badge.ready { color: var(--ok); background: rgba(127, 209, 168, .12); }

/* 缩略图上的识别按钮 */
.thumb .recognize {
  position: absolute; top: 8px; right: 8px; padding: 4px 12px; font-size: 13px;
  background: var(--gold); color: #10223a; font-weight: bold; border: 0;
}

/* 核对弹窗 */
.review {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: center;
  background: rgba(4, 12, 26, .85); padding: 20px;
}
.review-box {
  width: min(1500px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 14px; padding: 18px 22px;
}
.review-head { display: flex; align-items: baseline; gap: 14px; }
.review-head h2 { margin: 0; color: var(--gold); font-size: 20px; }
.review-head .close {
  margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 26px; padding: 0 6px;
}
.review-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; }
.review-img { display: grid; place-items: center; align-self: start; position: sticky; top: 0; min-height: 200px; }
.review-img > * { grid-area: 1 / 1; }
.review-img img { width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.issues li.checking { display: flex; align-items: center; gap: 10px; color: var(--muted); background: rgba(156, 178, 204, .08); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.teams { display: grid; gap: 12px; margin-top: 14px; }
table.team { width: 100%; border-collapse: collapse; font-size: 13px; }
table.team caption { text-align: left; color: var(--gold); padding-bottom: 4px; font-weight: bold; }
table.team[data-side="右"] caption { color: #f0a0a0; }
table.team th { color: var(--muted); font-weight: normal; padding: 2px 4px; text-align: left; }
table.team td { padding: 2px 3px; }
table.team td input { padding: 5px 6px; font-size: 13px; }
table.team td.num input { width: 56px; text-align: center; }
table.team td.mvp { text-align: center; }
table.team td.mvp input { width: 18px; height: 18px; accent-color: var(--gold); }
table.team tr.me td input[data-key="name"] { border-color: var(--gold); }
.notes { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; background: rgba(156, 178, 204, .08); color: var(--muted); font-size: 13px; }
.issues { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: 13px; }
.issues li { padding: 6px 10px; border-radius: 6px; }
.issues li.error { color: #ffb3b3; background: rgba(224, 112, 112, .14); }
.issues li.warn { color: var(--warn); background: rgba(240, 168, 104, .12); }
.issues li.ok { color: var(--ok); background: rgba(127, 209, 168, .12); }

@media (max-width: 1100px) {
  .poster-body { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; place-items: start; }
  .rank-table thead th { position: static; }
  .review-body { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .topbar { padding: 16px 14px 10px; gap: 10px; }
  .brand { flex-basis: 100%; margin-right: 0; }
  .brand h1 { font-size: 19px; }
  .brand p { font-size: 12px; }
  .stat { min-width: 0; flex: 1; padding: 4px 8px; }
  .stat b { font-size: 17px; }
  .stats { flex: 1; }
  .icon-btn { padding: 8px 12px; font-size: 14px; }
  .tabs-inner { padding: 0 8px; gap: 0; }
  .tab { flex: 1; justify-content: center; white-space: nowrap; padding: 12px 6px 9px; font-size: 15px; }
  main { padding: 14px 12px 36px; }
  .card { padding: 16px; }
  .rank-table { font-size: 14px; }
  .rank-table td, .rank-table thead th { padding: 9px 8px; }
}
