/* Pika AI Tutor — app styles. Tokens only (see tokens.css, Pika Design System). Light mode only, no emoji. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: var(--font-bold);
  font-size: 17px;
  line-height: 26px;
  color: var(--text-primary);
  background: var(--surface-bg);
  font-feature-settings: var(--font-features-default);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- type helpers ---------- */
.overline { font-size: 11px; line-height: 1; font-weight: var(--font-bold); letter-spacing: .6px; text-transform: uppercase; color: var(--text-secondary); }
.label { font-size: 13px; line-height: 1; font-weight: var(--font-semibold); letter-spacing: .3px; color: var(--text-secondary); }
.micro { font-size: 11px; line-height: 1; font-weight: var(--font-bold); letter-spacing: .6px; color: var(--text-secondary); }
.title1 { font-size: 24px; line-height: 32px; font-weight: var(--font-extrabold); color: var(--text-heading); margin: 0; }
.title2 { font-size: 20px; line-height: 28px; font-weight: var(--font-extrabold); color: var(--text-heading); margin: 0; }
.display { font-size: 32px; line-height: 40px; font-weight: var(--font-black); color: var(--text-heading); margin: 0; }
.muted { color: var(--text-secondary); font-weight: var(--font-semibold); }
.caption { font-size: 14px; line-height: 20px; font-weight: var(--font-regular); color: var(--text-secondary); }
.numeric { font-feature-settings: var(--font-features-numeric); }

/* ---------- icons (Iconsax via mask, color = currentColor) ---------- */
.ic { display: inline-block; width: var(--icon-md); height: var(--icon-md); background: currentColor; flex: none;
      -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.ic.sm { width: var(--icon-sm); height: var(--icon-sm); }
.ic.lg { width: var(--icon-lg); height: var(--icon-lg); }

/* ---------- buttons: the 3D push-down is for buttons only ---------- */
.btn {
  --bg: var(--color-primary); --depth: var(--color-primary-shadow); --fg: var(--text-on-brand);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 50px; padding: 0 var(--space-5); border: 0; border-radius: var(--radius-xl);
  background: var(--bg); color: var(--fg); border-bottom: var(--button-depth) solid var(--depth);
  font-size: 15px; line-height: 20px; font-weight: var(--font-extrabold); letter-spacing: .8px; text-transform: uppercase;
  cursor: pointer; user-select: none; transition: transform var(--motion-fast) var(--ease-spring), border-bottom-width var(--motion-fast);
}
.btn:active { transform: translateY(3px); border-bottom-width: 1px; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring-shadow); }
.btn[disabled] { --bg: var(--surface-disabled); --depth: var(--neutral-200); --fg: var(--text-disabled); cursor: not-allowed; }
.btn.lg { min-height: 60px; font-size: 17px; }
.btn.sm { min-height: 40px; padding: 0 var(--space-4); font-size: 13px; border-radius: var(--radius-lg); }
.btn.block { width: 100%; }
.btn.secondary { --bg: var(--surface-card); --depth: var(--neutral-200); --fg: var(--text-link); box-shadow: inset 0 0 0 2px var(--neutral-200); }
.btn.danger { --bg: var(--color-error); --depth: var(--color-error-shadow); }
.btn.reward { --bg: var(--color-reward); --depth: var(--color-reward-shadow); --fg: var(--text-on-warning); }
.btn.ghost { --bg: transparent; --depth: transparent; --fg: var(--text-secondary); border-bottom-width: 0; text-transform: none; letter-spacing: 0; font-size: 15px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-pill); border: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--state-hover); color: var(--text-primary); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--state-pressed); }
.icon-btn.on { background: var(--surface-primary); color: var(--cyan-600); }

