/*
 * 手语输入法 · 主界面样式
 * ------------------------------------------------------------
 * 设计方向：精密仪器 / 专业工具。浅色为主，冷灰底，克制的靛蓝强调色。
 * 语义色仅用于状态（通过 / 拒识 / 歧义），不用于装饰。
 * 同时支持浅色与深色（prefers-color-scheme），全部走 CSS 自定义属性。
 */

/* ---------- 设计令牌：浅色（默认） ---------- */
:root {
  color-scheme: light;

  /* 色彩 */
  --bg: #eef0f4;
  --bg-elevated: #ffffff;
  --bg-sunken: #e2e5ec;
  --bg-hover: #e6e9ef;
  --border: #d7dbe3;
  --border-strong: #c1c7d2;
  --text-primary: #1a1d24;
  --text-secondary: #575e6c;
  --text-on-accent: #f5f6fb;

  --accent: #3f4e9e;
  --accent-strong: #333f82;
  --accent-soft: rgba(63, 78, 158, 0.09);
  --accent-soft-strong: rgba(63, 78, 158, 0.16);

  --pass: #1e7a46;
  --pass-soft: rgba(30, 122, 70, 0.1);
  --reject: #b23b1f;
  --reject-soft: rgba(178, 59, 31, 0.1);
  --ambiguity: #6e4fb0;
  --ambiguity-soft: rgba(110, 79, 176, 0.1);

  --shadow-sm: 0 1px 2px rgba(23, 26, 33, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(23, 26, 33, 0.16);
  --scrim: rgba(17, 19, 26, 0.5);

  /* 字体 */
  --font-sans: "IBM Plex Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* 字号阶梯（模块化） */
  --fs-caption: 0.75rem;
  --fs-small: 0.8125rem;
  --fs-body-sm: 0.875rem;
  --fs-body: 1rem;
  --fs-body-lg: 1.125rem;
  --fs-title-sm: 1.25rem;
  --fs-title: 1.5rem;
  --fs-display-sm: 2rem;
  --fs-display: 2.75rem;

  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.75;
  --lh-loose: 1.85;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* 间距（4px 基准） */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --dur-fast: 120ms;
  --dur-base: 220ms;
  --dur-slow: 420ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  --container-max: 1320px;
}

/* ---------- 设计令牌：深色（系统跟随） ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161b;
    --bg-elevated: #1b1e26;
    --bg-sunken: #0e0f13;
    --bg-hover: #232733;
    --border: #2a2e38;
    --border-strong: #3a4050;
    --text-primary: #e9ebf1;
    --text-secondary: #a7afc0;
    --text-on-accent: #10121a;

    --accent: #96a3f0;
    --accent-strong: #b3bdf5;
    --accent-soft: rgba(150, 163, 240, 0.14);
    --accent-soft-strong: rgba(150, 163, 240, 0.22);

    --pass: #4ade95;
    --pass-soft: rgba(74, 222, 149, 0.12);
    --reject: #ff8368;
    --reject-soft: rgba(255, 131, 104, 0.12);
    --ambiguity: #c0a8f5;
    --ambiguity-soft: rgba(192, 168, 245, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 28px -10px rgba(0, 0, 0, 0.55);
    --scrim: rgba(6, 7, 10, 0.65);
  }
}
/* 允许未来接入手动切换（data-theme 属性），当前页面未提供开关 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --bg-elevated: #1b1e26;
  --bg-sunken: #0e0f13;
  --bg-hover: #232733;
  --border: #2a2e38;
  --border-strong: #3a4050;
  --text-primary: #e9ebf1;
  --text-secondary: #a7afc0;
  --text-on-accent: #10121a;
  --accent: #96a3f0;
  --accent-strong: #b3bdf5;
  --accent-soft: rgba(150, 163, 240, 0.14);
  --accent-soft-strong: rgba(150, 163, 240, 0.22);
  --pass: #4ade95;
  --pass-soft: rgba(74, 222, 149, 0.12);
  --reject: #ff8368;
  --reject-soft: rgba(255, 131, 104, 0.12);
  --ambiguity: #c0a8f5;
  --ambiguity-soft: rgba(192, 168, 245, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 28px -10px rgba(0, 0, 0, 0.55);
  --scrim: rgba(6, 7, 10, 0.65);
}

/* ---------- 重置与基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: var(--fw-regular);
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
  overflow-x: hidden; /* body 永不横向滚动；宽内容自带滚动容器 */
  min-height: 100vh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* [hidden] 必须始终生效——避免被 .live-grid 等 display:grid/flex 规则在特异性打平时覆盖 */
[hidden] {
  display: none !important;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--accent-soft-strong);
}

