/* ABOUTME: 语文听写小助手样式表 */
/* ABOUTME: 简洁工具风格：浅灰底、白卡、深色正文、单一主色蓝，规范见 DESIGN.md */

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

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2329;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --warn-ink: #b45309;
  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
}

/* ================= 整体布局 ================= */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.app-header {
  text-align: center;
  padding-top: 8px;
}

.logo-badge {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-badge svg {
  width: 24px;
  height: 24px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-top: 4px;
}

.app-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

/* ================= 屏幕切换 ================= */
.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.screen.is-active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ================= 卡片 ================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow-card);
}

.card-flat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: 12px;
}

/* ================= 按钮 ================= */
.btn {
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1rem;
  padding: 0.65em 1.4em;
  color: var(--ink);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

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

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

.btn-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

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

.btn-ghost {
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.btn-xl {
  width: 100%;
  font-size: 1.2rem;
  font-weight: 500;
  padding: 0.75em 1em;
  margin-top: 16px;
}

.btn-sm {
  font-size: 0.88rem;
  padding: 0.4em 1em;
}

.btn svg {
  width: 1.05em;
  height: 1.05em;
}

/* ================= 配置屏 ================= */
#wordInput {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#wordInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#wordInput.shake {
  animation: shake 0.4s ease;
  border-color: #dc2626;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
}

.config-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.word-count {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.config-tools {
  display: flex;
  gap: 4px;
}

.support-note {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.tip {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ================= 进度区 ================= */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-text {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4em;
  font-size: 1.05rem;
}

.progress-text strong {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary);
  padding: 0 0.1em;
}

.divider {
  color: var(--ink-soft);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}

/* ================= 状态指示 ================= */
.status-pill {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4em 1.1em;
  font-size: 0.95rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-soft);
  flex: none;
}

.status-pill.status-speaking .status-dot {
  background: var(--primary);
}

.status-pill.status-waiting .status-dot {
  background: var(--success);
  animation: blink 1.4s ease-in-out infinite;
}

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

/* ================= 词语卡片 ================= */
.word-card {
  text-align: center;
  padding: 28px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.word-label {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.current-word {
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.06em;
  color: var(--ink);
  word-break: break-all;
  transition: filter 0.2s ease;
}

.current-word.is-hidden {
  filter: blur(16px);
  user-select: none;
}

.toggle-word {
  margin-top: 6px;
}

/* ================= 监听指示 ================= */
.listening-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  border-radius: var(--radius);
  padding: 12px 16px;
  color: #1e40af;
  font-size: 0.98rem;
}

.mic-pulse {
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-pulse svg {
  width: 22px;
  height: 22px;
}

.mic-pulse::before,
.mic-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: ripple 1.8s ease-out infinite;
}

.mic-pulse::after {
  animation-delay: 0.9s;
}

@keyframes ripple {
  from {
    transform: scale(1);
    opacity: 0.6;
  }
  to {
    transform: scale(1.7);
    opacity: 0;
  }
}

.mic-notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  font-size: 0.92rem;
}

/* ================= 控制按钮区 ================= */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.controls .btn {
  flex: 1 1 140px;
  max-width: 210px;
  font-size: 1.05rem;
  padding: 0.7em 1em;
}

/* ================= 已完成面板 ================= */
.done-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.done-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.done-head h3 {
  font-size: 1rem;
  font-weight: 600;
}

.done-head .remain {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.done-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.done-list li {
  background: #f3f4f6;
  color: #374151;
  border-radius: 6px;
  padding: 0.25em 0.8em;
  font-size: 0.95rem;
}

.done-list li.empty {
  background: transparent;
  color: var(--ink-soft);
}

/* ================= 完成屏 ================= */
.done-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 22px;
}

.done-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-badge svg {
  width: 32px;
  height: 32px;
}

.done-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.done-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.review-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 10px 0 6px;
}

.review-list li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4em 0.9em;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}

.review-list .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.78em;
}

.done-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* ================= 语音引擎徽标 ================= */
.engine-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5em;
  padding: 0.1em 0.6em;
  border-radius: 4px;
  font-size: 0.75rem;
  vertical-align: middle;
}

.engine-badge.engine-ai {
  background: var(--primary-soft);
  color: var(--primary);
}

.engine-badge.engine-system,
.engine-badge.engine-checking {
  background: #f3f4f6;
  color: var(--ink-soft);
}

/* ================= 小屏适配 ================= */
@media (max-width: 420px) {
  .controls .btn {
    flex: 1 1 100%;
    max-width: none;
  }
}