/* ---------- golden soft card ---------- */
.card { background: var(--surface-soft); border: 1px solid var(--border-soft); box-shadow: var(--shadow-soft); border-radius: var(--radius-2xl); padding: var(--space-5); }
.card.white { background: var(--surface-card); box-shadow: var(--shadow-soft-on-white); }
.card.tight { padding: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.input, select.input {
  height: 52px; padding: 0 var(--space-4); border-radius: var(--radius-xl); border: 1.5px solid var(--border-default);
  background: var(--surface-card); font-size: 17px; font-weight: var(--font-bold); color: var(--text-heading); outline: none; width: 100%;
}
.input::placeholder { color: var(--text-placeholder); font-weight: var(--font-semibold); }
.input:focus { border-color: var(--border-focus); box-shadow: var(--focus-ring-shadow); }
.error-text { color: var(--color-error); font-size: 14px; line-height: 20px; font-weight: var(--font-semibold); min-height: 20px; }

/* ---------- chips / segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1.5px solid var(--border-default);
  background: var(--surface-card); color: var(--text-heading); font-size: 15px; font-weight: var(--font-extrabold); cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.chip.selected { border-color: var(--cyan-400); color: var(--cyan-600); background: var(--surface-primary); box-shadow: var(--shadow-brand-sm); }
/* Trúc 14/10: parts not ready yet («Sắp ra mắt»): shown, greyed, not pickable */
.soon { opacity: .55; cursor: not-allowed; }
.mode.soon:hover { transform: none; }
.soon-tag { display: inline-block; margin-left: var(--space-2); padding: 1px 8px; border-radius: var(--radius-pill); font-size: 11px;
  line-height: 18px; font-weight: var(--font-extrabold); letter-spacing: .03em; vertical-align: 2px;
  background: var(--surface-primary); color: var(--cyan-600); border: 1px solid var(--cyan-400); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: var(--z-header); display: flex; align-items: center; gap: var(--space-3);
          min-height: var(--header-height); padding: var(--space-2) var(--screen-padding); background: var(--glass-tint);
          backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--glass-border); }
.topbar .grow { flex: 1; min-width: 0; }
/* pika-math-fe: về Đảo học (trang chủ của Pika Math) */
.topbar .brand-link { display: inline-flex; border-radius: var(--radius-lg); }
.topbar .brand-link:focus-visible, .dao-hoc-btn:focus-visible { outline: none; box-shadow: var(--focus-ring-shadow); }
.dao-hoc-btn { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-4); flex: none;
  border-radius: var(--radius-pill); background: var(--state-hover); color: var(--text-primary); font-weight: var(--font-extrabold);
  font-size: 15px; text-decoration: none; }
.dao-hoc-btn:hover { background: var(--state-pressed); }
.topbar .t { font-size: 17px; line-height: 24px; font-weight: var(--font-extrabold); color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { height: 28px; color: var(--color-primary); }
.logo img { height: 28px; width: auto; }

/* ---------- auth ---------- */
.auth { flex: 1; display: grid; place-items: center; padding: var(--space-8) var(--screen-padding); }
.auth-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: var(--space-4); }
.auth-hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.auth-hero img.mascot { width: 140px; height: 140px; object-fit: contain; }
.auth-box { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-box .caption { margin: 0; }
.auth-rieng { text-align: center; }
.auth-note { text-align: center; }
.auth-loi { padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: 1.5px solid var(--border-error);
            background: var(--surface-error); color: var(--text-heading); font-size: 15px; line-height: 22px; font-weight: var(--font-semibold); }
.auth-or { display: flex; align-items: center; gap: var(--space-3); color: var(--text-secondary); font-size: 13px; line-height: 1; font-weight: var(--font-semibold); }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border-default); }
.auth-old-title { text-align: center; }
.auth-old { display: flex; flex-direction: column; gap: var(--space-3); }
.auth-old[hidden] { display: none; }

/* ---------- Google sign-in button: Google's branding guidelines (the official "G" in its colours, vendored SVG and no
   Google script; white fill, #747775 1px border, #1F1F1F Roboto Medium text, state layer #303030 at 8 / 12 %) ---------- */
