:root {
  --bg: #f5f4f9;
  --surface: #ffffff;
  --surface-2: #f9f8fc;
  --text: #24222d;
  --muted: #6e6a7f;
  --line: #e0dde9;
  --line-strong: #bdb8cd;
  --accent: #c8467a;
  --accent-strong: #a8345f;
  --accent-weak: #fbeaf1;
  --danger: #c43c3c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .06);
  /* 英文 → Inter，中文 → Noto Sans SC（思源黑体），日文文本通过 lang="ja" 切换到 Noto Sans JP；均为自托管 */
  --font: "Inter", "Noto Sans SC", sans-serif;
  --font-ja: "Inter", "Noto Sans JP", "Noto Sans SC", sans-serif;
  --press: 3px;
  --label-w: 112px;
  --cols: 4;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
:lang(ja) { font-family: var(--font-ja); }

/* 整页背景图（包括顶栏下方），35% 不透明度，固定不随页面滚动 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: center / cover no-repeat; opacity: .35;
}
body[data-bg="bg_1"]::before { background-image: url(/static/img/bg_1.webp); }
body[data-bg="bg_2"]::before { background-image: url(/static/img/bg_2.webp); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
img { display: block; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  /* 顶栏几乎透明，让背景图透出来；轻微模糊保证页面滚动到顶栏下时文字仍可读 */
  background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, .35);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 13px; letter-spacing: .5px;
}
.nav { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav .who { color: var(--muted); margin: 0 4px; white-space: nowrap; }
.role-badge {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px;
  font-size: 12px; background: var(--accent-weak); color: var(--accent-strong); border: 1px solid #efc3d5;
}

.container { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- 按钮 ---------- */
/* 立体按钮：底部实色阴影作为按钮「厚度」，按下时整体下沉、阴影消失 */
.btn, .tab, .preset {
  --edge: #b9b4c9;
  position: relative;
  background: linear-gradient(#ffffff, #f4f2f8);
  border: 1px solid var(--line-strong);
  box-shadow: 0 var(--press) 0 var(--edge), 0 calc(var(--press) + 2px) 6px rgba(30, 20, 60, .12);
  transform: translateY(0);
  transition: background .15s, border-color .15s, color .15s, box-shadow .08s, transform .08s;
}
.btn:hover, .tab:hover, .preset:hover { --edge: #b0365f; border-color: var(--accent); color: var(--accent-strong); }
.btn:active:not(:disabled), .tab:active, .preset:active {
  transform: translateY(var(--press));
  box-shadow: 0 0 0 var(--edge), 0 1px 2px rgba(30, 20, 60, .12);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  font: inherit; font-size: 14px; line-height: 1.3; white-space: nowrap;
  color: var(--text); text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn:focus-visible, .input:focus-visible, .tab:focus-visible, .preset:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { --edge: #8a2a4e; background: linear-gradient(#d4558a, var(--accent)); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { --edge: #74203f; background: linear-gradient(#c8467a, var(--accent-strong)); color: #fff; }
.btn-danger { --edge: #e3a5a5; color: var(--danger); border-color: #e3a5a5; }
.btn-danger:hover { --edge: #a83232; background: linear-gradient(#fff, #fdf0f0); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 11px 22px; font-size: 16px; }
.btn .badge {
  min-width: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; line-height: 18px; text-align: center;
  background: var(--accent); color: #fff;
}
/* 审核 ✓ / ✗：两个合起来约等于一个小号「删除」按钮 */
.choice-group { display: inline-flex; gap: 4px; align-items: center; }
.icon-choice { width: 24px; height: 26px; padding: 0; border-radius: 7px; }
.icon-choice img { width: 14px; height: 14px; }
.btn.active { --edge: #b0365f; background: linear-gradient(#fff6fa, var(--accent-weak)); border-color: var(--accent); color: var(--accent-strong); }
.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-grid; place-items: center;
  font: inherit; font-size: 18px; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-weight: 700; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.input {
  width: 100%; padding: 8px 11px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
textarea.input { min-height: 96px; resize: vertical; }
select.input { cursor: pointer; }
.form-error { color: var(--danger); min-height: 20px; margin: 4px 0 8px; font-size: 13px; }

.auth-card {
  max-width: 400px; margin: 48px auto 0;
  padding: 32px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 22px; margin-bottom: 20px; }
.auth-card .btn-primary { width: 100%; padding: 10px; }
.auth-card .alt { text-align: center; margin-top: 16px; color: var(--muted); }

/* ---------- 首页 ---------- */
.hero { padding: 56px 0 36px; text-align: center; }
.hero h1 { font-size: 36px; letter-spacing: .5px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: 16px; margin: 14px auto 28px; max-width: 560px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 40px; }
.feature { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.feature h3 { font-size: 15px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); }
.visit {
  display: flex; gap: 8px; max-width: 420px; margin: 40px auto 0;
}

/* ---------- 页面头 ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 游戏库 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .input { max-width: 380px; }
.toolbar .count { color: var(--muted); margin-left: auto; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.lib-item {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.lib-item .cover { width: 100%; aspect-ratio: 5 / 7; }
.lib-item .meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lib-item .n-main { font-weight: 700; }
.lib-item .n-sub { color: var(--muted); font-size: 12px; }
.lib-item .ops { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; }
.lib-item .ops .btn { flex: 1; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* 封面 / 占位 */
.cover { object-fit: cover; background: #ece9f3; }
.cover-ph {
  display: grid; place-items: center; padding: 8px; text-align: center;
  color: #fff; font-weight: 700; font-size: 13px; line-height: 1.3; word-break: break-all;
  overflow: hidden;
}

/* ---------- Tier List ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  padding: 8px 18px; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--muted); border-radius: 8px;
}
.tab.active { --edge: #0d0c12; color: #fff; background: linear-gradient(#3a3746, var(--text)); border-color: var(--text); }
.tab .num { font-weight: 400; opacity: .7; margin-left: 4px; }

.board { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.tier-row { display: grid; grid-template-columns: var(--label-w) 1fr; min-height: 116px; }
.tier-row + .tier-row { border-top: 1px solid var(--line); }
.tier-label {
  display: grid; place-items: center; padding: 8px; text-align: center;
  color: #1d1b24; font-weight: 700; font-size: 18px; word-break: break-word;
}
/* 每行固定列数，卡片等宽铺满整行：宽屏 4 个，逐级减少 */
.tier-zone {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); align-content: start; gap: 8px;
  padding: 8px; background: var(--surface-2); min-height: 116px;
}
.tier-zone.drop-target { background: var(--accent-weak); }
.tier-zone .zone-hint { grid-column: 1 / -1; color: var(--muted); font-size: 12px; align-self: center; padding: 0 6px; }

/* 游戏标签：固定高度，封面在左，标题 + 最多 3 行评论在右 */
.card {
  position: relative; width: 100%; height: 100px; padding: 0;
  display: flex; flex-direction: row;
  font: inherit; text-align: left; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; overflow: hidden;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 4px 12px rgba(30, 20, 60, .14); }
.card[draggable="true"] { cursor: grab; }
.card.dragging { opacity: .4; }
.card .cover { width: 72px; height: 100%; flex: none; font-size: 11px; }
.card .info { flex: 1; min-width: 0; padding: 7px 10px; display: flex; flex-direction: column; gap: 3px; }
.card .ctitle {
  font-size: 14px; font-weight: 700; line-height: 1.35;
  white-space: pre; overflow: hidden; text-overflow: ellipsis;
}
.card .cline {
  font-size: 12px; line-height: 1.45; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 未分类：与等级行对齐但没有等级底色；为空时隐藏（拖动卡片时临时显示为投放区） */
.unsorted { display: grid; grid-template-columns: var(--label-w) 1fr; margin-top: 16px; }
.unsorted-head { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.unsorted .tier-zone {
  background: transparent; min-height: 116px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.unsorted .tier-zone.drop-target { background: var(--accent-weak); }
.unsorted.is-empty { display: none; }
.drag-active .unsorted.is-empty { display: grid; }

/* 卡片被拖到列表外时的提示 */
body.drag-outside::after {
  content: "松开鼠标即可移除"; position: fixed; left: 50%; bottom: 28px; z-index: 80;
  transform: translateX(-50%); padding: 10px 18px; border-radius: 8px;
  background: var(--danger); color: #fff; box-shadow: var(--shadow); pointer-events: none;
}
body.drag-outside .card.dragging { outline: 2px dashed var(--danger); outline-offset: -2px; }

.board-tip { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(24, 18, 40, .45);
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }

.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg .btn { flex: 1; }

.search-results {
  max-height: 260px; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px;
}
.result {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; font: inherit; text-align: left; color: var(--text);
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--surface-2); }
.result.selected { background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }
.result:disabled { cursor: not-allowed; opacity: .55; }
.result .cover { width: 36px; height: 50px; border-radius: 4px; flex: none; font-size: 9px; }
.result .names { display: flex; flex-direction: column; min-width: 0; }
.result .names span:first-child { font-weight: 700; }
.result .names span + span { color: var(--muted); font-size: 12px; }
.result .tag { margin-left: auto; font-size: 12px; color: var(--muted); flex: none; }

.cover-picker { display: flex; gap: 14px; align-items: flex-start; }
.cover-picker .preview { width: 96px; height: 134px; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.cover-picker .pick-ops { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.file-hidden { display: none; }

.detail { display: grid; grid-template-columns: 150px 1fr; gap: 18px; }
.detail .big-cover { width: 150px; height: 210px; border-radius: 8px; border: 1px solid var(--line); }
.detail .names { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.detail .names .n-main { font-size: 18px; font-weight: 700; }
.detail .names .n-sub { color: var(--muted); }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.preset {
  padding: 10px 6px; font: inherit; cursor: pointer; text-align: center;
  color: var(--text); border-radius: 8px;
}
.preset.active { --edge: #b0365f; border-color: var(--accent); background: linear-gradient(#fff6fa, var(--accent-weak)); color: var(--accent-strong); font-weight: 700; }
.preset small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 2px; }
.tier-edit { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tier-edit input[type=color] {
  width: 38px; height: 36px; padding: 2px; flex: none; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
.tier-edit .input { flex: 1; }

/* ---------- top-admin ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.users th { background: var(--surface-2); font-size: 13px; color: var(--muted); }
table.users tr:last-child td { border-bottom: 0; }
table.users td.ops { display: flex; gap: 6px; }
table.users td.pw { font-family: Consolas, "Courier New", monospace; cursor: pointer; user-select: all; }
table.users td.pw.unknown { font-family: inherit; color: var(--muted); cursor: default; }
.notice {
  padding: 12px 14px; margin-bottom: 16px; border-radius: 8px;
  background: #fff8e6; border: 1px solid #f0d58c; color: #6b5414;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 8px;
  background: #24222d; color: #fff; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.loading { padding: 48px; text-align: center; color: var(--muted); }

@media (max-width: 1160px) { :root { --cols: 3; } }
@media (max-width: 900px) { :root { --cols: 2; } }
@media (max-width: 640px) {
  :root { --cols: 1; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .container { padding: 20px 16px 48px; }
  .hero h1 { font-size: 28px; }
  :root { --label-w: 64px; }
  .tier-zone { gap: 6px; padding: 6px; }
  .tier-label { font-size: 14px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .detail { grid-template-columns: 1fr; }
  .detail .big-cover { margin: 0 auto; }
  .presets { grid-template-columns: repeat(2, 1fr); }
  .page-head .actions { margin-left: 0; }
}
