/* ============ The Muse — giao diện "hồng + đỏ đô", năng động ============ */
:root {
  --bg: #FFF6F8;
  --surface: #FFFFFF;
  --surface-2: #FCEAEF;
  --ink: #2B0E18;
  --ink-2: #6E4753;
  --ink-3: #8F6B77;
  --line: #F3DCE3;
  --accent: #9C1C44;            /* đỏ đô */
  --accent-ink: #FFFFFF;
  --accent-soft: #FCE4EB;
  --grad: linear-gradient(135deg, #8E1538 0%, #D63A6C 60%, #FF6A9A 100%);
  --hl: #DB2A65;                /* hồng tươi */
  --hl-ink: #FFFFFF;
  --mark: rgba(255, 79, 139, .32);
  --ok: #18865A;
  --ok-soft: #DDF4E8;
  --bad: #D6402E;
  --bad-soft: #FDE4DF;
  --shadow: 0 1px 2px rgba(43, 14, 24, .04), 0 4px 16px rgba(43, 14, 24, .05);
  --shadow-lift: 0 2px 4px rgba(43, 14, 24, .05), 0 12px 28px rgba(156, 28, 68, .16);
  --radius: 18px;
  --radius-sm: 12px;
  --head: "Lexend", "Be Vietnam Pro", system-ui, sans-serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16090E; --surface: #21111A; --surface-2: #2D1823; --ink: #FBEAF0; --ink-2: #D2AEBA; --ink-3: #9C7884; --line: #3E2330;
    --accent: #FF7AA5; --accent-ink: #1A0910; --accent-soft: #46192C; --hl: #DB2A65; --hl-ink: #FFFFFF; --mark: rgba(255, 79, 139, .42);
    --grad: linear-gradient(135deg, #B0234F 0%, #E2477A 60%, #FF7AA5 100%);
    --ok: #5FD39B; --ok-soft: #173325; --bad: #FF8A7E; --bad-soft: #3A1E1C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16090E; --surface: #21111A; --surface-2: #2D1823; --ink: #FBEAF0; --ink-2: #D2AEBA; --ink-3: #9C7884; --line: #3E2330;
  --accent: #FF7AA5; --accent-ink: #1A0910; --accent-soft: #46192C; --hl: #DB2A65; --hl-ink: #FFFFFF; --mark: rgba(255, 79, 139, .42);
  --grad: linear-gradient(135deg, #B0234F 0%, #E2477A 60%, #FF7AA5 100%);
  --ok: #5FD39B; --ok-soft: #173325; --bad: #FF8A7E; --bad-soft: #3A1E1C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15.5px; line-height: 1.6; min-height: 100vh; overflow-x: hidden;
  transition: background .25s, color .25s;
}
h1, h2, h3 { font-family: var(--head); line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.015em; }
h1 { font-size: clamp(1.55rem, 4vw, 2.1rem); font-weight: 600; }
h2 { font-size: 1.22rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--hl); color: var(--hl-ink); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: .87em; }
.hidden { display: none !important; }
.gap-in { display: inline-block; width: 9rem !important; margin: .2rem .3rem !important; padding: .35em .6em !important; }
@media (max-width: 480px) { .gap-in { width: 7.5rem !important; } }
mark { background: linear-gradient(transparent 58%, var(--mark) 58%) no-repeat 0 0 / 100% 100%; color: inherit; padding: 0 .1em; animation: hl .7s .25s both ease-out; }
@keyframes hl { from { background-size: 0 100%; } to { background-size: 100% 100%; } }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .55em 1.1em; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: .93rem;
  text-decoration: none; transition: background .15s, border-color .15s, transform .12s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary, .btn-accent { background: var(--grad); color: #fff; border-color: transparent; }
.btn-primary:hover, .btn-accent:hover { border-color: transparent; box-shadow: 0 6px 18px color-mix(in srgb, var(--hl) 40%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: .36em .85em; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.chip {
  border: 1px solid var(--line); background: var(--surface); padding: .4em .95em; border-radius: 999px;
  cursor: pointer; font-size: .9rem; transition: all .15s; color: var(--ink);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.card + .card { margin-top: .9rem; }
a.card { transition: transform .2s, box-shadow .2s, border-color .2s; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; color: var(--accent); font-weight: 600; margin-bottom: .35rem; }
.tag { display: inline-block; font-size: .74rem; padding: .14em .65em; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }

input[type=text], input[type=date], input[type=number], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55em .8em; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.7; }
label.field { display: block; font-size: .88rem; color: var(--ink-2); margin-bottom: .75rem; }
label.field > span { display: block; margin-bottom: .25rem; }

/* Lời của anh: bong bóng chat */
.anh-line {
  display: block; background: var(--accent-soft); color: var(--ink); padding: .65rem 1rem .75rem;
  border-radius: 16px 16px 16px 4px; font-size: .95rem; max-width: 560px; animation: pop .35s both;
}
.anh-line::before { content: "anh"; display: block; font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: .1rem; }
.anh-sign { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: .6em 1.15em; border-radius: 999px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- hiệu ứng vào trang ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.main > *, .single > *, .placeholder > * { animation: fadeUp .4s both ease-out; }
.main > *:nth-child(2) { animation-delay: .04s; } .main > *:nth-child(3) { animation-delay: .08s; }
.main > *:nth-child(4) { animation-delay: .12s; } .main > *:nth-child(5) { animation-delay: .16s; }
.main > *:nth-child(n+6) { animation-delay: .2s; }
.main[data-still] * { animation: none !important; } /* vẽ lại sau khi bấm chọn: không chạy hiệu ứng lại */

/* ============ Trang 5 cửa ============ */
.doors {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--hl) 16%, transparent), transparent 38%),
              radial-gradient(circle at 90% 92%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 40%);
}
.doors-list { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: .7rem; }
.door {
  display: flex; align-items: center; gap: 1rem; text-align: left; width: 100%; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.15rem; cursor: pointer; transition: transform .2s, border-color .2s, box-shadow .2s;
  animation: fadeUp .45s both ease-out;
}
.door:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-lift); }
.door-ic { width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; transition: transform .25s; }
.door-ic svg { width: 24px; height: 24px; }
.door:hover .door-ic { transform: rotate(-6deg) scale(1.06); background: var(--grad); color: #fff; }
.door:first-child .door-ic { background: var(--grad); color: #fff; }
.door-title { font-family: var(--head); font-weight: 600; font-size: 1.08rem; display: block; line-height: 1.3; }
.door-sub { font-size: .84rem; color: var(--ink-3); }
.door-arrow { margin-left: auto; color: var(--ink-3); transition: transform .2s, color .2s; flex: none; }
.door:hover .door-arrow { transform: translateX(3px); color: var(--accent); }

/* ============ Khung IELTS ============ */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: .7rem; }
.brand { font-family: var(--head); font-weight: 600; font-size: 1.08rem; text-decoration: none; white-space: nowrap; display: flex; align-items: center; gap: .45rem; }
.brand em { font-style: normal; font-size: .7rem; font-weight: 600; letter-spacing: .06em; padding: .15em .55em; border-radius: 999px; background: var(--hl); color: var(--hl-ink); }
.nav { display: flex; gap: .15rem; margin: 0 auto; }
.nav a { text-decoration: none; padding: .42em .9em; border-radius: 999px; font-size: .9rem; color: var(--ink-2); transition: background .15s, color .15s; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; flex: none; color: var(--ink-2); transition: border-color .15s, color .15s; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.main { max-width: 1080px; margin: 0 auto; padding: 1.6rem 16px calc(96px + env(safe-area-inset-bottom)); }

.tabbar { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar-in { justify-content: space-between; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; font-size: .7rem; color: var(--ink-3); padding: .3rem 0; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: color .15s; }
  .tabbar a svg { width: 21px; height: 21px; transition: transform .2s; }
  .tabbar a.on { color: var(--accent); font-weight: 500; }
  .tabbar a.on svg { transform: translateY(-1px); }
  .main { padding-top: 1.2rem; }
  body.in-session .tabbar { display: none; }
}

/* ---------- Trang chủ IELTS ---------- */
.hello { font-size: .92rem; color: var(--ink-2); margin-bottom: .3rem; }
.greet h1 { margin-bottom: .8rem; }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.2rem 0 1.4rem; }
.pill { display: inline-flex; align-items: baseline; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.pill b { font-family: var(--head); font-size: 1.05rem; color: var(--ink); font-weight: 600; }
.pill.hot { background: var(--hl); border-color: var(--hl); color: var(--hl-ink); }
.pill.hot b { color: var(--hl-ink); }
.today-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .55rem 0; }
.today-row + .today-row { border-top: 1px dashed var(--line); }
.today-row > span { font-size: .85rem; color: var(--ink-3); width: 6.5rem; flex: none; }
.plan { margin-top: .8rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.plan-step { display: flex; align-items: center; gap: .9rem; padding: .6rem 0; }
.plan-min { font-family: var(--head); font-weight: 600; color: var(--accent); width: 3rem; flex: none; font-size: .95rem; }
.plan-step .grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .8rem; }
.section-title h2 { margin: 0; }
.skill-tile { display: flex; flex-direction: column; gap: .55rem; text-decoration: none; }
.skill-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.skill-ic svg { width: 21px; height: 21px; }
.skill-tile b { font-family: var(--head); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat b { display: block; font-family: var(--head); font-weight: 600; font-size: 1.5rem; line-height: 1.25; }
.stat span { font-size: .8rem; color: var(--ink-3); }

/* ---------- Danh sách bài ---------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .42em 1.05em; border-radius: 999px; cursor: pointer; font-size: .9rem; color: var(--ink-2); transition: all .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 500; box-shadow: var(--shadow); }
.item-card { display: flex; flex-direction: column; gap: .5rem; transition: border-color .2s, box-shadow .2s; }
.item-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow); }
.item-card .btn-row { margin-top: auto; padding-top: .4rem; }
.item-meta { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ============ Phòng làm bài ============ */
.sess-bar { position: sticky; top: 0; z-index: 25; background: var(--surface); border-bottom: 1px solid var(--line); }
.sess-bar-in { max-width: 1400px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: .7rem; }
.sess-title { font-family: var(--head); font-weight: 500; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; padding: .3em .85em; border-radius: 999px; background: var(--surface-2); font-size: .93rem; }
.timer.low { background: var(--bad-soft); color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.mode-badge { font-size: .72rem; padding: .22em .7em; border-radius: 999px; background: var(--hl); color: var(--hl-ink); font-weight: 600; white-space: nowrap; }
@media (max-width: 420px) { .mode-badge { display: none; } .sess-bar-in { gap: .5rem; } }

.split { display: grid; grid-template-columns: 1fr 1fr; height: calc(100vh - 57px - 58px); height: calc(100dvh - 57px - 58px); }
.split > .pane { overflow-y: auto; padding: 1.5rem 1.7rem 2rem; }
.split > .pane + .pane { border-left: 1px solid var(--line); background: var(--surface); }
.passage { max-width: 640px; }
.passage p { margin-bottom: 1em; line-height: 1.8; font-size: 1rem; }
.passage .plabel { font-family: var(--head); font-weight: 600; color: var(--accent); margin-right: .45em; }
.pane-tabs { display: none; }
@media (max-width: 860px) {
  .split { display: block; height: auto; }
  .split > .pane { overflow: visible; padding: 1.1rem 16px 1.5rem; }
  .split > .pane + .pane { border-left: 0; }
  .split.show-q > .pane-passage, .split.show-p > .pane-questions { display: none; }
  .pane-tabs { display: flex; gap: .4rem; padding: .55rem 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 53px; z-index: 15; }
  .pane-tabs button { flex: 1; }
}
.single { max-width: 800px; margin: 0 auto; padding: 1.5rem 16px 2rem; }

.qgroup { margin-bottom: 1.8rem; }
.qgroup-head { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem .95rem; margin-bottom: .8rem; font-size: .9rem; color: var(--ink-2); }
.qgroup-head b { display: block; font-size: .95rem; color: var(--ink); font-family: var(--head); font-weight: 600; }
.q { padding: .6rem 0 .75rem; border-bottom: 1px dashed var(--line); }
.q:last-child { border-bottom: 0; }
.q-row { display: flex; gap: .7rem; align-items: flex-start; }
.qn { flex: none; min-width: 1.9rem; height: 1.9rem; border-radius: 10px; display: grid; place-items: center; font-size: .8rem; font-weight: 600; background: var(--surface-2); transition: background .2s, color .2s; }
.q-body { flex: 1; min-width: 0; }
.q-body select, .q-body input[type=text] { max-width: 340px; margin-top: .35rem; }
.opt { display: flex; gap: .55rem; align-items: flex-start; padding: .38rem .55rem; border-radius: 10px; cursor: pointer; transition: background .15s; }
.opt:hover { background: var(--surface-2); }
.opt input { margin-top: .32rem; accent-color: var(--accent); }
.q.is-ok .qn { background: var(--ok-soft); color: var(--ok); }
.q.is-bad .qn { background: var(--bad-soft); color: var(--bad); }
.fb { margin-top: .45rem; font-size: .87rem; padding: .55rem .75rem; border-radius: 10px; background: var(--surface-2); animation: pop .3s both; }
.fb.ok { background: var(--ok-soft); }
.fb.bad { background: var(--bad-soft); }
.headings-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .95rem; margin-bottom: .8rem; font-size: .9rem; }
.headings-box div { padding: .12rem 0; }

.sess-foot { position: sticky; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line); padding: .5rem 16px calc(.5rem + env(safe-area-inset-bottom)); }
.sess-foot-in { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: .6rem; }
.palette { display: flex; gap: 4px; overflow-x: auto; flex: 1; padding: 2px; scrollbar-width: thin; }
.palette button { flex: none; width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: .78rem; cursor: pointer; transition: all .15s; }
.palette button:hover { border-color: var(--accent); }
.palette button.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.palette button.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.palette button.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.palette .sep { width: 1px; background: var(--line); margin: 0 4px; flex: none; }

/* Listening */
.audio-box { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1.2rem; }
.audio-box .status { font-size: .85rem; color: var(--ink-2); flex: 1; min-width: 140px; }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s infinite ease-in-out; }
.eq i:nth-child(2) { animation-delay: .2s; } .eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.transcript { font-size: .9rem; }
.transcript div { padding: .32rem .55rem; border-radius: 8px; cursor: pointer; transition: background .15s; }
.transcript div:hover { background: var(--surface-2); }
.transcript b { color: var(--accent); font-weight: 600; margin-right: .3em; }
.form-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1rem; background: var(--surface); }

