/* Manten: giao diện tối giản, màu theo thương hiệu (xanh đậm, xanh nhạt, hồng nhạt). Ưu tiên điện thoại. */
:root {
  --brand: #10291a;
  --brand-2: #1a4a2a;
  --soft: #e5efd7;
  --pink: #fae6e6;
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #218838;
  --bad: #dc3545;
  --warn: #f0ad00;
  --radius: 14px;
  --tabbar-h: 58px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, 'Noto Sans JP', 'Yu Gothic', Arial, sans-serif;
  line-height: 1.5; font-size: 16px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
ruby rt { font-size: 0.55em; }

/* ---------- khung ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 17px; letter-spacing: .3px; }
.brand-text small { font-size: 11px; opacity: .75; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a { padding: 8px 14px; border-radius: 20px; font-size: 14px; opacity: .85; }
.topnav a:hover { opacity: 1; background: rgba(255,255,255,.1); }
.topnav a.on { background: var(--soft); color: var(--brand); opacity: 1; font-weight: 600; }

.view { max-width: 960px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 28px); min-height: calc(100vh - 56px); }
body.no-chrome .topbar, body.no-chrome .tabbar { display: none; }
body.no-chrome .view { padding-bottom: 28px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.tabbar a {
  flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11.5px; color: var(--muted);
}
.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--brand); font-weight: 700; }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .view { padding: 24px 20px 48px; }
}

/* ---------- thành phần chung ---------- */
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs a { color: var(--brand-2); font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.page-title { font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 14.5px; margin-bottom: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.06); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px;
  padding: 10px 18px; background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
}
.btn:hover { background: var(--brand-2); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: var(--soft); }
.btn.soft { background: var(--soft); color: var(--brand); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }

.bar { height: 8px; background: #e8ece9; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.bar.pink > i { background: #c0564e; }
.meta { font-size: 13px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--soft); color: var(--brand); border-radius: 99px; padding: 2px 9px; font-size: 12.5px; }
.chip.warn { background: #fff3cd; color: #8a6d00; }
.chip.ok { background: #d6efdc; color: #14632a; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 17px; }
.spinner { text-align: center; color: var(--muted); padding: 48px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 99;
  pointer-events: none; transition: all .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- đăng nhập ---------- */
.auth-wrap { max-width: 400px; margin: 6vh auto 0; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo .brand-mark { width: 56px; height: 56px; font-size: 30px; border-radius: 16px; background: var(--brand); color: var(--soft); margin: 0 auto 10px; }
.auth-logo h1 { font-size: 24px; color: var(--brand); }
.auth-logo p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; color: var(--brand); }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid #cfd8d2; border-radius: 10px; background: #fff; font-size: 16px;
}
.field input:focus { outline: 2px solid var(--soft); border-color: var(--brand-2); }
.form-err { color: var(--bad); font-size: 14px; margin: 4px 0 10px; min-height: 1em; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 14.5px; color: var(--muted); }
.auth-switch a { color: var(--brand-2); font-weight: 600; }

/* ---------- khóa học của tôi ---------- */
.hello { margin-bottom: 14px; }
.hello h1 { font-size: 22px; color: var(--brand); }
.hello p { margin: 2px 0 0; color: var(--muted); font-size: 14.5px; }
.course-card { display: block; padding: 18px; border-left: 5px solid var(--brand); transition: transform .12s, box-shadow .12s; }
.course-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.course-card h2 { font-size: 19px; color: var(--brand); }
.course-card .sub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.course-card .row { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 10px; }
.course-card .pct { font-weight: 700; color: var(--ok); }
.continue { display: flex; align-items: center; gap: 8px; background: var(--soft); color: var(--brand); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-weight: 600; }
.continue small { font-weight: 400; color: #425a47; display: block; }

/* ---------- chi tiết khóa / mục ---------- */
.hero { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.hero h1 { font-size: 22px; }
.hero p { margin: 2px 0 12px; opacity: .8; font-size: 14.5px; }
.hero .bar { background: rgba(255,255,255,.2); }
.hero .bar > i { background: var(--soft); }
.hero .meta { color: rgba(255,255,255,.8); margin-top: 6px; }
.hero .btn { background: var(--soft); color: var(--brand); margin-top: 12px; }
.sec-card { display: block; padding: 16px; }
.sec-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.sec-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.sec-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; font-size: 22px; flex: none; }
.sec-head h3 { font-size: 17px; color: var(--brand); }
.sec-head small { color: var(--muted); font-size: 13px; }
.sec-card .meta { margin-top: 6px; }
.sec-card.soon { opacity: .65; }
.sec-card.soon:hover { box-shadow: none; }

.group-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-2); margin: 18px 0 8px; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border-radius: 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.lesson-row:hover { background: #fafcf8; }
.lesson-num { width: 36px; height: 36px; border-radius: 10px; background: var(--soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.lesson-row.done .lesson-num { background: var(--ok); color: #fff; }
.lesson-body { flex: 1; min-width: 0; }
.lesson-body b { display: block; font-weight: 600; }
.lesson-body .types { font-size: 13px; color: var(--muted); }
.lesson-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lesson-row.done .lesson-state { color: var(--ok); font-weight: 600; }

/* ---------- bài học ---------- */
.lesson-title { font-size: 21px; color: var(--brand); font-weight: 700; margin-bottom: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; border-bottom: 2px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 10px 14px; border: 0; background: none; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--muted); font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab .ck { color: var(--ok); margin-left: 4px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.lesson-nav .btn { flex: 1; max-width: 260px; }
.lesson-nav .btn.right { margin-left: auto; }

.player { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; width: 100%; }
.player video, .player iframe { width: 100%; height: 100%; border: 0; display: block; }
.watch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* thẻ từ vựng */
.fc { perspective: 1000px; cursor: pointer; margin: 0 auto 14px; max-width: 560px; }
.fc-in { position: relative; height: clamp(300px, 62vh, 460px); transition: transform .45s; transform-style: preserve-3d; }
.fc.flip .fc-in { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0,0,0,.1); padding: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow-y: auto;
}
.fc-back { transform: rotateY(180deg); justify-content: flex-start; text-align: left; align-items: stretch; background: #fbfdf9; }
.fc-no { position: absolute; top: 10px; left: 14px; font-size: 12.5px; color: var(--muted); }
.fc-jp { font-size: 46px; font-weight: 700; color: var(--brand); line-height: 1.2; word-break: break-all; }
.fc-read { font-size: 20px; color: var(--brand-2); margin-top: 6px; }
.fc-type { margin-top: 8px; }
.fc-hint { position: absolute; bottom: 10px; font-size: 12.5px; color: #9ca3af; }
.fc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.fc-head .jp { font-size: 24px; font-weight: 700; color: var(--brand); }
.fc-head .read { color: var(--brand-2); }
.fc-vn { font-size: 19px; font-weight: 600; margin-bottom: 10px; }
.fc-ex { border-left: 3px solid var(--soft); padding: 4px 0 4px 10px; margin-bottom: 8px; font-size: 15px; }
.fc-ex .vn { color: var(--muted); font-size: 13.5px; }
.fc-notes { background: #f6f8f4; border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 14px; }
.fc-notes b { color: var(--brand); }
.fc-notes ul { margin: 4px 0 0; padding-left: 18px; }
.fc-controls { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.fc-count { background: #fff; border-radius: 99px; padding: 6px 16px; font-weight: 700; color: var(--muted); min-width: 84px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.fc-tools { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.shuffle.on { background: var(--brand); color: #fff; }
.word-list .w { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; background: #fff; border-radius: 10px; margin-bottom: 6px; cursor: pointer; }
.word-list .w.on { background: var(--pink); }
.word-list .w b { min-width: 84px; color: var(--brand); }
.word-list .w span { color: var(--muted); font-size: 14px; }

/* bài tập */
.quiz-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.q { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.06); padding: 14px 14px 8px; margin-bottom: 12px; }
.q-num { font-size: 12.5px; font-weight: 700; color: var(--brand-2); margin-bottom: 4px; }
.q-text { font-size: 17px; margin-bottom: 10px; line-height: 1.7; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.opt:hover { background: #f7faf5; }
.opt input { margin-top: 5px; flex: none; }
.opt.picked { background: #e6f7ff; border-color: #8ccaf0; }
.opt.right { background: #e4f5e8; border-color: #6fc283; }
.opt.wrong { background: #fde8ea; border-color: #ee9aa2; }
.opt .mk { margin-left: auto; font-weight: 700; }
.opt.right .mk { color: var(--ok); }
.opt.wrong .mk { color: var(--bad); }
.explain { background: #eef6ff; border-left: 4px solid var(--brand); border-radius: 8px; padding: 8px 12px; font-size: 14.5px; margin: 4px 0 10px; }
.quiz-bar { position: sticky; bottom: calc(var(--tabbar-h) + 8px); z-index: 20; background: #fff; border-radius: 99px; box-shadow: 0 2px 14px rgba(0,0,0,.18); padding: 8px 8px 8px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
@media (min-width: 900px) { .quiz-bar { bottom: 16px; } }
.result { text-align: center; padding: 22px 16px; margin-bottom: 14px; }
.result .big { font-size: 40px; font-weight: 800; color: var(--brand); }
.result.pass { background: #e4f5e8; }
.result.fail { background: var(--pink); }

.prose { background: #fff; border-radius: var(--radius); padding: 16px; line-height: 1.8; }

/* ---------- tiến độ / tài khoản / quản trị ---------- */
.prog-card { margin-bottom: 14px; }
.prog-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.prog-top h2 { font-size: 18px; color: var(--brand); }
.ring { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; color: var(--brand);
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), #e8ece9 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 7px; background: #fff; border-radius: 50%; }
.ring span { position: relative; font-size: 15px; }
.sec-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14.5px; }
.sec-line .nm { width: 120px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-line .bar { flex: 1; }
.sec-line .n { width: 54px; text-align: right; color: var(--muted); font-size: 13px; flex: none; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.recent li:last-child { border-bottom: 0; }
.recent .t { flex: 1; min-width: 0; }
.recent .t small { display: block; color: var(--muted); }
.recent .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.acct-grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .acct-grid { grid-template-columns: 1fr 1fr; } }
.acct-hd { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar { width: 60px; height: 60px; border-radius: 50%; background: var(--brand); color: var(--soft); display: grid; place-items: center; font-weight: 700; font-size: 24px; flex: none; }

.admin-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-tabs .tab { border: 1px solid var(--line); border-radius: 99px; margin: 0; background: #fff; }
.admin-tabs .tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.u-row { background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.u-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.u-top b { display: block; }
.u-top small { color: var(--muted); }
.u-courses { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 14.5px; }
.u-courses label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.u-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tbl th { font-size: 12.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
