/* ============================================
   辅助沟通页面样式 (Accessibility Communication)
   大字字幕 + 手写留言板 + 图片导出
   深色主题，高对比度，适合老人/平板使用
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0a0a15;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --text-muted: #666688;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --accent-dim: #0288d1;
  --danger: #ef5350;
  --success: #66bb6a;
  --warn: #ffa726;
  --border: #2a2a4a;
  --border-active: #3a3a6a;
  --radius: 12px;
  --radius-sm: 8px;
  --font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ========== 页面容器 ========== */

.page-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== 头部 ========== */

.page-header {
  text-align: center;
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-header .subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ========== 状态栏 ========== */

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  align-items: center;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-label {
  color: var(--text-muted);
  white-space: nowrap;
}

.status-value {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status-ok {
  color: var(--success);
  background: rgba(102, 187, 106, 0.15);
}

.status-warn {
  color: var(--warn);
  background: rgba(255, 167, 38, 0.15);
}

.status-error {
  color: var(--danger);
  background: rgba(239, 83, 80, 0.15);
}

.status-idle {
  color: var(--text-muted);
  background: rgba(102, 102, 136, 0.15);
}

.status-caption-detail {
  width: 100%;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  line-height: 1.5;
}

.status-model-info {
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0 0;
}

/* ========== 字幕区 ========== */

.caption-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.caption-main {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  border: 2px solid var(--border);
  transition: border-color 0.3s;
}

.caption-main.listening {
  border-color: var(--accent);
}

.caption-final {
  font-size: 64px;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  color: var(--text-primary);
  min-height: 1.3em;
  width: 100%;
}

.caption-interim {
  font-size: 36px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 8px;
  display: none;
  width: 100%;
}

.caption-placeholder {
  font-size: 24px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* 历史字幕 */
.caption-history-section {
  margin-top: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.caption-history-section h3 {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.caption-history-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px 16px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.history-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.5);
}

.history-item:last-child {
  border-bottom: none;
}

/* ========== 工具栏 ========== */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--border-active);
  border-color: var(--border-active);
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 83, 80, 0.15);
  border-color: var(--danger);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-large {
  padding: 14px 28px;
  font-size: 18px;
  border-radius: var(--radius);
}

.font-size-display {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 48px;
  text-align: center;
}

/* ========== 手写区 ========== */

.handwriting-section {
  display: none;
  margin-top: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  overflow: hidden;
}

.handwriting-section h3 {
  font-size: 14px;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

/* 手写输出区 */
.handwriting-output-wrap {
  position: relative;
  border-bottom: 1px solid var(--border);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 手写输出 canvas 宽度100%，高度由 JS 动态控制 */
#handwriting-output {
  width: 100%;
  min-height: 120px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  display: block;
}

/* 回到最新按钮 */
.btn-back-to-latest {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--font-family);
  background: rgba(79, 195, 247, 0.9);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 10;
  transition: background 0.2s;
}
.btn-back-to-latest:hover {
  background: rgba(79, 195, 247, 1);
}

/* 手写输入区 */
.handwriting-input-wrap {
  padding: 0;
}

#handwriting-input {
  width: 100%;
  height: 280px;
  background: var(--bg-input);
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* 手写设置 */
.handwriting-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.handwriting-settings label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.handwriting-settings select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
}

/* ========== 手写开关大按钮 ========== */

.btn-toggle-handwriting {
  display: block;
  width: 100%;
  padding: 18px;
  margin-top: 16px;
  font-size: 22px;
  font-weight: 700;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

.btn-toggle-handwriting:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79, 195, 247, 0.05);
}

.btn-toggle-handwriting.active {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79, 195, 247, 0.1);
}

/* ========== Toast ========== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  animation: toast-in 0.3s ease;
  pointer-events: none;
}

.toast-success {
  background: rgba(102, 187, 106, 0.9);
  color: #fff;
}

.toast-error {
  background: rgba(239, 83, 80, 0.9);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ========== 响应式 ========== */

@media (max-width: 640px) {
  .page-container {
    padding: 8px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .caption-main {
    padding: 16px;
    min-height: 140px;
  }

  .caption-final {
    font-size: 48px;
  }

  .caption-interim {
    font-size: 28px;
  }

  .toolbar {
    gap: 4px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .btn-large {
    padding: 12px 20px;
    font-size: 16px;
  }

  .status-bar {
    font-size: 11px;
    gap: 8px;
    padding: 8px 12px;
  }

  #handwriting-input {
    height: 200px;
  }

  .handwriting-output-wrap {
    max-height: 160px;
  }

  .handwriting-settings {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (min-width: 1200px) {
  .page-container {
    max-width: 1100px;
  }

  .caption-final {
    font-size: 80px;
  }
}

/* 全屏模式 */
:fullscreen .page-container {
  max-width: 100%;
  padding: 24px;
}

:fullscreen .caption-final {
  font-size: 96px;
}