/* Writing */
.write-area { min-height: 46vh; font-size: 1rem; padding: 1rem 1.1rem; }
.wc { font-size: .85rem; color: var(--ink-3); }
.wc.ok { color: var(--ok); font-weight: 500; }
.prompt-box { border-left: 3px solid var(--accent); padding: .45rem 0 .45rem 1rem; margin: .5rem 0 1rem; }
.chart-wrap { overflow-x: auto; margin: .5rem 0 1rem; }
.chart-wrap svg { max-width: 100%; height: auto; }

/* Speaking */
.speak-stage { text-align: center; padding: 1.4rem 0; }
.speak-q { font-family: var(--head); font-weight: 500; font-size: clamp(1.2rem, 3vw, 1.5rem); line-height: 1.45; margin: .6rem auto 1.2rem; max-width: 620px; animation: pop .35s both; }
.mic-btn { width: 86px; height: 86px; border-radius: 50%; border: 0; cursor: pointer; background: var(--grad); color: #fff; display: inline-grid; place-items: center; transition: transform .15s, background .2s; box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); }
.mic-btn svg { width: 34px; height: 34px; }
.mic-btn:hover { transform: scale(1.05); }
.mic-btn.rec { background: var(--bad); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 70% { box-shadow: 0 0 0 18px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.live-text { min-height: 3.2em; max-width: 620px; margin: 1rem auto 0; padding: .85rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); text-align: left; font-size: .95rem; }
.live-text .interim { color: var(--ink-3); }
.kb-fallback { position: fixed; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 26; }
.kb-fallback .btn { box-shadow: var(--shadow); opacity: .85; }
.kb-fallback .btn:hover { opacity: 1; }
.cue-card { text-align: left; max-width: 540px; margin: 0 auto; border: 1px solid var(--line); border-left: 4px solid var(--hl); border-radius: var(--radius-sm); padding: 1rem 1.2rem; background: var(--surface); }
.cue-card ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.big-timer { font-family: var(--head); font-weight: 600; font-size: 2.4rem; font-variant-numeric: tabular-nums; margin: .6rem 0; }
.step-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: .6rem; }
.step-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background .3s, width .3s; }
.step-dots i.on { background: var(--accent); }

