/* page-tool.css — 六个工具模块页的共用布局 */

/* ---------- 页头 ---------- */
.tool-head {
  padding: 36px 0 24px;
  border-bottom: 1px solid var(--line);
}
.tool-head-inner {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.tool-icon {
  width: 52px; height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--re-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--re);
}
.tool-icon svg { width: 28px; height: 28px; }
.tool-head .txt { flex: 1 1 300px; min-width: 0; }
.tool-head h1 { margin: 0 0 6px; font-size: var(--fs-h1); }
.tool-head .desc { margin: 0; color: var(--ink-mute); max-width: 62ch; }
.tool-head .crumb {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.tool-head .crumb a { color: var(--ink-mute); }
.tool-head .crumb a:hover { color: var(--re); }

/* ---------- 工作区 ---------- */
.workspace { padding: 28px 0 8px; }

/* v1.9.26 移动端首屏：画布优先 —— 三类结构统一用 order 把含 .stage 的列提到最前
 * ① .split 页：画布列是 split 第二子  ② grid-2 页：画布组在 shell 第二子
 * ③ domaincolor/hyperbolic/zeta：stage 直接挂 shell */
@media (max-width: 620px) {
  .split > :has(.stage) { order: -1; }
  .workspace > .shell { display: grid; }
  .workspace > .shell > .stage,
  .workspace > .shell > :has(.stage) { order: -1; }
  /* 页头收紧：图标缩小、留白减半（画布再省 ~60px） */
  .tool-head { padding: 18px 0 14px; }
  .tool-icon { width: 38px; height: 38px; border-radius: var(--r-md); }
  .tool-icon svg { width: 20px; height: 20px; }
  .tool-head-inner { gap: 12px; }
  .tool-head h1 { font-size: 1.45rem; margin-bottom: 4px; }
  .tool-head .crumb { margin-bottom: 4px; }
  .workspace { padding: 18px 0 8px; }
  /* 双画布页（源→像）配对收紧：含画布的 grid-2 gap + legend 间距压缩，
   * 让第二张画布的 badge 上移脱离安装胶囊遮挡（:has 精准命中画布组，不误伤面板组） */
  .workspace .grid-2:has(.stage) { gap: 10px; }
  .workspace .legend { margin-top: 8px; gap: 6px 14px; }
  /* v1.9.28 双画布页滚动提示：第一张画布底部悬一枚「↓ 下方还有对照图」角标。
   * 纯 :has 结构检测、零 JS 零 HTML：命中「子列直挂 .stage 且后面还有含 .stage 的兄弟列」，
   * 一套覆盖 grid-2 并排拆列（conformal/mobius/sphere/fft/plot/series）与
   * stack 纵向叠放（euler/phasor）两种双画布形态；单画布页与面板列永不命中。 */
  .workspace .grid-2:has(.stage) > div:has(> .stage):has(+ div .stage) > .stage::after,
  .workspace .stack > div:has(> .stage):has(+ div .stage) > .stage::after {
    content: "↓ 下方还有对照图";
    position: absolute;
    left: 50%; bottom: 10px;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-family: var(--mono);
    font-size: var(--fs-tiny);
    letter-spacing: 0.04em;
    color: var(--ink-mute);
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
    animation: hintBob 1.8s ease-in-out infinite;
  }
  @keyframes hintBob {
    0%, 100% { bottom: 10px; }
    50%      { bottom: 13px; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .workspace .grid-2:has(.stage) > div:has(> .stage):has(+ div .stage) > .stage::after,
  .workspace .stack > div:has(> .stage):has(+ div .stage) > .stage::after {
    animation: none;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel + .panel { margin-top: var(--gap); }
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-title h2 {
  margin: 0;
  font-size: var(--fs-h3);
}
.panel-title .tag { margin-left: auto; }

/* ---------- 输入行 ---------- */
.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
.input-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 620px) {
  .input-row, .input-row-3 { grid-template-columns: minmax(0, 1fr); }
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ---------- 结果区 ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.result-cell {
  padding: 13px 15px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.result-cell .k {
  display: block;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.05em;
  color: var(--ink-mute);
}
.result-cell .v {
  display: block;
  font-family: var(--math);
  font-size: 1.1rem;
  color: var(--ink);
  word-break: break-word;
  line-height: 1.4;
}
.result-cell.c-re .v { color: var(--re); }
.result-cell.c-im .v { color: var(--im); }
.result-cell.c-res .v { color: var(--res); }

/* ---------- 步骤演算 ---------- */
.working {
  padding: 16px 18px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--math);
  font-size: 0.98rem;
  line-height: 2;
  color: var(--ink-soft);
  overflow-x: auto;
}
.working .step {
  display: flex;
  gap: 12px;
  align-items: baseline;
  white-space: nowrap;
}
.working .step .lbl {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  font-style: normal;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.working .step .eq { flex: 1 1 auto; }
/* v2.0.0：窄屏账本行长公式（如卷绕数页 wind/N−P 对照）会撑破 flex，
 * 放开换行；宽屏仍保持 nowrap 的公式排版纪律 */
@media (max-width: 620px) {
  .working .step { flex-wrap: wrap; white-space: normal; }
}
.working .hl-re { color: var(--re); }
.working .hl-im { color: var(--im); }
.working .hl-res { color: var(--res); font-weight: 500; }

/* ---------- 说明区 ---------- */
.notes {
  padding: 36px 0;
  border-top: 1px solid var(--line);
}
.notes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap-lg);
  align-items: start;
}
@media (max-width: 900px) {
  .notes-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}
.notes h2 { margin-bottom: 14px; }
.notes h3 {
  margin: 20px 0 8px;
  font-size: 0.98rem;
  color: var(--ink);
}
.notes p { color: var(--ink-soft); font-size: var(--fs-small); line-height: 1.75; }
.notes ul {
  margin: 8px 0;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: var(--fs-small);
  line-height: 1.85;
}
.notes li + li { margin-top: 2px; }

/* 相关模块导航 */
.related {
  padding: 28px 0 8px;
  border-top: 1px solid var(--line);
}
.related h2 {
  margin-bottom: 16px;
  font-size: var(--fs-h3);
  color: var(--ink-mute);
}

/* ---------- 单位根专用：多边形顶点表 ---------- */
.vertex-table td.num { font-size: var(--fs-tiny); }
.vertex-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}

/* ---------- Mandelbrot 专用 ---------- */
.mandel-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 620px) {
  .mandel-info { grid-template-columns: minmax(0, 1fr); }
}
.preset-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- 相量专用 ---------- */
.phasor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.phasor-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--fs-small);
}
.phasor-item .sw {
  width: 12px; height: 12px;
  border-radius: 3px;
}
.phasor-item .nm {
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phasor-item .vv {
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* ---------- Möbius 专用 ---------- */
.matrix-input {
  display: grid;
  grid-template-columns: repeat(2, 62px);
  gap: 8px;
  padding: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  justify-content: center;
}
.matrix-input .input { text-align: center; padding: 7px 4px; min-height: 34px; }
.matrix-bracket {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.matrix-bracket .br {
  font-family: var(--math);
  font-size: 3rem;
  line-height: 1;
  color: var(--ink-faint);
  font-weight: 300;
}

/* ---------- 卷绕数：辐角账本 ---------- */
.wd-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  flex-wrap: wrap;
  text-align: center;
}
.wd-big {
  font-family: var(--math);
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 500;
  line-height: 1;
  color: var(--res);
  font-variant-numeric: tabular-nums;
}
.wd-big-lbl {
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  color: var(--ink-mute);
  letter-spacing: 0.03em;
}
.wd-big-lbl #wdTotalArg { color: var(--ink-soft); }

/* ---------- 关于页 ---------- */
.about-copy { max-width: 68ch; }
.about-copy p { margin-bottom: 1.1em; }
.about-copy h2 { margin-top: 40px; }
.about-copy h3 { margin-top: 28px; font-size: 1rem; }

.stack-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.stack-item {
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.stack-item .k {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  margin-bottom: 5px;
}
.stack-item .v {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  line-height: 1.6;
}

.license-note {
  padding: 18px 20px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  line-height: 1.8;
}
.license-note code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--im);
}

/* ---------- 课件课堂（M6） ---------- */
.lesson-chips { flex-wrap: wrap; gap: 8px; }
.lesson-chip[aria-selected="true"] {
  background: var(--res-soft);
  border-color: var(--res);
  color: var(--ink);
}
.lesson-text {
  margin: 10px 0 0;
  font-size: var(--fs-small);
  line-height: 1.95;
  color: var(--ink-soft);
  min-height: 5.6em;
}
.lesson-progress {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  align-items: center;
}
.lesson-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.lesson-dot:hover { border-color: var(--res); }
.lesson-dot.on {
  background: var(--res);
  border-color: var(--res);
  transform: scale(1.25);
}
.lesson-try { margin-left: auto; }

/* ---------- 复数谜题（M7） ---------- */
.pz-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.pz-level {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-tiny);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.pz-level:hover { border-color: var(--line-strong); }
.pz-level.on { border-color: var(--res); background: var(--res-soft); }
.pz-level.locked { opacity: 0.5; cursor: not-allowed; }
.pz-no {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}
.pz-nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pz-st { flex: 0 0 auto; color: var(--warn); letter-spacing: 1px; }
.pz-brief { margin: 8px 0 0; font-size: var(--fs-small); color: var(--ink-soft); line-height: 1.8; }
.pz-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.pz-op { position: relative; padding-left: 24px; }
.pz-key {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-mute);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 3px;
}
.pz-hint {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--bg-sunken);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--fs-small);
  color: var(--ink-soft);
  line-height: 1.8;
}
.pz-win { border-color: var(--res); }
.pz-stars { color: var(--warn); letter-spacing: 2px; }
.pz-win-note { margin: 6px 0 0; font-size: var(--fs-small); color: var(--ink-soft); }