.gsi-btn {
  position: relative; display: flex; align-items: center; justify-content: center; width: 100%; max-width: 400px; height: 48px;
  margin: 0 auto; padding: 0 12px; box-sizing: border-box; overflow: hidden; -webkit-appearance: none; appearance: none;
  background: #ffffff; border: 1px solid #747775; border-radius: 9999px; color: #1f1f1f; cursor: pointer; text-decoration: none;
  font-family: "Roboto", Arial, sans-serif; font-size: 16px; line-height: 20px; font-weight: 500; letter-spacing: .25px; white-space: nowrap;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
}
.gsi-btn .gsi-state { position: absolute; inset: 0; opacity: 0; transition: opacity .218s; }
.gsi-btn .gsi-wrap { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; }
.gsi-btn .gsi-icon { width: 20px; height: 20px; min-width: 20px; }
.gsi-btn .gsi-text { overflow: hidden; text-overflow: ellipsis; }
.gsi-btn:not([disabled]):hover { box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15); }
.gsi-btn:not([disabled]):hover .gsi-state { background-color: #303030; opacity: .08; }
.gsi-btn:not([disabled]):active .gsi-state, .gsi-btn:not([disabled]):focus-visible .gsi-state { background-color: #303030; opacity: .12; }
.gsi-btn:focus-visible { outline: 2px solid #1f1f1f; outline-offset: 2px; }
.gsi-btn[disabled] { cursor: default; background-color: #ffffff61; border-color: #1f1f1f1f; }
.gsi-btn[disabled] .gsi-wrap { opacity: .38; }

/* ---------- profile: the Google line ---------- */
.ho-so-google { display: flex; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; padding-top: var(--space-3); border-top: 1px solid var(--border-default); }
.ho-so-google.col { flex-direction: column; align-items: stretch; }
.ho-so-google .grow { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.modal img.ho-so-anh { width: 40px; height: 40px; border-radius: var(--radius-pill); flex: none; }
.ho-so-email { font-size: 15px; line-height: 20px; color: var(--text-heading); overflow-wrap: anywhere; }

/* ---------- home ---------- */
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: var(--space-6) var(--screen-padding) var(--space-12); display: flex; flex-direction: column; gap: var(--space-6); }
.hero { display: flex; align-items: center; gap: var(--space-5); }
.hero img { width: 112px; height: 112px; object-fit: contain; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.stat { display: flex; align-items: center; gap: var(--space-3); }
.stat .circle { width: 48px; height: 48px; border-radius: var(--radius-pill); display: grid; place-items: center; flex: none; }
.stat .num { font-size: 24px; line-height: 28px; font-weight: var(--font-black); color: var(--neutral-900); }
.c-cyan { background: var(--surface-primary); color: var(--cyan-500); }
.c-amber { background: var(--icon-amber-bg); color: var(--icon-amber); }
.c-coral { background: var(--icon-coral-bg); color: var(--icon-coral); }
.c-lime { background: var(--icon-lime-bg); color: var(--icon-lime); }
.c-indigo { background: var(--icon-indigo-bg); color: var(--icon-indigo); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.mode { display: flex; align-items: center; gap: var(--space-4); text-align: left; cursor: pointer; border: 1px solid var(--border-soft); transition: transform var(--motion-fast); }
.mode:hover { transform: translateY(-2px); }
.mode.selected { border-color: var(--cyan-400); box-shadow: var(--shadow-brand-sm); }
.mode .circle { width: 56px; height: 56px; border-radius: var(--radius-pill); display: grid; place-items: center; flex: none; }
.mode .mt { font-size: 17px; line-height: 24px; font-weight: var(--font-extrabold); color: var(--text-heading); }
.mode .md { font-size: 14px; line-height: 20px; font-weight: var(--font-semibold); color: var(--text-secondary); margin-top: 2px; }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); justify-content: space-between; }
.list { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); cursor: pointer; box-shadow: var(--shadow-soft-sm); color: var(--text-secondary); }
.row .rt { font-size: 15px; line-height: 22px; font-weight: var(--font-extrabold); color: var(--text-heading); }
.row .rd { font-size: 13px; line-height: 18px; font-weight: var(--font-semibold); color: var(--text-secondary); }
.row .grow { flex: 1; min-width: 0; }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-6); text-align: center; }
.empty img { width: 96px; height: 96px; object-fit: contain; }

/* ---------- learning session ---------- */
.session { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--space-4); padding: var(--space-4) var(--screen-padding);
           max-width: 1600px; width: 100%; margin: 0 auto; min-height: 0; height: calc(100dvh - var(--header-height) - 16px); grid-template-rows: minmax(0, 1fr); }
.board-card { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-3); border-bottom: 1px solid var(--neutral-100); }
.board { flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); scroll-behavior: smooth; min-height: 0; }
/* the current picture, fixed above the scrolling board (board.js stage()) */
.board-stage { flex: none; max-height: 62%; overflow-y: auto; padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--neutral-100);
               background: color-mix(in srgb, var(--surface-card) 90%, var(--cyan-100)); }