/* Kết quả */
.score-big { font-family: var(--head); font-weight: 600; font-size: 2.7rem; line-height: 1; animation: pop .45s both; }
.score-big small { font-size: 1rem; color: var(--ink-3); font-weight: 500; }
.prompt-out { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; min-height: 160px; background: var(--surface-2); }
.vocab-pick { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-top: 1px solid var(--line); }
.vocab-pick:first-child { border-top: 0; }
.vocab-pick input { margin-top: .35rem; accent-color: var(--accent); }

/* Từ vựng */
.flash { perspective: 1200px; max-width: 460px; margin: 0 auto; }
.flash-in { position: relative; min-height: 230px; transition: transform .55s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; cursor: pointer; }
.flash.flipped .flash-in { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.flash-back { transform: rotateY(180deg); background: var(--accent-soft); }
.flash-word { font-family: var(--head); font-weight: 600; font-size: 1.85rem; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; max-width: 620px; margin: 0 auto; }
.match-grid button { text-align: left; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; min-height: 52px; transition: all .15s; }
.match-grid button:hover { border-color: var(--accent); }
.match-grid button.sel { border-color: var(--accent); background: var(--accent-soft); }
.match-grid button.done { opacity: .3; pointer-events: none; transform: scale(.97); }
.match-grid button.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.word-row { display: flex; gap: .75rem; align-items: baseline; padding: .6rem 0; border-top: 1px solid var(--line); }
.word-row:first-child { border-top: 0; }
.word-row .w { font-weight: 600; }
.word-row .grow { flex: 1; min-width: 0; }

/* Lịch hoạt động */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 300px; }
.heat i { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 60%, var(--surface-2)); }
.heat i.l3 { background: var(--accent); }
.heat i.today { outline: 2px solid var(--hl); outline-offset: 1px; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--line); }
table.t th { font-weight: 500; color: var(--ink-3); font-size: .8rem; }