/* ---------- 页面骨架 ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  min-width: 0;
}

.topbar__name {
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar__subtitle {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: var(--sp-2);
  padding: 3px var(--sp-3) 3px var(--sp-2);
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex: none;
}
.status-dot--live {
  background: var(--pass);
  animation: pulse-dot 1.8s var(--ease-standard) infinite;
}
.status-dot--warn {
  background: var(--reject);
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--pass-soft);
  }
  50% {
    box-shadow: 0 0 0 4px var(--pass-soft);
  }
}

.topbar__spacer {
  flex: 1;
}

.topbar__version {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar__about {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.topbar__about:hover,
.topbar__about:focus-visible {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--sp-6);
}

.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: var(--sp-6);
  align-items: start;
}

@media (max-width: 960px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 15px;
  }
  .app-main {
    padding: var(--sp-4);
    gap: var(--sp-5);
  }
  .topbar {
    padding: var(--sp-3) var(--sp-4);
  }
}

.col {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  min-width: 0;
}
.col--left {
  position: sticky;
  top: calc(56px + var(--sp-5));
}
@media (max-width: 960px) {
  .col--left {
    position: static;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel__header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.panel__header .icon {
  color: var(--text-secondary);
  flex: none;
}
.panel__title {
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
}
.panel__hint {
  margin-left: auto;
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}
.panel__body {
  padding: var(--sp-5);
}

/* ---------- 页脚 ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
}
.app-footer__notice {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  text-align: center;
  max-width: 720px;
  line-height: var(--lh-relaxed);
}

/* 彩蛋 E 的载体：与背景同色、视觉上几乎不可见 */
#ghost-input {
  width: 34px;
  height: 18px;
  padding: 0 4px;
  border: none;
  outline: none;
  background: var(--bg);
  color: var(--bg);
  caret-color: var(--bg);
  font-size: 10px;
  border-radius: 3px;
  flex: none;
}
#ghost-input::placeholder {
  color: var(--bg);
}
#ghost-input:focus {
  color: var(--bg);
}

/* ================= 首屏：授权前说明卡 ================= */
.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}
.gate__card {
  max-width: 460px;
  width: 100%;
  padding: var(--sp-8) var(--sp-6);
  text-align: left;
}
.gate__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-5);
}
.gate__title {
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2);
}
.gate__desc {
  color: var(--text-secondary);
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-5);
}
.gate__list {
  list-style: none;
  margin: 0 0 var(--sp-6);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.gate__list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-body-sm);
  color: var(--text-primary);
  line-height: var(--lh-normal);
}
.gate__list .icon {
  color: var(--pass);
  margin-top: 2px;
  flex: none;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard),
    background var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.btn:active {
  transform: scale(0.98);
}
.btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
  width: 100%;
}
.btn--primary:hover {
  background: var(--accent-strong);
}
.btn--primary:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.btn--ghost:hover {
  background: var(--bg-hover);
}
.gate__privacy {
  margin-top: var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
}
.gate__privacy .icon {
  flex: none;
  margin-top: 1px;
}

/* ================= 加载态 ================= */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}
.loading__card {
  max-width: 460px;
  width: 100%;
  padding: var(--sp-8) var(--sp-6);
}
.loading__title {
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-5);
}
.loading__row {
  margin-bottom: var(--sp-4);
}
.loading__row-top {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-body-sm);
  margin-bottom: var(--sp-2);
}
.loading__row-label {
  color: var(--text-primary);
}
.loading__row-size {
  color: var(--text-secondary);
}
.loading__bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.loading__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  width: 0%;
  transition: width var(--dur-base) var(--ease-standard);
}
.loading__divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: var(--sp-5) 0;
}
.loading__summary {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ================= 取景区（左栏） ================= */
.viewfinder {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-sunken);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
}
.viewfinder__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 仅镜像显示；骨架绘制需在数据层自行翻转 x */
  background: var(--bg-sunken);
}
.viewfinder__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.viewfinder__prompt {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--sp-4) var(--sp-5);
  background: linear-gradient(to bottom, rgba(10, 12, 16, 0.62), rgba(10, 12, 16, 0));
  color: #f2f3f8;
  z-index: 3;
}
.viewfinder__prompt-word {
  font-size: var(--fs-title-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
}
.viewfinder__prompt-word .mono {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-regular);
  color: rgba(242, 243, 248, 0.72);
  margin-left: var(--sp-2);
}
.viewfinder__howto {
  margin-top: 2px;
  font-size: var(--fs-small);
  color: rgba(242, 243, 248, 0.82);
  line-height: var(--lh-normal);
}
.viewfinder__guide {
  position: absolute;
  inset: 12% 24% 18%;
  border: 1.5px dashed rgba(245, 246, 251, 0.55);
  border-radius: var(--radius-lg);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewfinder__guide .icon {
  color: rgba(245, 246, 251, 0.4);
  width: 84px;
  height: 84px;
}
.viewfinder__status {
  position: absolute;
  left: var(--sp-4);
  bottom: var(--sp-4);
  display: flex;
  gap: var(--sp-2);
  z-index: 3;
  flex-wrap: wrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-caption);
  font-family: var(--font-mono);
  background: rgba(10, 12, 16, 0.5);
  color: #f2f3f8;
  backdrop-filter: blur(4px);
}
.tag--nohand {
  background: rgba(178, 59, 31, 0.75);
}

