/* ===== hoc-tieng-viet 學越南文 — 主樣式 ===== */
/* 大字體優先、易讀、長時間學習友善 */

:root {
  --base-font-size: 22px;
  --pri: #E85A8A;       /* 主色：越南紅粉 */
  --pri-dark: #c14572;
  --pri-light: #ffe0eb;
  --accent: #FFB400;    /* 越南黃 */
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --text-dim: #999;
  --border: #e5e5e5;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius: 16px;
  --radius-lg: 24px;
}

[data-theme="dark"] {
  --bg: #1a1a1f;
  --bg-card: #25252d;
  --text: #f0f0f0;
  --text-muted: #aaa;
  --text-dim: #777;
  --border: #38383f;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
  --pri-light: #4a2235;
}

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

html { font-size: var(--base-font-size); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC",
               "Hiragino Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 80px;
  transition: background .3s, color .3s;
}

.hidden { display: none !important; }

/* ===== Splash ===== */
.splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ff6b9d, #ffb400);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeOut .5s ease 1.2s forwards;
}
.splash-inner { text-align: center; color: #fff; }
.splash-flag { font-size: 80px; margin-bottom: 16px; animation: bounce 1s; }
.splash-inner h1 { font-size: 2.2rem; margin-bottom: 8px; }
.splash-inner p { font-size: 1.4rem; opacity: .9; }
@keyframes fadeOut { to { opacity: 0; pointer-events: none; } }
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

/* ===== View 結構 ===== */
.view { min-height: 100vh; }
.view.fullscreen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
  padding-bottom: 32px;
}
#lesson-view { z-index: 120; }
#topic-detail-view { z-index: 110; }

/* ===== 登入 ===== */
.login-card {
  max-width: 480px;
  margin: 80px auto 0;
  padding: 32px 24px;
  text-align: center;
}
.logo { font-size: 2.2rem; margin-bottom: 4px; color: var(--pri); }
.logo-sub { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 24px; }
.login-intro { font-size: 1rem; color: var(--text-muted); margin-bottom: 24px; }
.login-note { font-size: .85rem; color: var(--text-dim); margin-top: 16px; }

.big-input {
  display: block;
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  margin-bottom: 12px;
  transition: border .2s;
}
.big-input:focus {
  outline: none;
  border-color: var(--pri);
}

/* ===== 頂部列 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  gap: 12px;
  box-shadow: var(--shadow);
}
.topbar-title {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 8px;
  transition: background .15s;
}
.icon-btn:hover { background: var(--pri-light); }
.lesson-progress {
  background: var(--pri-light);
  color: var(--pri-dark);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 600;
}

/* ===== Tab 切換 ===== */
.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 8px rgba(0,0,0,.04);
}
.tab {
  flex: 1;
  padding: 12px 4px;
  background: none;
  border: none;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: color .15s;
}
.tab.active { color: var(--pri); font-weight: 700; }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px;
  box-shadow: var(--shadow);
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--pri), #ff8a5b);
  color: #fff;
  padding: 32px 24px;
  text-align: center;
}
.hero-greeting { font-size: 2.4rem; font-weight: 700; margin-bottom: 8px; }
.hero-subtitle { font-size: 1.05rem; opacity: .95; }

/* ===== 今日金句 ===== */
.daily-card { margin-top: -16px; position: relative; z-index: 2; }
.card-label {
  display: inline-block;
  background: var(--pri-light);
  color: var(--pri-dark);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.big-vi {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--pri);
  margin-bottom: 4px;
  line-height: 1.4;
}
.ipa {
  font-size: 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
}
.big-zh {
  font-size: 1.3rem;
  margin-bottom: 4px;
  line-height: 1.5;
}
.big-en {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.daily-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}
.btn-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--pri-light);
  background: var(--bg-card);
  color: var(--pri);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, background .15s;
}
.btn-circle:active { transform: scale(.92); }
.btn-circle:hover { background: var(--pri-light); }

.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--pri-light);
  font-size: .95rem;
  color: var(--pri-dark);
  text-align: center;
  display: none;
}
.feedback.show { display: block; }

/* ===== 統計 ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px;
  margin-top: 16px;
}
.stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--pri); }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== 區塊標題 ===== */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 24px 16px 8px;
  color: var(--text);
}

/* ===== 主題卡片 ===== */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px;
}
.topic-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.topic-card:active { transform: scale(.97); }
.topic-card:hover { box-shadow: var(--shadow-lg); }
.topic-icon { font-size: 2.4rem; margin-bottom: 8px; }
.topic-name-vi { font-size: 1.1rem; font-weight: 700; color: var(--pri); margin-bottom: 2px; }
.topic-name-zh { font-size: 1rem; color: var(--text); margin-bottom: 8px; }
.topic-desc { font-size: .8rem; color: var(--text-muted); }