.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem .9rem; }
.sheet-grid label { display: flex; align-items: center; gap: .5rem; }
.sheet-grid label b { width: 1.8rem; text-align: right; font-size: .85rem; color: var(--ink-3); flex: none; }
.sheet-part { grid-column: 1 / -1; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-top: .6rem; }
.mark-row { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.placeholder { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; text-align: center; }
.placeholder .anh-line { margin: 0 auto 1.4rem; text-align: left; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Điện thoại: thanh tab kỹ năng nằm một hàng, trượt ngang được */
@media (max-width: 480px) {
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; padding: .42em .9em; }
}

/* ===== Điện thoại 5.8 inch (360–375px ngang, 740–812px dọc) ===== */
html { -webkit-tap-highlight-color: transparent; }
/* Tai thỏ khi xoay ngang: chừa lề an toàn hai bên */
.topbar-in, .main, .sess-bar-in, .single, .pane-tabs { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.sess-foot, .tabbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
@media (max-width: 480px) {
  body { font-size: 15px; }
  /* Ô nhập chữ ≥ 16px để iPhone không tự phóng to màn hình khi bấm vào */
  input[type=text], input[type=date], input[type=number], select, textarea, .gap-in { font-size: 16px; }
  /* Nút đủ to cho ngón tay */
  .chip { min-height: 38px; padding: .45em 1em; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .palette button { width: 34px; height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  /* Gọn lại cho màn nhỏ */
  .card { padding: 1rem; border-radius: 16px; }
  h1 { font-size: 1.42rem; }
  .today-row { flex-direction: column; align-items: flex-start; gap: .45rem; }
  .today-row > span { width: auto; }
  .pills { gap: .4rem; margin: 1rem 0 1.1rem; }
  .pill { padding: .4rem .75rem; }
  .plan-step { gap: .6rem; }
  .plan-min { width: 2.4rem; }
  .speak-stage { padding: .8rem 0; }
  .speak-q { margin-bottom: .9rem; }
  .mic-btn { width: 76px; height: 76px; }
  .big-timer { font-size: 2rem; }
  .kb-fallback { right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .score-big { font-size: 2.3rem; }
  .door { padding: .85rem 1rem; }
  .door-ic { width: 42px; height: 42px; }
  .flash-word { font-size: 1.6rem; }
  .match-grid button { padding: .6rem .7rem; font-size: .9rem; }
  .sheet-grid { grid-template-columns: repeat(2, 1fr); gap: .45rem .7rem; }
  .sheet-grid label b { width: 1.5rem; }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
/* Màn thấp (740px) */
@media (max-width: 480px) and (max-height: 760px) {
  .write-area { min-height: 36vh; }
  .flash-in { min-height: 200px; }
  .live-text { min-height: 2.6em; }
}
