:root {
  --cream: #faf7f2; --card: #ffffff; --navy: #1b2a4a; --ink: #24304a; --muted: #6b7489; --line: #ebe6dc;
  --blue: #3557d6; --blue-soft: #e8edff; --red: #e63946; --red-soft: #fdebed; --gold: #f4b740;
  --green: #2f9e6f; --green-soft: #e3f6ec; --amber: #f08c00; --amber-soft: #fff1db; --pink-soft: #fde7ec; --teal-soft: #dff5f7;
  --radius: 18px; --shadow: 0 1px 2px rgba(27,42,74,.05), 0 6px 24px rgba(27,42,74,.06);
  --admin-bg: #0f172a; --admin-card: #111c33; --admin-line: #22304d; --admin-ink: #e2e8f0; --admin-muted: #94a3b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--cream); color: var(--ink); font: 15px/1.55 'Plus Jakarta Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .serif { font-family: 'Fraunces', Georgia, serif; color: var(--navy); line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 5vw, 52px); } h2 { font-size: clamp(22px, 3vw, 30px); } h3 { font-size: 18px; }
a { color: var(--blue); text-decoration: none; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
button, .btn { font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 10px 18px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; justify-content: center; transition: transform .08s, background .2s; text-align: center; }
button:active, .btn:active { transform: scale(.98); }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: #2846b8; }
.btn-dark { background: var(--navy); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-soft { background: var(--blue-soft); color: var(--blue); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; color: var(--navy); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
label.check input { width: auto; margin-top: 3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.split { grid-template-columns: 2fr 1fr; }
.speak-grid { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); }
@media (max-width: 860px) { .speak-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue); }
.pill.gold { background: #fff4cc; color: #8a6100; } .pill.red { background: var(--red-soft); color: var(--red); } .pill.green { background: var(--green-soft); color: var(--green); } .pill.grey { background: #eef0f4; color: var(--muted); }
.tag-demo { background: #fff4cc; color: #8a6100; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.section { padding: 56px 0; }
.center { text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.tricolor { display: inline-flex; height: 4px; width: 54px; border-radius: 4px; overflow: hidden; }
.tricolor i { flex: 1; } .tricolor i:nth-child(1) { background: var(--blue); } .tricolor i:nth-child(2) { background: #fff; border: 1px solid var(--line); } .tricolor i:nth-child(3) { background: var(--red); }

/* public header */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(250,247,242,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: 'Fraunces', serif; font-weight: 700; color: var(--navy); font-size: 18px; }
.logo .flag { width: 30px; height: 30px; border-radius: 8px; background: var(--navy); display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px 6px; gap: 0; }
.logo .flag i:nth-child(1) { background: var(--blue); } .logo .flag i:nth-child(2) { background: #fff; } .logo .flag i:nth-child(3) { background: var(--red); }
.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav a { color: var(--ink); font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--blue); }
.menu-btn { display: none; margin-left: auto; background: none; font-size: 22px; padding: 6px 10px; }
@media (max-width: 900px) {
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--cream); flex-direction: column; padding: 16px; border-bottom: 1px solid var(--line); align-items: stretch; }
  .nav.open { display: flex; }
  .menu-btn { display: block; }
}
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero p.lead { font-size: 18px; color: var(--muted); max-width: 540px; }
.hero-teachers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tcard { border-radius: var(--radius); padding: 16px; text-align: center; border: 1px solid var(--line); background: #fff; position: relative; transition: transform .15s, box-shadow .15s; }
.tcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tcard.sel { outline: 3px solid var(--blue); }
.tcard .avatar { margin: 0 auto 8px; }
.avatar { border-radius: 50%; overflow: hidden; display: block; flex: none; }
.avatar.talking { animation: talk .5s ease-in-out infinite alternate; }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.03); } }
.feature { display: flex; gap: 14px; }
.feature .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; }
footer { border-top: 1px solid var(--line); padding: 32px 0; color: var(--muted); font-size: 13px; margin-top: 40px; }
.price { font-family: 'Fraunces', serif; font-size: 34px; color: var(--navy); font-weight: 700; }
.plan.popular { border: 2px solid var(--blue); }
ul.ticks { list-style: none; padding: 0; margin: 12px 0; } ul.ticks li { padding: 4px 0 4px 24px; position: relative; } ul.ticks li::before { content: '✓'; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.auth { max-width: 460px; margin: 40px auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* student portal */
.portal { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; font-size: 14px; }
.side a:hover { background: var(--cream); }
.side a.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 12px 6px; font-weight: 700; }
.main { padding: 22px 28px 90px; max-width: 1180px; width: 100%; }
.ptop { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.ptop h2 { min-width: 0; flex: 1 1 auto; }
.main { min-width: 0; }
.ptop h2 { margin: 0; font-size: 22px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; position: relative; padding: 0; color: var(--ink); }
.iconbtn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.bottomnav { display: none; }
@media (max-width: 860px) {
  .portal { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 90px; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); gap: 2px; padding: 4px 8px; }
  .bottomnav a.on { color: var(--blue); font-weight: 600; }
  .bottomnav a span { font-size: 20px; }
}
.skill { border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; min-height: 132px; display: flex; flex-direction: column; border: 1px solid transparent; }
.skill h3 { margin: 8px 0 2px; }
.skill .blob { position: absolute; right: -18px; bottom: -22px; width: 92px; height: 92px; border-radius: 40% 60% 55% 45%; opacity: .55; }
.skill .go { margin-top: auto; align-self: flex-start; background: #fff; color: var(--navy); }
.premium-card { background: linear-gradient(135deg, #fff 0%, #fff 55%, var(--blue-soft) 100%); }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; display: flex; gap: 12px; align-items: center; background: #fff; }
.stat .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; }
.stat b { display: block; font-size: 16px; color: var(--navy); }
.bar { height: 10px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), #6d8bff); border-radius: 99px; }
.count { display: flex; gap: 8px; align-items: center; justify-content: center; }
.count div { background: #f1ecfb; color: #6b3fb8; border-radius: 12px; min-width: 56px; padding: 8px 6px; text-align: center; }
.count b { display: block; font-size: 22px; font-family: 'Fraunces', serif; }
.count small { font-size: 11px; color: #8a76b5; }
.todo { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.todo:last-child { border-bottom: 0; }
.todo .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; flex: none; }
.todo.done .tick { background: var(--green); border-color: var(--green); color: #fff; }
.todo.done .t { text-decoration: line-through; color: var(--muted); }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 12px 14px; position: relative; }
.lock { filter: grayscale(.4); opacity: .65; }
.lock-ic { font-size: 13px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; min-height: 260px; overflow-y: auto; padding: 4px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; }
.msg.t { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.s { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.s.bad { background: #5b6fd6; }
.msg .fixline { display: block; margin-top: 6px; font-size: 13px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { min-height: 48px; max-height: 120px; resize: vertical; flex: 1; min-width: 0; }
.mic-status { min-height: 22px; margin-top: 8px; font-size: 14px; }
.mic-status.err { color: var(--red); }
.say { background: none; border: 0; padding: 2px 6px; font-size: 16px; cursor: pointer; border-radius: 8px; }
.say:hover { background: var(--blue-soft); }
.word-ok { color: var(--green); font-weight: 600; }
.word-miss { color: var(--red); font-weight: 600; text-decoration: underline wavy; }
@media (max-width: 860px) {
  .msg { max-width: 92%; }
  .chat { max-height: 58vh; }
  .grid.g2, .grid.g3 { grid-template-columns: minmax(0, 1fr); }
}
.mic { width: 52px; height: 52px; border-radius: 50%; background: var(--red); color: #fff; font-size: 22px; padding: 0; flex: none; }
.mic.on { animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(230,57,70,.5); } 100% { box-shadow: 0 0 0 16px rgba(230,57,70,0); } }
.wave { display: inline-flex; gap: 2px; align-items: center; height: 18px; }
.wave i { width: 3px; background: currentColor; border-radius: 2px; animation: w 0.9s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .1s } .wave i:nth-child(3) { animation-delay: .2s } .wave i:nth-child(4) { animation-delay: .3s }
@keyframes w { 0%,100% { height: 4px } 50% { height: 16px } }

/* lesson player */
.player { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 24px; display: grid; grid-template-columns: 160px 1fr; gap: 22px; align-items: center; min-height: 260px; position: relative; overflow: hidden; }
.player .cap { font-size: 20px; line-height: 1.45; min-height: 90px; }
.player .cap.fr { font-family: 'Fraunces', serif; font-size: 26px; color: #ffd8dc; }
.player .ctl { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.player .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255,255,255,.15); }
.player .prog i { display: block; height: 100%; background: var(--red); transition: width .3s; }
@media (max-width: 640px) { .player { grid-template-columns: 1fr; text-align: center; } .player .avatar { margin: 0 auto; } .player .ctl { justify-content: center; } }

/* flashcards */
.flash { perspective: 1000px; height: 260px; cursor: pointer; max-width: 460px; margin: 0 auto; }
.flash .inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flash.flip .inner { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.flash .back { transform: rotateY(180deg); background: var(--blue-soft); }
.flash .word { font-family: 'Fraunces', serif; font-size: 36px; color: var(--navy); }

/* quiz */
.opt { display: block; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); color: var(--ink); padding: 12px 16px; margin: 8px 0; font-weight: 500; justify-content: flex-start; }
.opt:hover:not(:disabled) { border-color: var(--blue); }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.picked { border-color: var(--blue); background: var(--blue-soft); }

/* picture activity */
.scene { border-radius: var(--radius); min-height: 260px; display: grid; place-items: center; position: relative; overflow: hidden; border: 1px solid var(--line); }
.scene .em { font-size: clamp(54px, 9vw, 84px); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; filter: drop-shadow(0 6px 10px rgba(0,0,0,.08)); }
.scene .ttl { position: absolute; top: 12px; left: 14px; background: rgba(255,255,255,.85); padding: 4px 12px; border-radius: 99px; font-weight: 600; font-size: 13px; }
.score-ring { width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; font-family: 'Fraunces', serif; font-size: 30px; color: var(--navy); flex: none; }
.diff del { color: var(--red); text-decoration: line-through; } .diff ins { color: var(--green); text-decoration: none; font-weight: 700; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.chart .b { flex: 1; background: var(--blue-soft); border-radius: 6px 6px 0 0; position: relative; min-width: 14px; }
.chart .b i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--blue); border-radius: 6px 6px 0 0; }
.chart .b span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.chart .b em { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; font-style: normal; color: var(--navy); font-weight: 600; }

.badge { text-align: center; padding: 16px 10px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.badge .e { font-size: 34px; }
.badge.off { opacity: .4; filter: grayscale(1); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; background: var(--red-soft); color: var(--red); padding: 6px 12px; border-radius: 10px; }
.exam-lock { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 13px; }
.banner { background: #fff4cc; color: #6b4b00; padding: 10px 16px; font-size: 13px; text-align: center; }
.banner a { color: #6b4b00; font-weight: 700; text-decoration: underline; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; }

/* admin portal — deliberately different look */
.admin { background: var(--admin-bg); color: var(--admin-ink); min-height: 100vh; display: grid; grid-template-columns: 220px 1fr; }
.admin h1, .admin h2, .admin h3 { color: #fff; font-family: 'Plus Jakarta Sans', sans-serif; }
.admin .aside { border-right: 1px solid var(--admin-line); padding: 18px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin .aside a { display: flex; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--admin-muted); font-size: 14px; }
.admin .aside a.on, .admin .aside a:hover { background: var(--admin-card); color: #fff; }
.admin .amain { padding: 22px 26px 60px; overflow-x: hidden; }
.admin .card { background: var(--admin-card); border-color: var(--admin-line); box-shadow: none; color: var(--admin-ink); }
.admin th { color: var(--admin-muted); } .admin td, .admin th { border-color: var(--admin-line); }
.admin input, .admin select, .admin textarea { background: #0b1324; color: var(--admin-ink); border-color: var(--admin-line); }
.admin label { color: var(--admin-muted); }
.admin .muted, .admin small { color: var(--admin-muted); }
.admin .btn-ghost { color: var(--admin-ink); border-color: var(--admin-line); }
.admin a { color: #8ea8ff; }
.kpi b { display: block; font-size: 26px; color: #fff; font-weight: 700; }
.kpi span { font-size: 12px; color: var(--admin-muted); text-transform: uppercase; letter-spacing: .05em; }
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.kanban .col { min-width: 210px; background: #0b1324; border: 1px solid var(--admin-line); border-radius: 12px; padding: 10px; }
.kanban .lead { background: var(--admin-card); border: 1px solid var(--admin-line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: 13px; cursor: pointer; }
.hbar { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; }
.hbar .t { width: 150px; flex: none; color: var(--admin-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .b { flex: 1; height: 16px; background: #0b1324; border-radius: 6px; overflow: hidden; }
.hbar .b i { display: block; height: 100%; background: linear-gradient(90deg, #3557d6, #7c93ff); }
.sev-error { color: #ff8b94; } .sev-warn { color: #ffd166; } .sev-info { color: var(--admin-muted); }
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .admin .aside { position: static; height: auto; display: flex; overflow-x: auto; gap: 4px; border-right: 0; border-bottom: 1px solid var(--admin-line); padding: 8px; }
  .admin .aside a { white-space: nowrap; }
  .admin .aside .hide-m { display: none; }
  .admin .amain { padding: 16px; }
}

@media print {
  .side, .bottomnav, .ptop, .banner, .main > p.center { display: none !important; }
  .portal { display: block; }
  body { background: #fff; }
  #cert { box-shadow: none; }
}
