/* ============================================================
   style.css — 珍珑·棋谱 (uqn.cn/kifu) 布局
   颜色一律走 theme.css 的变量, 与 go-tsumego(/tm) 同一套。
   棋子红绿/黑白是 board.js 的「配色」, 与「主题」是两件事。
   ============================================================ */

* { box-sizing: border-box; }

/* 关掉移动端点击高亮遮罩(与 /tm 同根因) */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

/* ── 顶栏 ── */
.tm-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tm-head-in {
  max-width: 1000px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink-strong); }
.brand .logo { color: var(--accent); font-size: 20px; }
.brand-txt { font-size: 16px; letter-spacing: .5px; }
.tm-nav { display: flex; align-items: center; gap: 14px; }
.tm-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.tm-nav a:hover { color: var(--accent); }
.theme-btn {
  background: transparent; border: 1px solid var(--line2); border-radius: 8px;
  padding: 3px 9px; cursor: pointer; font-size: 15px; color: var(--ink);
}
.theme-btn:hover { border-color: var(--accent); }

/* ── 主体 ── */
.tm-wrap {
  max-width: 1000px; margin: 0 auto; padding: 12px 16px 8px;
  display: flex; gap: 20px; align-items: flex-start;
}
.board-panel { flex: 1 1 auto; min-width: 0; }
.side-panel { flex: 0 0 320px; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }

/* ── 棋盘(与 /tm 同: 正方形靠 padding-bottom:100%) ── */
.board-box { display: flex; justify-content: center; }
.board-frame { position: relative; width: 100%; max-width: 520px; }
.board-frame::before { content: ""; display: block; padding-bottom: 100%; }
#board {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  background: #dcb35c;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  touch-action: manipulation;
  display: block;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.board-status {
  margin-top: 10px; font-size: 13px; color: var(--muted);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.bs-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.bs-nav { justify-content: flex-start; width: 100%; row-gap: 4px; }
.board-status b { color: var(--accent); }
.step-info { color: var(--ink-strong); font-weight: 600; }
.whoami { color: var(--muted); font-size: 12.5px; }
.whoami a { color: var(--accent); text-decoration: none; }
.progress { color: var(--muted); font-size: 12.5px; }
.k-meta { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; min-height: 1.4em; }
.board-status .btn-nav { font-size: 12.5px; padding: 3px 14px; border-radius: 16px; margin-left: 4px; }
.sep { color: var(--muted2); }

/* ── 侧栏卡片 ── */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
}
.card-h { font-size: 13px; color: var(--muted); margin-bottom: 8px; letter-spacing: .5px; }
.p-title { font-size: 17px; margin: 0 0 8px; color: var(--ink-strong); font-weight: 600;
  min-height: 1.5em; }
.p-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; min-height: 22px; }
.chip {
  font-size: 12px; padding: 2px 9px; border-radius: 20px;
  background: var(--panel2); border: 1px solid var(--line2); color: var(--ink);
}
.chip.ghost { color: var(--muted); }
.chip.cat { text-decoration: none; color: var(--accent); border-color: var(--accent); }
.chip.cat:hover { background: var(--accent); color: var(--on-accent); }
.p-task { font-size: 13.5px; color: var(--text-soft); margin: 0 0 6px; min-height: 3.2em; }

/* 变化分支 */
.branches { display: flex; flex-direction: column; gap: 6px; }
.branch-h { font-size: 12px; color: var(--muted); }
.branch {
  font-family: inherit; font-size: 13px; text-align: left;
  background: var(--panel2); color: var(--accent);
  border: 1px solid var(--line2); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; transition: all .12s;
}
.branch:hover { border-color: var(--accent); }
.move-comment {
  margin-top: 8px; font-size: 12.5px; color: var(--text-soft);
  white-space: pre-wrap; line-height: 1.6; min-height: 1.4em;
}

/* 按钮 */
.btn {
  font-family: inherit; font-size: 13.5px; cursor: pointer;
  padding: 7px 10px; border-radius: 9px;
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line2); transition: all .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-mini { font-size: 12px; padding: 4px 9px; }

/* ── 棋谱列表 / 馆列表 ── */
.list-card { height: 46vh; display: flex; flex-direction: column; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.filters { display: flex; gap: 4px; }
.fbtn {
  font-family: inherit; font-size: 11.5px; cursor: pointer;
  background: transparent; border: 1px solid var(--line2); border-radius: 14px;
  color: var(--muted); padding: 1px 9px;
}
.fbtn.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.plist { overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; }
/* 馆卡片(网格) */
.cols { display: grid; grid-template-columns: 1fr; gap: 8px; }
.col-card {
  display: flex; flex-direction: column; gap: 3px;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: 7px 9px; text-decoration: none; color: var(--ink);
}
.col-card:hover { background: var(--panel2); }
.cc-name { font-size: 13.5px; color: var(--ink-strong); font-weight: 600; }
.cc-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.cc-count { font-size: 11.5px; color: var(--accent); }
/* 棋谱项 */
.kifu-item {
  display: flex; flex-direction: row; align-items: baseline; gap: 6px;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: 7px 9px; cursor: pointer; color: var(--ink); text-decoration: none;
}
.kifu-item:hover { background: var(--panel2); }
.kifu-item.active { background: var(--band-bg); border-color: var(--accent); }
.ki-title { flex: 1 1 auto; font-size: 13.5px; }
.ki-meta { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); }
.mk {
  flex: 0 0 auto;
  font-size: 11px; line-height: 1;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  border: 1px solid var(--line2);
  color: transparent;             /* 空占位: 未看时透明框占位, 对齐已看项 */
}
.mk.ok {
  background: var(--ok);
  border-color: var(--ok-dark, #1e8449);
  color: #fff;                    /* 已看: 绿色方框 + 白色 √ */
  font-weight: 700;
}
.empty { font-size: 12.5px; color: var(--muted2); padding: 10px 4px; }
.sub { font-size: 12.5px; color: var(--muted2); }
.back { font-size: 12.5px; margin-top: 8px; }
.back a { color: var(--accent); text-decoration: none; }

.tip { font-size: 12px; color: var(--muted2); margin: 0; padding: 0 4px; }

/* ── 页脚 ── */
.tm-foot {
  max-width: 1000px; margin: 20px auto 30px; padding: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted); text-align: center;
}
.tm-foot a { color: var(--muted); text-decoration: none; margin: 0 3px; }
.tm-foot a:hover { color: var(--accent); }
.tm-foot-2 { margin-top: 8px; font-size: 11.5px; color: var(--muted2); }

/* ── 窄屏 ── */
@media (max-width: 720px) {
  .tm-wrap { flex-direction: column; align-items: stretch; row-gap: 5px; }
  .board-panel { width: 100%; flex: 0 0 auto; }
  .side-panel { flex: 1 1 auto; max-width: none; width: 100%; }
  .list-card { height: 45vh; }
  .board-frame { max-width: none; }
}
@media (max-height: 800px) and (min-width: 721px) {
  .board-frame { max-width: calc(100vh - 250px); }
}
