/* ════════════════════════════════════════
   主容器
   ════════════════════════════════════════ */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 80px;
  min-height: 100vh;
  min-height: 100dvh;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════
   工作流程卡片
   ════════════════════════════════════════ */
.wf-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 24px 20px;
  margin-bottom: 16px;
  transition: background-color 0.25s ease;
  animation: card-enter 0.35s ease both;
}
#wf-transcription { animation-delay: 0.05s; }
#wf-results       { animation-delay: 0.10s; }

.wf-card-title {
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ════════════════════════════════════════
   使用引導（Onboarding Guide）
   ════════════════════════════════════════ */
#onboarding-guide {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--accent-bg);
}
.guide-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.guide-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--inner);
  border-radius: 999px;
  padding: 8px 16px;
}
.guide-num {
  width: 22px;
  height: 22px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.guide-text {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.guide-arrow {
  color: var(--muted);
  font-size: 1rem;
  padding: 0 2px;
}

/* ════════════════════════════════════════
   HOSPID 輸入區
   ════════════════════════════════════════ */
#hospid-bar {
  margin-bottom: 16px;
}
#hospid-bar .field-label {
  margin-top: 0;
  margin-bottom: 8px;
}
#hospid-bar #hospid-input {
  width: 100%;
}

/* ════════════════════════════════════════
   錄音狀態文字
   ════════════════════════════════════════ */
#ext-rec-status {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin: 0 0 20px;
  min-height: 1.4em;
  transition: color 0.2s;
}
#ext-rec-status.rec-warning {
  color: var(--rec);
  font-weight: 500;
  animation: rec-warning-pulse 1s ease-in-out infinite;
}
@keyframes rec-warning-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ════════════════════════════════════════
   錄音按鈕組
   ════════════════════════════════════════ */
.rec-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* 卡片式模式按鈕 */
.rec-mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 14px 18px;
  border-radius: 20px;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
  text-align: center;
  min-height: 120px;
  /* 主要：即時辨識 */
  background: var(--ink);
  color: var(--surface);
  border: 2px solid transparent;
  box-shadow: 0 4px 16px rgba(47, 74, 61, 0.22);
}

/* 外框變體：普通辨識 */
.rec-mode-card.rec-mode-outlined {
  background: transparent;
  color: var(--text);
  border-color: var(--accent-bg);
  box-shadow: none;
}

/* 圓形圖示容器（圖示以 CSS 切換） */
.rec-card-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1.4rem;
  flex-shrink: 0;
  transition: background 0.2s;
}
.rec-mode-outlined .rec-card-icon {
  background: var(--accent-bg);
}

/* 文字 */
.rec-card-label {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}
.rec-card-sub {
  font-size: 0.7rem;
  opacity: 0.6;
  line-height: 1;
}

/* LIVE 標籤 */
.rec-live-tag {
  position: absolute;
  top: 10px;
  right: 11px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

/* Hover */
@media (hover: hover) and (pointer: fine) {
  .rec-mode-card:hover {
    background: var(--ink-soft);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(47, 74, 61, 0.3);
  }
  .rec-mode-card.rec-mode-outlined:hover {
    background: var(--accent-bg);
    border-color: var(--ink-soft);
  }
}
.rec-mode-card:active { transform: scale(0.97); }

/* 圖示切換：預設顯示麥克風，錄音中由 CSS 換成對應動畫。
   三種圖示永遠存在於 DOM，僅以顯示切換，因此停止後必然還原初始狀態。 */
.rec-card-icon .icon-eq,
.rec-card-icon .icon-stop { display: none; }
.rec-card-icon .icon-mic  { display: block; }

/* ──────────────────────────────────────────
   錄音中：即時辨識 ── 「現場直播」
   麥克風 → 跳動等化器，並向外擴散漣漪
   ────────────────────────────────────────── */
.rec-mode-card[data-streaming="1"] {
  background: rgba(181, 72, 47, 0.08);
  border-color: var(--rec);
  color: var(--rec);
  box-shadow: none;
}
.rec-mode-card[data-streaming="1"] .rec-card-icon {
  background: rgba(181, 72, 47, 0.12);
  overflow: visible;
}
.rec-mode-card[data-streaming="1"] .icon-mic { display: none; }
.rec-mode-card[data-streaming="1"] .icon-eq  { display: flex; }

/* 等化器音柱 */
.icon-eq {
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 22px;
}
.icon-eq i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--rec);
  transform-origin: center;
  animation: eq-bounce 0.9s ease-in-out infinite;
}
.icon-eq i:nth-child(1) { animation-delay: 0s;    }
.icon-eq i:nth-child(2) { animation-delay: 0.18s; }
.icon-eq i:nth-child(3) { animation-delay: 0.36s; }
.icon-eq i:nth-child(4) { animation-delay: 0.12s; }
.icon-eq i:nth-child(5) { animation-delay: 0.3s;  }
@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.25); }
  50%      { transform: scaleY(1);    }
}

