/* =====================================================
 *  style.css — 移动优先、零成本 AI 口语 PWA
 *  清新可爱风（v2）
 *  配色：薄荷绿 + 蜜桃粉 + 奶油白
 *  圆角 24px，圆体字，软阴影
 * ===================================================== */

:root {
  /* 清新配色 */
  --bg:           #FFFCF5;          /* 奶油白背景 */
  --bg-2:         #FFF4E6;          /* 蜜桃渐变 */
  --surface:      #FFFFFF;
  --surface-2:    #FFF9F0;          /* 卡片柔背景 */
  --border:       rgba(125, 211, 192, 0.22);
  --border-hi:    rgba(125, 211, 192, 0.55);

  --text:         #2D3D3A;          /* 深墨绿文字 */
  --text-2:       #5F6F6B;
  --text-3:       #9AA8A4;

  /* 主色：薄荷绿 */
  --mint:         #7DD3C0;
  --mint-deep:    #4FB8A4;
  --mint-soft:    #D9F2EB;
  /* 强调：蜜桃粉 */
  --peach:        #FFB5C5;
  --peach-deep:   #FF8FA8;
  --peach-soft:   #FFE0E7;
  /* 点缀：奶油黄 */
  --cream:        #FFD89B;
  /* 点缀：天空蓝 */
  --sky:          #A8D8FF;

  --danger:       #E5607A;
  --warn-bg:      #FFF1D9;
  --warn-text:    #8A5A1F;
  --ok:           #4FB8A4;

  --radius-sm:    14px;
  --radius:       20px;
  --radius-lg:    28px;
  --shadow-sm:    0 2px 8px rgba(125, 211, 192, 0.12);
  --shadow:       0 8px 28px rgba(255, 181, 197, 0.18);
  --shadow-hover: 0 12px 36px rgba(125, 211, 192, 0.25);
  --tap:          44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #1A2624;
    --bg-2:         #243531;
    --surface:      #2A3A37;
    --surface-2:    #324540;
    --border:       rgba(125, 211, 192, 0.22);
    --border-hi:    rgba(125, 211, 192, 0.5);
    --text:         #F5F0E5;
    --text-2:       #C8D5D2;
    --text-3:       #8899A5;
    --mint-soft:    #1F3F38;
    --peach-soft:   #3D2A30;
    --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow:       0 8px 28px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 12px 36px rgba(125, 211, 192, 0.18);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei",
               "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== 背景渐变 + 浮动 blob ===== */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  z-index: -1;
  pointer-events: none;
}
body::before {
  width: 320px; height: 320px;
  background: var(--mint);
  top: -120px; left: -100px;
  animation: float-a 14s ease-in-out infinite;
}
body::after {
  width: 280px; height: 280px;
  background: var(--peach);
  bottom: -100px; right: -80px;
  animation: float-b 16s ease-in-out infinite;
}
@keyframes float-a { 50% { transform: translate(40px, 60px); } }
@keyframes float-b { 50% { transform: translate(-30px, -40px); } }

@media (prefers-color-scheme: dark) {
  body::before, body::after { opacity: 0.18; }
}

/* ===== 顶部 header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  background: transparent;
}
.app-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 800;
  letter-spacing: 0.5px;
}
.app-title .logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--mint) 0%, var(--peach) 100%);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.app-title .emoji {
  font-size: 26px;
}
.tab-bar {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.tab-bar button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s;
}
.tab-bar button.active {
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(125, 211, 192, 0.4);
}

/* ===== 主容器 ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 100px;
}

/* ===== 卡片通用 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:active { transform: scale(0.98); }

.section-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
  font-weight: 600;
}
.section-label .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--mint);
  display: inline-block;
}

/* ===== 输入区 ===== */
.input-wrap {
  position: relative;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 14px 14px 56px;
  transition: border-color 0.2s;
}
.input-wrap:focus-within {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px var(--mint-soft);
}
#inputText {
  width: 100%;
  min-height: 60px;
  border: none;
  background: transparent;
  resize: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  line-height: 1.6;
}
#inputText::placeholder { color: var(--text-3); }