.ring-wrap {
  position: absolute;
  right: var(--sp-4);
  bottom: var(--sp-4);
  width: 72px;
  height: 72px;
  z-index: 3;
}
.ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 6;
}
.ring-value {
  fill: none;
  stroke: #ffffff;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-base) var(--ease-standard), stroke var(--dur-base) var(--ease-standard);
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: #ffffff;
}

.viewfinder-below {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3) var(--sp-1) 0;
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}
.viewfinder-below span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.viewfinder-below .icon {
  width: 14px;
  height: 14px;
}

/* ================= 五通道面板 ================= */
.channels {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.channel-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 52px 72px;
  align-items: center;
  gap: var(--sp-3);
  min-height: 34px;
}
.channel-row__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  overflow: hidden;
}
.channel-row__label .icon {
  color: var(--text-secondary);
  flex: none;
  width: 15px;
  height: 15px;
}
.channel-row__label-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.channel-row__label-text > span:first-child {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
}
.channel-row__label-en {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-row__track {
  position: relative;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.channel-row__fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-base) var(--ease-standard), background var(--dur-base) var(--ease-standard);
}
.channel-row__track--dashed {
  background: repeating-linear-gradient(
    to right,
    var(--border-strong) 0,
    var(--border-strong) 6px,
    transparent 6px,
    transparent 12px
  );
  background-color: transparent;
}
.channel-row__value {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  text-align: right;
}
.channel-row__code {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  text-align: right;
  white-space: nowrap;
  /* 不设 overflow:hidden——通道编码恒短（≤6 字符）不需要省略号，
     且这里嵌了「非手动」行的提示气泡（.channel-row__tooltip），
     父级一旦裁剪溢出，气泡会被整个裁掉（曾经真实踩过这个坑）。 */
}
.channel-row--ambiguous .channel-row__code {
  color: var(--ambiguity);
}
.channel-row--dim {
  opacity: 0.62;
}
.channel-row--dim .channel-row__code {
  color: var(--text-secondary);
}
.channel-row__info {
  position: relative;
  display: inline-flex;
  border: none;
  background: none;
  padding: 0;
  margin-left: 3px;
  color: var(--text-secondary);
  cursor: help;
  flex: none;
}
.channel-row__info .icon {
  width: 13px;
  height: 13px;
}
.channel-row__tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 236px;
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--bg-elevated);
  font-size: var(--fs-caption);
  font-family: var(--font-sans);
  line-height: var(--lh-normal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
  z-index: 10;
  text-align: left;
}
.channel-row__info:hover .channel-row__tooltip,
.channel-row__info:focus-visible .channel-row__tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ================= 候选词得分列表 ================= */
.candidates {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.candidate-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1.3fr) minmax(0, 1fr) 46px;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-standard);
}
.candidate-row--ambiguous {
  background: var(--ambiguity-soft);
}
.candidate-row__rank {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  text-align: center;
}
.candidate-row__word {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.candidate-row__zh {
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  flex: none;
}
.candidate-row__pinyin {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.candidate-row__badge {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--ambiguity);
  color: var(--text-on-accent);
  font-size: 10px;
  font-family: var(--font-mono);
  flex: none;
}
.candidate-row__track {
  position: relative;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  overflow: hidden;
}
.candidate-row__fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background: var(--text-secondary);
  transition: width var(--dur-base) var(--ease-standard);
}
.candidate-row--top .candidate-row__fill {
  background: var(--accent);
}
.candidate-row--ambiguous .candidate-row__fill {
  background: var(--ambiguity);
}
.candidate-row__score {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  text-align: right;
}