/* 向外擴散的直播漣漪（兩道錯開的環） */
.rec-mode-card[data-streaming="1"] .rec-card-icon::before,
.rec-mode-card[data-streaming="1"] .rec-card-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--rec);
  animation: live-ripple 1.8s ease-out infinite;
  pointer-events: none;
}
.rec-mode-card[data-streaming="1"] .rec-card-icon::after {
  animation-delay: 0.9s;
}
@keyframes live-ripple {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(2.1); opacity: 0;    }
}

/* LIVE 標籤閃爍 */
.rec-mode-card[data-streaming="1"] .rec-live-tag {
  background: var(--rec);
  color: #fff;
  animation: live-blink 1s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ──────────────────────────────────────────
   錄音中：普通辨識 ── 「單次擷取」
   麥克風 → 呼吸的停止方塊，外圈旋轉掃描環
   ────────────────────────────────────────── */
.rec-mode-card.rec-mode-outlined[data-rec="1"] {
  background: rgba(181, 72, 47, 0.08);
  border-color: var(--rec);
  color: var(--rec);
}
.rec-mode-card.rec-mode-outlined[data-rec="1"] .rec-card-icon {
  background: rgba(181, 72, 47, 0.12);
  overflow: visible;
}
.rec-mode-card.rec-mode-outlined[data-rec="1"] .icon-mic  { display: none; }
.rec-mode-card.rec-mode-outlined[data-rec="1"] .icon-stop {
  display: block;
  color: var(--rec);
  animation: stop-breathe 1.3s ease-in-out infinite;
}
@keyframes stop-breathe {
  0%, 100% { transform: scale(0.82); opacity: 0.7; }
  50%      { transform: scale(1);    opacity: 1;   }
}

/* 旋轉掃描環（錐形漸層 + 環狀遮罩） */
.rec-mode-card.rec-mode-outlined[data-rec="1"] .rec-card-icon::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(var(--rec) 0deg 90deg, transparent 90deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: sweep-rotate 1.2s linear infinite;
  pointer-events: none;
}
@keyframes sweep-rotate {
  to { transform: rotate(360deg); }
}

/* 偏好減少動態時，停用所有動畫 */
@media (prefers-reduced-motion: reduce) {
  .icon-eq i,
  .rec-mode-card[data-streaming="1"] .rec-card-icon::before,
  .rec-mode-card[data-streaming="1"] .rec-card-icon::after,
  .rec-mode-card[data-streaming="1"] .rec-live-tag,
  .rec-mode-card.rec-mode-outlined[data-rec="1"] .icon-stop,
  .rec-mode-card.rec-mode-outlined[data-rec="1"] .rec-card-icon::before {
    animation: none;
  }
}

/* ════════════════════════════════════════
   輔助工具列
   ════════════════════════════════════════ */
.rec-util-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.btn-ghost-sm {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost-sm:hover {
    color: var(--text);
    background: var(--accent-bg);
  }
}

/* 下載語音按鈕（音波 icon 樣式） */
.btn-audio-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--accent-bg);
  color: var(--muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-audio-dl svg { flex-shrink: 0; opacity: 0.8; }
@media (hover: hover) and (pointer: fine) {
  .btn-audio-dl:hover {
    color: var(--text);
    background: var(--accent-bg);
    border-color: var(--ink-soft);
  }
}

/* 動作互斥鎖 */
.action-locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none !important;
  transform: none !important;
  animation: none !important;
}

