/* 音准页（/zh/violin-tuner/）页面壳
 * ----------------------------------------------------------------------------
 * 只放本页独有的东西：卡片外壳、模式切换、麦克风按钮、页脚、正文说明。
 * 读数组件（大唱名/指针/轨迹/小结）的样式在 /assets/practice/ears.css，
 * 首页练习用的是同一份。色板走 UI-SPEC.md，不引入第二套配色。 */

.tn-shell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* ---------- 顶部控制 ---------- */
.tn-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.tn-modes {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--accent-soft);
  border-radius: 999px;
}

.tn-modes button,
.tn-modes a,
.tn-chip {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 11px;
  font: 650 12px/1.1 inherit;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.tn-modes button:hover,
.tn-modes a:hover {
  color: var(--accent);
}

.tn-modes button.is-on {
  background: var(--paper);
  border-color: var(--line);
  color: var(--accent);
}

.tn-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tn-chip {
  border-color: var(--line);
  background: var(--paper);
}

.tn-chip:hover {
  background: var(--accent-soft);
  border-color: #c7d2fe;
  color: var(--accent);
}

.tn-mic {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font: 700 12px/1.1 inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.tn-mic:hover { background: #4338ca; border-color: #4338ca; }
.tn-mic.is-on {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}
.tn-mic:disabled { opacity: .6; cursor: progress; }

/* A4 校准：只在调音器模式出现 */
.tn-cal {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--accent-soft);
  font: 700 11px/1 var(--mono);
  color: var(--muted);
}

.tn-cal[hidden] { display: none; }

.tn-cal > span {
  padding: 0 6px;
  letter-spacing: .04em;
}

.tn-cal button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 8px;
  font: 700 11px/1 var(--mono);
  cursor: pointer;
}

.tn-cal button:hover { color: var(--accent); }

.tn-cal button.is-on {
  background: var(--paper);
  border-color: var(--line);
  color: var(--accent);
}

/* ---------- 调音器：琴头与四根弦 ---------- */
.tn-tune {
  padding: 14px 4px 0;
  text-align: center;
}

.tn-tune[hidden] { display: none; }

.tn-ask {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.tn-ask.is-done { color: var(--good); }

.tn-peg {
  display: flex;
  justify-content: center;
  margin: 0 auto 6px;
  max-width: 260px;
}

.tn-peg-img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 210px;
  user-select: none;
  -webkit-user-drag: none;
}

.tn-strings {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.tn-string {
  appearance: none;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font: 650 12px/1 inherit;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.tn-string b {
  font: 700 13px/1 var(--mono);
  color: var(--ink);
}

.tn-string:hover {
  border-color: #c7d2fe;
  background: var(--accent-soft);
  color: var(--accent);
}

.tn-string.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tn-string.is-on b { color: #fff; }

.tn-string.is-done:not(.is-on) {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: var(--good);
}

.tn-string.is-done:not(.is-on) b { color: var(--good); }

@media print {
  .tn-tune { display: none !important; }
}

/* ---------- 底部状态 ---------- */
.tn-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font: 500 11px/1 var(--mono);
  color: #9a9384;
}

.tn-spacer { flex: 1 1 auto; }

/* ---------- 正文里的说明块（服务端渲染，不依赖 JS） ---------- */
.tn-error {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger, #b91c1c);
  font-size: 13px;
}

.tn-loading {
  margin: 0;
  padding: 24px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.tn-read {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.tn-read li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.tn-read li strong {
  flex: 0 0 auto;
  min-width: 168px;
  color: var(--ink);
}

.tn-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
  font-size: 13px;
}

.tn-links a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.tn-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tn-faq {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 11px 14px;
  margin-bottom: 8px;
}

.tn-faq summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
}

.tn-faq p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

@media (max-width: 640px) {
  /* 换行后麦克风按钮保持在最右：主操作固定在同一只眼的落点 */
  .tn-acts { margin-left: 0; width: 100%; }
  .tn-mic { margin-left: auto; }
}

/* ============================================================================
 * 节拍器（mt- 前缀）
 * 视觉语言沿用同一套纸感：米白面板、细线摆杆、靛蓝配重。
 * 默认只露「速度 + 开始」，其余参数收在「更多设置」里。
 * ========================================================================== */
.tn-metro {
  padding: 10px 4px 4px;
}
.tn-metro[hidden] { display: none; }

.mt-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mt-stage { min-height: 260px; justify-content: center; }
/* 底座与指针是两张透明 webp 叠出来的：底座负责外壳/刻度/支点孔，
 * 指针单独旋转，所以 transform-origin 必须落在支点孔上（tools/make_metronome_art.py 算出来的
 * left 49.63% / bottom 23.29%，换图要重跑那个脚本，别手调） */
.mt-media {
  position: relative;
  width: 150px;
  margin: 0 auto;
}
.mt-base-img { width: 100%; display: block; }
.mt-media { overflow: visible; }
/* 摆杆和转轴圆盘是一整块：绕圆盘圆心摆，幅度大时会甩到机身外（真机就是这样） */
.mt-needle {
  position: absolute;
  left: 50%;
  top: 5.50%;
  height: 78.27%;
  width: auto;
  transform-origin: 50% 86.88%;   /* 转盘圆心 */
  transform: translateX(-50%) rotate(0deg);
  will-change: transform;
}

/* 色块样式：长条 = 重音拍，半条 = 非重音拍；
 * 当前拍按相位往上长，重音红、非重音白，其余拍留暗色 */
.mt-bars {
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  height: 232px;
  padding: 16px 20px;   /* 留给光晕外溢的余地 */
  /* 不要底板：柱子直接站在页面背景上，光晕才是「发出来的」而不是「涂在板上」 */
  background: transparent;
}
.mt[data-style="bar"] .mt-media { display: none; }
.mt[data-style="bar"] .mt-bars { display: flex; }
.mt[data-style="bar"] .mt-dots { display: none; }

/* 每根柱子一个细边框的「灯管」：没轮到是素色，轮到就点亮成霓虹 */
.mt-bar {
  position: relative;
  width: 42px;
  height: 100%;
  border-radius: 10px;
  border: 1px solid #d3c8b2;
  background: #e9e2d2;
  box-shadow: inset 0 1px 3px rgba(30, 36, 51, .07);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
/* 长条 = 重音，半条 = 非重音 */
.mt-bar:not(.is-accent) { height: 52%; }
.mt-bar i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  background: #d8cfba;   /* 未点亮：单色填充，比面板深一档才看得见轮廓 */
  transition: background .12s, box-shadow .12s;
}
/* 点亮：垂直渐变让中段最亮，两端略暗，像一根通电的灯管 */
.mt-bar.is-on i {
  background: linear-gradient(
    180deg,
    #c7d2fe 0%,
    #6366f1 38%,
    #4f46e5 50%,
    #6366f1 62%,
    #c7d2fe 100%
  );
  box-shadow: inset 0 0 12px rgba(255, 255, 255, .5);
}
/* 中央一条虚化的白色核心：灯管里那根最亮的丝 */
.mt-bar.is-on i::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 10%;
  bottom: 10%;
  width: 34%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  filter: blur(3px);
}
.mt-bar.is-on.is-accent i {
  background: linear-gradient(
    180deg,
    #fdba74 0%,
    #f97362 38%,
    #e63946 50%,
    #f97362 62%,
    #fdba74 100%
  );
  box-shadow: inset 0 0 12px rgba(255, 255, 255, .55);
}
.mt-bar.is-on.is-accent i::after {
  background: rgba(255, 255, 255, .66);
}
/* 外发光必须挂在柱子上：i 的光会被 .mt-bar 的 overflow:hidden 裁掉。
 * 三层由近及远（近亮远淡），才有霓虹那种"溢出边界"的晕。 */
.mt-bar.is-on {
  border-color: #c7d2fe;
  box-shadow:
    0 0 5px 1px rgba(99, 102, 241, .55),
    0 0 18px 5px rgba(99, 102, 241, .42),
    0 0 40px 13px rgba(99, 102, 241, .24),
    inset 0 1px 3px rgba(30, 36, 51, .07);
}
.mt-bar.is-on.is-accent {
  border-color: #f97362;
  box-shadow:
    0 0 5px 1px rgba(230, 57, 70, .6),
    0 0 20px 6px rgba(230, 57, 70, .46),
    0 0 44px 15px rgba(230, 57, 70, .26),
    inset 0 1px 3px rgba(30, 36, 51, .07);
}

/* 逐拍重音开关 */
/* 逐拍重音开关：和上面几行一样用方形圆角，别单独一套圆形 */
.mt-accents { display: flex; gap: 6px; flex-wrap: wrap; }
.mt-acc {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}
.mt-acc i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfc7b6;
  transition: background .14s;
}
.mt-acc:hover { border-color: #e8b4ae; }
.mt-acc.is-on { border-color: #e04b3f; background: #fdecea; }
.mt-acc.is-on i { background: #e04b3f; }

.mt-dots {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 12px;
}
.mt-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d9d2c3;
  transition: transform .09s ease, background .12s ease;
}
/* 重音拍的点大 1/3（6 → 8px），亮起时红色；非重音亮起时靛蓝 */
.mt-dots i.is-accent { width: 8px; height: 8px; }
.mt-dots i.is-on {
  background: var(--accent);
  transform: scale(1.35);
}
.mt-dots i.is-on.is-accent { background: #e04b3f; }

.mt-tempo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 4px;
}
.mt-step {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 600 18px/1 var(--mono);
  cursor: pointer;
  transition: .14s;
}
.mt-step:hover { border-color: #c7d2fe; color: var(--accent); background: var(--accent-soft); }
.mt-step:active { transform: translateY(1px); }

.mt-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 108px;
  min-width: 108px;
}
.mt-num b {
  font: 600 56px/1 Georgia, serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -.02em;
}
/* BPM 数字可直接点开输入：虚线底表示可编辑，键盘 Tab 也能聚焦 */
.mt-num b[data-mt-bpm] {
  cursor: text;
  border-bottom: 1px dotted var(--line);
  outline: none;
}
.mt-num b[data-mt-bpm]:hover,
.mt-num b[data-mt-bpm]:focus-visible {
  color: var(--accent);
  border-bottom-color: currentColor;
}
.mt-num b[data-mt-bpm]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.mt-bpm-input {
  width: 100%;
  min-width: 92px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 600 56px/1 Georgia, serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  text-align: center;
  outline: none;
  appearance: none;
}
.mt-bpm-input.is-bad { border-bottom-color: #e04b3f; }
.mt-num i {
  font: 600 10px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--muted);
  font-style: normal;
  margin-top: 4px;
}

.mt-term {
  margin: 2px 0 0;
  text-align: center;
  font: 500 12px/1.2 Georgia, serif;
  font-style: italic;
  letter-spacing: .04em;
  color: #9a9384;
}

.mt-basic {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.mt-go {
  appearance: none;
  min-width: 168px;
  padding: 11px 26px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: 650 15px/1 inherit;
  cursor: pointer;
  transition: .15s;
}
.mt-go:hover { background: #4338ca; border-color: #4338ca; }
.mt-go:active { transform: translateY(1px); }
.mt-go.is-on {
  background: var(--paper);
  color: var(--accent);
  border-color: var(--accent);
}

.mt-more {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px auto 0;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 650 12px/1 inherit;
  cursor: pointer;
  transition: color .15s;
}
.mt-more:hover { color: var(--accent); }
.mt-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform .18s ease;
}
.mt-more.is-open .mt-caret { transform: rotate(180deg); }

.mt-adv {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 12px;
}
.mt-adv[hidden] { display: none; }

/* 速度滑杆是这一排里最常用的控件：给足触摸高度、加粗轨道、放大滑块 */
.mt-range { display: block; }
.mt-range input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 30px;              /* 触摸区，不是轨道高度 */
  margin: 0;
  background: transparent;
  cursor: pointer;
}
/* 轨道：已滑过的部分用靛蓝，靠 --p 控制分界点 */
.mt-range input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--p, 50%),
    #e6e0d3 var(--p, 50%) 100%
  );
}
.mt-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -8px;          /* (24-8)/2，让滑块居中于轨道 */
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(30, 36, 51, .28);
  transition: transform .12s;
}
.mt-range input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.mt-range input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #e6e0d3;
}
.mt-range input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}
.mt-range input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(30, 36, 51, .28);
}
.mt-range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  font: 500 10px/1 var(--mono);
  color: #9a9384;
  font-variant-numeric: tabular-nums;
}