/* ================= 结果区 ================= */
.results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.results__stream {
  min-height: 84px;
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-3);
  overflow-x: auto;
}
.results__empty {
  color: var(--text-secondary);
  font-size: var(--fs-body-sm);
}
.result-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-display-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  animation: chip-in var(--dur-slow) var(--ease-standard);
}
.result-chip__conf {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  font-weight: var(--fw-regular);
  color: var(--text-secondary);
}
@keyframes chip-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.results__note {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}

/* ================= 词表 & 最小对比对 ================= */
.tier-group {
  margin-bottom: var(--sp-4);
}
.tier-group:last-child {
  margin-bottom: 0;
}
.tier-group__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tier-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.word-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--fs-body-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard);
}
.word-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.word-chip:active {
  transform: scale(0.97);
}
.word-chip__pinyin {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}
.word-chip--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.word-chip__done {
  color: var(--pass);
  width: 13px;
  height: 13px;
}

.minimal-pairs {
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}
.minimal-pairs__title {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-1);
}
.minimal-pairs__desc {
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
  line-height: var(--lh-relaxed);
}
.minimal-pairs__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
@media (max-width: 520px) {
  .minimal-pairs__grid {
    grid-template-columns: 1fr;
  }
}
.pair-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}
.pair-card__label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pair-card__words {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
}
.pair-card__vs {
  color: var(--text-secondary);
  font-size: var(--fs-caption);
}

/* ================= 降级态 ================= */
.degraded {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}
.degraded__card {
  max-width: 480px;
  width: 100%;
  padding: var(--sp-8) var(--sp-6);
  text-align: left;
}
.degraded__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--reject-soft);
  color: var(--reject);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-5);
}
.degraded__title {
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2);
}
.degraded__desc {
  color: var(--text-secondary);
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--sp-4);
}
.degraded__steps {
  list-style: none;
  margin: 0 0 var(--sp-6);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.degraded__steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-normal);
}
.degraded__steps .icon {
  color: var(--accent);
  margin-top: 2px;
  flex: none;
  width: 15px;
  height: 15px;
}
.degraded__actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.degraded__actions .btn {
  flex: 1 1 auto;
}
.degraded__meta {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}

/* ================= 反馈：无动效可用时的兜底 ================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ================= 通用滚动容器（宽内容自持滚动，body 不滚） ================= */
.scroll-x {
  overflow-x: auto;
}

/* ---------- 面板操作按钮（集成阶段追加） ---------- */
.panel__actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn--ghost {
  font: 500 var(--fs-caption) / 1 var(--font-sans);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
  min-height: 32px;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn--ghost:disabled { opacity: 0.45; cursor: default; }
.btn--ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 校准过程中的行内状态条 */
.calib-status {
  margin: 10px 0 0;
  font: 500 var(--fs-small) / var(--lh-normal) var(--font-sans);
  color: var(--text-secondary);
}
.calib-status[data-tone="active"] { color: var(--accent); }
.calib-status[data-tone="done"] { color: var(--pass); }

@media (max-width: 560px) {
  .panel__actions { width: 100%; margin-left: 0; margin-top: 8px; }
  .btn--ghost { flex: 1; min-height: 44px; }
}

/* ---------- 移动端触摸目标（集成阶段追加） ----------
 * WCAG 2.5.5 / iOS HIG 都要求可点击区域至少 44×44。
 * 桌面用鼠标不受此限，所以只在窄屏与粗指针下强制。
 */
@media (max-width: 768px), (pointer: coarse) {
  .topbar__about {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-inline: 10px;
  }

  /* 主按钮留出余量，避免亚像素舍入后正好卡在 44 以下 */
  .btn--primary,
  .gate__start,
  button.btn {
    min-height: 48px;
  }

  /* 词表里的词条也是要点的 */
  .word-chip,
  .word-list__item,
  .word-list button {
    min-height: 44px;
  }
}

/* ---------- 修：非手动通道的提示气泡在窄屏溢出（集成阶段） ----------
 * 原本是 left:50% + translateX(-50%) 居中定位、固定 236px 宽，
 * 而它的锚点就在面板最右侧，于是一半伸出视口。
 * 即使 opacity:0 也照样占布局、制造 scrollWidth —— 375px 下实测横向溢出 111px。
 * 改为右对齐并限宽，气泡向左展开，不会越过视口右边界。
 */
.channel-row__tooltip {
  left: auto;
  right: 0;
  transform: translateY(4px);
  width: auto;
  max-width: min(236px, calc(100vw - 32px));
  white-space: normal;
}
.channel-row__info:hover .channel-row__tooltip,
.channel-row__info:focus-visible .channel-row__tooltip {
  transform: translateY(0);
}