.board-stage:empty { display: none; }
.board-stage .blk-visual > .overline { margin-bottom: var(--space-2); }
.board-stage.cu .blk-visual { opacity: .5; }
.board-stage.cu .blk-visual > .overline::after { content: var(--bang-vua-xong, " · bài vừa xong"); }
/* KaTeX's hidden MathML is absolutely positioned: keep it inside the scrolling boxes, not under the page */
.board, .board-stage, .chat { position: relative; }
.side { display: flex; flex-direction: column; gap: var(--space-3); min-height: 0; }
.cam-card { padding: var(--space-3); }
.cam-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: var(--neutral-800); aspect-ratio: 4 / 3; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-off { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-inverse); padding: var(--space-4); }
.cam-badge { position: absolute; top: var(--space-2); left: var(--space-2); padding: 6px 10px; border-radius: var(--radius-pill); background: var(--surface-overlay); color: var(--text-inverse); }
.cam-orient { position: absolute; top: var(--space-2); right: var(--space-2); display: flex; gap: var(--space-1); }
.cam-orient-btn { width: 36px; height: 36px; border: 0; border-radius: var(--radius-pill); background: var(--surface-overlay);
  color: var(--text-inverse); font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.cam-orient-btn[aria-pressed="true"] { background: var(--cyan-500); }
.cam-orient-btn:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
.cam-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }
.cam-actions .btn { flex: 1; }
a.btn { text-decoration: none; }