/* ════════════════════════════════════════
   轉錄區塊
   ════════════════════════════════════════ */
.hl-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 100px;
  margin-bottom: 12px;
}
.hl-display {
  flex: 1;
  background: var(--inner);
  color: var(--text);
  border: 1px solid var(--accent-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  line-height: 1.9;
  font-family: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-y: auto;
  min-height: 100px;
  max-height: 240px;
  transition: border-color 0.2s;
}
.hl-display:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
.hl-wrap > textarea {
  position: absolute;
  left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
  border: 0; padding: 0; margin: 0;
  resize: none; overflow: hidden;
}

/* 高亮顏色：穴位 = 淡綠膠囊，療法 = 內層色膠囊 */
.hl-acu {
  background: var(--accent-bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .hl-acu:hover { background: var(--ink); color: var(--surface); }
}
/* 三顆療法：赭紅主題 + 前綴「三顆種子」(∴) 標記，獨一無二 */
.hl-treat {
  background: var(--treat-bg);
  color: var(--rec);
  border-radius: 5px 9px 9px 5px;
  padding: 1px 7px 1px 4px;
  font-weight: 600;
  border: 1px solid var(--treat-line);
  box-shadow: inset 2px 0 0 var(--rec);
  transition: background 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.hl-treat::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 4px 0 2px;
  vertical-align: -1px;
  background:
    radial-gradient(circle 1.5px at 50% 1.7px,  var(--rec) 95%, transparent 96%),
    radial-gradient(circle 1.5px at 1.7px 7px,  var(--rec) 95%, transparent 96%),
    radial-gradient(circle 1.5px at 7.3px 7px,  var(--rec) 95%, transparent 96%);
  background-repeat: no-repeat;
}
@media (hover: hover) and (pointer: fine) {
  .hl-treat:hover {
    background: var(--rec);
    color: var(--surface);
    box-shadow: inset 2px 0 0 var(--rec);
  }
  .hl-treat:hover::before {
    background:
      radial-gradient(circle 1.5px at 50% 1.7px,  var(--surface) 95%, transparent 96%),
      radial-gradient(circle 1.5px at 1.7px 7px,  var(--surface) 95%, transparent 96%),
      radial-gradient(circle 1.5px at 7.3px 7px,  var(--surface) 95%, transparent 96%);
    background-repeat: no-repeat;
  }
}

/* NER 雙欄 */
#ner-row {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}
.ner-col { flex: 1 1 0; min-width: 0; }

/* textarea 通用 */
#transcription-output,
#ner-acupoints-output,
#ner-treatments-output {
  font-size: 1rem;
  line-height: 1.85;
}

/* ════════════════════════════════════════
   結果卡片
   ════════════════════════════════════════ */

/* 卡片標題列 */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--accent-bg);
}
.card-header .section-label {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}
.edit-btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Tab Bar */
.result-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--accent-bg);
}
.result-tab-bar button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  padding: 6px 16px 9px;
  cursor: pointer;
  margin-bottom: -1px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
@media (hover: hover) and (pointer: fine) {
  .result-tab-bar button:hover { color: var(--text); }
}
.result-tab-bar button.tab-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* Tab Panels */
.result-tab-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
}
.result-tab-panel.tab-active { display: flex; }

/* DATA panel */
#data-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40px;
}

