:root {
  --bg: #f4f3f0;
  --panel: #ffffff;
  --panel-2: #ebe9e4;
  --text: #1c1b1a;
  --muted: #6b6862;
  --line: #dcd9d2;
  --accent: #e2483d;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 4px 14px rgb(0 0 0 / .06);
  --t-S: #ff7a7a; --t-A: #ffb36b; --t-B: #ffdc6b; --t-C: #a8e07a; --t-F: #7fb4ff; --t-X: #a3a3a8; --t-U: #c9c5bd;
  --card-w: 112px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --panel: #1d1d21; --panel-2: #26262b; --text: #ecebe8; --muted: #9a978f;
    --line: #2f2f35; --accent: #ff6157; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3);
    --t-U: #55534e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px max(16px, calc((100vw - 1240px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .02em; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#search {
  width: 180px; padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel);
}
.btn {
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; white-space: nowrap; min-height: 36px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--accent); }
.btn.icon { width: 38px; padding: 0; display: grid; place-items: center; }
.btn.icon svg { width: 18px; height: 18px; }
.btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- board ---------- */
.board { max-width: 1240px; margin: 18px auto; padding: 0 16px; display: grid; gap: 8px; }
.tier {
  display: grid; grid-template-columns: 96px 1fr; min-height: calc(var(--card-w) * 1.5 + 54px);
  background: var(--panel); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.tier-label {
  background: var(--tc); color: #161514;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 8px 4px; text-align: center;
}
.tier-label .big { font-size: 30px; font-weight: 800; line-height: 1.1; }
.tier-label .small { font-size: 12px; font-weight: 600; opacity: .75; }
.tier-label .count { font-size: 11px; opacity: .6; margin-top: 4px; }
.zone {
  display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; align-content: flex-start; min-height: 100%;
}
.zone.empty::after { content: attr(data-empty); color: var(--muted); font-size: 13px; align-self: center; padding: 0 6px; }
.tier.U .tier-label { color: var(--text); }
.tier.X .tier-label .big { letter-spacing: .04em; }

/* ---------- card ---------- */
.card {
  position: relative; width: var(--card-w); display: flex; flex-direction: column;
  background: var(--panel-2); border-radius: 8px; overflow: hidden; cursor: pointer;
  user-select: none; -webkit-user-select: none; transition: transform .12s ease;
}
.card:hover { transform: translateY(-2px); }
.card .cover { aspect-ratio: 2 / 3; width: 100%; object-fit: cover; display: block; background: var(--line); }
.card .ph {
  aspect-ratio: 2 / 3; display: grid; place-items: center; padding: 8px; text-align: center;
  font-weight: 700; font-size: 14px; color: var(--muted); background: var(--line);
}
.card .meta { padding: 6px 7px 7px; display: grid; gap: 2px; }
.card .name { font-size: 12.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .cmt { font-size: 11px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .cmt-btn {
  justify-self: start; margin-top: 2px; padding: 1px 7px; font-size: 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
}
.card .cmt-btn:hover { color: var(--text); border-color: var(--muted); }
.card .handle {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 6px;
  background: rgb(0 0 0 / .55); color: #fff; display: none; place-items: center; font-size: 15px;
  touch-action: none; cursor: grab;
}
.editing .card .handle { display: grid; }
.editing .card { cursor: grab; }
.card .review {
  position: absolute; top: 4px; left: 4px; padding: 1px 6px; border-radius: 5px; font-size: 10.5px; font-weight: 700;
  background: #ffd24a; color: #1a1a1a;
}
.card.placeholder { opacity: .25; outline: 2px dashed var(--muted); }
.card.hidden-by-search { display: none; }
.ghost {
  position: fixed; z-index: 100; pointer-events: none; width: var(--card-w);
  transform: rotate(3deg) scale(1.04); box-shadow: 0 10px 30px rgb(0 0 0 / .35); opacity: .95;
}
body.dragging, body.dragging * { cursor: grabbing !important; }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 26px 16px 40px; }

/* ---------- dialogs ---------- */
.dlg {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.dlg.small { width: min(400px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgb(0 0 0 / .5); }
.dlg form, .dlg > div { padding: 20px; }
.dlg h2 { margin: 0 0 14px; font-size: 18px; }
.dlg input[type=text], .dlg input[type=password], .dlg input[type=search], .dlg textarea, .dlg select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
}
.dlg textarea { min-height: 72px; resize: vertical; }
.dlg label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row.between { justify-content: space-between; margin-top: 14px; }
.err { color: var(--accent); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }
.detail .pic img, .detail .pic .ph { width: 100%; border-radius: 10px; aspect-ratio: 2/3; object-fit: cover; display: grid; place-items: center; background: var(--line); color: var(--muted); }
.detail .fields { display: grid; gap: 10px; align-content: start; }
.detail h3 { margin: 0; font-size: 20px; }
.detail .alt { color: var(--muted); font-size: 13px; margin-top: 2px; }
.detail .comment { white-space: pre-wrap; margin: 6px 0 0; }
.detail .comment.other { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--tc); color: #161514; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 9px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  :root { --card-w: 86px; }
  .top { padding: 10px 16px; }
  .brand h1 { font-size: 19px; }
  .actions { width: 100%; }
  #search { flex: 1; width: auto; min-width: 0; }
  .board { padding: 0 8px; gap: 6px; }
  .tier { grid-template-columns: 58px 1fr; }
  .tier-label .big { font-size: 22px; }
  .tier-label .small { font-size: 10.5px; }
  .zone { gap: 7px; padding: 7px; }
  .card .cmt { display: none; }
  .detail { grid-template-columns: 1fr; }
  .detail .pic { max-width: 180px; }
  .grid2 { grid-template-columns: 1fr; }
}
