/* ============================================================
   单词学习 · iPad 友好的大字号大按钮样式
   ============================================================ */

:root {
  --color-bg: #f3f4f6;
  --color-card: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-line: #e5e7eb;
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-success: #10b981;
  --color-success-dark: #059669;
  --color-success-bg: #d1fae5;
  --color-danger: #ef4444;
  --color-danger-dark: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-warn: #f59e0b;
  --color-warn-bg: #fef3c7;

  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);

  --font-size-base: 18px;
  --font-size-lg: 22px;
  --font-size-xl: 28px;
  --font-size-2xl: 40px;
  --font-size-3xl: 56px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Roboto, sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============ 视图切换 ============ */
.view {
  display: none;
  animation: fadeIn 0.2s ease-out;
}
.view--active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ 头部 ============ */
.header {
  text-align: center;
  margin-bottom: 24px;
}
.header__title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}
.header__subtitle {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--font-size-base);
}

/* ============ 卡片 ============ */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card--study {
  padding: 32px 24px;
}

/* ============ 统计 ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.stats__item {
  text-align: center;
  padding: 16px 8px;
  background: var(--color-bg);
  border-radius: var(--radius);
}
.stats__value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}
.stats__value--warn {
  color: var(--color-warn);
}
.stats__value--success {
  color: var(--color-success);
}
.stats__label {
  margin-top: 4px;
  font-size: 14px;
  color: var(--color-muted);
}

/* ============ 表单 ============ */
.form {
  margin-bottom: 24px;
}
.form__label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  flex: 1 1 80px;
  min-height: 56px;
  padding: 0 16px;
  border: 2px solid var(--color-line);
  background: var(--color-card);
  color: var(--color-text);
  border-radius: var(--radius);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}
.chip:active {
  transform: scale(0.97);
}
.chip--active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

/* ============ 按钮 ============ */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.actions--bottom {
  margin-top: 24px;
  position: sticky;
  bottom: 0;
  padding-bottom: 8px;
}
.actions--judge {
  flex-direction: row;
  gap: 14px;
}
.actions--judge .btn {
  flex: 1;
}

.btn {
  width: 100%;
  min-height: 64px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  font-family: inherit;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:not(:disabled):hover {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--color-muted);
}

.btn--success {
  background: var(--color-success);
  color: #fff;
}
.btn--success:not(:disabled):hover {
  background: var(--color-success-dark);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger:not(:disabled):hover {
  background: var(--color-danger-dark);
}

.btn-icon {
  width: 48px;
  height: 48px;
  border: none;
  background: var(--color-card);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text);
  touch-action: manipulation;
}
.btn-icon:active {
  transform: scale(0.95);
}

.hint {
  text-align: center;
  color: var(--color-muted);
  font-size: 14px;
  margin: 0;
}

.resume-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}
.resume-panel__text {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}
.actions--resume {
  margin-bottom: 0;
}

/* ============ 学习页 ============ */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.progress {
  flex: 1;
}
.progress__text {
  font-size: 14px;
  color: var(--color-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.progress__bar {
  height: 8px;
  background: var(--color-line);
  border-radius: 4px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.word {
  text-align: center;
  padding: 20px 0 28px;
}
.word__pos {
  display: inline-block;
  min-height: 24px;
  padding: 2px 12px;
  background: var(--color-bg);
  color: var(--color-muted);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.word__pos:empty {
  display: none;
}
.word__text {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.15;
  word-break: break-word;
  margin-bottom: 8px;
}
.word__phonetic {
  font-size: var(--font-size-lg);
  color: var(--color-muted);
  font-family: "Times New Roman", Georgia, serif;
  font-style: italic;
  min-height: 28px;
}
.word__phonetic:empty::before {
  content: " ";
}

/* ============ 闪卡释义区 ============ */
.card-answer {
  border-top: 2px dashed var(--color-line);
  margin: 0 -24px;
  padding: 24px 24px 8px;
  animation: revealAnswer 0.25s ease-out;
}
@keyframes revealAnswer {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-answer__meaning {
  text-align: center;
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.5;
  padding: 8px 0 16px;
}

/* ============ 结果页 ============ */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--color-line);
  margin-bottom: 24px;
}
.summary__item {
  text-align: center;
  padding: 12px 4px;
}
.summary__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}
.summary__value--success {
  color: var(--color-success);
}
.summary__value--warn {
  color: var(--color-warn);
}
.summary__label {
  margin-top: 6px;
  font-size: 14px;
  color: var(--color-muted);
}

.summary-extra {
  text-align: center;
  margin-bottom: 24px;
}
.summary-extra__line {
  margin: 0;
  font-size: var(--font-size-base);
  color: var(--color-muted);
}
.summary-extra__line strong {
  color: var(--color-text);
  font-weight: 700;
}

/* ============ 加载/错误覆盖层 ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.overlay--hidden {
  display: none;
}
.overlay__box {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  font-size: var(--font-size-base);
  box-shadow: var(--shadow-lg);
  max-width: 80%;
  text-align: center;
}

/* ============ 大屏 / iPad 横屏微调 ============ */
@media (min-width: 768px) {
  .app {
    padding: 40px 24px 60px;
  }
  .word__text {
    font-size: 64px;
  }
  .card-answer__meaning {
    font-size: 32px;
  }
  .actions--judge .btn {
    min-height: 72px;
    font-size: 24px;
  }
}

.app-footer {
  text-align: center;
  padding: 24px 0 12px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  letter-spacing: 0.5px;
}

@media (max-width: 380px) {
  :root {
    --font-size-base: 16px;
    --font-size-lg: 19px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;
    --font-size-3xl: 42px;
  }
}
