/* ============ Noto Sans Mono webfont（安卓兜底，全量不裁剪） ============ */
@font-face {
  font-family: "Noto Sans Mono";
  src: url("fonts/NotoSansMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Mono";
  src: url("fonts/NotoSansMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex; flex-direction: column;
  background: #f5f6fa; color: #1f2937;
  overflow: hidden;
}

/* ============ 顶部工具栏 ============ */
.toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px;
  background: #fff; border-bottom: 1px solid #e9e6f2;
  flex-shrink: 0;
}
.toolbar .title { font-size: 15px; font-weight: 800; margin-right: auto; color: #7030a0; }
.toolbar .hint { font-size: 12px; color: #9ca3af; }
.toolbar button {
  padding: 6px 12px; font-size: 13px; font-weight: 600;
  border: 2px solid #e5e7eb; border-radius: 10px;
  background: #fff; color: #374151; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.toolbar button:hover { background: #f3f0fb; border-color: #d6cbf0; }
.toolbar button:disabled { opacity: .4; cursor: not-allowed; }
.toolbar button.primary {
  background: #7030a0; border-color: #5b21b6; color: #fff;
}
.toolbar button.primary:hover { background: #5b21b6; }
.toolbar button.primary.on { background: #f97316; border-color: #ea580c; }
.zoom-label {
  font-size: 12px; color: #6b7280; min-width: 44px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============ 批注工具栏（进入批注模式才显示） ============ */
.annotate-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px;
  padding: 8px 16px;
  background: #fff7ed; border-bottom: 2px solid #fdba74;
  flex-shrink: 0;
}
.annotate-bar .ab-label { font-size: 13px; font-weight: 800; color: #c2410c; }
.annotate-bar .group { display: flex; align-items: center; gap: 6px; }
.annotate-bar .group .cap { font-size: 12px; color: #9a3412; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12);
  transition: opacity .12s;
}
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #c2410c; }
.size-btn {
  width: 34px; height: 26px; border-radius: 8px;
  border: 2px solid #e5e7eb; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .12s;
}
.size-btn.active { border-color: #c2410c; background: #ffedd5; }
.size-btn .dot { border-radius: 50%; background: #c2410c; }
.annotate-bar button.text {
  padding: 5px 12px; font-size: 13px; font-weight: 600;
  border: 2px solid #e5e7eb; border-radius: 10px;
  background: #fff; color: #374151; cursor: pointer;
}
.annotate-bar button.text:hover { background: #fff1e2; border-color: #fdba74; }
.annotate-bar button.text.on {
  background: #f97316; border-color: #ea580c; color: #fff;
}

/* ============ 画布视口 ============ */
#viewport {
  flex: 1; position: relative; overflow: hidden;
  cursor: grab; touch-action: none;
  background:
    radial-gradient(circle at 1px 1px, #e4e7f0 1px, transparent 0) 0 0 / 24px 24px;
}
#viewport:active { cursor: grabbing; }
#viewport.annotating { cursor: crosshair; }

#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-select: none; }

/* ============ 白色页面背景 ============ */
.page {
  position: absolute; left: 0; top: 0;
  background: #fff;
}

/* ============ 标题 ============ */
.title {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  font-family: "Menlo", "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  font-size: 26.67px; font-weight: 700;  /* = 20pt，Excel 标题字号（128=Menlo，中文=微软雅黑） */
  color: #7030a0;
  white-space: nowrap;
  user-select: none; -webkit-user-select: none;
}

/* ============ 网格 ============ */
.grid {
  position: absolute;
  display: grid;
  gap: 0;                            /* 无间隙，纯白背景不显示网格线 */
  background: #fff;
}
.cell {
  display: flex; align-items: center; justify-content: flex-start;
  padding: 0 5px;
  background: #fff;
  font-family: "Menlo", "Consolas", "Monaco", "Noto Sans Mono", monospace;
  font-size: 26.67px; font-weight: 700;  /* = 20pt，Excel 原字号 */
  white-space: nowrap; overflow: hidden;
  user-select: none;
}
.cell.item .k { color: #000; }
.cell.item .ipa { font-weight: 700; }
.cell.item { cursor: pointer; }
.cell.empty { background: #fff; }

/* 分类小标题：黑字 + 浅灰底 */
.cell.header {
  background: #e7e6e6; color: #000;
  font-family: "微软雅黑", "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  font-size: 25.33px; font-weight: 400;  /* = 19pt，Excel 分类标题字号（不加粗） */
}

/* ============ 批注层 ============ */
#annotations { position: absolute; left: 0; top: 0; pointer-events: none; }
#annotations path { fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ============ 单元格选中：蒙层 + 单词卡片 ============ */
#spotlight {
  position: absolute; inset: 0;
  z-index: 20; overflow: hidden; pointer-events: none;
}
.sl-part { position: absolute; background: rgba(0, 0, 0, .6); pointer-events: auto; }
.sl-ring {
  position: absolute; pointer-events: none;
  border: 3px solid #7030a0; border-radius: 6px;
  box-shadow: 0 0 0 4px rgba(112, 48, 160, .22), 0 0 18px rgba(112, 48, 160, .35);
}

#cardLayer { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 30; }
.word-card {
  position: absolute; z-index: 30;
  min-width: 280px;   /* 原来 560px 的一半；绝对定位默认收缩到内容宽，长单词自动撑宽 */
  max-width: 560px;
  background: #fff;
  border: 2px solid #e9e6f2;
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .22);
  padding: 14px 18px 16px;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  user-select: none; -webkit-user-select: none;
}
.word-card::before {
  content: '';
  position: absolute;
  top: -9px;              /* 卡片上侧，指向格子 */
  left: 24px;
  border: 9px solid transparent;
  border-top: none;
  border-bottom-color: #fff;
}
.wc-close {
  position: absolute; top: 6px; right: 8px;
  width: 26px; height: 26px;
  border: none; background: transparent;
  font-size: 20px; line-height: 1; color: #9ca3af;
  cursor: pointer; border-radius: 8px;
}
.wc-close:hover { background: #f3f0fb; color: #5b21b6; }
.wc-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-right: 22px; /* 给关闭按钮留空 */
}
.wc-combo {
  font-family: "Menlo", "Consolas", "Noto Sans Mono", monospace;
  font-size: 26.67px; font-weight: 700; color: #111827;
}
.wc-ipa {
  font-family: "Menlo", "Consolas", "Noto Sans Mono", monospace;
  font-size: 26.67px; font-weight: 700;
}
.wc-label {
  margin-top: 12px; font-size: 14px; font-weight: 600;
  color: #9ca3af; letter-spacing: 1px;
}
.wc-words {
  list-style: none; margin: 8px 0 0; padding: 0;
}
.wc-words li.word-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 3px 0;
}
.word-en {
  font-family: "Menlo", "Consolas", "Noto Sans Mono", monospace;
  font-size: 22px; font-weight: 600; color: #1f2937;
  white-space: nowrap;
}
.word-cn { font-size: 18px; color: #666; white-space: nowrap; }
.wc-words li.wc-empty { color: #9ca3af; font-weight: 400; }

/* ============ 分页 ============ */
.wc-pager { margin-top: 14px; }
.wc-pager-line { border-top: 1px solid #e5e7eb; margin-bottom: 10px; }
.wc-pager-bar { display: flex; align-items: center; justify-content: center; gap: 14px; }
.wc-pager-btn {
  width: 36px; height: 30px;
  border: 2px solid #e5e7eb; border-radius: 8px;
  background: #fff; color: #374151;
  font-size: 18px; line-height: 1; cursor: pointer;
}
.wc-pager-btn:hover:not(:disabled) { background: #f3f0fb; border-color: #d6cbf0; }
.wc-pager-btn:disabled { opacity: .35; cursor: not-allowed; }
.wc-pager-info {
  font-size: 16px; font-weight: 600; color: #374151;
  font-variant-numeric: tabular-nums; min-width: 52px; text-align: center;
}
