/* ===== 設計系統 ===== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0f766e;
  --secondary-light: #ccfbf1;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-placeholder: #cbd5e1;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --warning-text: #92400e;
  --error-bg: #fee2e2;
  --error-border: #ef4444;
  --error-text: #991b1b;
  --info-bg: #dbeafe;
  --info-border: #3b82f6;
  --info-text: #1e40af;
  --success-bg: #d1fae5;
  --success-border: #10b981;
  --success-text: #065f46;
  --change-bg: #ede9fe;
  --change-border: #8b5cf6;
  --change-text: #5b21b6;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 150ms ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.header-nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.header-nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.header-nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--border-focus);
}

.header-nav-link[aria-current="page"] {
  color: var(--primary);
  background: var(--primary-light);
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.card-header .icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.card-body {
  padding: 20px;
}

/* ===== Action Panel ===== */
.action-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.action-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
}

.action-box:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.action-box:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}

.action-box .action-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform var(--transition);
}

.action-box:hover .action-icon {
  transform: scale(1.08);
}

.action-box.recording .action-icon {
  animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50% { box-shadow: 0 0 0 16px rgba(239,68,68,0); }
}

.action-icon.mic {
  background: #fef2f2;
  color: #ef4444;
}

.action-icon.upload {
  background: var(--primary-light);
  color: var(--primary);
}

.action-box h3 {
  font-size: 15px;
  font-weight: 600;
}

.action-box p {
  font-size: 13px;
  color: var(--text-muted);
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.recording-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #ef4444;
  font-weight: 500;
}

.recording-indicator.active {
  display: flex;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Pipeline Settings ===== */
.pipeline-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: end;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.setting-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition);
}

.setting-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mode-btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.mode-btn:not(:first-child) {
  border-left: 1px solid var(--border);
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

.mode-btn:hover:not(.active) {
  background: var(--bg);
}

/* ===== Pipeline Steps Card ===== */
.pipeline-card .card-header {
  gap: 10px;
}

.pipeline-audio-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
}

.pipeline-audio-status.ready {
  background: var(--success-bg);
  color: var(--success-text);
}

.pipeline-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.step-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.step-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}

.step-result {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}

.step-result.done {
  max-height: 400px;
  overflow-y: auto;
}

.step-result-text {
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.step-json {
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  background: #0f172a;
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.step-loading {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  animation: blink 1.2s ease-in-out infinite;
}

.step-error {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--error-text);
  background: var(--error-bg);
}

.pipeline-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ===== Performance Meta Bar ===== */
.perf-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.perf-chip {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===== Loading ===== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
}

.loading-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 48px 64px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-card h3 {
  font-size: 18px;
  font-weight: 600;
}

.loading-card p {
  font-size: 14px;
  color: var(--text-secondary);
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  width: 100%;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.loading-step.active {
  color: var(--primary);
  font-weight: 500;
}

.loading-step.done {
  color: var(--secondary);
}

.step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  transition: all var(--transition);
}

.loading-step.active .step-dot {
  border-color: var(--primary);
  background: var(--primary-light);
}

.loading-step.done .step-dot {
  border-color: var(--secondary);
  background: var(--secondary-light);
}

/* ===== Alerts ===== */
.alerts-section {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.alerts-section.active {
  display: flex;
}

.alert-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-group-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.alert-item {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  border-left: 3px solid;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-item.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.alert-item.change {
  background: var(--change-bg);
  border-color: var(--change-border);
  color: var(--change-text);
}

.alert-item.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

/* ===== Transcript ===== */
.transcript-section {
  display: none;
}

.transcript-section.active {
  display: block;
}

/* ===== History records ===== */
.history-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
}

.history-status.ready {
  background: var(--success-bg);
  color: var(--success-text);
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-upload-box {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition), background var(--transition);
}

.history-upload-box:hover,
.history-upload-box:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-light);
}