.mt-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mt-label {
  flex: 0 0 42px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.mt-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.mt-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  /* 方形圆角：胶囊形在 8 个一排时太挤，方角更整齐 */
  border-radius: 9px;
  min-width: 44px;
  padding: 7px 12px;
  font: 650 12px/1.1 inherit;
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
}
.mt-chip:hover { border-color: #c7d2fe; color: var(--accent); }
.mt-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.mt-chip.is-on:hover { background: #4338ca; border-color: #4338ca; color: #fff; }
/* 图标是外部 SVG，用 mask 上色：跟着 currentColor 走，选中态自动变靛蓝 */
.mt-ico {
  display: block;
  background: currentColor;
  -webkit-mask-image: var(--ico);
  mask-image: var(--ico);
  /* SVG 默认按亮度算：黑色形状会等于全透明，必须显式按 alpha */
  -webkit-mask-source-type: alpha;
  mask-mode: alpha;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.mt-chip:has(.mt-ico) {
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


@media (min-width: 901px) {
  .mt-media { width: 244px; }
}

@media (max-width: 900px) {
  .mt-media { width: 176px; }
  .mt-bars { height: 196px; padding: 14px 16px; }
  .mt-bar { width: 36px; }
}

@media (max-width: 620px) {
  .mt-media { width: 150px; }
  .mt-bars { height: 168px; gap: 7px; padding: 12px; }
  .mt-bar { width: 28px; }
  .mt-num b { font-size: 44px; }
  .mt-bpm-input { font-size: 44px; }
  .mt-num { flex-basis: 92px; min-width: 92px; }
  .mt-go { width: 100%; }
  .mt-label { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .mt-dots i, .mt-caret, .mt-go, .mt-step { transition: none; }
}

@media print {
  .tn-metro { display: none !important; }
}

