/* ===== 基础重置 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #e86a58;
  --color-primary-dark: #d45543;
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2c2c2c;
  --color-text-secondary: #888888;
  --color-border: #e8e4df;
  --color-highlight: #fff3e0;
  --color-current: #ffe0b2;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 40px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 标题栏 ===== */
.header {
  background: linear-gradient(135deg, var(--color-primary), #f08a7a);
  color: #fff;
  padding: 20px 24px 18px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(232, 106, 88, 0.2);
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-tag {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 2px;
  display: block;
}

/* ===== 容器 ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== 输入区 ===== */
.input-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.input-hint {
  text-align: center;
  padding: 8px 0;
  margin-bottom: 12px;
}

/* ===== 输入方式切换卡片 ===== */
.input-methods {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.method-card {
  flex: 1;
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.method-card:active {
  border-color: var(--color-primary);
}

.method-card-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.method-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.method-card-desc {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.3;
}

.btn-upload {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
}

.hidden-input {
  display: none;
}

.ocr-progress {
  font-size: 0.78rem;
  color: var(--color-primary);
  margin-top: 6px;
}

.method-divider-v {
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
  font-size: 0.78rem;
}

.method-divider-v span {
  white-space: nowrap;
}

.method-card-hint {
  font-size: 0.7rem;
  color: var(--color-primary);
  margin-top: 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hint-text {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.hint-text code {
  background: #f0ede8;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.78rem;
}

.text-input {
  width: 100%;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  color: var(--color-text);
  background: #fdfdfd;
  transition: border-color 0.2s;
  min-height: 160px;
}

.text-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.text-input::placeholder {
  color: #c0c0c0;
}

.char-count {
  text-align: right;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
  margin-bottom: 4px;
}

/* ===== 按钮 ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--color-primary), #f08a7a);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 1px;
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.hint-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--color-primary);
  border-radius: 18px;
  font-size: 0.82rem;
  color: var(--color-primary);
  cursor: pointer;
}

/* ===== 剪贴板检测 ===== */
.clipboard-banner {
  background: linear-gradient(135deg, var(--color-primary), #f08a7a);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(232, 106, 88, 0.25);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.banner-text {
  font-size: 0.88rem;
  font-weight: 500;
  flex: 1;
}

.banner-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== 操作指南 ===== */
.guide-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.guide-close {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-body {
  padding: 14px 16px;
}

.method-box {
  margin-bottom: 8px;
}

.method-box.primary {
  background: #fff8f0;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 12px;
}

.method-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text);
}

.method-steps {
  font-size: 0.82rem;
  color: #555;
  line-height: 1.8;
}

.method-steps code {
  background: #f0ede8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
}

.method-steps strong {
  color: #333;
}

.copy-code-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--color-primary), #f08a7a);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}

.method-divider {
  text-align: center;
  margin: 10px 0;
  position: relative;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.method-divider::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--color-border);
}

.method-divider::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--color-border);
}

.method-divider span {
  background: var(--color-surface);
  padding: 0 8px;
  position: relative;
  z-index: 1;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 8px;
}

/* ===== 播放区 ===== */
.player-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.article-info {
  padding: 16px 20px 8px;
}

.article-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
}

.article-meta {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.text-display {
  padding: 8px 20px 16px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.8;
  color: #555;
}

.text-display p {
  padding: 6px 10px;
  margin: 2px 0;
  border-radius: 6px;
  transition: background 0.3s;
}

.text-display p.current {
  background: var(--color-current);
  color: #333;
  font-weight: 500;
}

/* ===== 播放控制器 ===== */
.player-controls {
  background: #fcfcfc;
  border-top: 1px solid var(--color-border);
  padding: 16px 20px 20px;
}

/* 进度条 */
.progress-bar {
  position: relative;
  height: 6px;
  background: #e8e4df;
  border-radius: 3px;
  margin-bottom: 6px;
  cursor: pointer;
  touch-action: none;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--color-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: left 0.1s linear;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  margin-bottom: 14px;
}

.control-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  margin-bottom: 14px;
}

.btn-control {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.btn-control:active {
  background: #f0f0f0;
}

.btn-play {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(232, 106, 88, 0.35);
  transition: transform 0.1s;
}

.btn-play:active {
  transform: scale(0.95);
}

/* 倍速 */
.speed-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.speed-label {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-right: 4px;
}

.speed-btn {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}

.speed-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ===== 加载状态 ===== */
.loading {
  text-align: center;
  padding: 40px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loadingText {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
}

.loading-progress {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* ===== 设置区 ===== */
.settings-section {
  margin-bottom: 16px;
}

.settings-toggle {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-align: center;
}

.settings-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-row select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: var(--color-text);
}

/* ===== 通用工具 ===== */
.hidden {
  display: none !important;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .header {
    padding: 14px 16px 12px;
  }
  .header-title {
    font-size: 1.3rem;
  }
  .container {
    padding: 12px;
  }
  .text-display {
    max-height: 220px;
  }
}