.input-toolbar {
  position: absolute;
  bottom: 12px; left: 14px; right: 14px;
  display: flex; gap: 8px; align-items: center;
}
.tool-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text-2);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.tool-btn:active { transform: scale(0.9); }
.tool-btn.recording {
  background: linear-gradient(135deg, var(--peach) 0%, var(--peach-deep) 100%);
  color: white;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 143, 168, 0.5); }
  50%      { box-shadow: 0 0 0 12px rgba(255, 143, 168, 0); }
}
.spacer { flex: 1; }
.go-btn {
  border: none;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: white;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(125, 211, 192, 0.45);
  transition: all 0.2s;
}
.go-btn:active { transform: scale(0.95); }
.go-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Loading ===== */
.loading {
  display: none;
  text-align: center;
  padding: 24px;
  color: var(--text-2);
}
.loading.show { display: block; }
.loading-dots {
  display: inline-flex; gap: 6px; margin-bottom: 8px;
}
.loading-dots span {
  width: 10px; height: 10px;
  background: var(--mint);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.16s; background: var(--peach); }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; background: var(--cream); }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ===== 翻译结果卡 ===== */
.result-card {
  background: linear-gradient(160deg, var(--surface) 0%, var(--mint-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border-hi);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: '✨';
  position: absolute;
  top: 14px; right: 18px;
  font-size: 28px;
  animation: spin-slow 8s linear infinite;
}
@keyframes spin-slow { 50% { transform: rotate(15deg); } }

.lang-switch {
  display: inline-flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.lang-switch button {
  border: none;
  background: transparent;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s;
}
.lang-switch button.active {
  background: linear-gradient(135deg, var(--mint) 0%, var(--peach) 100%);
  color: white;
}

.result-text {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 12px;
  color: var(--text);
  word-wrap: break-word;
}
.result-zh {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
}
.word {
  cursor: pointer;
  border-radius: 6px;
  padding: 0 2px;
  transition: background 0.15s;
}
.word:hover { background: var(--mint-soft); }

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 4px;
}
.chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.chip:active {
  background: var(--mint-soft);
  border-color: var(--mint);
  transform: scale(0.97);
}

.tagline {
  display: inline-block;
  background: var(--peach-soft);
  color: var(--warn-text);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
}

/* ===== TTS 控制条 ===== */
.tts-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.voice-select, .speed-select {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: white;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(125, 211, 192, 0.4);
  transition: all 0.2s;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn.peach {
  background: linear-gradient(135deg, var(--peach) 0%, var(--peach-deep) 100%);
  box-shadow: 0 4px 12px rgba(255, 143, 168, 0.4);
}
.icon-btn.ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.icon-btn.heart.active { color: var(--peach-deep); }

/* ===== 词典弹窗 ===== */
.dict-modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 61, 58, 0.55);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in 0.2s;
}
.dict-modal.show { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.dict-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.dict-word {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.dict-phonetic {
  color: var(--mint-deep);
  font-size: 15px;
  margin: 4px 0 16px;
}
.dict-pos {
  display: inline-block;
  background: var(--mint-soft);
  color: var(--mint-deep);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}
.dict-def {
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  margin: 4px 0 12px;
}
.dict-example {
  font-style: italic;
  color: var(--text-2);
  border-left: 3px solid var(--peach);
  padding-left: 12px;
  margin: 4px 0;
  font-size: 14px;
}
.dict-loading { text-align: center; color: var(--text-2); padding: 16px; }
.dict-error { color: var(--danger); padding: 8px 0; }
.dict-actions {
  display: flex; gap: 8px; margin-top: 16px;
  justify-content: flex-end;
}

/* ===== 句子库 / 复习 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state .icon-big {
  font-size: 64px;
  margin-bottom: 12px;
  display: block;
  filter: grayscale(0.3);
}
.empty-state .hint { font-size: 14px; margin-top: 8px; }

.sentence-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.sentence-card .body { flex: 1; min-width: 0; }
.sentence-card .en {
  font-size: 16px; font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  word-wrap: break-word;
}
.sentence-card .zh {
  font-size: 13px; color: var(--text-2);
  margin: 0;
}
.sentence-card .meta {
  display: flex; gap: 8px;
  font-size: 12px; color: var(--text-3);
  margin-top: 6px;
}
.sentence-card .actions {
  display: flex; flex-direction: column; gap: 6px;
}
.sentence-card .icon-btn { width: 36px; height: 36px; font-size: 14px; }

.review-card {
  background: linear-gradient(160deg, var(--mint-soft) 0%, var(--peach-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  border: 1px solid var(--border-hi);
  box-shadow: var(--shadow);
}
.review-card .en {
  font-size: 24px; font-weight: 700;
  color: var(--text);
  margin: 12px 0;
  line-height: 1.5;
}
.review-card .zh { color: var(--text-2); margin: 0 0 16px; }
.score-bar {
  background: var(--surface);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  margin: 12px 0;
  position: relative;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint) 0%, var(--peach) 100%);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0;
}
.score-label {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: var(--text);
  color: var(--surface);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Footer 状态条 ===== */
.app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 12px 20px 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
}

/* ===== 工具：隐藏 ===== */
.hidden { display: none !important; }