/* JSON panel */
#tab-json textarea {
  resize: none;
  min-height: 120px;
}
#api-output {
  font-size: 0.85rem;
  font-family: "Consolas", "Menlo", monospace;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* 上傳按鈕區 */
.schema-status {
  margin-top: 14px;
  font-size: 0.82rem;
  line-height: 1.4;
}
.schema-status:empty {
  display: none;
}
.schema-status.schema-ok {
  color: #2e7d32;
}
.schema-status.schema-invalid {
  color: #c62828;
}
.upload-action-row {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--accent-bg);
  display: flex;
  justify-content: flex-end;
}
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: 999px;
  padding: 12px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 12px rgba(47, 74, 61, 0.18);
}
@media (hover: hover) and (pointer: fine) {
  .btn-upload:hover {
    background: var(--ink-soft);
    box-shadow: 0 5px 16px rgba(47, 74, 61, 0.28);
  }
}
.btn-upload:active { transform: scale(0.97); }
.btn-upload:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ════════════════════════════════════════
   其他保留樣式
   ════════════════════════════════════════ */

/* 小節標題 */
.section-label {
  display: block;
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

/* 欄位標籤 */
.field-label {
  display: block;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  margin-top: 12px;
  margin-bottom: 6px;
}
.output-label {
  font-size: 0.69rem;
  color: var(--muted);
  letter-spacing: 0.11em;
  font-weight: 500;
}

/* 輸入框通用 */
input[type="text"], textarea, select {
  width: 100%;
  background: var(--inner);
  color: var(--text);
  border: 1px solid var(--accent-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem; /* ≥16px 避免 iOS Safari 自動 zoom-in */
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--ink);
}
input::placeholder, textarea::placeholder {
  color: var(--muted);
}

/* Body Part Section（結果卡片中的部位區塊） */
.body-part-section {
  background: var(--inner);
  border-radius: var(--radius-sm);
  padding: 10px 14px 12px 20px;
  position: relative;
  transition: box-shadow 0.2s ease;
}
.body-part-section::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: var(--ink);
  border-radius: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .body-part-section:hover { box-shadow: var(--shadow); }
}
.body-part-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.body-part-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
}
.body-part-count {
  font-size: 0.72rem;
  color: var(--surface);
  font-weight: 600;
  background: var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
}
.acu-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 穴位 Card（chip 樣式） */
.acu-card {
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--accent-bg);
}
.acu-card-name { color: var(--text); }
.acu-card-qty {
  background: var(--accent-bg);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.72rem;
  color: var(--ink);
  font-weight: 600;
}

/* ════════════════════════════════════════
   傷科手法（療法）— 獨立視覺：填色膠囊 + 「手」印章
   與穴位的描邊膠囊明確區隔
   ════════════════════════════════════════ */
.therapy-section::before {
  background: linear-gradient(180deg, var(--rec), var(--ink-soft));
}
.therapy-section .body-part-name::before {
  content: '✦';
  margin-right: 5px;
  color: var(--rec);
  font-size: 0.72rem;
}
.therapy-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--surface);
  background: var(--rec);
  border-radius: 999px;
  padding: 1px 8px;
}

.treatment-card {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px 5px 6px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--surface);
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-soft) 100%);
  box-shadow: 0 2px 8px rgba(47, 74, 61, .22), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .treatment-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(47, 74, 61, .28), inset 0 1px 0 rgba(255, 255, 255, .12);
  }
}
.treatment-card-icon {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.treatment-card-name { color: var(--surface); }

/* 上傳分隔線（相容性保留） */
.upload-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  margin: 10px 0;
}

/* file input（相容性保留） */
input[type="file"] { display: none; }

/* ════════════════════════════════════════
   Loading overlay（保持原樣）
   ════════════════════════════════════════ */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ════════════════════════════════════════
   普通辨識步驟進度器
   ════════════════════════════════════════ */