.history-upload-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: #eef2ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-upload-box h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.history-upload-box p {
  font-size: 13px;
  color: var(--text-muted);
}

.history-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12px;
}

.history-file-name {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.history-file-size {
  color: var(--text-muted);
  white-space: nowrap;
}

.history-file-remove {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.history-file-remove:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.history-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.history-select {
  min-width: 150px;
}

.history-select-wide {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 360px;
}

.history-meta {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1 1 100%;
}

.history-insight-section {
  display: none;
}

.history-insight-section.active {
  display: block;
}

.history-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.history-insight-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-height: 100%;
}

.history-insight-panel:nth-child(n+4) {
  grid-column: span 1;
}

.history-insight-head {
  min-height: 76px;
  padding: 12px 14px;
  border-left: 4px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-insight-kicker {
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.history-insight-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.history-insight-count {
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-insight-list {
  list-style: none;
  padding: 10px 14px 12px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.history-insight-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 9px;
  align-items: start;
}

.history-insight-item + .history-insight-item {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.history-insight-dot {
  width: 7px;
  height: 7px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.history-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.history-insight-baseline .history-insight-head { border-left-color: var(--secondary); background: #f0fdfa; }
.history-insight-baseline .history-insight-dot { background: var(--secondary); }
.history-insight-current .history-insight-head { border-left-color: var(--primary); background: #eff6ff; }
.history-insight-current .history-insight-dot { background: var(--primary); }
.history-insight-change .history-insight-head { border-left-color: #7c3aed; background: #f5f3ff; }
.history-insight-change .history-insight-dot { background: #7c3aed; }
.history-insight-focus .history-insight-head { border-left-color: var(--success-border); background: var(--success-bg); }
.history-insight-focus .history-insight-dot { background: var(--success-border); }
.history-insight-missing .history-insight-head { border-left-color: var(--warning-border); background: var(--warning-bg); }
.history-insight-missing .history-insight-dot { background: var(--warning-border); }
.history-insight-risk .history-insight-head { border-left-color: var(--error-border); background: var(--error-bg); }
.history-insight-risk .history-insight-dot { background: var(--error-border); }

.history-soapie {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-soapie-header {
  padding: 10px 14px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.history-soapie-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.history-soapie-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.history-soapie-item:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.history-soapie-item span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-soapie-item p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.history-source-note {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
}

/* ===== LINE 家屬通知 ===== */
.line-family-section {
  display: none;
}

.line-family-section.active {
  display: block;
}

.line-family-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  line-height: 1.55;
}

.line-family-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 14px;
}

.line-family-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.line-family-select {
  min-width: 140px;
}

.line-family-select-wide {
  min-width: 200px;
  flex: 1 1 200px;
  max-width: 320px;
}

.line-family-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  font-family: inherit;
  resize: vertical;
  min-height: 160px;
  margin-bottom: 12px;
}

.line-family-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.line-family-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.line-family-meta {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1 1 100%;
}

.line-family-audio {
  width: 100%;
  margin-top: 4px;
}

/* ===== Raw JSON output ===== */
.json-output-section {
  display: none;
}

.json-output-section.active {
  display: block;
}

.json-output-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.5;
}

.json-output-hint code {
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-primary);
}

.json-output-body {
  padding-top: 16px;
}

.json-output-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.json-output-pre {
  margin: 0;
  padding: 16px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  max-height: min(70vh, 520px);
  border: 1px solid #1e293b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.json-output-pre code {
  font-family: inherit;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  color: inherit;
}

.json-output-pre:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}

.transcript-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  margin-bottom: 12px;
}

.transcript-toggle:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.transcript-content {
  display: none;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.transcript-content.show {
  display: block;
}

.transcript-legend {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.transcript-correction {
  background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
  color: var(--text-primary);
  padding: 0 2px;
  border-radius: 3px;
  font-style: normal;
  font-weight: 600;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.transcript-correction:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.transcript-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.transcript-tab {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.transcript-tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.transcript-tab:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.transcript-tab:not(:first-child) { border-left: none; }

.transcript-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== SOAPIE ===== */
.soapie-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.soapie-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.soapie-card:hover {
  box-shadow: var(--shadow);
}

.soapie-label {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.soapie-label .letter {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.soapie-card[data-key="S"] .soapie-label { background: #fef3c7; color: #92400e; }
.soapie-card[data-key="S"] .letter { background: #f59e0b; }
.soapie-card[data-key="O"] .soapie-label { background: #dbeafe; color: #1e40af; }
.soapie-card[data-key="O"] .letter { background: #3b82f6; }
.soapie-card[data-key="A"] .soapie-label { background: #fce7f3; color: #9d174d; }
.soapie-card[data-key="A"] .letter { background: #ec4899; }
.soapie-card[data-key="P"] .soapie-label { background: #d1fae5; color: #065f46; }
.soapie-card[data-key="P"] .letter { background: #10b981; }
.soapie-card[data-key="I"] .soapie-label { background: #ede9fe; color: #5b21b6; }
.soapie-card[data-key="I"] .letter { background: #8b5cf6; }
.soapie-card[data-key="E"] .soapie-label { background: #e0e7ff; color: #3730a3; }
.soapie-card[data-key="E"] .letter { background: #6366f1; }

.soapie-card textarea {
  width: 100%;
  border: none;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
}

.soapie-card textarea:focus {
  outline: none;
  background: #fafbff;
}

/* ===== Modules Accordion ===== */
.modules-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.module-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.module-item:hover {
  box-shadow: var(--shadow-sm);
}

.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--surface);
  border: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: background var(--transition);
}

.module-header:hover {
  background: var(--bg);
}

.module-header:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.module-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.module-badge.A { background: #6366f1; }
.module-badge.B { background: #ef4444; }
.module-badge.C { background: #0ea5e9; }
.module-badge.D { background: #f97316; }
.module-badge.E { background: #eab308; }
.module-badge.F { background: #14b8a6; }
.module-badge.G { background: #ec4899; }
.module-badge.H { background: #8b5cf6; }
.module-badge.I { background: #06b6d4; }
.module-badge.J { background: #10b981; }

.module-title { flex: 1; }

.module-status {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
}

.module-status.has-data {
  background: var(--success-bg);
  color: var(--success-text);
}

.module-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.module-item.open .module-chevron {
  transform: rotate(180deg);
}

.module-body {
  display: none;
  padding: 0 16px 16px;
  background: var(--surface);
}

.module-item.open .module-body {
  display: block;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-item.full-width {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.field-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  line-height: 1.5;
}

.field-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.field-input.not-mentioned {
  color: var(--text-placeholder);
  font-style: italic;
}

.field-input.not-mentioned:focus {
  color: var(--text-primary);
  font-style: normal;
}

textarea.field-input {
  resize: vertical;
  min-height: 60px;
}

/* ===== Results hidden by default ===== */
.results-area {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.results-area.active {
  display: flex;
}

/* ===== Button ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .5;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-container { padding: 16px; }
  .action-panel { grid-template-columns: 1fr; }
  .soapie-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .pipeline-settings { grid-template-columns: 1fr; }
  .history-insight-grid { grid-template-columns: 1fr; }
  .history-insight-panel:nth-child(n+4) { grid-column: auto; }
  .history-soapie-grid { grid-template-columns: 1fr; }
  .history-soapie-item:nth-child(odd) { border-right: none; }
  .app-header { padding: 12px 16px; }
  .app-header h1 { font-size: 17px; }
  .action-box { padding: 24px 16px; }
  .loading-card { padding: 32px 24px; }
  .perf-meta-bar { flex-direction: column; }
}

@media (max-width: 480px) {
  .soapie-grid { gap: 12px; }
  .card-body { padding: 16px; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-placeholder); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Accessibility: reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
