:root {
  --night: #0B0F2E; --ink: #0D1233; --lime: #C8F31D; --mint: #3CF0C8; --sky: #5FC8FF; --blue: #2440F0;
  --bg: #F4F6FB; --card: #fff; --line: #E2E6F0; --muted: #5B6180;
  --grad: linear-gradient(90deg, #C8F31D, #3CF0C8, #5FC8FF, #2440F0);
}
* { box-sizing: border-box }
html, body { margin: 0 }
body { font-family: "Be Vietnam Pro", system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.5 }
h1, h2, h3, .btn, .kicker, .brand span { font-family: Lexend, "Be Vietnam Pro", sans-serif }
a { color: var(--blue) }
.boot { min-height: 100vh; display: grid; place-items: center }
.boot-msg { color: var(--muted); font-weight: 600; padding: 24px; text-align: center }
.bar { height: 6px; background: var(--grad) }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 18px;
  font-weight: 700; font-size: 16px; background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; min-height: 48px }
.btn:hover { filter: brightness(1.15) }
.btn:disabled { opacity: .5; cursor: wait }
.btn.big { font-size: 18px; padding: 14px 22px; min-height: 56px }
.btn.sm { font-size: 14px; padding: 8px 12px; min-height: 40px; border-radius: 10px }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--ink) }
.btn.tw { background: var(--blue); margin-top: 6px }
.btn.on { background: #1E9E6A }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--night) }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 24px; padding: 28px 24px 22px; display: flex; flex-direction: column; gap: 8px; position: relative }
.login-logo { height: 28px; align-self: flex-start }
.login-card h1 { margin: 2px 0 10px; font-size: 26px }
.login-card label { font-weight: 600; font-size: 14px }
.login-card input { font: inherit; font-size: 18px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px }
.login-card input:focus { border-color: var(--blue); outline: none }
.login-card .btn { margin-top: 10px }
.msg { color: #C0392B; min-height: 1.4em; margin: 4px 0 0; font-size: 14px }
.hint { color: var(--muted); font-size: 13px; margin: 0 }

/* top */
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); gap: 12px }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink) }
.brand img { height: 24px }
.brand span { font-weight: 600; color: var(--muted) }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600 }
.main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 60px }
h2 { font-size: 21px; margin: 0 0 12px }
.empty { padding: 40px 16px; text-align: center; color: var(--muted) }