#transcribe-stepper {
  display: flex;
  align-items: flex-start;
  padding: 14px 10px 12px;
  margin-bottom: 16px;
  background: var(--inner);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-bg);
}

.tstepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 58px;
}

.tstepper-connector {
  flex: 1;
  height: 2px;
  background: var(--accent-bg);
  margin-top: 19px;
  transition: background 0.4s ease;
  min-width: 8px;
  position: relative;
  overflow: hidden;
}

.tstepper-connector[data-done="1"] {
  background: var(--ink);
}

/* 連線流動動畫：緊接在 active step 前的那條 connector */
.tstepper-connector[data-active="1"] {
  background: var(--accent-bg);
}
.tstepper-connector[data-active="1"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--ink) 40%,
    var(--ink) 60%,
    transparent 100%
  );
  animation: tstepper-flow 1.1s linear infinite;
}
@keyframes tstepper-flow {
  from { transform: translateX(-100%); }
  to   { transform: translateX(200%); }
}

.tstepper-node-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tstepper-node {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 0.25s, color 0.25s;
  position: relative;
  z-index: 1;
}

.tstepper-label {
  font-size: 0.69rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.25s, font-weight 0.25s;
}

/* active */
.tstepper-step[data-state="active"] .tstepper-node {
  background: var(--ink);
  color: var(--surface);
}
.tstepper-step[data-state="active"] .tstepper-label {
  color: var(--ink);
  font-weight: 600;
}
/* glow 光暈 */
.tstepper-step[data-state="active"] .tstepper-node-wrap::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 74, 61, 0.18) 0%, transparent 70%);
  animation: tstepper-glow 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tstepper-glow {
  0%, 100% { opacity: 0.5; transform: scale(0.88); }
  50%       { opacity: 1;   transform: scale(1.1); }
}
/* spinning arc */
.tstepper-step[data-state="active"] .tstepper-node-wrap::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: var(--ink);
  border-right-color: var(--ink);
  animation: tstepper-arc-spin 0.85s linear infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes tstepper-arc-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* done */
.tstepper-step[data-state="done"] .tstepper-node {
  background: var(--ink);
  color: var(--surface);
  animation: tstepper-done-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes tstepper-done-pop {
  from { transform: scale(0.8); }
  to   { transform: scale(1); }
}
.tstepper-step[data-state="done"] .tstepper-node .tstepper-num { display: none; }
.tstepper-step[data-state="done"] .tstepper-node::after {
  content: '✓';
  font-size: 1rem;
  font-weight: 700;
  color: var(--surface);
}
.tstepper-step[data-state="done"] .tstepper-label {
  color: var(--ink);
}

/* error */
.tstepper-step[data-state="error"] .tstepper-node {
  background: var(--rec);
  color: #fff;
}
.tstepper-step[data-state="error"] .tstepper-node .tstepper-num { display: none; }
.tstepper-step[data-state="error"] .tstepper-node::after {
  content: '✕';
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}
.tstepper-step[data-state="error"] .tstepper-label {
  color: var(--rec);
  font-weight: 600;
}

/* ════════════════════════════════════════
   即時辨識波形圖
   ════════════════════════════════════════ */
#waveform-visualizer {
  display: flex;
  align-items: center;
  padding: 0 16px;
  margin-bottom: 16px;
  background: var(--inner);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-bg);
  height: 86px;
  overflow: hidden;
  transition: border-color 0.35s ease;
}
#waveform-visualizer.hidden { display: none; }
#waveform-visualizer.wf-active { border-color: var(--ink); }
#transcribe-stepper.hidden { display: none; }
#waveform-canvas {
  width: 100%;
  height: 54px;
  display: block;
}

/* ════════════════════════════════════════
   #transcribe-btn（隱藏狀態，保留樣式供 JS 控制）
   ════════════════════════════════════════ */
#transcribe-btn {
  background: var(--ink);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 6px 14px;
  transition: transform 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}
#transcribe-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