/* ---------- camera source picker (cam-nguon.js): webcams, and the phone through VDO.ninja ---------- */
.cam-wrap.tu-xa video { object-fit: contain; }  /* a phone in portrait: show the whole page, not a crop */
.cam-off-nut { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.cam-tin { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
           gap: var(--space-2); padding: var(--space-3); text-align: center; color: var(--text-inverse); background: var(--surface-overlay);
           font-size: 14px; line-height: 20px; overflow-y: auto; }
.cam-tin-a { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.cam-tin-btn { min-height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1.5px solid rgba(255, 255, 255, .75);
               background: transparent; color: var(--text-inverse); font-size: 13px; font-weight: var(--font-extrabold); cursor: pointer; }
.cam-tin-btn:hover { background: rgba(255, 255, 255, .12); }
.cam-tin-btn:focus-visible { outline: var(--focus-ring-width, 2px) solid var(--focus-ring-color); outline-offset: 2px; }
.modal.cam-nguon { max-width: 480px; text-align: left; align-items: stretch; gap: var(--space-3); padding: var(--space-5);
                   max-height: calc(100dvh - 2 * var(--space-4)); overflow-y: auto; }
.cam-nguon-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.cam-nguon-list { display: flex; flex-direction: column; gap: var(--space-2); }
.cam-nguon-none { margin: 0; }
.cam-nguon-row { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 56px; padding: var(--space-2) var(--space-3);
                 border-radius: var(--radius-xl); border: 1.5px solid var(--border-default); background: var(--surface-card); color: var(--text-heading);
                 text-align: left; cursor: pointer; transition: border-color var(--motion-fast), background var(--motion-fast); }
.cam-nguon-row:hover { background: var(--surface-bg); }
.cam-nguon-row.selected { border-color: var(--cyan-400); background: var(--surface-primary); box-shadow: var(--shadow-brand-sm); }
.cam-nguon-row:focus-visible { outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring-shadow); }
.cam-nguon-ic { width: 40px; height: 40px; border-radius: var(--radius-pill); display: grid; place-items: center; flex: none;
                background: var(--surface-primary); color: var(--cyan-500); }
.cam-nguon-phone .cam-nguon-ic { background: var(--icon-indigo-bg); color: var(--icon-indigo); }
.cam-nguon-tx { display: flex; flex-direction: column; min-width: 0; }
.cam-nguon-tx .rt { font-size: 15px; line-height: 22px; font-weight: var(--font-extrabold); overflow-wrap: anywhere; }
.cam-nguon-tx .rd { font-size: 13px; line-height: 18px; font-weight: var(--font-semibold); color: var(--text-secondary); }
.cam-vdo { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--neutral-100); }
.cam-vdo-tabs button { font-size: 14px; line-height: 18px; padding: 6px var(--space-2); }
.cam-vdo-tao { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3) var(--space-4); align-items: start; }
.cam-vdo-qr { line-height: 0; border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; background: #fff; }
.cam-vdo-buoc { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 20px;
                font-weight: var(--font-semibold); color: var(--text-primary); }
.cam-vdo-url { grid-column: 1 / -1; display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
               background: var(--surface-sunken); color: var(--text-primary); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
               font-size: 12px; line-height: 18px; font-weight: var(--font-semibold); word-break: break-all; user-select: all; }
.cam-vdo-nut { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.cam-vdo-nut .btn { flex: 1 1 auto; }
.cam-vdo-dan { display: flex; flex-direction: column; gap: var(--space-2); }
.cam-vdo-dan .input { font-size: 15px; }
.cam-vdo-tt { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
              background: var(--surface-primary); color: var(--cyan-600); font-size: 14px; line-height: 20px; font-weight: var(--font-bold); }
.cam-vdo-tt .dot { width: 10px; height: 10px; margin-top: 5px; border-radius: var(--radius-pill); background: currentColor; flex: none; }
.cam-vdo-tt.cho .dot { animation: blink .8s infinite alternate; }
.cam-vdo-tt.ok { background: var(--surface-success); color: var(--green-500); }
.cam-vdo-tt.canh { background: var(--surface-warning); color: var(--orange-500); }
.cam-vdo-tt.loi { background: var(--surface-error); color: var(--red-500); }
.cam-vdo-rieng { margin: 0; font-size: 13px; line-height: 18px; }
@media (max-width: 560px) {
  .modal.cam-nguon { padding: var(--space-4); }
  .cam-vdo-tao { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .cam-vdo-buoc { justify-self: stretch; }
  .cam-tin { font-size: 12px; line-height: 16px; padding: var(--space-2); gap: var(--space-1); }
  .cam-tin-btn { min-height: 28px; padding: 0 var(--space-2); font-size: 12px; }
  .cam-off-nut .btn { min-height: 36px; padding: 0 var(--space-3); font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .cam-vdo-tt.cho .dot { animation: none; }
}
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: 14px; font-weight: var(--font-bold); color: var(--text-secondary); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: var(--radius-pill); background: var(--neutral-300); position: relative; cursor: pointer; transition: background var(--motion-normal); flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: var(--radius-pill); background: var(--white); box-shadow: var(--shadow-raised); transition: transform var(--motion-normal) var(--ease-spring); }
.switch input:checked { background: var(--color-primary); }
.switch input:checked::after { transform: translateX(18px); }

.chat-card { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.chat { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.msg { max-width: 88%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); font-size: 15px; line-height: 22px; animation: pop var(--motion-normal) var(--ease-spring); word-wrap: break-word; }
.msg.tutor { align-self: flex-start; background: var(--surface-card); border: 1px solid var(--neutral-100); color: var(--text-primary); }
.msg.user { align-self: flex-end; background: var(--surface-primary); color: var(--neutral-800); border: 1px solid var(--cyan-100); }
.msg.pending { border-style: dashed; color: var(--text-secondary); }
.msg.caption-live { align-self: flex-end; background: transparent; border: 1.5px dashed var(--cyan-200); color: var(--text-secondary); }
.msg.bc { align-self: flex-start; background: transparent; color: var(--text-secondary); font-size: 13px; line-height: 18px; padding: 0 var(--space-2); font-weight: var(--font-semibold); }
.msg.notice { align-self: center; background: var(--surface-sunken); color: var(--text-secondary); font-size: 13px; line-height: 18px; font-weight: var(--font-semibold); }
.msg img { border-radius: var(--radius-md); max-height: 160px; }
.msg.speaking { border-color: var(--cyan-400); box-shadow: var(--shadow-brand-sm); }
.composer { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--neutral-100); background: var(--surface-card); }
.composer .input { height: 48px; flex: 1; min-width: 0; font-size: 15px; }
.mic-dock { display: flex; align-items: center; gap: var(--space-3); }
.mic-btn { width: 64px; min-width: 64px; min-height: 60px; padding: 0; border-radius: var(--radius-pill); }
.mic-btn.off { --bg: var(--surface-card); --depth: var(--neutral-200); --fg: var(--text-secondary); box-shadow: inset 0 0 0 2px var(--neutral-200); }
.level { flex: 1; height: 8px; border-radius: var(--radius-pill); background: var(--neutral-150); overflow: hidden; }
.level > i { display: block; height: 100%; width: 0; background: var(--color-primary); border-radius: var(--radius-pill); transition: width 80ms linear; }

.status { display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); min-height: 32px; border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--text-secondary); font-size: 13px; font-weight: var(--font-extrabold); white-space: nowrap; }
.status .dot { width: 10px; height: 10px; border-radius: var(--radius-pill); background: currentColor; }
.status.listening { background: var(--surface-success); color: var(--green-500); }
.status.listening .dot { animation: pulse 1.4s infinite; }
.status.thinking { background: var(--surface-warning); color: var(--orange-500); }
.status.thinking .dot { animation: blink .8s infinite alternate; }
.status.speaking { background: var(--surface-primary); color: var(--cyan-600); }
.status.speaking .dot { animation: pulse .7s infinite; }
.timer { font-feature-settings: var(--font-features-numeric); color: var(--text-secondary); font-size: 15px; }

/* ---------- board blocks ---------- */
.blk { animation: rise var(--motion-slow) var(--ease-in-signature); }
.blk-title { font-size: 20px; line-height: 28px; font-weight: var(--font-black); color: var(--text-heading); margin: 0; }
.blk-text { font-size: 17px; line-height: 26px; color: var(--text-primary); margin: 0; }
.blk-text.note { color: var(--text-secondary); font-weight: var(--font-semibold); }
.blk-text.hint, .blk-text.success, .blk-text.warning { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); }
.blk-text .chip-ic { width: 32px; height: 32px; border-radius: var(--radius-pill); display: grid; place-items: center; color: var(--white); flex: none; }
.blk-text.hint .chip-ic { background: var(--color-reward); }
.blk-text.success .chip-ic { background: var(--color-correct); }
.blk-text.warning .chip-ic { background: var(--color-warning); }
.blk-problem { padding: var(--space-4) var(--space-5); border-radius: var(--radius-xl); background: var(--surface-card); border: 1.5px solid var(--cyan-100); }
/* pre-line: the problem keeps the page's lines (628: a book page of five exercises read as one paragraph) */
.blk-problem .body { margin-top: var(--space-2); font-size: 17px; line-height: 28px; color: var(--text-heading); white-space: pre-line; }
.blk-plan { padding: var(--space-4) var(--space-5); border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); }
.plan-steps { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plan-steps li { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); transition: background var(--motion-normal); }
.plan-steps .dot { width: 28px; height: 28px; border-radius: var(--radius-pill); display: grid; place-items: center; flex: none; margin-top: 1px;
                   background: var(--neutral-100); color: var(--text-secondary); font-size: 13px; font-weight: var(--font-black); }