/* home */
.hello { display: flex; gap: 18px; align-items: center; background: var(--night); color: #fff; border-radius: 22px; padding: 18px 22px; margin-bottom: 18px }
.hello h1 { margin: 0 0 4px; font-size: 28px }
.hello p { margin: 0; color: #C9D0F0 }
.hello .count { margin-top: 8px; color: #fff }
.hello .count b { color: var(--lime); font-size: 22px; font-family: Lexend }
.hello { justify-content: space-between; flex-wrap: wrap }
.next { display: flex; flex-direction: column; gap: 6px; color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; max-width: 220px }
.next img { width: 220px; border-radius: 14px; border: 3px solid var(--mint); display: block }
.next:hover span { color: var(--lime) }
.passport { background: #fff; border-radius: 22px; padding: 18px; margin-bottom: 22px; border: 1px solid var(--line) }
.chang h3 { font-size: 15px; margin: 12px 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap }
.chang small { font-family: "Be Vietnam Pro"; font-weight: 500; color: var(--muted) }
.stamps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 2px dashed #C3C9DA; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4px; color: #9AA1B8 }
.stamp .num { font: 700 18px Lexend }
.stamp .bn { font-size: 10px; line-height: 1.15; font-weight: 600 }
.stamp.on { border: 0; background: var(--c); color: var(--ink); box-shadow: inset 0 0 0 3px rgba(13, 18, 51, .15) }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px }
.lesson { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 10px 12px; text-decoration: none; color: var(--ink) }
a.lesson:hover { border-color: var(--blue) }
.lesson .ln { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: var(--lime); display: grid; place-items: center; font: 700 18px Lexend }
.lesson .lt { font-weight: 600; display: flex; flex-direction: column; line-height: 1.25 }
.lesson .lt small { font-weight: 500; color: var(--muted); font-size: 12px }
.lesson .ls { font-size: 13px; color: var(--muted); font-weight: 600; text-align: right }
.lesson .ls.ok { color: #1E9E6A }
.lesson.locked { opacity: .55 }
.lesson.locked .ln { background: #C3C9DA; color: #fff }

/* lesson */
.back { display: inline-block; margin-bottom: 10px; font-weight: 600; text-decoration: none }
.lhead { display: flex; justify-content: space-between; gap: 16px; align-items: center; background: #fff; border-radius: 22px; padding: 20px 22px; border: 1px solid var(--line); margin-bottom: 16px }
.kicker { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--blue) }
.lhead h1 { font-size: 32px; margin: 4px 0 6px; line-height: 1.15 }
.story { margin: 0 0 10px; max-width: 560px }
.lesson-thumb { width: 300px; max-width: 42%; border-radius: 16px; flex: none; border: 1px solid var(--line) }
.stepno { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: var(--ink); font-size: 16px; margin-right: 10px; vertical-align: 2px }
.panel h3 { font-size: 16px; margin: 18px 0 8px }
.panel > .btn.tw { margin: 0 0 4px }
.tip { margin: 8px 0 12px !important; font-size: 14px }
.play { background: #ECFBF6; border-color: #B7EBDB }
.play p { margin: 0 0 12px }
.panel { background: #fff; border-radius: 22px; padding: 18px 20px; border: 1px solid var(--line); margin-bottom: 16px }
.panel .sub { color: var(--muted); margin: -6px 0 12px }
.prog { height: 10px; border-radius: 6px; background: #E8ECF5; overflow: hidden; margin-bottom: 14px }
.prog i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .3s }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: var(--bg) }
.steps li.done { background: #E3F8EE }
.steps input { width: 26px; height: 26px; margin: 2px 0 0; accent-color: #1E9E6A; flex: none }
.steps label { display: flex; gap: 10px; cursor: pointer }
.steps .no { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--lime); display: grid; place-items: center; font: 700 13px Lexend }
.steps li.done .no { background: #1E9E6A; color: #fff }
.code { margin: 0; background: var(--bg); border-radius: 16px; padding: 12px; text-align: center; overflow-x: auto }
.code svg { max-width: 100%; height: auto }
.code figcaption { font-size: 13px; color: var(--muted); margin-top: 6px }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px }
.card { border: 2px dashed var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center }
.card svg { max-width: 100%; height: auto }
.card p { margin: 0 }
.doctor { background: #FFF6E0; border-color: #F4D58A }
.doctor p { margin: 0 0 12px }
.chall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px }
.ch { border: 3px solid var(--mint); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px }
.ch.lv1 { border-color: var(--sky) } .ch.lv2 { border-color: var(--blue) }
.ch > b { font-family: Lexend; display: flex; justify-content: space-between }
.ch p { margin: 0; flex: 1 }
.stars { color: #F5B301; letter-spacing: 2px }
.stars.big { font-size: 22px }
.howto { margin: 0 0 12px; padding-left: 20px }
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }
.upload input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0 }
.upload input[type=text] { flex: 1 1 260px; font: inherit; padding: 12px; border: 2px solid var(--line); border-radius: 12px; min-height: 48px }
.fname { color: var(--muted); font-size: 14px }
.subs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px }
.subs li { background: var(--bg); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start }
.when { font-size: 13px; color: var(--muted); font-weight: 600 }
.knote { font-size: 14px }
.review p { margin: 4px 0 0 }
.pill { display: inline-block; background: var(--lime); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; margin-left: 8px }
.wait { font-size: 14px; color: var(--muted) }
.home-task { background: var(--ink); color: #fff; border-radius: 18px; padding: 14px 18px }
.home-task b { color: var(--lime); font-family: Lexend }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 9; max-width: calc(100% - 32px) }

@media (max-width: 760px) {
  .stamps { grid-template-columns: repeat(4, 1fr) }
  .chall { grid-template-columns: 1fr }
  .lhead { flex-direction: column-reverse; align-items: stretch }
  .lesson-thumb { width: 100%; max-width: none }
  .next, .next img { width: 100%; max-width: none }
  .lhead h1 { font-size: 26px }
}

/* ---------- trang làm bài: hướng dẫn trái, TurboWarp phải ---------- */
body.ws-mode { overflow: hidden }
body.ws-mode #app { height: 100vh; display: flex; flex-direction: column }
body.ws-mode .main { max-width: none; width: 100%; margin: 0; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column }
body.ws-mode .top { padding: 6px 14px }
.wsbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap }
.wsbar .back { margin: 0; white-space: nowrap }
.wstitle { display: flex; flex-direction: column; line-height: 1.15; min-width: 0 }
.wstitle small { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em }
.wstitle b { font: 700 19px Lexend }
.phases { display: flex; gap: 6px; flex-wrap: wrap }
.ph { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px 6px 6px; font: 600 15px Lexend; color: var(--ink); cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 40px }
.ph span { width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 13px }
.ph.on { border-color: var(--ink); background: var(--ink); color: #fff }
.ph.on span { background: var(--lime); color: var(--ink) }
.wsright { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.wsmenu { display: flex; gap: 6px }
.save { font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: #E3F8EE; color: #137A50; white-space: nowrap }
.save.saving, .save.dirty { background: #FFF6E0; color: #8A5A00 }
.save.err { background: #FDE8E7; color: #B3261E }
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px 1fr }
.ws.wide { grid-template-columns: 0 1fr }
.ws.wide .guide { padding: 0; overflow: hidden; border: 0 }
.guide { overflow-y: auto; padding: 16px 18px 40px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px }
.guide h2 { margin: 0; font-size: 22px }
.guide .lead { margin: 0; font-size: 17px }
.guide-thumb { width: 100%; border-radius: 16px; border: 1px solid var(--line) }
.howbox { background: #ECFBF6; border: 1px solid #B7EBDB; border-radius: 16px; padding: 12px 14px }
.howbox p { margin: 4px 0 0 }
.howbox.bug { background: #FFF6E0; border-color: #F4D58A }
.guide .tip { color: var(--muted); font-size: 14px; margin: 0 }
.guide .btn.next { width: 100% }
.dots { display: flex; gap: 6px; flex-wrap: wrap }
.dot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font: 700 14px Lexend; cursor: pointer; color: var(--muted) }
.dot.ok { background: #1E9E6A; border-color: #1E9E6A; color: #fff }
.dot.cur { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 3px var(--lime) }
.dot.cur.ok { color: #fff }
.stepcard { border: 3px solid var(--ink); border-radius: 18px; padding: 14px 16px; background: #fff }
.stepcard.done { border-color: #1E9E6A; background: #F2FBF6 }
.stepno-big { font: 700 14px Lexend; color: var(--blue); text-transform: uppercase; letter-spacing: .05em }
.stepcard p { margin: 6px 0 0; font-size: 18px; line-height: 1.5 }
.stepnav { display: flex; gap: 8px }
.stepnav .btn.big { flex: 1 }
.yay { background: var(--ink); color: #fff; border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px }
.yay b { color: var(--lime); font-family: Lexend }
.yay .btn { background: var(--lime); color: var(--ink) }
.more { border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px }
.more summary { cursor: pointer; font-weight: 700; font-family: Lexend; padding: 4px 0 }
.more .svg { overflow-x: auto; margin: 8px 0 }
.more svg { max-width: none; height: auto }
.more .card { border: 2px dashed var(--line); border-radius: 14px; padding: 10px; margin: 8px 0; text-align: left }
.more .card .svg svg { max-width: 100% }
.more .card p, .more .note { margin: 4px 0 0; font-size: 14px }
.guide .chall { grid-template-columns: 1fr }
.guide .home-task { margin-top: 4px }
.mini { margin: 0; padding-left: 20px }
.review { background: #FFFBEA; border: 1px solid #F4D58A; border-radius: 14px; padding: 10px 12px }
.review p { margin: 6px 0 0 }
.stagebox { position: relative; background: #E9EEF7; min-width: 0 }
.frame { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; background: #fff; transform-origin: 0 0 }
.frame-note { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; pointer-events: none }
.stagebox.ready .frame-note { display: none }
.ws[data-phase="play"] .editor { visibility: hidden }
.ws:not([data-phase="play"]) .player { display: none }
.ws[data-phase="play"] .frame-note { display: none }
@media (max-width: 1100px) { .ws { grid-template-columns: 320px 1fr } .ph { padding-right: 10px } .wsmenu .btn { padding: 6px 8px } }
@media (max-width: 860px) {
  body.ws-mode { overflow: auto }
  body.ws-mode #app { height: auto }
  .ws { display: flex; flex-direction: column }
  .stagebox { height: 70vh }
}

/* ---------- tinh gọn trang làm bài (v2) ---------- */
body.ws-mode .top, body.ws-mode .bar { display: none }
.wsbar { padding: 5px 10px; gap: 10px; min-height: 46px; border-bottom: 3px solid transparent; border-image: var(--grad) 1 }
.wstitle small { font-size: 11px }
.wstitle b { font-size: 15px; font-weight: 600 }
.phases { gap: 4px }
.ph { font-size: 13.5px; font-weight: 500; padding: 3px 12px 3px 4px; min-height: 32px; border-width: 1.5px; gap: 6px }
.ph span { width: 22px; height: 22px; font-size: 12px }
.wsright { gap: 6px }
.save { font-size: 12px; font-weight: 500; padding: 4px 10px 4px 8px; display: inline-flex; align-items: center; gap: 6px }
.save::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8 }
.ibtn { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; padding: 0; text-decoration: none; flex: none }
.ibtn:hover { border-color: var(--ink) }
.ibtn.armed { background: #FDE8E7; border-color: #B3261E; color: #B3261E }
.ico { display: inline-grid; place-items: center }
.ws { grid-template-columns: 300px 1fr }
.guide { padding: 12px 14px 32px; gap: 10px; font-size: 14.5px }
.guide h2 { font-size: 17px }
.guide .lead { font-size: 15px }
.howbox { padding: 10px 12px; border-radius: 12px }
.guide .btn { font-size: 14.5px; font-weight: 600; min-height: 40px; padding: 8px 14px; border-radius: 10px }
.guide .btn.sm { min-height: 34px; font-size: 13.5px }
.dot { width: 28px; height: 28px; font-size: 12.5px; border-width: 1.5px }
.stepcard { border-width: 2px; border-radius: 14px; padding: 10px 12px }
.stepno-big { font-size: 12px }
.stepcard p { font-size: 15.5px; line-height: 1.5 }
.stepnav .btn.ghost { flex: none; width: 48px; padding: 0 }
.stepnav .btn:not(.ghost) { flex: 1 }
.yay { padding: 10px 12px; border-radius: 12px; font-size: 14px }
.more { padding: 6px 10px; border-radius: 12px; font-size: 14px }
.more summary { font-size: 14px; font-weight: 600 }
.guide .ch { padding: 10px; border-width: 2px; border-radius: 12px; font-size: 14px }
.guide .home-task { padding: 10px 12px; border-radius: 12px; font-size: 14px }
.stagebox:fullscreen { background: #000 }
.fsbar { display: none }
.stagebox.fs .fsbar { display: flex; position: absolute; z-index: 5; bottom: 44px; left: 80px; align-items: center; gap: 8px; max-width: min(640px, 48%);
  background: rgba(13, 18, 51, .92); color: #fff; border-radius: 999px; padding: 4px 4px 4px 14px; font-size: 13.5px; box-shadow: 0 4px 16px rgba(0,0,0,.25) }
.fsstep { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.fsstep:empty { display: none }
.fsbar .ibtn { width: 30px; height: 30px; border-radius: 999px; background: var(--lime); border: 0 }
@media (max-width: 1100px) { .ws { grid-template-columns: 270px 1fr } .wstitle small { display: none } }
.guide .btn.next { width: 100%; align-self: stretch }
