:root {
  --bg: #F6F1EA;
  --paper: #FFFDF9;
  --ink: #3B2F27;
  --muted: #8E7F72;
  --line: #E6DCCF;
  --accent: #C28A8F;
  --accent-ink: #9C5F67;
  --brown: #7B5B44;
  --brown-deep: #3B2F27;
  --blush: #F3E4E2;
  --mine: #EFDDD8;
  --mine-ink: #3A2621;
  --teal: #8A5A45;
  --teal-soft: #F3E6DE;
  --warn: #B4703A;
  --warn-soft: #FBEDE2;
  --tip: #F8E9EC;
  --tip-ink: #8A4152;
  --wall: #F1E9E0;
  --ok: #4F7A55;
  --ok-soft: #E7F1E6;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ko: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --tabs-h: 64px;
  --shadow: 0 1px 2px rgba(58, 38, 33, .05), 0 8px 24px rgba(58, 38, 33, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1513; --paper: #271E1B; --ink: #F4E9E5; --muted: #B9A39B; --line: #3D2F2A;
    --accent: #E596A7; --accent-ink: #F0B3C1; --brown: #D9B59E; --brown-deep: #140F0D; --blush: #3A262B;
    --mine: #563640; --mine-ink: #FBEFF1; --teal: #DDB79F; --teal-soft: #33261F; --warn: #F2B266; --warn-soft: #3A2B19;
    --tip: #3A262B; --tip-ink: #F2C3CE; --wall: #221A17; --ok: #9CCB9F; --ok-soft: #1F2E20; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1513; --paper: #271E1B; --ink: #F4E9E5; --muted: #B9A39B; --line: #3D2F2A;
  --accent: #E596A7; --accent-ink: #F0B3C1; --brown: #D9B59E; --brown-deep: #140F0D; --blush: #3A262B;
  --mine: #563640; --mine-ink: #FBEFF1; --teal: #DDB79F; --teal-soft: #33261F; --warn: #F2B266; --warn-soft: #3A2B19;
  --tip: #3A262B; --tip-ink: #F2C3CE; --wall: #221A17; --ok: #9CCB9F; --ok-soft: #1F2E20; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 'Be Vietnam Pro', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[lang="ko"], .ko { font-family: var(--ko); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .35em; }
p { margin: 0 0 .5em; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.pron { font-family: var(--ko); color: var(--teal); font-size: .9rem; }

/* ---------- Khung chung ---------- */
.view { max-width: 720px; margin: 0 auto; }
.page { padding: 0 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
.page-head { padding: 22px 0 10px; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--muted); }

/* ---------- MINJI: man hinh nhan tin ---------- */
.chat-view {
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom));
  background: var(--wall);
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--paper); border-bottom: 1px solid var(--line); position: relative;
}
.avatar { width: 44px; height: 44px; border-radius: 16px; flex: none; }
.who-box { min-width: 0; flex: 1; }
.name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name small { font-weight: 400; color: var(--muted); font-size: .76rem; }
.status { font-family: 'Gowun Dodum', var(--ko); color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { font-size: .78rem; color: var(--muted); text-align: right; line-height: 1.25; white-space: nowrap; }
.clock b { display: block; color: var(--ink); font-size: .95rem; }
.head-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.head-btn svg { width: 22px; height: 22px; fill: var(--muted); }
.head-btn:hover { background: var(--bg); }

.menu { background: var(--paper); border-bottom: 1px solid var(--line); padding: 10px 14px 14px; }
.menu-title { font-size: .82rem; font-weight: 600; color: var(--muted); margin: 8px 0 6px; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; font-size: .86rem; }
.seg button.on { background: var(--paper); font-weight: 600; color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
select, input[type="text"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.thread { flex: 1; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.day { align-self: center; background: rgba(0,0,0,.12); color: #fff; font-size: .76rem; padding: 3px 12px; border-radius: 99px; margin: 10px 0 6px; }
.divider { align-self: center; background: var(--paper); color: var(--muted); font-size: .8rem; padding: 5px 12px; border-radius: 99px; margin: 10px 0 6px; text-align: center; max-width: 90%; }

.row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.row.me { justify-content: flex-end; }
.row .mini { width: 34px; height: 34px; border-radius: 12px; flex: none; margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 4px; max-width: 80%; min-width: 0; }
.row.me .stack { align-items: flex-end; }
.sender { font-size: .78rem; color: var(--ink); opacity: .75; margin-left: 2px; }
.bubble {
  background: var(--paper); color: var(--ink); padding: 8px 12px; border-radius: 4px 16px 16px 16px;
  font: 400 1.04rem/1.5 var(--ko); word-break: keep-all; overflow-wrap: anywhere; width: fit-content; max-width: 100%;
}
.bubble + .bubble { border-radius: 16px; }
.row.me .bubble { background: var(--mine); color: var(--mine-ink); border-radius: 16px 4px 16px 16px; }
.bubble .pron { display: block; margin-top: 2px; }
.bubble .vi { display: block; font: .9rem/1.45 'Be Vietnam Pro', sans-serif; color: var(--muted); margin-top: 4px; }
.hide-ko .row:not(.me) .bubble .t, .hide-ko .row:not(.me) .bubble .pron { filter: blur(6px); transition: filter .2s; }
.hide-ko .row:not(.me) .stack.peek .bubble .t, .hide-ko .row:not(.me) .stack.peek .bubble .pron { filter: none; }
.meta { font-size: .7rem; color: var(--ink); opacity: .55; }
.tools { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  border: 0; background: rgba(255,255,255,.75); color: var(--ink); border-radius: 99px; padding: 4px 10px;
  font-size: .78rem; display: inline-flex; align-items: center; gap: 4px; min-height: 30px;
}
.chip svg { width: 14px; height: 14px; fill: currentColor; }
.chip.on { background: var(--ink); color: var(--paper); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip { background: rgba(255,255,255,.1); } }

.fix { background: var(--paper); border-radius: 14px; padding: 10px 12px; font-size: .9rem; max-width: 100%; border-left: 4px solid var(--warn); }
.fix.sach { border-left-color: var(--teal); }
.fix .lb { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); }
.fix.sach .lb { color: var(--teal); }
.fix .wrong { text-decoration: line-through; color: var(--muted); font-family: var(--ko); }
.fix .right { font: 600 1.04rem/1.5 var(--ko); }
.fix .tools { margin-top: 6px; }
.fix .chip { background: var(--bg); }
.tip { align-self: center; background: var(--tip); color: var(--tip-ink); border-radius: 14px; padding: 9px 12px; font-size: .88rem; max-width: 92%; margin: 4px 0; }
.tip b { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.hint-bar { background: var(--paper); border-top: 1px solid var(--line); padding: 8px 12px; font-size: .9rem; }
.hint-bar .ko { font-weight: 600; cursor: pointer; }
.composer { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--paper); border-top: 1px solid var(--line); }
.composer input { min-height: 46px; border-radius: 23px; padding: 10px 16px; }
.mic, .send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; }
.mic { background: var(--accent); color: #fff; }
.mic svg, .send svg { width: 24px; height: 24px; fill: currentColor; }
.mic.recording { animation: pulse 1s infinite; background: #A92D3A; }
.send { background: var(--bg); color: var(--ink); }
.send:disabled { opacity: .4; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(226,98,111,.25); } }
.mic-status { margin: 0; font-size: .82rem; text-align: center; color: var(--muted); background: var(--paper); min-height: 0; }
.mic-status:empty { display: none; }

/* ---------- CANH DOI THAT ---------- */
.timeline { position: relative; padding-left: 58px; }
.timeline::before { content: ''; position: absolute; left: 44px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.scene-item {
  position: relative; display: block; width: 100%; text-align: left; border: 0; background: var(--paper);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 10px;
}
.scene-item::before { content: ''; position: absolute; left: -19px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }
.scene-item .time { position: absolute; left: -60px; top: 13px; font-size: .78rem; color: var(--muted); width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.scene-item .ko { color: var(--accent-ink); font-size: .85rem; }
.scene-item b { display: block; font-size: 1.02rem; }
.scene-item .done { font-size: .78rem; color: var(--teal); }

.back { border: 0; background: transparent; color: var(--accent-ink); padding: 6px 0; font-weight: 600; margin-bottom: 4px; }
.scene-top { background: var(--paper); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.scene-top .ko { color: var(--accent-ink); }
.scene-top .bc { color: var(--muted); }
.scene-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.script { background: var(--paper); border-radius: 18px; padding: 6px 14px; margin-bottom: 12px; }
.line { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line.playing { background: linear-gradient(90deg, var(--warn-soft), transparent); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.spk { font: 700 .86rem var(--ko); padding-top: 3px; }
.line .k { font: 500 1.12rem/1.5 var(--ko); }
.line .v { color: var(--muted); font-size: .92rem; }
.hide-vi .line .v { display: none; }
.line .tools { margin-top: 6px; }
.line .chip { background: var(--bg); }
.line .result { margin-top: 6px; }
.stage { grid-column: 1 / -1; text-align: center; font-size: .84rem; color: var(--muted); font-style: italic; padding: 8px 0; border-top: 1px solid var(--line); }

.compare { display: grid; gap: 10px; margin-bottom: 12px; }
.cmp { background: var(--paper); border-radius: 16px; padding: 12px 14px; }
.cmp .sach { font-family: var(--ko); color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.3); }
.cmp .doi { font: 600 1.1rem var(--ko); color: var(--ink); }
.cmp .lbl { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 6px; }
.cmp .lbl.real { color: var(--teal); }
.cmp p { margin: 4px 0 0; font-size: .9rem; color: var(--muted); }
.culture { background: var(--tip); color: var(--tip-ink); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.culture b { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
h2.sec { font-size: 1.05rem; margin: 18px 0 8px; }

.filter { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.filter .chip { background: var(--paper); white-space: nowrap; flex: none; min-height: 36px; padding: 6px 12px; font-size: .86rem; }
.filter .chip small { opacity: .6; margin-left: 2px; }
.filter .chip.on { background: var(--ink); color: var(--paper); }
#scene-list:not(.timeline) { padding-left: 0; }
#scene-list:not(.timeline) .scene-item::before { display: none; }

/* ---------- DOC ---------- */
#doc-tabs { margin-bottom: 14px; background: var(--paper); }
#doc-tabs button.on { background: var(--bg); }
.news { background: var(--paper); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.news h3 { font: 600 1.06rem/1.5 var(--ko); margin: 2px 0 4px; }
.news .lead { font: .95rem/1.6 var(--ko); color: var(--muted); }
.news .chip, a.chip { background: var(--bg); text-decoration: none; }
.meta2 { font-size: .76rem; color: var(--muted); margin: 0; }
.ex-box { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: .94rem; }
.ex-box h4 { margin: 12px 0 6px; font-size: .9rem; }
.sent { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 6px 0; align-items: start; }
.sent [lang="ko"] { font: 500 1rem/1.55 var(--ko); }
.sent .chip { background: var(--bg); min-height: 28px; padding: 2px 8px; }
.vocab div { padding: 4px 0; }
.vocab .w { font: 700 1rem var(--ko); border: 0; background: transparent; padding: 0; color: var(--accent-ink); }
.hv { font-size: .8rem; color: var(--teal); background: var(--teal-soft); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.retell { background: var(--tip); color: var(--tip-ink); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.retell [lang="ko"] { font: 500 1rem/1.6 var(--ko); color: var(--ink); margin: 4px 0; }
.retell .chip { background: var(--paper); margin-top: 6px; }
.reading { background: var(--paper); border-radius: 18px; padding: 16px; margin-bottom: 8px; }
.rs { margin: 0 0 10px; cursor: pointer; font: 1.1rem/1.9 var(--ko); }
.rs .rv { display: none; font: .92rem/1.5 'Be Vietnam Pro', sans-serif; color: var(--teal); margin-top: 2px; }
.rs.open { background: var(--teal-soft); border-radius: 10px; padding: 4px 8px; margin-left: -8px; margin-right: -8px; }
.rs.open .rv { display: block; }
textarea { width: 100%; font: 1rem/1.6 var(--ko); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; }
#dan-out .ex-box { background: var(--paper); border-radius: 18px; padding: 16px; border-top: 0; }

/* ---------- THANH NGU, CAMBRIDGE, CHUYEN THU TIENG ---------- */
.idiom { padding: 12px 0; border-top: 1px solid var(--line); }
.idiom:first-of-type { border-top: 0; }
.idiom-k .w { font: 700 1.08rem var(--ko); border: 0; background: transparent; padding: 0; color: var(--accent-ink); text-align: left; }
.idiom-v { font-weight: 600; margin: 2px 0; }
.idiom-vd { display: flex; gap: 8px; align-items: flex-start; margin-top: 4px; }
.idiom-vd .chip { background: var(--bg); min-height: 28px; padding: 2px 8px; flex: none; }
.idiom-vd span { font: 1rem/1.5 var(--ko); }
a.cam { font-size: .76rem; color: var(--teal); text-decoration: none; border: 1px solid var(--teal-soft); border-radius: 6px; padding: 0 6px; white-space: nowrap; }
.idiom .chip, .idiom a.chip { background: var(--bg); text-decoration: none; }
.lang-switch { display: inline-flex; background: var(--bg); border-radius: 99px; padding: 2px; margin-left: 4px; flex: none; }
.lang-switch a { font-size: .74rem; padding: 3px 8px; border-radius: 99px; color: var(--muted); text-decoration: none; font-weight: 600; }
.lang-switch a.on { background: var(--paper); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- ON TAP ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stats div { background: var(--paper); border-radius: 14px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 1.35rem; }
.stats span { font-size: .76rem; color: var(--muted); }
.review { background: var(--paper); border-radius: 18px; padding: 18px 16px; text-align: center; }
.review .from { font-size: .78rem; color: var(--muted); }
.review .ask { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.review .vi-big { font-size: 1.2rem; font-weight: 600; margin: 4px 0 12px; }
.review .ko-big { font: 600 1.55rem/1.4 var(--ko); margin: 14px 0 2px; }
.review .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.empty { color: var(--muted); padding: 6px 0; }

/* ---------- GHI CHU ---------- */
.block { background: var(--paper); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.block h2 { font-size: 1.08rem; }
.memory { list-style: none; padding: 0; margin: 0; }
.memory li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-family: var(--ko); }
.memory li:first-child { border-top: 0; }
.memory button { border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; flex: none; }
.word { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.word:first-child { border-top: 0; }
.word .w { font: 700 1.05rem var(--ko); border: 0; background: transparent; padding: 0; text-align: left; color: var(--accent-ink); }
.word .ex { grid-column: 1 / -1; font-family: var(--ko); font-size: .92rem; color: var(--muted); }
.rule { padding: 10px 0; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; }
.rule .ex { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.rule .ex button { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 6px 12px; text-align: left; font-family: var(--ko); }
.rule .ex button span { display: block; color: var(--teal); font-size: .88rem; }
.field { display: block; font-size: .9rem; font-weight: 500; margin: 10px 0; }
.field select, .field input { margin-top: 4px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- Nut, ket qua, thong bao ---------- */
.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 9px 14px; font-weight: 500; min-height: 42px; display: inline-flex; align-items: center; gap: 6px; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.recording { background: var(--accent); color: #fff; border-color: var(--accent); animation: pulse 1s infinite; }
.chip.recording { background: var(--accent); color: #fff; animation: pulse 1s infinite; }
.result { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: .9rem; text-align: left; }
.result .heard { font-family: var(--ko); }
.result .miss { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 2px; }
.score { font-weight: 700; }
.score.good { color: var(--teal); } .score.mid { color: var(--warn); } .score.low { color: var(--accent-ink); }
.voice-warn { background: var(--warn-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.chat-view .voice-warn { margin: 0; border-radius: 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  display: flex; justify-content: center; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs button { flex: 1; max-width: 180px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .74rem; color: var(--muted); }
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs button.on { color: var(--accent-ink); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 760px) {
  .chat-view { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* =====================================================================
   NGON NGU CUA R - giao dien hong & nau
   ===================================================================== */
body { letter-spacing: .005em; }
h1, h2, .page-head h1, .scene-top h2, .daily h2, .block h2, h2.sec { font-family: var(--serif); font-weight: 600; color: var(--brown); letter-spacing: 0; }
.page-head { padding: 26px 0 14px; }
.page-head h1 { font-size: 1.85rem; line-height: 1.15; }
.block, .review, .scene-top, .script, .reading, .news, .cmp, .stats div, .scene-item, .lesson, .qcard { box-shadow: var(--shadow); }
.block, .scene-top, .script, .reading, .qcard { border: 1px solid var(--line); }
.stats div { border: 1px solid var(--line); }
.stats b { font-family: var(--serif); color: var(--accent-ink); font-size: 1.6rem; }
.btn { border-radius: 999px; padding: 10px 18px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-ink)); border: 0; box-shadow: 0 6px 16px rgba(199, 107, 126, .28); }
.btn.teal { background: var(--brown); border-color: var(--brown); color: #FFF6F2; }
.btn.big { width: 100%; justify-content: center; padding: 14px; font-size: 1.02rem; }
.chip.on { background: var(--brown); color: #FFF6F2; }
.filter .chip.on { background: var(--brown); color: #FFF6F2; }
.culture { border-left: 3px solid var(--accent); }
.tip { border-left: 3px solid var(--accent); }

/* Thanh tab nau socola */
.tabs { background: var(--brown-deep); border-top: 0; box-shadow: 0 -6px 20px rgba(58, 38, 33, .18); }
.tabs button { color: #C9B1A8; }
.tabs button.on { color: #F6C9D2; }
.tabs button.on svg { filter: drop-shadow(0 0 6px rgba(246, 201, 210, .45)); }

/* Man hinh nhan tin */
.chat-head { background: var(--paper); box-shadow: 0 2px 10px rgba(58, 38, 33, .06); border-bottom: 1px solid var(--line); }
.chat-head .name { font-family: var(--serif); color: var(--brown); font-size: 1.15rem; }
.chat-head .name small { font-family: 'Be Vietnam Pro', sans-serif; }
.avatar { border-radius: 50%; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.row .mini { border-radius: 50%; }
.thread { background:
  radial-gradient(circle at 20% 10%, rgba(199, 107, 126, .07), transparent 40%),
  radial-gradient(circle at 80% 70%, rgba(92, 58, 46, .06), transparent 45%), var(--wall); }
.bubble { box-shadow: 0 1px 2px rgba(58, 38, 33, .06); }
.row.me .bubble { background: linear-gradient(135deg, #F7DDE2, #F1CDD4); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .row.me .bubble { background: var(--mine); } }
.mic { background: linear-gradient(135deg, var(--accent), var(--accent-ink)); box-shadow: 0 6px 16px rgba(199, 107, 126, .35); }
.send { background: var(--brown); color: #FFF6F2; }
.day { background: rgba(92, 58, 46, .55); }
.lang-switch { background: var(--blush); }
.lang-switch a.on { color: var(--brown); }

/* ---------- LUYEN TAP ---------- */
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--accent-ink); margin: 0 0 4px; font-weight: 600; }
.daily { background: linear-gradient(140deg, #FBE7EB 0%, #F6E7DF 100%); border-radius: 18px; padding: 18px; margin: -16px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .daily { background: linear-gradient(140deg, #3A262B, #2E231F); } }
.daily h2 { font-size: 1.45rem; margin-bottom: 6px; }
.done-today { color: var(--ok); font-weight: 600; }
#lt-daily { overflow: hidden; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 8px; }
.lesson { text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.lesson:hover { border-color: var(--accent); }
.lesson b { font-size: .98rem; color: var(--brown); }
.lesson small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-meta { font-size: .76rem; color: var(--accent-ink); font-weight: 600; }
.bar { display: block; height: 6px; background: var(--blush); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brown)); border-radius: 99px; }
.bar.thick { height: 8px; margin: 6px 0 10px; }
.play-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 14px; font-size: .9rem; color: var(--muted); }
.countdown { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.countdown i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width .1s linear; }
.qcard { background: var(--paper); border-radius: 20px; padding: 20px 18px; }
.qcard.center, .center { text-align: center; }
.qtext { color: var(--muted); font-size: .95rem; margin-bottom: 6px; }
.qbig { font: 600 1.35rem/1.45 var(--ko); color: var(--ink); margin: 4px 0 8px; word-break: keep-all; }
.qbig[lang="vi"] { font-family: 'Be Vietnam Pro', sans-serif; }
.opts { display: grid; gap: 8px; margin-top: 12px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; font: 1rem/1.4 var(--ko); }
.opt[lang="vi"] { font-family: 'Be Vietnam Pro', sans-serif; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--accent-ink); background: var(--blush); }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.answer-row.center { justify-content: center; }
.answer-row input { flex: 1; min-width: 180px; min-height: 48px; border-radius: 14px; font: 1.05rem var(--ko); }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.piece { border: 1.5px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px 11px; font: 1rem var(--ko); }
.piece:disabled { opacity: .3; }
.piece.on { display: inline-block; background: var(--blush); border-color: var(--accent); }
.built { min-height: 48px; border: 1.5px dashed var(--line); border-radius: 12px; padding: 8px; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.big-mic { width: 72px; height: 72px; }
.big-mic svg { width: 34px; height: 34px; }
.link { border: 0; background: none; color: var(--accent-ink); text-decoration: underline; padding: 0; font: inherit; }
.fb { margin-top: 14px; border-radius: 14px; padding: 12px 14px; text-align: left; }
.fb.ok { background: var(--ok-soft); }
.fb.no { background: var(--blush); }
.fb b { font-family: var(--serif); font-size: 1.1rem; color: var(--brown); }
.fb.ok b { color: var(--ok); }
.fb-ans { font: 600 1.08rem/1.5 var(--ko); margin-top: 4px; }
.fb-ex { margin-top: 6px; font-size: .92rem; color: var(--ink); }
.result-big { font: 700 3rem var(--serif); color: var(--accent-ink); margin: 6px 0; }
.notes-card { background: var(--teal-soft); border-radius: 14px; padding: 12px 14px; margin: 8px 0; font-size: .92rem; }
.notes-card b { color: var(--brown); }
.lt-hide { display: none !important; }
.stats b, .result-big, .lesson-meta { font-variant-numeric: lining-nums tabular-nums; }
@media (max-width: 420px) { .chat-head .name small { display: none; } .clock { font-size: .72rem; } }
/* Nut nhom tu xuong dong, khong can keo ngang (may tinh khong keo duoc) */
.filter { flex-wrap: wrap; overflow: visible; }
.filter .chip { flex: 0 1 auto; }
/* Phan xa hoi - dap */
.px-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 8px; }
.px-modes .btn { justify-content: center; text-align: center; }
@media (max-width: 420px) { .px-modes { grid-template-columns: 1fr; } }
.px-topics { margin-top: 10px; padding-bottom: 0; }
.px-topics .chip { background: rgba(255,255,255,.7); }
.px-friend { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 10px; text-align: left; }
.px-friend img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.px-bubble { background: var(--bg); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 10px 14px; font: 1.1rem/1.5 var(--ko); }
.px-bubble .chip { margin-left: 6px; background: var(--paper); vertical-align: middle; }
.px-q { font-weight: 600; }
.px-task { font: 600 1.15rem/1.5 'Be Vietnam Pro', sans-serif; color: var(--brown); margin: 4px 0 8px; }
.fb-sub { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 10px; }

/* =====================================================================
   NGON NGU CUA R v3 - trang web: menu chung, dang nhap, trang chu (kem & nau)
   ===================================================================== */
:root { --nav-h: 56px; }
.btn.primary { background: var(--brown); box-shadow: 0 8px 20px rgba(123, 91, 68, .25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.teal { background: var(--paper); color: var(--brown); border: 1px solid var(--brown); }
.mic { background: var(--brown); box-shadow: 0 6px 16px rgba(123, 91, 68, .3); }
.send { background: var(--accent); }
.row.me .bubble { background: #EFDDD8; }
.daily { background: linear-gradient(140deg, #F3E4E2 0%, #EFE5D9 100%); }
.tabs { background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(59, 47, 39, .06); }
.tabs button { color: var(--muted); }
.tabs button.on { color: var(--brown); }
.tabs button.on svg { filter: none; color: var(--accent-ink); }
.page-head h1 { font-weight: 500; font-size: 2.1rem; }

/* Thanh menu chung */
.site-nav {
  position: sticky; top: 0; z-index: 20; height: var(--nav-h);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(246, 241, 234, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-nav { background: rgba(28, 21, 19, .92); } }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-r { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--brown); color: #FBF3EC; font: italic 600 1.05rem var(--serif); }
.brand-t { font: 500 1.08rem var(--serif); letter-spacing: .01em; }
.site-links { display: flex; gap: 4px; margin-left: auto; }
.site-links a { text-decoration: none; color: var(--muted); font-size: .9rem; padding: 7px 12px; border-radius: 99px; }
.site-links a:hover { color: var(--ink); }
.site-links a.on { color: var(--brown); background: var(--blush); font-weight: 600; }
.acct { border: 1px solid var(--brown); background: transparent; color: var(--brown); border-radius: 99px; padding: 6px 14px; font-size: .88rem; font-weight: 500; flex: none; }
.acct.in { background: var(--brown); color: #FBF3EC; }
@media (max-width: 560px) {
  .site-nav { gap: 6px; padding: 0 10px; }
  .brand-t { display: none; }
  .site-links a { padding: 6px 8px; font-size: .84rem; }
  .acct { padding: 5px 10px; font-size: .8rem; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
body.has-nav .chat-view { height: calc(100dvh - var(--tabs-h) - var(--nav-h) - env(safe-area-inset-bottom)); }
.lang-switch { display: none; }

/* Hop dang nhap */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(59, 47, 39, .45); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--paper); border-radius: 22px; padding: 26px 22px 18px; width: min(400px, 100%); position: relative; box-shadow: 0 20px 60px rgba(59, 47, 39, .25); }
.modal-card h2 { font: 500 1.7rem var(--serif); margin-bottom: 4px; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 1.6rem; color: var(--muted); }
.modal-card input { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-top: 4px; }
.m-err { color: var(--accent-ink); font-size: .88rem; min-height: 1.2em; margin: 4px 0 8px; }

/* Trang chu */
body.landing { background: var(--bg); padding: 0; }
.landing main { max-width: 1180px; margin: 0 auto; padding: 0 28px 40px; }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; min-height: calc(100vh - var(--nav-h) - 20px); padding: 30px 0; }
.kicker { text-transform: uppercase; letter-spacing: .22em; font-size: .74rem; font-weight: 600; color: var(--brown); margin: 0 0 18px; }
.hero-title { font: 400 clamp(3.2rem, 8vw, 6.4rem)/1 var(--serif); letter-spacing: .06em; color: var(--ink); margin: 0; }
.hero-sub { font: italic 400 clamp(1.4rem, 2.6vw, 2rem) var(--serif); color: var(--brown); margin: 8px 0 0; }
.hero-rule { display: block; width: 52px; height: 1px; background: var(--brown); margin: 28px 0; opacity: .6; }
.hero-head { font: 500 clamp(2.2rem, 4.6vw, 3.8rem)/1.12 var(--serif); color: var(--ink); margin: 0 0 22px; }
.hero-lead { color: var(--muted); font-size: 1.04rem; line-height: 1.7; max-width: 30em; margin-bottom: 30px; }
.hero-cta { display: inline-flex; align-items: center; gap: 22px; background: var(--brown); color: #FBF3EC; text-decoration: none; padding: 18px 34px; border-radius: 99px; font-weight: 500; box-shadow: 0 14px 30px rgba(123, 91, 68, .28); }
.hero-cta span { font-size: 1.3rem; }
.hero-cta:hover { filter: brightness(1.07); }
.hero-login { display: block; border: 0; background: transparent; color: var(--ink); opacity: .8; font: inherit; font-size: .94rem; padding: 0; margin: 22px 0 0; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.hero-lock { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .86rem; margin-top: 36px; }
.hero-lock svg { width: 16px; height: 16px; fill: var(--muted); }
.hero-art { position: relative; margin: 0; border-radius: 340px 340px 26px 26px; overflow: hidden; aspect-ratio: 4 / 5; box-shadow: 0 30px 60px rgba(59, 47, 39, .18); }
.hero-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(40, 26, 16, .55)); }
.hero-art figcaption { position: absolute; left: 34px; bottom: 34px; z-index: 1; color: #FFF6EC; font: italic 400 clamp(1.3rem, 2.4vw, 1.9rem)/1.25 var(--serif); }
.hero-no { position: absolute; right: 26px; bottom: 26px; z-index: 1; color: #FFF6EC; font-size: .7rem; letter-spacing: .2em; font-weight: 600; }
.chon { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 30px 0 50px; scroll-margin-top: 80px; }
.lang-card { display: flex; align-items: center; gap: 18px; padding: 22px 24px; border-radius: 22px; background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .2s; }
.lang-card:hover { transform: translateY(-3px); }
.lang-card img { width: 64px; height: 64px; border-radius: 50%; }
.lang-card .kicker { margin-bottom: 4px; }
.lang-card h3 { font: 500 1.7rem var(--serif); margin: 0; }
.lang-card p { margin: 0; color: var(--muted); }
.lang-card > span { margin-left: auto; font-size: 1.5rem; color: var(--brown); }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; border-top: 1px solid var(--line); padding-top: 34px; }
.features span { font: italic 400 1rem var(--serif); color: var(--accent-ink); }
.features h4 { font: 500 1.35rem var(--serif); margin: 4px 0 6px; color: var(--ink); }
.features p { color: var(--muted); margin: 0; }
.landing-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 50px; }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 26px; padding-top: 24px; }
  .hero-art { order: -1; aspect-ratio: 1 / 1; border-radius: 220px 220px 22px 22px; }
  .hero-lock { margin-top: 22px; }
  .chon, .features { grid-template-columns: 1fr; }
  .landing main { padding: 0 16px 30px; }
}

/* Trang Nhap bai */
body.plain { padding-bottom: 30px; }
.nhap { max-width: 860px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
.field textarea { margin-top: 4px; }
.n-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) auto; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.n-row:first-child { border-top: 0; }
.n-cell span { display: block; font-size: .74rem; color: var(--muted); }
.n-cell input { width: 100%; font: .95rem var(--ko); padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.n-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.n-item:first-child { border-top: 0; }