.plan-steps .body { flex: 1; min-width: 0; }
.plan-steps .st { font-size: 16px; line-height: 26px; font-weight: var(--font-bold); color: var(--text-heading); }
.plan-steps .res { font-size: 15px; line-height: 24px; color: var(--green-500); font-weight: var(--font-bold); }
.plan-steps .res:empty { display: none; }
.plan-steps li.todo .st { color: var(--text-secondary); }
.plan-steps li.current { background: var(--surface-primary); }
.plan-steps li.current .dot { background: var(--color-primary); color: var(--white); animation: pulse 1.4s infinite; }
.plan-steps li.done .dot { background: var(--color-correct); color: var(--white); }
.plan-steps li.error { background: var(--surface-error); }
.plan-steps li.error .dot { background: var(--color-error); color: var(--white); }
.plan-steps li.pulse-once { animation: pop var(--motion-normal) var(--ease-spring); }
/* sub-questions under a step: question, formula/hint, the answer once the student finds it */
.plan-steps .asks { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plan-steps .asks:empty { display: none; }
.plan-steps .asks > li { display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
                         background: var(--surface-card); border-left: 3px solid var(--color-primary); }
.plan-steps .asks > li.answered { border-left-color: var(--color-correct); }
.plan-steps .asks .q { font-size: 15px; line-height: 22px; font-weight: var(--font-bold); color: var(--text-heading); }
.plan-steps .asks .q:empty, .plan-steps .asks .hint:empty, .plan-steps .asks .a:empty { display: none; }
.plan-steps .asks .hint { margin-top: var(--space-1); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
                          background: var(--surface-warning); color: var(--text-primary); font-size: 14px; line-height: 22px; }
.plan-steps .asks .hint::before { content: var(--bang-goi-y, "Gợi ý: "); font-weight: var(--font-extrabold); color: var(--orange-500); }
.plan-steps .asks .a { margin-top: var(--space-1); font-size: 15px; line-height: 22px; font-weight: var(--font-bold); color: var(--green-500); }
.plan-steps .asks .a::before { content: "→ "; }
.blk-plan .conclude { display: flex; gap: var(--space-3); align-items: flex-start; margin-top: var(--space-3); padding: var(--space-3) var(--space-4);
                      border-radius: var(--radius-lg); background: var(--surface-success); color: var(--text-heading); font-size: 16px; line-height: 24px; font-weight: var(--font-bold); }
.blk-plan .conclude .chip-ic { width: 32px; height: 32px; border-radius: var(--radius-pill); display: grid; place-items: center; color: var(--white); background: var(--color-correct); flex: none; }
.blk-work { padding: var(--space-4) var(--space-5); border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); }
.work-lines { list-style: none; counter-reset: wl; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.work-lines li { counter-increment: wl; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3);
                 border-radius: var(--radius-md); border-left: 3px solid var(--neutral-300); background: var(--surface-card); }