/* ---------- 复数对令（duel，A1） ---------- */
.dl-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border-radius: var(--r-md);
}
.dl-score .dl-name { font-size: var(--fs-small); color: var(--ink-mute); }
.dl-score .dl-nums { font-family: var(--mono); font-size: 26px; line-height: 1; }
.dl-score .dl-nums i { margin: 0 8px; color: var(--ink-mute); font-style: normal; font-size: 18px; }
.dl-score .dl-s0 { color: var(--re); }
.dl-score .dl-s1 { color: var(--im); }
.dl-brief { margin: 10px 0 0; font-size: var(--fs-small); color: var(--ink-soft); line-height: 1.8; min-height: 1.6em; }
.dl-modes { display: flex; gap: 8px; margin-bottom: 12px; }
.tag-p0 { color: var(--re); background: var(--re-soft); border-color: transparent; }
.tag-p1 { color: var(--im); background: var(--im-soft); border-color: transparent; }
.dl-win-note { margin: 6px 0 0; font-size: var(--fs-small); color: var(--ink-soft); }
.dl-over { border-color: var(--res); }
.dl-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.dl-replay[hidden] { display: none; }
.dl-replay input[type="range"] { flex: 1 1 120px; min-width: 0; }
.dl-rp-n { font-family: var(--mono); font-size: var(--fs-small); color: var(--ink-mute); white-space: nowrap; }
.dl-kifu {
  margin: 10px 0 0; padding: 10px 12px;
  max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel);
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: var(--ink-soft); white-space: pre;
}

/* ============ 识色辨函（riddle） ============ */
.rd-stats {
  display: flex; gap: 8px; margin: 0 0 12px;
}
.rd-stat {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel);
}
.rd-stat b { font-family: var(--mono); font-size: 20px; line-height: 1; color: var(--ink); }
.rd-stat span { font-size: var(--fs-tiny); color: var(--ink-mute); }
.rd-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.rd-opt {
  font-family: var(--mono); font-size: 13px;
  min-height: 42px; padding: 8px 10px;
  white-space: normal; word-break: break-all; text-align: center;
}
.rd-opt:disabled { opacity: 0.72; cursor: default; }
.rd-good { border-color: var(--res); background: var(--res-soft); color: var(--res); }
.rd-bad { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.rd-note { margin-top: 12px; }
.rd-note p { margin: 6px 0; font-size: var(--fs-small); color: var(--ink-soft); line-height: 1.7; }
.rd-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
@media (max-width: 520px) {
  .rd-opts { grid-template-columns: 1fr; }
}

