/* ============================================================
   tools.css —— 工具集样式（工具主页 / 计划 / 番茄钟 / 看板 /
   术语 / 公式模板 / AI 答疑 / 背诵）
   全部使用 variables.css 令牌，自动适配三主题
   ============================================================ */

/* ---------- 通用：工具卡、分段选择器、进度条 ---------- */
.tool-card {
  transition: transform .15s ease, box-shadow .15s ease;
  cursor: pointer;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}

/* 分段选择器（页内 Tab） */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-2);
  cursor: pointer;
  min-height: 40px;
  transition: background .15s ease, color .15s ease;
}
.seg-btn.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* 进度条 */
.pbar {
  height: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
}
.pbar-in {
  height: 100%;
  border-radius: 6px;
  background: var(--primary);
  transition: width .3s ease;
}

/* 计划任务勾选 */
.plan-check {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.plan-day {
  margin-bottom: 12px;
}

/* ---------- 番茄钟 ---------- */
.pomo-card {
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}
.pomo-mode {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.pomo-ring {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 8px auto 4px;
}
.pomo-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.pomo-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 12;
}
.pomo-prog {
  fill: none;
  stroke: var(--primary);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset .6s linear, stroke .3s ease;
}
.pomo-prog.break {
  stroke: var(--success);
}
.pomo-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* ---------- 数据看板 ---------- */
.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dash-svg {
  width: 100%;
  min-width: 480px;
  height: auto;
  display: block;
}
.dash-bar {
  fill: var(--primary);
  opacity: .85;
  transition: opacity .15s ease;
}
.dash-bar:hover {
  opacity: 1;
}
.dash-axis {
  font-size: 10px;
  fill: var(--text-3);
  text-anchor: middle;
}
.dash-baseline {
  stroke: var(--border);
  stroke-width: 1;
}

/* 掌握度堆叠条 */
.dash-stack {
  display: flex;
  width: 100%;
  height: 30px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.dash-stack-in {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: width .3s ease;
}
.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}
.dash-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.dash-legend-item i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* 覆盖率热力图 */
.heat-card {
  margin-bottom: 12px;
}
.heat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.heat-cell {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.heat-1 { background: color-mix(in srgb, var(--primary) 20%, var(--surface)); }
.heat-2 { background: color-mix(in srgb, var(--primary) 35%, var(--surface)); }
.heat-3 { background: color-mix(in srgb, var(--primary) 50%, var(--surface)); }
.heat-4 { background: color-mix(in srgb, var(--primary) 65%, var(--surface)); color: #fff; }
.heat-5 { background: color-mix(in srgb, var(--primary) 80%, var(--surface)); color: #fff; }
.heat-6 { background: var(--primary); color: #fff; }
.heat-cell-n {
  font-weight: 600;
}

/* ---------- 术语词典 ---------- */
.gloss-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.gloss-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gloss-abbr {
  font-size: 20px;
  color: var(--primary);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.gloss-cn {
  font-size: 16px;
  font-weight: 600;
}
.gloss-en {
  font-size: 13px;
  color: var(--text-3);
  font-style: italic;
}
.gloss-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
}

/* 背诵模式（全屏） */
.recite-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 28, 36, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.recite-card {
  position: relative;
  width: min(560px, 92vw);
  min-height: 300px;
  cursor: pointer;
  outline: none;
}
.recite-front,
.recite-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  transition: opacity .2s ease;
}
.recite-back {
  visibility: hidden;
  opacity: 0;
  overflow-y: auto;
  justify-content: flex-start;
}
.recite-card.flipped .recite-front {
  visibility: hidden;
  opacity: 0;
}
.recite-card.flipped .recite-back {
  visibility: visible;
  opacity: 1;
}
.recite-abbr {
  font-size: 44px;
  font-weight: 700;
  color: var(--primary);
  font-family: ui-monospace, Consolas, monospace;
}
.recite-cn {
  font-size: 22px;
  font-weight: 600;
}
.recite-hint {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 12px;
}
.recite-en {
  font-size: 15px;
  color: var(--text-3);
  font-style: italic;
}
.recite-desc {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  text-align: left;
}
.recite-cat {
  margin-top: auto;
  align-self: flex-start;
}
.recite-ctrls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.recite-counter {
  min-width: 80px;
  text-align: center;
  color: #fff;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 公式与模板 ---------- */
.formula-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.formula-expr {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  overflow-x: auto;
  white-space: nowrap;
}
.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-steps {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tpl-steps li {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
}
.tpl-tip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- AI 答疑 ---------- */
.ai-snippet {
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.75;
  margin-bottom: 6px;
  color: var(--text-2);
}
.ai-snippet mark {
  background: #fff3a3;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
[data-theme="dark"] .ai-snippet mark,
[data-theme="eye"] .ai-snippet mark {
  color: #1f2933;
}
.ai-src-link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  min-height: 40px;
}
.ai-src-link:hover {
  background: var(--primary-soft);
}

/* ---------- 全局搜索结果（下拉面板） ---------- */
.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 120;
  padding: 6px;
}
.search-group-title {
  font-size: 12px;
  color: var(--text-3);
  padding: 8px 10px 4px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: pointer;
  min-height: 44px;
}
.search-item:hover,
.search-item.active {
  background: var(--surface-2);
}
.search-item-title {
  font-size: 14px;
  color: var(--text);
  flex: 1;
}
.search-item-sub {
  font-size: 12px;
  color: var(--text-3);
}
.search-item mark {
  background: #fff3a3;
  color: inherit;
  border-radius: 3px;
}
.search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- 响应式：窄屏 ---------- */
@media (max-width: 720px) {
  .pomo-ring {
    width: 220px;
    height: 220px;
  }
  .pomo-time {
    font-size: 40px;
  }
  .recite-abbr {
    font-size: 36px;
  }
  .heat-cell {
    width: 30px;
    height: 30px;
  }
  .seg-btn {
    padding: 8px 12px;
  }
}