.work-lines li::before { content: counter(wl); width: 24px; height: 24px; border-radius: var(--radius-pill); display: grid; place-items: center; flex: none;
                         background: var(--neutral-100); color: var(--text-secondary); font-size: 12px; font-weight: var(--font-black); }
.work-lines .expr { flex: 1; min-width: 0; font-size: 17px; overflow-x: auto; }
.work-lines .tag { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 13px; font-weight: var(--font-extrabold); white-space: nowrap; }
.work-lines li.ok { border-left-color: var(--color-correct); background: var(--surface-success); }
.work-lines li.ok .tag { color: var(--green-500); }
.work-lines li.error { border-left-color: var(--color-error); background: var(--surface-error); }
.work-lines li.error .tag { color: var(--red-500); }
.work-lines li.caution { border-left-color: var(--yellow-400); background: var(--yellow-100); }  /* the server's yellow while a deep flow leads: no red, no tag */
.work-lines li.caution .tag { display: none; }
.work-lines li.writing { border-left-style: dashed; color: var(--text-secondary); }
.work-lines li.writing .tag { color: var(--text-secondary); font-weight: var(--font-semibold); }
.blk-math { padding: var(--space-3) var(--space-4); border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); overflow-x: auto; }
.blk-math .lbl { margin-bottom: var(--space-2); }
.blk-steps { counter-reset: s; display: flex; flex-direction: column; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.blk-steps li { counter-increment: s; display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); }
.blk-steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--surface-primary); color: var(--cyan-600); display: grid; place-items: center; font-size: 13px; font-weight: var(--font-black); flex: none; margin-top: 2px; }
.blk-steps .note { color: var(--text-secondary); font-size: 14px; line-height: 20px; font-weight: var(--font-semibold); }
.blk-svg { border-radius: var(--radius-xl); background: var(--surface-card); box-shadow: var(--shadow-soft-sm); padding: var(--space-3); }
.blk-svg svg { width: 100%; height: auto; display: block; }
.blk-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface-card); border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-soft-sm); font-size: 15px; }
.blk-table th { background: var(--surface-primary); color: var(--cyan-600); text-align: left; padding: var(--space-2) var(--space-3); font-weight: var(--font-extrabold); }
.blk-table td { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--neutral-100); }
.blk-quiz { display: flex; flex-direction: column; gap: var(--space-3); }
.blk-quiz .q { font-size: 17px; line-height: 26px; font-weight: var(--font-extrabold); color: var(--text-heading); }
.opt { min-height: 56px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-2xl); border: 1.5px solid var(--border-soft); background: var(--surface-card); box-shadow: var(--shadow-soft-sm);
       color: var(--text-heading); font-size: 17px; font-weight: var(--font-extrabold); text-align: left; cursor: pointer; transition: transform var(--motion-fast); }