/* ===== 課程列表 ===== */
.lesson-list { padding: 16px; }
.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s;
  display: flex;
  align-items: center;
  gap: 16px;
}
.lesson-card:active { transform: scale(.97); }
.lesson-card-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pri-light);
  color: var(--pri-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.lesson-card-info { flex: 1; }
.lesson-card-title-vi {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--pri);
  margin-bottom: 2px;
}
.lesson-card-title-zh {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 4px;
}
.lesson-card-desc {
  font-size: .85rem;
  color: var(--text-muted);
}
.lesson-card-meta {
  font-size: .8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== 學習頁（句子卡）===== */
.lesson-intro {
  background: var(--pri-light);
  color: var(--pri-dark);
  font-size: .95rem;
  margin: 12px 16px;
}

.phrase-card-area {
  padding: 16px;
}
.phrase-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 3px solid var(--pri-light);
}
.phrase-category {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--pri-light);
  color: var(--pri-dark);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 8px;
  margin: 0 auto 16px;
  font-weight: 600;
}
.phrase-vi {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--pri);
  margin-bottom: 8px;
  line-height: 1.3;
  word-break: break-word;
}
.phrase-ipa {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 16px;
}
.phrase-zh {
  font-size: 1.5rem;
  margin-bottom: 4px;
  font-weight: 500;
}
.phrase-en {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.phrase-context {
  font-size: .9rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 12px;
  margin-top: 12px;
  text-align: left;
}
.phrase-context::before { content: '💡 '; }
.phrase-context:empty { display: none; }
.phrase-grammar {
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: 6px;
}
.phrase-grammar::before { content: '📝 '; }
.phrase-grammar:empty { display: none; }
.phrase-example {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 12px;
  text-align: left;
  font-size: .9rem;
}

/* ===== 學習動作鈕（大、易點）===== */
.phrase-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 12px;
  padding: 0 16px;
  margin: 16px 0;
}
.action-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .15s;
  color: var(--text);
}
.action-btn:active { transform: scale(.95); }
.action-btn.primary {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}
.action-btn.recording {
  background: #ff4444;
  color: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,68,68,.5); }
  50% { box-shadow: 0 0 0 12px rgba(255,68,68,0); }
}
.action-icon { font-size: 1.8rem; }
.action-label { font-size: .8rem; font-weight: 600; }

.record-feedback {
  margin: 0 16px 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}
.record-feedback .score {
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}
.record-feedback .score.good { color: #4caf50; }
.record-feedback .score.mid { color: #ff9800; }
.record-feedback .score.bad { color: #f44336; }
.record-feedback .transcript {
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
  font-size: 1rem;
  margin: 8px 0;
}
.record-feedback .fb-text {
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted);
}

/* ===== 上一句下一句 ===== */
.phrase-nav {
  display: flex;
  gap: 12px;
  padding: 0 16px 32px;
}
.nav-btn {
  flex: 1;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: transform .15s;
}
.nav-btn:active { transform: scale(.97); }
.nav-btn.primary {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 旅遊景點 ===== */
.city-switch {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 12px;
}
.city-btn {
  flex: 1;
  padding: 12px;
  border-radius: 24px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: .95rem;
}
.city-btn.active {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}

.attractions { padding: 0 16px 32px; }
.attraction-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.attraction-img {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, #f8a5c2, #ffb88c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: rgba(255,255,255,.5);
}
.attraction-img img { width: 100%; height: 100%; object-fit: cover; }
.attraction-info { padding: 16px; }
.attraction-name-vi {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--pri);
  margin-bottom: 2px;
}
.attraction-name-zh { font-size: 1.1rem; margin-bottom: 8px; }
.attraction-desc { font-size: .95rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.attraction-tips {
  font-size: .85rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 12px;
  margin-top: 8px;
}
.attraction-tips::before { content: '💡 '; }
.attraction-play-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--pri-light);
  color: var(--pri-dark);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

/* ===== 收藏列表 ===== */
.phrase-list { padding: 0 16px 32px; }
.phrase-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.phrase-item-vi {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--pri);
  margin-bottom: 4px;
}
.phrase-item-zh { font-size: 1.05rem; margin-bottom: 8px; }
.phrase-item-actions { display: flex; gap: 8px; }

/* ===== 個人頁 ===== */
.me-card { text-align: center; }
.me-name { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.me-email { color: var(--text-muted); margin-bottom: 16px; }

/* ===== 按鈕 ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--pri);
  color: #fff;
  border: none;
  cursor: pointer;
  margin-top: 8px;
  transition: transform .15s;
}
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--pri);
  border: 2px solid var(--pri);
  cursor: pointer;
  transition: transform .15s;
}
.btn-secondary:active { transform: scale(.98); }

/* ===== 設定 Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { flex: 1; font-size: 1.2rem; }
.modal-body { padding: 20px; padding-bottom: 60px; }

.setting-group {
  margin-bottom: 28px;
}
.setting-label {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}
.seg-control {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.seg-btn {
  flex: 1;
  min-width: 80px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  transition: all .15s;
}
.seg-btn.active {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  font-size: 1rem;
}
.checkbox-row input[type=checkbox] {
  width: 20px; height: 20px; accent-color: var(--pri);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: .95rem;
  z-index: 300;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== 適配 PC ===== */
@media (min-width: 768px) {
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(3, 1fr); max-width: 720px; margin-left: auto; margin-right: auto; }
  .card, .attraction-card, .lesson-card, .phrase-item { max-width: 720px; margin-left: auto; margin-right: auto; }
  .lesson-card { margin-bottom: 12px; }
  .phrase-card { max-width: 720px; margin: 0 auto; }
  .phrase-actions, .phrase-nav { max-width: 720px; margin-left: auto; margin-right: auto; }
}
