/* ===== TiếngHàn.TV — Design System (cảm hứng Taegeukgi) ===== */
:root {
  --primary: #4f46e5;       /* Xanh dương hoàng gia */
  --primary-dark: #3730a3;  /* Xanh chuẩn cờ Hàn Quốc */
  --accent: #f59e0b;        /* Đỏ */
  --bg: #ffffff;
  --surface: #f4f5f7;       /* Xám nhạt */
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', 'Poppins', system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.ko, .ko-tokens, .reading .sentence, [lang='ko'] { font-family: 'Poppins', 'Inter', sans-serif; }

a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.empty { padding: 1.5rem 0; text-align: center; }

/* ---- Layout ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-family: 'Poppins', sans-serif; font-size: 1rem;
}
.brand-name { font-size: 1.05rem; }
.brand-name .dot { color: var(--accent); }
.level-badge {
  background: var(--accent); color: #fff;
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.level-badge.sm { padding: 2px 8px; font-size: .7rem; }
.pos-tag { color: var(--muted); font-size: .8rem; margin-left: 6px; }

.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--surface); }
.btn-lg { padding: 14px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---- Landing / Hero ---- */
.hero { text-align: center; padding: 32px 0 24px; }
.hero-mark {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 16px;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-family: 'Poppins', sans-serif; font-size: 2rem;
  box-shadow: var(--shadow);
}
.hero h1 { font-size: 1.9rem; line-height: 1.3; }
.hero h1 em { color: var(--accent); font-style: normal; }
.lead { color: var(--muted); max-width: 520px; margin: 12px auto 24px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; gap: 12px; margin-top: 32px; }
.feature-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.feature-card span { font-size: 1.6rem; }
.feature-card h3 { margin: 8px 0 4px; font-size: 1rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: .9rem; }
@media (min-width: 640px) { .features { grid-template-columns: repeat(3, 1fr); } }

/* ---- Auth ---- */
.auth-card, .onboarding, .dash, .diary, .profile-page, .vocab-page, .history-page, .result, .notfound {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.form { display: grid; gap: 14px; margin-top: 12px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: .9rem; }
input, select, textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
input:disabled { background: var(--surface); color: var(--muted); }
.auth-switch { text-align: center; margin-top: 16px; color: var(--muted); }
.alert { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-size: .9rem; }
.alert-error { background: #fdecef; color: var(--accent); border: 1px solid #f6c6cf; }

/* ---- Onboarding ---- */
.level-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
@media (min-width: 560px) { .level-grid { grid-template-columns: repeat(3, 1fr); } }
.level-card {
  text-align: left; background: #fff; border: 2px solid var(--border);
  border-radius: 12px; padding: 12px; cursor: pointer; display: grid; gap: 4px;
}
.level-card .lv-badge { color: var(--accent); font-weight: 700; font-size: .82rem; }
.level-card .lv-group { font-weight: 600; }
.level-card .lv-desc { color: var(--muted); font-size: .8rem; }
.level-card.selected { border-color: var(--primary); background: #eef2ff; }

/* ---- Dashboard ---- */
.greet { margin-bottom: 16px; }
.cta-card {
  display: flex; align-items: center; gap: 14px; padding: 18px;
  background: var(--primary); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
}
.cta-card:hover { background: var(--primary-dark); }
.cta-ic { font-size: 1.8rem; }
.cta-card strong { display: block; }
.cta-card small { opacity: .85; font-size: .85rem; }
.cta-arrow { margin-left: auto; font-size: 1.4rem; }
.quick-link {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-top: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.quick-link:hover { border-color: var(--primary); }
.quick-link > span:first-child { font-family: 'Poppins', sans-serif; font-size: 1.5rem; color: var(--primary); }
.quick-link strong { display: block; }
.quick-link small { color: var(--muted); font-size: .82rem; }
.hero-sub { margin-top: 16px; }
.hero-sub a { font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: var(--surface); border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; color: var(--primary); }
.stat span { font-size: .78rem; color: var(--muted); }
.section-title { margin: 20px 0 10px; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lesson-list a {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 12px 14px; background: var(--surface); border-radius: 10px; color: var(--text);
}
.lesson-snippet { flex: 1; }
.lesson-meta { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ---- Diary ---- */
.diary textarea { min-height: 160px; resize: vertical; }
.diary-controls { display: flex; align-items: center; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.diary-controls label { display: flex; align-items: center; gap: 8px; }
.diary-controls select { width: auto; }
.diary-controls .btn { margin-left: auto; }
.topic-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: .82rem; cursor: pointer; color: var(--text);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.loading { text-align: center; padding: 30px 0; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--surface); border-top-color: var(--primary); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Result / Reading ---- */
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.back { color: var(--muted); }
.reading { display: grid; gap: 18px; }
.sentence { border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.ko-line { display: flex; align-items: flex-start; gap: 8px; }
.ko-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.word {
  font-family: 'Poppins', sans-serif; font-size: 1.35rem; line-height: 1.9;
  background: transparent; border: none; border-bottom: 2px dotted var(--border);
  padding: 0 2px; cursor: pointer; color: var(--text);
}
.word:hover { color: var(--primary); border-bottom-color: var(--primary); }
.listen-sentence {
  flex: none; background: var(--surface); border: none; border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer; font-size: 1rem; margin-top: 6px;
}
.toggle-vi { background: none; border: none; color: var(--primary); font-size: .82rem; cursor: pointer; padding: 6px 0; }
.vi-line { margin: 4px 0 0; color: var(--muted); }

/* ---- Bottom sheet (popup từ) ---- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #fff; border-radius: 20px 20px 0 0; padding: 18px 20px 26px;
  max-width: 720px; margin: 0 auto; box-shadow: var(--shadow-lg);
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 14px; }
.sheet-word-row { display: flex; align-items: center; gap: 10px; }
.sheet-word-row h2 { font-family: 'Poppins', sans-serif; font-size: 2rem; margin: 0; }
.listen-word {
  background: var(--surface); border: none; border-radius: 8px;
  width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem;
}
.reading-romaja { color: var(--muted); font-style: italic; margin: 4px 0 8px; }
.w-meaning { font-size: 1.1rem; font-weight: 600; margin: 10px 0 4px; }
.w-explain { margin: 0 0 12px; font-size: .9rem; }
.w-image img { max-width: 100%; border-radius: 10px; }
body.sheet-open { overflow: hidden; }

@media (min-width: 640px) {
  .sheet-panel { bottom: auto; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%);
    border-radius: 16px; width: 420px; animation: none; }
}

/* ---- Vocab ---- */
.vocab-grid { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 12px; }
@media (min-width: 520px) { .vocab-grid { grid-template-columns: repeat(2, 1fr); } }
.vocab-card { background: var(--surface); border-radius: 12px; padding: 14px; display: grid; gap: 4px; }
.vc-head { display: flex; align-items: center; justify-content: space-between; }
.vc-head .ko { font-family: 'Poppins', sans-serif; font-size: 1.4rem; font-weight: 700; }
.vc-meaning { font-weight: 500; }
.vc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.del-vocab { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: .6; }
.del-vocab:hover { opacity: 1; }

/* ---- Profile ---- */
.logout-form { margin-top: 16px; }
.notfound { text-align: center; }
.notfound h1 { font-size: 3rem; color: var(--primary); }

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: center;
  height: 62px; background: #fff; border-top: 1px solid var(--border);
  max-width: 720px; margin: 0 auto;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; color: var(--muted); flex: 1; padding: 6px 0;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .ic { font-size: 1.2rem; }
.bottom-nav .fab {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; margin-top: -20px;
  display: grid; place-items: center; font-size: 1.4rem; box-shadow: var(--shadow);
}
.bottom-nav .fab span { line-height: 1; }

/* ===== Phase 3 — Luyện phản xạ hội thoại ===== */
.practice-cta { margin-bottom: 10px; }
.conv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.conv-progress { font-size: .85rem; color: var(--muted); font-weight: 600; }
.progress-bar { height: 6px; background: var(--surface); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }

/* Bong bóng câu hỏi (AI) */
.bubble { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; }
.bubble-ai { }
.bubble-body {
  background: var(--surface); border-radius: 4px 16px 16px 16px; padding: 12px 14px; max-width: 85%;
}
.bubble .q-ko { font-family: 'Poppins', sans-serif; font-size: 1.25rem; margin: 0; }
.mini-listen { flex: none; background: var(--primary); color: #fff; border: none; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; font-size: .95rem; }
.ac-listen { width: auto; border-radius: 999px; padding: 4px 12px; font-size: .78rem; height: auto; }
.toggle-vi-inline { background: none; border: none; color: var(--primary); font-size: .78rem; cursor: pointer; padding: 4px 0 0; }
.vi-inline { margin: 4px 0 0; color: var(--muted); }

/* Thẻ câu trả lời gợi ý */
.answer-card { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 14px; padding: 14px; margin-bottom: 18px; }
.ac-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ac-label { font-size: .78rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }
.answer-ko { font-family: 'Poppins', sans-serif; font-size: 1.5rem; line-height: 1.7; margin: 0 0 6px; }
.answer-ko .aw { padding: 0 1px; border-radius: 4px; }
.answer-ko .aw.good { color: #067647; background: #e7f7ef; }
.answer-ko .aw.warn { color: #b45309; background: #fdf3e3; }
.answer-ko .aw.bad  { color: var(--accent); background: #fdecef; text-decoration: underline wavy; }

/* Vùng ghi âm */
.record-area { text-align: center; }
.record-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 14px 26px; font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer;
  box-shadow: var(--shadow);
}
.record-btn.listening { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(198,12,48,.4); } 50% { box-shadow: 0 0 0 12px rgba(198,12,48,0); } }
.record-result { margin-top: 14px; }
.score-badge {
  display: inline-grid; place-items: center; width: 70px; height: 70px; border-radius: 50%;
  font-size: 1.3rem; font-weight: 800; color: #fff; margin-bottom: 8px;
}
.score-badge.good { background: #067647; }
.score-badge.warn { background: #d97706; }
.score-badge.bad  { background: var(--accent); }
.recognized { font-size: .85rem; margin: 4px 0 12px; }
.turn-actions { display: flex; gap: 10px; justify-content: center; }

/* Tổng kết */
.conv-summary { text-align: center; padding: 20px 0; }
.score-ring {
  width: 110px; height: 110px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff;
  background: var(--primary);
}
.score-ring.good { background: #067647; }
.score-ring.warn { background: #d97706; }
.score-ring.bad  { background: var(--accent); }
.summary-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ===== Kho từ vựng: ảnh + header ===== */
.vocab-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.vc-img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
.get-img { width: 100%; padding: 8px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; margin-bottom: 8px; font: inherit; font-size: .82rem; }
.get-img:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Ôn luyện trắc nghiệm ===== */
.setup-quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.setup-quick span { color: var(--muted); font-size: .85rem; }
.setup-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.setup-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.setup-item:hover { background: var(--surface); }
.setup-item input { width: auto; }
.si-ko { font-family: 'Poppins', sans-serif; font-weight: 600; min-width: 70px; }
.si-vi { flex: 1; font-size: .9rem; }
.setup-bar {
  position: sticky; bottom: 70px; display: flex; justify-content: space-between; align-items: center;
  background: #fff; padding: 12px 0; border-top: 1px solid var(--border);
}
#selectedCount { font-weight: 600; }

.q-prompt { text-align: center; padding: 18px 0 22px; }
.q-word { font-size: 2rem; font-weight: 700; }
.q-word.ko { font-family: 'Poppins', sans-serif; font-size: 2.4rem; }
.q-audio-inline { margin-top: 8px; background: var(--surface); border: none; border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit; }
.q-audio-big {
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 2rem;
}
.q-img { max-width: 220px; width: 100%; height: 160px; object-fit: cover; border-radius: 12px; }
.q-hint { margin: 12px 0 0; }
.q-options { display: grid; gap: 10px; }
.opt {
  padding: 14px 16px; border: 2px solid var(--border); border-radius: 12px; background: #fff;
  font: inherit; font-size: 1.05rem; cursor: pointer; text-align: center; transition: .12s;
}
.opt.ko { font-family: 'Poppins', sans-serif; font-size: 1.3rem; }
.opt:hover:not([disabled]) { border-color: var(--primary); }
.opt[disabled] { cursor: default; }
.opt-correct { border-color: #067647 !important; background: #e7f7ef; color: #067647; }
.opt-wrong { border-color: var(--accent) !important; background: #fdecef; color: var(--accent); }
.q-actions { margin-top: 16px; text-align: center; }

/* ===== Bảng chữ cái Hangul ===== */
.alphabet { }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 16px 0; padding-bottom: 4px; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.section-intro { margin: 0 0 14px; }
.group-label { margin: 18px 0 10px; font-size: 1rem; color: var(--primary); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.char-cell {
  display: grid; place-items: center; gap: 2px; padding: 12px 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: .12s;
}
.char-cell:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.cc-char { font-family: 'Poppins', sans-serif; font-size: 1.9rem; line-height: 1; }
.cc-romaja { font-size: .78rem; color: var(--muted); }

/* Popup chi tiết chữ */
.char-detail { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.cd-big { font-family: 'Poppins', sans-serif; font-size: 4rem; line-height: 1; }
.cd-side { display: grid; gap: 4px; }
.cd-romaja { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.cd-name { font-size: .85rem; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.cd-block { padding: 10px 0; border-top: 1px solid var(--border); }
.cd-block p { margin: 6px 0 0; }
.cd-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cd-mnemonic { background: #eef2ff; border-radius: 12px; padding: 12px 14px; border-top: none; margin-top: 6px; }
.cd-mnemonic .cd-label { color: var(--primary); }

/* ============================================================
   NÂNG CẤP GIAO DIỆN — vibe Hàn Quốc (icon SVG, taegeuk, mềm mại)
   ============================================================ */
:root {
  --primary: #4f46e5;        /* xanh cờ Hàn Quốc */
  --primary-dark: #4338ca;
  --accent: #f59e0b;         /* đỏ cờ Hàn Quốc */
  --bg: #f2f5fa;
  --surface: #f1f4f9;
  --border: #e7ebf1;
  --text: #14181f;
  --muted: #697588;
  --radius: 18px;
  --radius-lg: 24px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 18px rgba(16,24,40,.06);
  --shadow-lg: 0 18px 44px rgba(16,24,40,.18);
}
body { background: var(--bg); }

/* Icon SVG dùng chung */
.ic-svg { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex: none; }
.btn .ic-svg { width: 18px; height: 18px; }

/* Top bar + dải màu cờ tinh tế */
.topbar {
  border-bottom: none;
  box-shadow: 0 1px 0 rgba(16,24,40,.04), 0 4px 20px rgba(16,24,40,.05);
  backdrop-filter: saturate(1.1);
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 45%, #fff 50%, var(--accent) 55%, var(--accent) 100%);
  opacity: .9;
}
.brand-mark { width: 30px; height: 30px; background: transparent; padding: 0; }
.brand-mark svg { width: 100%; height: 100%; display: block; border-radius: 50%; filter: drop-shadow(0 1px 3px rgba(0,0,0,.18)); }
.brand-name { letter-spacing: -.01em; }

/* Nút bấm mềm mại, có chiều sâu */
.btn { border-radius: 12px; transition: transform .12s ease, box-shadow .12s ease, background .12s ease, filter .12s ease; }
.btn-primary { background: linear-gradient(180deg, #6366f1, var(--primary)); border: none; box-shadow: 0 2px 8px rgba(79,70,229,.26); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79,70,229,.32); background: linear-gradient(180deg, #6366f1, var(--primary-dark)); }
.btn-outline { border-width: 1.5px; }
.btn-outline:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

/* Thẻ nội dung: bo tròn hơn, viền nhạt, bóng mềm */
.auth-card, .onboarding, .dash, .diary, .profile-page, .vocab-page, .history-page, .result, .notfound,
.alphabet, .review, .conv { border-color: var(--border); border-radius: var(--radius-lg); }
.feature-card, .lesson-list a, .stat, .vocab-card, .char-cell, .answer-card, .setup-list, .bubble-body {
  border-color: var(--border);
}

/* CTA chính: gradient + icon trong ô bo tròn */
.cta-card {
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: 0 10px 26px rgba(79,70,229,.28);
}
.cta-card:hover { background: linear-gradient(135deg, #6366f1 0%, #312e81 100%); transform: translateY(-1px); transition: .15s; }
.cta-ic { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.cta-ic .ic-svg { width: 24px; height: 24px; }
.cta-arrow .ic-svg { width: 22px; height: 22px; }

/* Quick link (bảng chữ cái) */
.quick-link { border-radius: var(--radius-lg); }
.quick-link .ql-mark {
  width: 48px; height: 48px; border-radius: 14px; background: #eef2ff; color: var(--primary);
  display: grid; place-items: center; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.15rem; flex: none;
}
.quick-link .cta-arrow { color: var(--muted); }

/* Feature cards (landing): icon tròn */
.feature-card { border-radius: var(--radius-lg); }
.fc-ic { width: 48px; height: 48px; border-radius: 14px; background: #eef2ff; color: var(--primary); display: grid; place-items: center; }
.fc-ic .ic-svg { width: 24px; height: 24px; }
.hero-mark { border-radius: 20px; box-shadow: 0 10px 30px rgba(79,70,229,.28); }

/* Bottom nav: icon SVG + fab gradient */
.bottom-nav { border-top: none; box-shadow: 0 -2px 20px rgba(16,24,40,.07); }
.bottom-nav a { gap: 3px; transition: color .12s; }
.bottom-nav a .ic { display: grid; place-items: center; }
.bottom-nav a .ic .ic-svg { width: 23px; height: 23px; }
.bottom-nav a.active .ic .ic-svg { transform: translateY(-1px); }
.bottom-nav .fab {
  background: linear-gradient(135deg, #e0455a, var(--accent));
  box-shadow: 0 8px 20px rgba(245,158,11,.42);
}
.bottom-nav .fab .ic-svg { width: 24px; height: 24px; color: #fff; }

/* Tabs (bảng chữ cái) + char cell mềm hơn */
.tab { transition: .12s; }
.char-cell { border-radius: 16px; }
.cc-char { font-weight: 500; }

/* Badge level: bo tròn viên thuốc, nhẹ nhàng */
.level-badge { box-shadow: 0 2px 6px rgba(245,158,11,.25); }

/* Chip: mềm */
.chip { transition: .12s; }
.chip:hover { transform: translateY(-1px); }

/* --- Căn chỉnh icon trong các nút phát âm/ghi âm --- */
.listen-sentence, .listen-word, .mini-listen, .q-audio-big {
  display: inline-flex; align-items: center; justify-content: center;
}
.listen-sentence .ic-svg { width: 17px; height: 17px; }
.listen-word .ic-svg { width: 20px; height: 20px; }
.mini-listen { gap: 5px; color: #fff; }
.mini-listen .ic-svg { width: 17px; height: 17px; }
.ac-listen .ic-svg { width: 14px; height: 14px; }
.record-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.record-btn .ic-svg { width: 20px; height: 20px; }
.q-audio-inline { display: inline-flex; align-items: center; gap: 6px; }
.q-audio-inline .ic-svg { width: 16px; height: 16px; }
.q-audio-big .ic-svg { width: 32px; height: 32px; }
#cdListen { gap: 6px; }
#cdListen .ic-svg { width: 16px; height: 16px; }
.get-img { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.get-img .ic-svg { width: 15px; height: 15px; }

/* ============ Hiệu ứng chuyển động nhẹ ============ */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.container > section { animation: fadeInUp .35s ease both; }

/* Hội thoại: mỗi lượt trôi lên nhẹ */
.bubble { animation: fadeInUp .32s ease both; }
.answer-card { animation: fadeInUp .34s ease .04s both; }
.record-area { animation: fadeInUp .34s ease .08s both; }

/* Trắc nghiệm: câu hỏi + đáp án hiện dần (so le) */
.q-prompt { animation: fadeInUp .3s ease both; }
.q-options .opt { animation: fadeInUp .32s ease both; }
.q-options .opt:nth-child(1) { animation-delay: .04s; }
.q-options .opt:nth-child(2) { animation-delay: .09s; }
.q-options .opt:nth-child(3) { animation-delay: .14s; }
.q-options .opt:nth-child(4) { animation-delay: .19s; }

/* Tổng kết + lưới chữ cái */
.conv-summary:not(.hidden), #summaryPanel:not(.hidden) { animation: fadeInUp .4s ease both; }
.char-grid { animation: fadeIn .35s ease both; }

/* Bottom sheet: nền mờ dần (panel đã có slideUp) */
.sheet-backdrop { animation: fadeIn .2s ease; }

/* Tôn trọng người dùng tắt hiệu ứng */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   BỐ CỤC KIỂU MOBILE APP — khung hẹp như điện thoại + dashboard
   ============================================================ */
:root { --app-width: 480px; }

.container { max-width: var(--app-width); }
.topbar { max-width: var(--app-width); margin: 0 auto; }
.bottom-nav { max-width: var(--app-width); }

/* --- Trang chủ dạng app --- */
.dash {
  background: transparent; border: none; box-shadow: none; padding: 0;
  animation: fadeIn .35s ease both;
}

/* Header gradient tràn viền cột, bo góc dưới */
.dash-hero {
  margin: -20px -16px 0; padding: 24px 20px 46px;
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  border-radius: 0 0 28px 28px; color: #fff;
}
.dash-hero-row { display: flex; justify-content: space-between; align-items: flex-start; }
.dash-hi { margin: 0; opacity: .82; font-size: .92rem; }
.dash-name { margin: 2px 0 0; color: #fff; font-size: 1.7rem; font-weight: 700; }
.dash-level {
  background: rgba(255,255,255,.18); color: #fff; padding: 6px 13px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; box-shadow: none; backdrop-filter: blur(4px);
}

/* Thẻ thống kê nổi lên đè header */
.dash-stats {
  position: relative; z-index: 1; margin: -30px 6px 0; padding: 16px 8px;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.dash-stats .ds { text-align: center; display: grid; gap: 3px; }
.dash-stats .ds + .ds { border-left: 1px solid var(--border); }
.dash-stats .ds b { font-size: 1.55rem; font-weight: 800; color: var(--primary); line-height: 1; }
.dash-stats .ds span { font-size: .72rem; color: var(--muted); }

.dash .cta-card { margin-top: 18px; }

/* Tiêu đề mục + link "Tất cả" */
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 12px; }
.section-head .section-title { margin: 0; font-size: 1.05rem; }
.see-all { font-size: .82rem; font-weight: 600; color: var(--primary); }

/* Lưới shortcut kiểu icon app */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); }
.qa-ic {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(16,24,40,.08); transition: transform .14s ease, box-shadow .14s ease;
}
.qa:hover .qa-ic { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(16,24,40,.14); }
.qa-ic .ic-svg { width: 25px; height: 25px; }
.qa-blue  { background: #eef2ff; color: var(--primary); font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.05rem; }
.qa-green { background: #e7f7ef; color: #067647; }
.qa-red   { background: #fdecef; color: var(--accent); }
.qa-amber { background: #fdf3e3; color: #b45309; }
.qa-label { font-size: .74rem; color: var(--muted); text-align: center; }

/* Trạng thái rỗng */
.empty-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 20px; text-align: center; box-shadow: var(--shadow);
}
.empty-card .empty-emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.empty-card p { margin: 0; }

/* Danh sách bài học: thẻ trắng nổi nhẹ cho hợp vibe app */
.dash .lesson-list a { background: #fff; box-shadow: var(--shadow); border: 1px solid var(--border); }

/* --- Áp phong cách app cho các trang danh sách/nội dung --- */
/* Bỏ khung "hộp" nặng: nội dung/thẻ nổi trực tiếp trên nền */
.vocab-page, .history-page, .alphabet, .conv, .review {
  background: transparent; border: none; box-shadow: none; padding: 0;
}
.vocab-page > h1, .history-page > h1, .alphabet > h1 { font-size: 1.5rem; }
.page-sub { color: var(--muted); margin: 2px 0 16px; font-size: .9rem; }

/* Item danh sách/thẻ: nền trắng, bóng mềm */
.lesson-list a { background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 14px; }
.lesson-list a:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(16,24,40,.10); transition: .14s; }
.vocab-card { background: #fff; box-shadow: var(--shadow); }
.vocab-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(16,24,40,.12); transition: .14s; }

/* Empty card: có nút hành động */
.empty-card .btn { margin-top: 16px; }

/* Bảng chữ cái không còn hộp -> tabs dính mép trên khi cuộn */
.alphabet .tabs {
  position: sticky; top: 56px; z-index: 5; margin-top: 4px;
  background: var(--bg); padding-top: 8px;
}

/* Hội thoại: thanh tiến trình dính mép trên cho gọn */
.conv .conv-head { padding-top: 2px; }

/* ============================================================
   CHI TIẾT BÀI HỌC — đẹp hơn + text nhiều màu theo loại từ
   ============================================================ */
.result, .fc-screen { background: transparent; border: none; box-shadow: none; padding: 0; }
.lesson-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Nhật ký gốc (đóng/mở) */
.source-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.source-card summary {
  cursor: pointer; font-weight: 600; font-size: .92rem; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.source-card summary::-webkit-details-marker { display: none; }
.source-card[open] summary { margin-bottom: 8px; }
.source-card p { margin: 0; color: var(--muted); font-size: .92rem; }

.lesson-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.lesson-actions .btn { gap: 6px; }

/* Chú thích màu loại từ */
.pos-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.pos-legend .pl { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pl.w-noun { background: #e7eefc; color: #1d4ed8; }
.pl.w-verb { background: #fdecef; color: #c0392b; }
.pl.w-adj  { background: #e7f7ef; color: #0d9488; }
.pl.w-adv  { background: #f3ecff; color: #7c3aed; }
.pl.w-part { background: #eef1f5; color: #64748b; }

/* Thẻ câu */
.sentence-card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sc-num {
  width: 24px; height: 24px; border-radius: 8px; background: var(--surface);
  color: var(--muted); font-size: .78rem; font-weight: 700; display: grid; place-items: center; flex: none;
}
.sentence-card .listen-sentence { width: 32px; height: 32px; margin: 0; background: #eef2ff; color: var(--primary); }

/* Từ tô màu theo loại từ */
.word.w-noun { color: #1d4ed8; border-bottom-color: #a9c3f7; }
.word.w-verb { color: #c0392b; border-bottom-color: #f0b3bd; }
.word.w-adj  { color: #0d9488; border-bottom-color: #9fded4; }
.word.w-adv  { color: #7c3aed; border-bottom-color: #cdb8f7; }
.word.w-pron { color: #0891b2; border-bottom-color: #a5dce8; }
.word.w-num  { color: #d97706; border-bottom-color: #f2cf9b; }
.word.w-part { color: #64748b; border-bottom-color: #cbd5e1; }
.word:hover { background: rgba(0,0,0,.05); border-bottom-style: solid; border-radius: 6px 6px 0 0; }

/* ============================================================
   FLASHCARD — thẻ lật 3D
   ============================================================ */
.fc-card { perspective: 1200px; margin: 12px 0 4px; }
.fc-inner {
  position: relative; width: 100%; min-height: 320px;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4,.2,.2,1); cursor: pointer;
}
.fc-inner.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 26px; border-radius: 22px; box-shadow: var(--shadow-lg);
}
.fc-front { background: linear-gradient(160deg, #ffffff, #eef2ff); }
.fc-back { background: linear-gradient(160deg, #6366f1, #4338ca); color: #fff; transform: rotateY(180deg); }
.fc-tag { position: absolute; top: 16px; left: 18px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .55; }
.fc-back .fc-tag { opacity: .8; }
.fc-word { font-family: 'Poppins', sans-serif; font-size: 2.8rem; font-weight: 700; color: var(--text); text-align: center; }
.fc-audio { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--primary); color: #fff; cursor: pointer; display: grid; place-items: center; }
.fc-audio .ic-svg { width: 22px; height: 22px; }
.fc-flip-hint { position: absolute; bottom: 18px; font-size: .78rem; color: var(--muted); }
.fc-reading { font-size: 1.1rem; font-style: italic; opacity: .85; }
.fc-meaning { font-size: 1.8rem; font-weight: 700; text-align: center; line-height: 1.3; }
.fc-back .pos-tag { color: rgba(255,255,255,.8); margin: 0; }
.fc-explain { font-size: .85rem; opacity: .85; text-align: center; margin: 2px 0 0; max-width: 260px; }
.fc-save { margin-top: 8px; }
.fc-back .fc-save { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.45); color: #fff; }

.fc-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.fc-btn { padding: 15px; border-radius: 14px; border: 2px solid; font: inherit; font-weight: 700; cursor: pointer; background: #fff; transition: .14s; }
.fc-unknown { border-color: #f0b3bd; color: var(--accent); }
.fc-unknown:hover { background: #fdecef; transform: translateY(-1px); }
.fc-known { border-color: #a3d9b8; color: #067647; }
.fc-known:hover { background: #e7f7ef; transform: translateY(-1px); }
.fc-hint { text-align: center; margin-top: 14px; font-size: .82rem; }

/* ============================================================
   TiếngAnh.TV — logo chữ "A" + tinh chỉnh riêng bản tiếng Anh
   ============================================================ */
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7c74f0);
  color: #fff; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.15rem;
  box-shadow: 0 3px 8px rgba(79,70,229,.35);
}
.brand-mark svg { display: none; }

/* IPA symbols cần font hỗ trợ tốt (Poppins thiếu vài ký hiệu) */
.cc-char, .cd-big { font-family: 'Inter', system-ui, 'Segoe UI', sans-serif; letter-spacing: -.01em; }

/* Trả lời tự do: gợi ý trễ + thẻ nhận xét AI */
.hint-link {
  display: block; margin: 12px auto 0; background: none; border: none;
  color: var(--primary); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; padding: 8px;
}
.hint-appear { animation: hintIn .35s ease both; }
@keyframes hintIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.fb-card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; margin-top: 16px; box-shadow: var(--shadow); text-align: left;
}
.fb-head { display: flex; align-items: center; gap: 12px; }
.fb-head .score-badge { width: 56px; height: 56px; font-size: 1.05rem; flex: none; margin-bottom: 0; }
.fb-said { margin: 0; font-size: .92rem; }
.fb-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; margin-top: 12px; }
.spinner.sm { width: 22px; height: 22px; border-width: 3px; margin: 0; }
.fb-comment { margin: 12px 0 0; font-size: .95rem; }
.fb-corrected { background: var(--surface); border-radius: 12px; padding: 10px 14px; margin-top: 12px; }
.fb-label { font-size: .72rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }
.fb-corrected-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.fb-corrected-row .ko { margin: 4px 0 0; font-size: 1.15rem; }
.fb-tip { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }

/* Từ bấm được (tra nghĩa) trong hội thoại */
.cw {
  background: none; border: none; font: inherit; color: inherit; cursor: pointer;
  padding: 0 1px; border-bottom: 1px dotted rgba(0,0,0,.25); border-radius: 4px 4px 0 0;
}
.cw:hover { color: var(--primary); border-bottom: 1px solid var(--primary); background: rgba(0,0,0,.04); }

/* Cấu trúc câu (ngữ pháp) */
.patterns { margin-top: 10px; display: grid; gap: 6px; }
.pattern-item {
  background: var(--surface); border-left: 3px solid var(--primary);
  border-radius: 8px; padding: 8px 12px; font-size: .85rem;
}
.pattern-badge { display: block; font-weight: 700; color: var(--primary); }
.pattern-meaning { color: var(--text); }
.pattern-example { display: block; color: var(--muted); margin-top: 3px; }

/* Player nghe cả bài */
.player-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.player-rate { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.player-rate select { width: auto; padding: 8px 10px; font-size: .85rem; }
.sentence-card.playing { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,.06), var(--shadow); }
.sentence-card.playing .sc-num { background: var(--primary); color: #fff; }

/* Biến thể Dễ hơn / Khó hơn */
.variant-row { display: flex; gap: 8px; margin-top: 12px; }
.variant-card {
  margin-top: 10px; background: #fff; border: 1px dashed var(--border);
  border-radius: 12px; padding: 10px 14px;
}
.variant-label { font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }

/* Cấu hình giọng đọc (Hồ sơ) */
.voice-settings { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.voice-settings .section-title { margin: 0 0 12px; }
.voice-settings input[type='range'] { padding: 0; accent-color: var(--primary); }
.vs-note { font-size: .8rem; margin: 0; }

/* Ghim biến thể làm gợi ý chính */
.variant-actions { margin-top: 8px; }
.pin-btn { border-color: var(--primary); color: var(--primary); font-weight: 600; }