.opt:active { transform: scale(.98); }
.opt.selected { border-color: var(--cyan-400); color: var(--cyan-600); background: color-mix(in srgb, var(--cyan-500) 8%, var(--surface-card)); box-shadow: var(--shadow-brand-sm); }
.photo { position: relative; border-radius: var(--radius-xl); overflow: hidden; background: var(--surface-card); box-shadow: var(--shadow-soft-sm); }
.photo img { width: 100%; }
.photo .box { position: absolute; border: 2.5px solid var(--neutral-400); border-radius: var(--radius-sm); }
.photo .box.ok { border-color: var(--color-correct); background: color-mix(in srgb, var(--green-500) 8%, transparent); }
.photo .box.error { border-color: var(--color-error); background: color-mix(in srgb, var(--red-500) 10%, transparent); }
.photo .box b { position: absolute; top: -12px; left: -12px; width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--neutral-500); color: var(--white); font-size: 12px; line-height: 24px; text-align: center; }
.photo .box.ok b { background: var(--color-correct); }
.photo .box.error b { background: var(--color-error); }
.photo .note { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--space-2) var(--space-3); background: var(--surface-overlay); color: var(--text-inverse); font-size: 14px; line-height: 20px; }
.board-empty { margin: auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); max-width: 360px; }
.board-empty img { width: 132px; height: 132px; object-fit: contain; }

/* ---------- toast / modal ---------- */
.toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); z-index: var(--z-toast); background: var(--neutral-800); color: var(--text-inverse);
         padding: var(--space-3) var(--space-5); border-radius: var(--radius-pill); font-size: 15px; box-shadow: var(--shadow-modal); animation: pop var(--motion-normal) var(--ease-spring); max-width: 90vw; }
.overlay { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--surface-overlay); display: grid; place-items: center; padding: var(--space-4); }
.modal { width: 100%; max-width: 440px; background: var(--surface-card); border-radius: var(--radius-2xl); box-shadow: var(--shadow-modal); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); text-align: center; align-items: center; }
.modal img { width: 120px; height: 120px; object-fit: contain; }

/* ---------- history ---------- */
.history-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--space-4); align-items: start; }
.history-grid .board { padding: 0; overflow: visible; }

/* ---------- motion ---------- */
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes blink { from { opacity: .35; } to { opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .session { grid-template-columns: minmax(0, 1fr) 360px; }
}
/* the chat keeps room for several messages: a smaller camera preview, a compact mic row on short screens */
.cam-wrap { max-height: 24dvh; }
@media (max-height: 820px) {
  .cam-wrap { max-height: 20dvh; }
  .mic-dock { padding-top: var(--space-2); padding-bottom: var(--space-2); }
  .mic-dock .label { display: none; }
  .mic-btn { width: 52px; min-width: 52px; min-height: 44px; }
  .chat-card > .card-head { padding-top: var(--space-2) !important; }
}
@media (max-width: 900px) {
  /* one screen, nothing grows the page: the board on top (its stage + its own scroll), camera and chat side by side
     below, the chat a scrolling box (Trúc 07/10) */
  .session { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: calc(100dvh - var(--header-height) - 8px);
             padding-top: var(--space-2); padding-bottom: var(--space-2); gap: var(--space-2); }
  .board-card { min-height: 0; }
  .board-stage { max-height: 58%; }
  .side { flex-direction: row; height: 34dvh; min-height: 220px; gap: var(--space-2); }
  .cam-card { flex: 0 0 40%; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
  .cam-wrap { flex: 1; min-height: 0; aspect-ratio: auto; }
  .chat-card { flex: 1; min-width: 0; min-height: 0; }
  .modes { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .side { height: 36dvh; }
  .cam-card { flex-basis: 38%; padding: var(--space-2); }
  .cam-actions { margin-top: var(--space-2); gap: var(--space-1); }
  .cam-actions .btn { min-height: 36px; padding: 0 var(--space-2); font-size: 13px; }
  .chat { padding: var(--space-2); }
  .msg { font-size: 14px; line-height: 20px; max-width: 94%; }
  .composer { padding: var(--space-2); }
  .composer .input { height: 40px; }
  .board { padding: var(--space-3); }
  .board-stage { padding: var(--space-2) var(--space-3); }
}
@media (max-width: 560px) {
  .topbar { gap: var(--space-2); padding-left: var(--space-3); padding-right: var(--space-3); }
  .dao-hoc-btn { width: 44px; padding: 0; justify-content: center; }
  .dao-hoc-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar .t { font-size: 15px; }
  .topbar .grow .micro { display: none; }
  .topbar .status { padding: 0 var(--space-2); }
  .topbar .status > span:last-child { display: none; }  /* colour + motion of the dot still show the state */
  .topbar .timer { font-size: 13px; }
  .topbar .btn.sm { padding-left: var(--space-3); padding-right: var(--space-3); }
  .stats { grid-template-columns: 1fr; }
  .hero img { width: 80px; height: 80px; }
  .display { font-size: 24px; line-height: 32px; }
}
