*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --red:    #FF6B6B;
  --orange: #FF6B35;
  --yellow: #FFCB45;
  --green:  #2ED573;
  --teal:   #1FCBA6;
  --teal-d: #11917A;
  --blue:   #1E90FF;
  --purple: #A55EEA;
  --pink:   #FF6EB4;
  --white:  #FFFFFF;
  --bg:     #F2FBF9;
  --card:   #FFFFFF;
  --text1:  #1A2340;
  --text2:  #5A6890;
  --text3:  #A0AABF;
  --shadow: 0 6px 0 rgba(0,0,0,0.12);
  --shadow-sm: 0 3px 0 rgba(0,0,0,0.10);
  --brand:  #1FCBA6;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text1);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}
.bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bubble-shape {
  position: absolute; border-radius: 50%; opacity: 0.10;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg) scale(1); }
  50%  { transform: translateY(-40px) rotate(180deg) scale(1.1); }
  100% { transform: translateY(0) rotate(360deg) scale(1); }
}
/* HEADER */
.header {
  background: linear-gradient(135deg, #1FCBA6 0%, #13B392 45%, #0FA678 100%);
  padding: 0 20px; height: 60px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0; position: relative; z-index: 10;
  box-shadow: 0 4px 0 rgba(27,184,147,0.35);
}
.logo {
  font-family: 'Baloo 2', cursive; font-size: 24px; color: white;
  display: flex; align-items: center; gap: 10px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15); letter-spacing: 0.5px;
}
@keyframes orbitRing { 0%{transform:rotate(0deg);} 100%{transform:rotate(360deg);} }
@keyframes spin { 0%{ transform:rotate(0deg); } 100%{ transform:rotate(360deg); } }
.badge-pill { background: rgba(255,255,255,0.25); color: white; font-size: 11px; font-weight: 800; padding: 4px 12px; border-radius: 20px; border: 2px solid rgba(255,255,255,0.4); letter-spacing: 0.05em; }
.header-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.score-pill { background: var(--yellow); color: #7A5900; font-size: 13px; font-weight: 900; padding: 5px 14px; border-radius: 20px; border: none; box-shadow: 0 4px 0 #C89A00; display: flex; align-items: center; gap: 5px; transition: transform 0.1s; }
.score-pill.pop { animation: popScore 0.4s ease; }
@keyframes popScore { 0%{transform:scale(1);} 40%{transform:scale(1.4);} 70%{transform:scale(0.9);} 100%{transform:scale(1);} }
/* LAYOUT */
.layout { display: grid; grid-template-columns: 300px 1fr; flex: 1; overflow: hidden; position: relative; z-index: 1; }
/* SIDEBAR */
.sidebar { background: linear-gradient(180deg, #F0FFFA 0%, #E8F8F4 60%, #F2FBF9 100%); border-right: 3px solid rgba(46,196,160,0.15); padding: 0 0 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 0; }
.topic-btn { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 0; border: none; border-left: 3px solid transparent; background: transparent; cursor: pointer; font-family: 'Nunito', Arial; font-size: 13px; font-weight: 700; color: var(--text2); text-align: left; transition: all 0.15s ease; margin: 0; box-shadow: none; }
.topic-btn:hover { background: rgba(46,196,160,0.10); color: var(--teal-d); border-left-color: var(--teal); }
.topic-btn.active { background: rgba(46,196,160,0.15); color: var(--teal-d); border-left-color: var(--teal); font-weight: 900; }
.topic-btn[data-color="red"].active    { color: var(--red);    border-left-color: var(--red);    background: rgba(255,71,87,0.08); }
.topic-btn[data-color="orange"].active { color: var(--orange); border-left-color: var(--orange); background: rgba(255,107,53,0.08); }
.topic-btn[data-color="green"].active  { color: #1A8A50;       border-left-color: var(--green);  background: rgba(46,213,115,0.08); }
.topic-btn[data-color="blue"].active   { color: #1065B5;       border-left-color: var(--blue);   background: rgba(30,144,255,0.08); }
.topic-btn[data-color="buddy"].active  { color: var(--teal-d); border-left-color: var(--teal);   background: rgba(46,196,160,0.12); }
.prog-track { height: 10px; background: #F0EEFF; border-radius: 10px; overflow: hidden; }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: 10px; transition: width 0.6s cubic-bezier(.34,1.56,.64,1); width: 0%; position: relative; }
.prog-fill::after { content:''; position:absolute; right:0; top:0; width:10px; height:100%; background:rgba(255,255,255,0.4); border-radius:0 10px 10px 0; }
.stars-row { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.star-item { font-size: 16px; filter: grayscale(1) opacity(0.3); transition: all 0.3s; }
.star-item.lit { filter: none; animation: starPop 0.4s ease; }
@keyframes starPop { 0%{transform:scale(0);} 60%{transform:scale(1.4);} 100%{transform:scale(1);} }
/* EXPAND */
.expand-arrow { margin-left: auto; font-size: 10px; color: var(--text3); transition: transform 0.25s cubic-bezier(.34,1.56,.64,1); display: inline-block; }
.expand-arrow.open { transform: rotate(90deg); }
.subtopic-list { overflow: hidden; max-height: 0; transition: max-height 0.35s ease; }
.subtopic-list.open { max-height: 260px; }
.sub-btn { margin-left: 16px !important; font-size: 12px !important; padding: 7px 10px !important; border-radius: 10px !important; }
/* MAIN AREA */
.main-area { display: flex; flex-direction: column; height: 100%; overflow: hidden; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #DDD; border-radius: 10px; }
/* NEW CHAT BTN - small, top-left of chat */
.new-chat-btn {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  padding: 6px 12px;
  background: linear-gradient(135deg, #3742FA, #A55EEA);
  border: none; border-radius: 10px; cursor: pointer;
  font-family: 'Nunito', Arial; font-size: 13px; font-weight: 900; color: white;
  box-shadow: 0 3px 0 rgba(55,66,250,0.3); transition: all 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.new-chat-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 rgba(55,66,250,0.3); }
.chat-panel-wrap { position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
/* WELCOME */
.welcome-wrap { display:flex; align-items:center; justify-content:center; flex:1; min-height:300px; }
.welcome-box { text-align:center; max-width:460px; padding:16px; }
.robot-face { width:80px; height:80px; margin:0 auto 14px; background: linear-gradient(135deg,#3742FA,#A55EEA); border-radius:24px; display:flex; align-items:center; justify-content:center; font-size:44px; box-shadow: 0 8px 0 rgba(55,66,250,0.35); animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 0%,100%{transform:rotate(-3deg);} 50%{transform:rotate(3deg);} }
.welcome-mascot { height:132px; width:auto; margin:0 auto 12px; display:block; animation: wobble 3s ease-in-out infinite; filter: drop-shadow(0 12px 20px rgba(18,49,74,.16)); }
.welcome-title { font-family:'Baloo 2',cursive; font-size:30px; color:var(--text1); margin-bottom:8px; }
.welcome-title span { color:var(--orange); }
.welcome-sub { font-size:16.5px; color:var(--text2); line-height:1.7; margin-bottom:20px; font-weight:600; }
.welcome-sub strong { color:var(--purple); }
/* MESSAGES */
.msg-row { display:flex; gap:10px; max-width:80%; animation:slideIn 0.25s cubic-bezier(.34,1.56,.64,1); }
@keyframes slideIn { from{opacity:0;transform:translateY(12px) scale(0.95);} to{opacity:1;transform:translateY(0) scale(1);} }
.msg-row.user { align-self:flex-end; flex-direction:row-reverse; }
.msg-row.ai   { align-self:flex-start; }
.avatar { width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; margin-top:2px; box-shadow:0 3px 0 rgba(0,0,0,0.12); }
.avatar.ai   { background:linear-gradient(135deg,#3742FA,#A55EEA); }
.avatar.user { background:linear-gradient(135deg,#2ED573,#1E90FF); }
.bubble { padding:11px 15px; font-size:14px; line-height:1.65; color:var(--text1); font-weight:600; }
.msg-row.ai .bubble { background:white; border-radius:20px 20px 20px 6px; box-shadow:0 4px 0 rgba(0,0,0,0.08); border:2px solid rgba(0,0,0,0.04); }
.msg-row.user .bubble { background:linear-gradient(135deg,#3742FA,#A55EEA); color:white; border-radius:20px 20px 6px 20px; box-shadow:0 4px 0 rgba(55,66,250,0.3); }
.bubble p{margin-bottom:5px;} .bubble p:last-child{margin-bottom:0;} .bubble strong{font-weight:900;}
/* TYPING */
.dots-wrap{display:flex; gap:5px; align-items:center; padding:4px 0;}
.dot{ width:9px; height:9px; border-radius:50%; background:var(--purple); opacity:0.6; animation:boing 1.0s ease-in-out infinite; }
.dot:nth-child(2){animation-delay:0.15s;} .dot:nth-child(3){animation-delay:0.30s;}
@keyframes boing { 0%,80%,100%{transform:scale(1);} 40%{transform:scale(1.5);opacity:1;} }
/* INPUT */
.input-area { padding:10px 16px 14px; background:white; border-top:3px solid rgba(0,0,0,0.06); display:flex; flex-direction:column; gap:10px; flex-shrink:0; }

/* ── Nút mở BẢNG ký hiệu (cạnh nút chụp ảnh) + ô XEM TRƯỚC + BẢNG dạng bottom-sheet ── */
.math-open-btn{ flex-shrink:0; width:46px; height:46px; min-height:46px; border:none; border-radius:14px; background:linear-gradient(135deg,#7C5CFF,#5b3fb0); color:#fff; font-family:'Nunito',Arial; font-size:15px; font-weight:900; cursor:pointer; -webkit-tap-highlight-color:transparent; box-shadow:0 3px 0 rgba(91,63,176,.3); }
.math-open-btn:active{ transform:translateY(2px); box-shadow:0 1px 0 rgba(91,63,176,.3); }
.mk-math-btn{ display:inline-flex; align-items:center; gap:7px; padding:10px 14px; border:none; border-radius:12px; background:linear-gradient(135deg,#7C5CFF,#5b3fb0); color:#fff; font-family:'Nunito',Arial; font-size:13px; font-weight:900; cursor:pointer; min-height:44px; -webkit-tap-highlight-color:transparent; }
.mk-math-btn:active{ transform:translateY(1px); }
.math-preview{ display:none; align-items:center; gap:8px; flex-wrap:wrap; margin:7px 2px 0; padding:7px 12px; background:#F2FBFF; border:1.5px solid #CFE6F5; border-radius:12px; }
.math-preview .mp-label{ font-size:11px; font-weight:900; color:#4a7fa5; flex-shrink:0; }
.math-preview .mp-math{ font-size:18px; color:#12314A; }
#math-panel-backdrop{ display:none; position:fixed; inset:0; background:rgba(18,28,48,.4); z-index:9998; }
#math-panel-backdrop.show{ display:block; }
#math-panel{ display:none; position:fixed; left:50%; top:50%; transform:translate(-50%,-46%) scale(.95); opacity:0; width:min(560px,92vw); max-height:min(78vh,560px); background:#fff; border-radius:24px; box-shadow:0 24px 70px rgba(18,28,48,.34); z-index:9999; flex-direction:column; overflow:hidden; transition:transform .24s cubic-bezier(.34,1.45,.5,1), opacity .18s ease; }
#math-panel.show{ display:flex; transform:translate(-50%,-50%) scale(1); opacity:1; }
.mp-head{ display:flex; align-items:center; justify-content:space-between; padding:13px 18px; border-bottom:1px solid #EEF3F1; font-weight:900; color:#12314A; font-size:15px; flex-shrink:0; }
.mp-close{ width:36px; height:36px; border:none; background:#F1F5F4; border-radius:10px; cursor:pointer; font-size:16px; font-weight:900; color:#66788a; }
.mp-body{ overflow-y:auto; padding:6px 16px 18px; -webkit-overflow-scrolling:touch; }
.mp-cat{ font-size:11px; font-weight:900; color:#5b7fa5; text-transform:uppercase; letter-spacing:.04em; margin:14px 2px 7px; }
.mp-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(48px,1fr)); gap:8px; }
.mp-key{ height:48px; border:1.5px solid #E0D8FF; background:#F7F4FF; color:#5b3fb0; border-radius:12px; font-size:19px; font-weight:800; cursor:pointer; font-family:'Nunito',Arial; -webkit-tap-highlight-color:transparent; }
.mp-key:active{ transform:translateY(1px); background:#DFD3FF; }
.qp { font-family:'Nunito',Arial; font-size:13px; font-weight:800; padding:7px 13px; border-radius:18px; border:2.5px solid #EEE; background:white; color:var(--text2); cursor:pointer; transition:all 0.15s cubic-bezier(.34,1.56,.64,1); box-shadow:0 2px 0 rgba(0,0,0,0.07); }
.qp:nth-child(1):hover{border-color:var(--purple);color:var(--purple);transform:scale(1.05);}
.qp:nth-child(2):hover{border-color:var(--teal);color:var(--teal);transform:scale(1.05);}
.qp:nth-child(3):hover{border-color:var(--orange);color:var(--orange);transform:scale(1.05);}
.qp:nth-child(4):hover{border-color:var(--red);color:var(--red);transform:scale(1.05);}
.qp:nth-child(5):hover{border-color:var(--green);color:var(--green);transform:scale(1.05);}
.input-row{display:flex; gap:10px; align-items:flex-end;}
.input-box { flex:1; min-height:48px; max-height:130px; padding:11px 16px; border-radius:18px; border:3px solid #E0E0F0; background:#FAFAFF; font-family:'Nunito',Arial; font-size:14px; font-weight:700; color:var(--text1); resize:none; outline:none; transition:all 0.2s; line-height:1.5; }
.input-box:focus{border-color:var(--purple); background:white; box-shadow:0 0 0 4px rgba(165,94,234,0.12);}
.input-box::placeholder{color:var(--text3); font-weight:600;}
.send-btn { width:48px; height:48px; border-radius:16px; background:linear-gradient(135deg,#FF6B35,#FF6B6B); border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; color:white; font-size:20px; flex-shrink:0; box-shadow:0 5px 0 rgba(200,50,30,0.35); transition:all 0.15s; }
.send-btn:hover{transform:translateY(-2px); box-shadow:0 7px 0 rgba(200,50,30,0.35);}
.send-btn:active{transform:translateY(2px); box-shadow:0 2px 0 rgba(200,50,30,0.35);}
.send-btn:disabled{background:#DDD; box-shadow:0 3px 0 #BBB; cursor:not-allowed; transform:none;}

/* ── Image attach button ── */
.attach-btn {
  width:48px; height:48px; border-radius:16px;
  background:linear-gradient(135deg,#A55EEA,#3742FA);
  border:none; cursor:pointer; display:flex; align-items:center;
  justify-content:center; color:white; font-size:20px; flex-shrink:0;
  box-shadow:0 5px 0 rgba(55,66,250,0.35); transition:all 0.15s;
}
.attach-btn:hover{transform:translateY(-2px); box-shadow:0 7px 0 rgba(55,66,250,0.35);}
.attach-btn:active{transform:translateY(2px); box-shadow:0 2px 0 rgba(55,66,250,0.35);}
.attach-btn:disabled{background:#DDD; box-shadow:0 3px 0 #BBB; cursor:not-allowed; transform:none;}

/* ── Image preview bar ── */
.img-preview-bar {
  display:none; align-items:center; gap:10px;
  background:#F0EEFF; border-radius:14px; padding:8px 12px;
  border:2px solid #D8D0FF;
}
.img-preview-bar.visible { display:flex; }
.img-preview-thumb {
  width:52px; height:52px; object-fit:cover; border-radius:10px;
  border:2px solid #C0B0FF; flex-shrink:0;
}
.img-preview-label {
  flex:1; font-size:12px; font-weight:800; color:var(--purple);
}
.img-preview-remove {
  background:none; border:none; cursor:pointer; font-size:18px;
  color:var(--text3); padding:2px 6px; border-radius:8px;
  transition:all 0.15s; flex-shrink:0;
}
.img-preview-remove:hover{ background:#FFE0E0; color:var(--red); }
/* CONFETTI */
.confetti-piece { position:fixed; width:10px; height:10px; top:-10px; border-radius:2px; animation:confettiFall 1.5s ease-in forwards; pointer-events:none; z-index:999; }
@keyframes confettiFall { to{transform:translateY(100vh) rotate(720deg); opacity:0;} }

/* ════════════════════════════════════════
   GRADE PANEL (Đại Số / Hình Học)
════════════════════════════════════════ */
.grade-panel {
  flex: 1; overflow-y: auto; padding: 20px 22px;
  background: var(--bg); display: none; flex-direction: column; gap: 20px;
}
.grade-panel.active { display: flex; }

/* GRADE HEADER - compact & harmonious */
.grade-header {
  display: flex; align-items: center; gap: 14px;
  background: white; border-radius: 18px; padding: 16px 20px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.07); border: 2px solid #F0F0FF;
}
.grade-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 30px; flex-shrink: 0; box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.grade-title { font-family: 'Baloo 2', cursive; font-size: 25px; color: var(--text1); line-height: 1.1; }
.grade-desc { font-size: 14.5px; color: var(--text2); font-weight: 600; margin-top: 3px; }
.grade-action-btn {
  flex: 1; min-width: 120px; padding: 12px 14px;
  border: none; border-radius: 14px; cursor: pointer;
  font-family: 'Nunito', Arial; font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.grade-action-btn:hover { transform: translateY(-3px); }
.grade-action-btn:active { transform: translateY(1px); }
.btn-blue { background: linear-gradient(135deg,#3742FA,#1E90FF); color: white; box-shadow: 0 4px 0 rgba(30,144,255,0.35); }
.btn-green { background: linear-gradient(135deg,#2ED573,#27AE60); color: white; box-shadow: 0 4px 0 rgba(46,213,115,0.35); }
.btn-buddy { background: linear-gradient(135deg,#A55EEA,#FF6EB4); color: white; box-shadow: 0 4px 0 rgba(165,94,234,0.3); }

/* OVERVIEW SECTION */
.overview-section {
  background: white; border-radius: 18px; padding: 20px 22px;
  border: 2px solid #E8E8FF; box-shadow: 0 4px 0 rgba(0,0,0,0.06);
}
.overview-desc { font-size: 15.5px; color: var(--text2); line-height: 1.75; font-weight: 600; margin-bottom: 14px; }
.topics-list-title { font-size: 12.5px; font-weight: 900; color: var(--text3); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px; }
.topics-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-pill {
  background: linear-gradient(135deg, #F5F0FF, #EEF4FF);
  border: 2px solid #DDD8FF; border-radius: 20px;
  padding: 6px 16px; font-size: 12px; font-weight: 800; color: var(--purple);
  cursor: pointer; transition: all 0.15s;
}
.topic-pill:hover { background: var(--purple); color: white; border-color: var(--purple); transform: scale(1.05); }
.tdv-back-btn { font-size: 12px; font-weight: 800; color: var(--text2); background: #F5F5FF; border: 2px solid #E8E8FF; border-radius: 10px; padding: 6px 14px; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.tdv-back-btn:hover { background: var(--purple); color: white; border-color: var(--purple); }

/* LOADING STATE */
.loading-state { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px; color: var(--text2); font-weight: 700; }
.loading-spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #F0EEFF; border-top-color: var(--purple); animation: spin 0.8s linear infinite; }

/* ══ CÂU HỎI ÔN TẬP PANEL ══ */
.practice-panel {
  background: white; border-radius: 18px; padding: 22px 24px;
  border: 2px solid #E8E0FF; box-shadow: 0 6px 0 rgba(0,0,0,0.07);
  display: flex; flex-direction: column; gap: 18px;
}
.practice-header { display: flex; align-items: center; justify-content: space-between; }
.practice-title { font-family: 'Baloo 2', cursive; font-size: 20px; color: var(--text1); }
.practice-type-row { display: flex; gap: 10px; }
.practice-type-btn {
  flex: 1; padding: 12px 14px; border: 2.5px solid #E8E8FF; border-radius: 12px;
  background: white; cursor: pointer; font-family: 'Nunito', Arial; font-size: 14.5px; font-weight: 800;
  color: var(--text2); text-align: center; transition: all 0.15s;
}
.practice-type-btn.active, .practice-type-btn:hover { background: var(--purple); color: white; border-color: var(--purple); }
.exercises-wrap { display: flex; flex-direction: column; gap: 12px; }
.ex-item-card {
  background: linear-gradient(135deg,#F8F0FF,#F0F4FF); border-radius: 14px; padding: 14px 18px;
  border-left: 4px solid var(--purple); font-size: 14px; color: var(--text1); font-weight: 600;
}
.ex-item-card .ex-q { font-weight: 800; margin-bottom: 8px; }
.ex-item-card .ex-sol { color: var(--green); font-weight: 700; margin-top: 8px; padding-top: 8px; border-top: 2px dashed #D0F0DA; display:flex; flex-direction:column; gap:3px; }
.ex-item-card .ex-sol .sol-title { font-size:11px; font-weight:900; color:var(--purple); text-transform:uppercase; letter-spacing:0.08em; margin-bottom:4px; }
.ex-item-card .ex-sol .sol-step { font-size:13px; color:var(--text1); font-weight:700; padding:3px 0; border-bottom:1px dashed #c3efd0; line-height:1.6; }
.ex-item-card .ex-sol .sol-step:last-child { border-bottom:none; }
.ex-number { display: inline-block; background: var(--purple); color: white; border-radius: 8px; padding: 2px 8px; font-size: 11px; font-weight: 900; margin-right: 6px; }
.refresh-btn {
  padding: 10px 20px; background: linear-gradient(135deg,#3742FA,#A55EEA); color: white;
  border: none; border-radius: 12px; cursor: pointer; font-family: 'Nunito', Arial;
  font-size: 13px; font-weight: 900; box-shadow: 0 4px 0 rgba(55,66,250,0.3);
  transition: all 0.15s; align-self: flex-start; display: flex; align-items: center; gap: 6px;
}
.refresh-btn:hover { transform: translateY(-2px); }

/* ══ LÀM BÀI KIỂM TRA PANEL ══ */
.test-panel {
  background: white; border-radius: 18px; padding: 22px 24px;
  border: 2px solid #FFE0B0; box-shadow: 0 6px 0 rgba(0,0,0,0.07);
  display: flex; flex-direction: column; gap: 18px;
}
.test-type-btn {
  flex: 1; padding: 10px 14px; border: 2.5px solid #FFE0B0; border-radius: 12px;
  background: white; cursor: pointer; font-family: 'Nunito', Arial; font-size: 12px; font-weight: 800;
  color: var(--text2); text-align: center; transition: all 0.15s;
}
.test-type-btn.active, .test-type-btn:hover { background: var(--orange); color: white; border-color: var(--orange); }
.timer-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.timer-label { font-size: 13px; font-weight: 800; color: var(--text2); }
.timer-input { width: 70px; padding: 8px 10px; border: 2.5px solid #E0E0F0; border-radius: 10px; font-family: 'Nunito', Arial; font-size: 14px; font-weight: 800; color: var(--text1); outline: none; text-align: center; }
.timer-input:focus { border-color: var(--orange); }
.start-btn { padding: 9px 20px; background: linear-gradient(135deg,#FF6B35,#FF6B6B); color: white; border: none; border-radius: 12px; cursor: pointer; font-family: 'Nunito', Arial; font-size: 13px; font-weight: 900; box-shadow: 0 4px 0 rgba(255,71,87,0.3); transition: all 0.15s; }
.start-btn:hover { transform: translateY(-2px); }
.timer-display { font-size: 28px; font-weight: 900; color: var(--red); font-family: 'Baloo 2', cursive; min-width: 80px; display: none; }
.timer-display.running { display: block; }
.test-exercises-wrap { display: flex; flex-direction: column; gap: 12px; }
.test-ex-item {
  background: linear-gradient(135deg,#FFF8F0,#FFF3E0); border-radius: 14px; padding: 14px 18px;
  border-left: 4px solid var(--orange); font-size: 14px; color: var(--text1); font-weight: 600;
}
.answer-input {
  width: 100%; margin-top: 10px; padding: 8px 12px;
  border: 2px solid #FFE0B0; border-radius: 10px;
  font-family: 'Nunito', Arial; font-size: 13px; font-weight: 700;
  outline: none; background: white;
}
.answer-input:focus { border-color: var(--orange); }
.answer-input.correct { border-color: var(--green); background: #F0FFF6; color: #1a7a40; }
.answer-input.wrong { border-color: var(--red); background: #FFF0F0; color: #c0392b; }
.mk-btn {
  min-width:38px; height:36px; padding:0 9px;
  border:1.5px solid #E0D8FF; background:#F7F4FF; color:#5b3fb0;
  border-radius:9px; font-size:16px; font-weight:800; line-height:1;
  font-family:'Nunito', Arial; cursor:pointer; -webkit-tap-highlight-color:transparent;
}
.mk-btn:hover { background:#ECE4FF; }
.mk-btn:active { transform:translateY(1px); background:#DFD3FF; }
.mk-hint { font-size:11px; color:#8a8a99; font-weight:700; margin-top:5px; line-height:1.4; }
.answer-correct-tag { display:inline-block; background:var(--green); color:white; border-radius:8px; padding:2px 10px; font-size:12px; font-weight:900; margin-top:6px; }
.answer-wrong-tag { display:inline-block; background:var(--red); color:white; border-radius:8px; padding:2px 10px; font-size:12px; font-weight:900; margin-top:6px; }
.solution-steps { background: linear-gradient(135deg,#F0FFF4,#E8FFEE); border-radius:12px; padding:12px 16px; margin-top:10px; border-left:4px solid var(--green); display:none; }
.solution-steps.show { display:block; }
.solution-steps .sol-title { font-size:12px; font-weight:900; color:var(--green); text-transform:uppercase; letter-spacing:0.08em; margin-bottom:8px; }
.solution-steps .sol-step { font-size:13px; color:var(--text1); font-weight:700; padding:4px 0; border-bottom:1px dashed #c3efd0; line-height:1.6; }
.solution-steps .sol-step:last-child { border-bottom:none; }

/* Tô nền cả khối câu hỏi sau khi AI chấm: đúng = xanh, sai = đỏ */
.test-ex-item { transition: background .3s ease, border-color .3s ease; }
.test-ex-item.graded-correct { background:#EAFBF1 !important; border-color:#2ED573 !important; box-shadow:inset 0 0 0 2px rgba(46,213,115,.25); }
.test-ex-item.graded-wrong   { background:#FFF0F0 !important; border-color:#FF4757 !important; box-shadow:inset 0 0 0 2px rgba(255,71,87,.25); }
/* Với câu SAI, đổi hộp lời giải sang tông đỏ để phân biệt rõ */
.test-ex-item.graded-wrong .solution-steps { background:linear-gradient(135deg,#FFF0F0,#FFE4E4); border-left-color:#FF4757; }
.test-ex-item.graded-wrong .solution-steps .sol-title { color:#c0392b; }
.test-ex-item.graded-wrong .solution-steps .sol-step { border-bottom-color:#F2C4C4; }

/* Difficulty selector */
.difficulty-row { display:flex; gap:6px; flex-wrap:wrap; margin-top:2px; }
.diff-btn {
  padding:5px 10px; border:2px solid #E8E8FF; border-radius:8px;
  background:white; cursor:pointer; font-family:'Nunito',Arial; font-size:11px; font-weight:800;
  color:var(--text2); text-align:center; transition:all 0.15s; white-space:nowrap;
}
.diff-btn.diff-trungbinh.active, .diff-btn.diff-trungbinh:hover { background:#2ED573; color:white; border-color:#2ED573; }
.diff-btn.diff-kho.active, .diff-btn.diff-kho:hover { background:#FF6B35; color:white; border-color:#FF6B35; }
.diff-btn.diff-nangcao.active, .diff-btn.diff-nangcao:hover { background:#A55EEA; color:white; border-color:#A55EEA; }
.difficulty-label { font-size:11px; font-weight:900; color:var(--text3); text-transform:uppercase; letter-spacing:0.08em; margin-bottom:3px; }

/* Generate button */
.generate-btn {
  padding:11px 22px; background:linear-gradient(135deg,#3742FA,#A55EEA); color:white;
  border:none; border-radius:13px; cursor:pointer; font-family:'Nunito',Arial;
  font-size:14px; font-weight:900; box-shadow:0 4px 0 rgba(55,66,250,0.3);
  transition:all 0.15s; display:flex; align-items:center; gap:8px; align-self:flex-start;
}
.generate-btn:hover { transform:translateY(-2px); box-shadow:0 6px 0 rgba(55,66,250,0.3); }
.generate-btn:disabled { background:#ccc; box-shadow:0 3px 0 #aaa; cursor:not-allowed; transform:none; }

/* Empty state */
.empty-state { display:flex; flex-direction:column; align-items:center; gap:10px; padding:36px 20px; color:var(--text3); font-weight:700; font-size:14px; text-align:center; }
.empty-state .empty-icon { font-size:40px; }
.empty-mascot { height:118px; width:auto; margin-bottom:2px; filter: drop-shadow(0 10px 18px rgba(18,49,74,.14)); }

.kt-action-row { display: none; gap: 10px; flex-wrap: wrap; align-items: center; }
.kt-action-row.visible { display: flex !important; }

/* Submit button */
.submit-test-btn {
  padding:12px 28px; background:linear-gradient(135deg,#2ED573,#27AE60); color:white;
  border:none; border-radius:14px; cursor:pointer; font-family:'Nunito',Arial;
  font-size:14px; font-weight:900; box-shadow:0 5px 0 rgba(46,213,115,0.4);
  transition:all 0.15s; display:flex; align-items:center; gap:8px; align-self:flex-start;
}
.submit-test-btn:hover { transform:translateY(-2px); box-shadow:0 7px 0 rgba(46,213,115,0.4); }
.submit-test-btn:disabled { background:#ccc; box-shadow:0 3px 0 #aaa; cursor:not-allowed; transform:none; }
.mk-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:8px; }
.mk-photo-btn {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:11px 16px; border:none; border-radius:12px; width:100%; max-width:340px;
  background:linear-gradient(135deg,#1FCBA6,#3742FA); color:#fff;
  font-family:'Nunito',Arial; font-size:14px; font-weight:900; line-height:1;
  cursor:pointer; -webkit-tap-highlight-color:transparent;
  box-shadow:0 3px 0 rgba(55,66,250,0.30); min-height:46px;
}
.mk-photo-btn:hover { filter:brightness(1.05); }
.mk-photo-btn:active { transform:translateY(2px); box-shadow:0 1px 0 rgba(55,66,250,0.30); }
.mk-photo-btn:disabled { opacity:.6; cursor:not-allowed; }
.mk-photo-thumb { display:none; margin-top:8px; align-items:center; gap:10px; background:#F2FFFB; border:1.5px solid #B9E8DC; border-radius:12px; padding:8px 10px; }
.mk-photo-thumb.show { display:flex; }
.mk-photo-thumb img { width:54px; height:54px; object-fit:cover; border-radius:8px; border:1px solid #cceee2; flex-shrink:0; }
.mk-photo-thumb .t-label { font-size:12px; font-weight:800; color:#0f8a6a; line-height:1.4; word-break:break-word; min-width:0; }
.mk-photo-thumb .t-retake { margin-left:auto; flex-shrink:0; font-size:12px; font-weight:900; color:#3742FA; background:#EAF0FF; border:none; border-radius:9px; padding:9px 12px; cursor:pointer; min-height:40px; -webkit-tap-highlight-color:transparent; }
.answer-input.from-photo { border-color:#1FCBA6; background:#F2FFFB; }

/* Score summary */
.test-result-summary {
  background:linear-gradient(135deg,#F8F0FF,#EEF4FF); border-radius:16px; padding:18px 22px;
  border:2px solid #E0D8FF; text-align:center; display:none;
}
.test-result-summary.show { display:block; }
.result-score { font-family:'Baloo 2',cursive; font-size:32px; color:var(--purple); }
.result-label { font-size:14px; color:var(--text2); font-weight:700; margin-top:4px; }

/* TOPIC CONTENT PANEL (old ones) */
.topic-content-panel { flex: 1; overflow-y: auto; padding: 20px 22px; background: var(--bg); display: none; flex-direction: column; gap: 20px; }
.topic-content-panel.active { display: flex; }
.subtopic-card { background: white; border-radius: 18px; padding: 16px 10px 12px; cursor: pointer; text-align: center; border: 3px solid #F0F0FF; box-shadow: 0 4px 0 rgba(0,0,0,0.07); transition: all 0.2s cubic-bezier(.34,1.56,.64,1); display: flex; flex-direction: column; align-items: center; gap: 7px; }
.subtopic-card:hover { transform: translateY(-5px) scale(1.04); box-shadow: 0 9px 0 rgba(0,0,0,0.09); }
.sc-img { font-size: 42px; line-height: 1; }
.sc-name { font-size: 15px; font-weight: 900; color: var(--text1); line-height: 1.3; }
.sc-desc { font-size: 12.5px; font-weight: 600; color: var(--text3); line-height: 1.4; }
/* Blackboard messages */
.board-msg { animation: slideBoardIn 0.3s cubic-bezier(.34,1.56,.64,1); }
@keyframes slideBoardIn { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:none;} }
.board-msg.student { background: rgba(255,255,255,0.08); border-radius: 8px; padding: 8px 12px; border-left: 3px solid #FFCB45; }
.board-msg.teacher { background: rgba(255,255,255,0.05); border-radius: 8px; padding: 8px 12px; border-left: 3px solid #2ED573; }
.board-sender { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px; }
.board-msg.student .board-sender { color: #FFCB45; }
.board-msg.teacher .board-sender { color: #2ED573; }
.board-text { font-size: 13px; color: rgba(255,255,255,0.9); line-height: 1.6; font-weight: 600; font-family: 'Nunito', Arial; }
.board-text strong { color: white; font-weight: 900; }
/* Teacher animations */
@keyframes teacherTalk { 0%,100%{d:path('M43 72 Q50 77 57 72');} 50%{d:path('M43 72 Q50 80 57 72');} }
@keyframes armPoint { 0%,100%{transform:rotate(0deg);} 50%{transform:rotate(-15deg);} }
@keyframes armIdle { 0%,100%{transform:rotate(0deg);} 50%{transform:rotate(5deg);} }

/* ══════════════════════════════════════════════════
   AI BYPASS RISK — GUARDRAIL OVERLAY
══════════════════════════════════════════════════ */
.bypass-warning-overlay {
  position: fixed; inset: 0; background: rgba(255,71,87,0.92);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  animation: bypassFadeIn 0.35s ease;
}
@keyframes bypassFadeIn { from{opacity:0;transform:scale(0.9);} to{opacity:1;transform:scale(1);} }
.bypass-warning-box {
  background: white; border-radius: 24px; padding: 32px 36px; max-width: 420px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  border: 4px solid var(--red);
}
.bypass-icon { font-size: 56px; margin-bottom: 12px; animation: shake 0.5s ease; }
@keyframes shake { 0%,100%{transform:rotate(0deg);} 25%{transform:rotate(-8deg);} 75%{transform:rotate(8deg);} }
.bypass-title { font-family:'Baloo 2',cursive; font-size:22px; color:var(--red); margin-bottom:8px; }
.bypass-msg { font-size:14px; color:var(--text2); line-height:1.7; font-weight:600; margin-bottom:20px; }
.bypass-close-btn {
  background:linear-gradient(135deg,#FF6B6B,#FF6B35); color:white;
  border:none; border-radius:14px; padding:12px 28px;
  font-family:'Nunito',Arial; font-size:14px; font-weight:900;
  cursor:pointer; box-shadow:0 5px 0 rgba(200,50,30,0.4);
  transition:all 0.15s;
}
.bypass-close-btn:hover { transform:translateY(-2px); }
@keyframes pulseBadge { 0%,100%{opacity:1;} 50%{opacity:0.5;} }

/* ══════════════════════════════════════════════════
   FRUSTRATION DROP-OFF — DETECTION BAR
══════════════════════════════════════════════════ */
.frustration-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: linear-gradient(135deg,#FF6B35,#FF6B6B);
  padding: 12px 20px; display: flex; align-items: center; gap: 14px;
  transform: translateY(100%); transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
  visibility: hidden;   /* ẩn hẳn khi chưa show — tránh bóng hồng rỉ lên đáy */
}
.frustration-bar.show { transform: translateY(0); visibility: visible; box-shadow: 0 -4px 20px rgba(255,71,87,0.35); }
.frust-icon { font-size: 28px; flex-shrink:0; }
.frust-text { flex:1; }
.frust-title { font-size:14px; font-weight:900; color:white; margin-bottom:2px; }
.frust-sub { font-size:12px; color:rgba(255,255,255,0.85); font-weight:600; }
.frust-actions { display:flex; gap:8px; flex-shrink:0; }
.frust-btn {
  padding:8px 14px; border:none; border-radius:10px;
  font-family:'Nunito',Arial; font-size:12px; font-weight:900;
  cursor:pointer; transition:all 0.15s;
}
.frust-btn-simple { background:white; color:var(--red); }
.frust-btn-simple:hover { background:#FFE9EA; }
.frust-btn-dismiss { background:rgba(255,255,255,0.2); color:white; border:2px solid rgba(255,255,255,0.5); }
.frust-btn-dismiss:hover { background:rgba(255,255,255,0.3); }

/* ══════════════════════════════════════════════════
   STEP-BY-STEP HINT SYSTEM
══════════════════════════════════════════════════ */
.hint-system-wrap {
  background:white; border-radius:18px; padding:16px 18px;
  border:3px solid var(--yellow); box-shadow:0 6px 0 rgba(200,160,0,0.2);
  margin-top:8px; animation:slideIn 0.3s ease;
}
.hint-system-header {
  display:flex; align-items:center; gap:10px; margin-bottom:12px;
}
.hint-system-title { font-family:'Baloo 2',cursive; font-size:16px; color:#7A5900; }
.hint-level-row { display:flex; gap:8px; margin-bottom:12px; }
.hint-level-btn {
  flex:1; padding:8px 10px; border:2.5px solid #EEE; border-radius:12px;
  background:white; cursor:pointer; font-family:'Nunito',Arial;
  font-size:12px; font-weight:900; transition:all 0.18s cubic-bezier(.34,1.56,.64,1);
  text-align:center;
}
.hint-level-btn:hover { transform:translateY(-2px); box-shadow:0 4px 0 rgba(0,0,0,0.1); }
.hint-level-btn.light { border-color:#2ED573; color:#27AE60; }
.hint-level-btn.light.active { background:#2ED573; color:white; box-shadow:0 4px 0 rgba(46,213,115,0.3); }
.hint-level-btn.medium { border-color:var(--orange); color:var(--orange); }
.hint-level-btn.medium.active { background:var(--orange); color:white; box-shadow:0 4px 0 rgba(255,107,53,0.3); }
.hint-level-btn.strong { border-color:var(--red); color:var(--red); }
.hint-level-btn.strong.active { background:var(--red); color:white; box-shadow:0 4px 0 rgba(255,71,87,0.3); }
.hint-content-area {
  background:#FFFBF0; border-radius:12px; padding:14px;
  border-left:4px solid var(--yellow); font-size:13px;
  color:var(--text1); line-height:1.75; font-weight:600;
  min-height:60px;
}
.hint-progress-dots { display:flex; gap:6px; margin-top:10px; }
.hint-dot { width:10px; height:10px; border-radius:50%; background:#EEE; transition:all 0.3s; }
.hint-dot.revealed { background:var(--yellow); box-shadow:0 0 6px var(--yellow); }
.get-hint-btn {
  margin-top:10px; padding:10px 20px;
  background:linear-gradient(135deg,var(--yellow),#FFA500);
  color:#7A5900; border:none; border-radius:12px;
  font-family:'Nunito',Arial; font-size:13px; font-weight:900;
  cursor:pointer; box-shadow:0 4px 0 rgba(200,130,0,0.3);
  transition:all 0.15s; display:flex; align-items:center; gap:7px;
}
.get-hint-btn:hover { transform:translateY(-2px); box-shadow:0 6px 0 rgba(200,130,0,0.3); }
.get-hint-btn:disabled { background:#DDD; color:#AAA; box-shadow:none; cursor:not-allowed; transform:none; }

/* ══════════════════════════════════════════════════
   AI PROMPT PLAYGROUND — Lớp học viết Prompt
══════════════════════════════════════════════════ */
.prompt-playground-panel {
  padding:0; overflow-y:auto; height:100%;
  display:none; flex-direction:column; background:var(--bg);
}
.prompt-playground-panel.active { display:flex; }

/* ══════════════════════════════════════════════════
   TƯ DUY ĐẶT CÂU HỎI — Question Crafting Classroom
══════════════════════════════════════════════════ */
.qc-screen { display:flex; flex-direction:column; gap:14px; }
.qc-step-indicator { display:flex; align-items:center; gap:4px; padding:10px 14px; background:white; border-radius:12px; border:2px solid rgba(46,196,160,.15); flex-shrink:0; }
.qc-step { font-size:11px; font-weight:900; color:var(--text3); padding:4px 8px; border-radius:8px; cursor:default; white-space:nowrap; transition:all .2s; }
.qc-step.qc-active { background:var(--teal); color:white; }
.qc-step.qc-done { color:var(--teal); cursor:pointer; }
.qc-step.qc-done:hover { background:#E8FFF8; }
.qc-step-line { flex:1; height:2px; background:#E0E0E0; border-radius:2px; transition:background .4s; }
.qc-step-line.qc-done { background:var(--teal); }
.qc-subject-pill { padding:6px 14px; border:2px solid rgba(46,196,160,.3); border-radius:20px; background:white; color:var(--text2); font-family:'Nunito',Arial; font-size:12px; font-weight:800; cursor:pointer; transition:all .15s; }
.qc-subject-pill.qc-active, .qc-subject-pill:hover { background:var(--teal); color:white; border-color:var(--teal); }
.qc-textarea { width:100%; box-sizing:border-box; border:2px solid rgba(46,196,160,.25); border-radius:12px; padding:12px 14px; font-family:'Nunito',Arial; font-size:13px; font-weight:700; color:var(--text1); resize:vertical; outline:none; transition:border-color .2s; background:white; }
.qc-textarea:focus { border-color:var(--teal); box-shadow:0 0 0 3px rgba(46,196,160,.12); }
.qc-criteria-chip { display:flex; align-items:center; gap:6px; background:white; border:2px solid #E8E8E8; border-radius:10px; padding:8px 10px; font-weight:900; transition:all .35s; font-size:12px; }
.qc-criteria-chip.qc-good { border-color:var(--teal); background:#F0FFF8; }
.qc-criteria-chip.qc-ok  { border-color:#FFCB45; background:#FFFBF0; }
.qc-criteria-chip.qc-bad { border-color:#FF6B8A; background:#FFF5F8; }
.qc-action-btn { width:100%; padding:13px; border:none; border-radius:14px; font-family:'Nunito',Arial; font-size:14px; font-weight:900; cursor:pointer; transition:all .18s; }
.qc-action-btn:hover { transform:translateY(-2px); }
.qc-action-btn:active { transform:translateY(1px); }

/* ══════════════════════════════════════════════════
   BUDDY 3D MASCOT — SVG INLINE SYSTEM
══════════════════════════════════════════════════ */
@keyframes mascotBob { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-7px);} }
@keyframes mascotWiggle { 0%,100%{transform:rotate(0deg);} 25%{transform:rotate(-5deg);} 75%{transform:rotate(5deg);} }
@keyframes mascotPop { 0%{transform:scale(1);} 40%{transform:scale(1.12);} 70%{transform:scale(.96);} 100%{transform:scale(1);} }
.buddy-sprite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
}
.buddy-sprite svg { width:100%; height:100%; display:block; }

/* ══════════════════════════════════════════════════
   VISUAL MATH AI
══════════════════════════════════════════════════ */
.visual-math-panel {
  padding:20px; overflow-y:auto; height:100%;
  display:none; flex-direction:column; gap:16px; background:var(--bg);
}
.visual-math-panel.active { display:flex; }
.vm-header {
  background:linear-gradient(135deg,#1E90FF,#2ED573);
  border-radius:20px; padding:20px 24px; color:white;
  box-shadow:0 6px 0 rgba(30,144,255,0.35);
}
.vm-title { font-family:'Baloo 2',cursive; font-size:22px; margin-bottom:6px; }
.vm-desc { font-size:13px; opacity:0.9; font-weight:600; line-height:1.6; }

/* ══════════════════════════════════════════════════
   AUTH STYLES
══════════════════════════════════════════════════ */
.auth-header-btn {
  background: rgba(255,255,255,0.22); border: 2px solid rgba(255,255,255,0.5);
  color: white; font-family: 'Nunito', Arial; font-size: 13px; font-weight: 800;
  padding: 6px 14px; border-radius: 20px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.18s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
}
.auth-header-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.04); }

.user-avatar-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.22); border: 2px solid rgba(255,255,255,0.5);
  color: white; font-family: 'Nunito', Arial; font-size: 12.5px; font-weight: 800;
  padding: 4px 9px 4px 5px; border-radius: 20px; cursor: pointer;
  line-height:1.2; appearance:none;
  transition: all 0.18s; position: relative; white-space: nowrap;
}
.user-avatar-pill:hover { background: rgba(255,255,255,0.35); }
#user-info-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: max-content; min-width: 220px; max-width: calc(100vw - 24px);
  background: white; border-radius: 14px; padding: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18); border: 2px solid #F0EEFF;
  z-index: 200; box-sizing: border-box;
}
.user-dropdown-name { font-size: 14px; font-weight: 900; color: var(--text1); }
.user-dropdown-email { font-size: 11px; color: var(--text3); font-weight: 600; margin-top: 2px; word-break: break-all; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; min-height: 34px; box-sizing: border-box;
  text-align: left; padding: 7px 9px; border: none;
  background: none; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 800; line-height: 1.35;
  color: #44586B; text-decoration: none; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.user-dropdown-item-icon { flex: 0 0 22px; text-align: center; font-size: 16px; line-height: 1; }
.user-dropdown-item:hover,
.user-dropdown-item:focus-visible { background: #EAF8F4; color: var(--mint-d); }
.user-dropdown-item:focus-visible { outline: 2px solid var(--mint); outline-offset: 1px; }

/* ═══════════ NOTIFICATION CENTER (chuông thông báo) ═══════════ */
#notif-wrap { position: relative; }
.notif-bell {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.22); border: 2px solid rgba(255,255,255,0.5);
  color: white; font-size: 17px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s cubic-bezier(.34,1.56,.64,1);
}
.notif-bell:hover { background: rgba(255,255,255,0.38); transform: scale(1.08); }
.notif-bell:active { transform: scale(0.96); }
.notif-bell.ring { animation: bellRing 0.7s ease; }
@keyframes bellRing {
  0%,100% { transform: rotate(0); }
  15% { transform: rotate(-20deg); } 30% { transform: rotate(16deg); }
  45% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); }
  75% { transform: rotate(-4deg); }
}
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  padding: 0 4px; background: var(--red); color: white; border-radius: 10px;
  border: 2px solid white; font-size: 10px; font-weight: 900; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.22); animation: badgePop 0.35s ease;
}
@keyframes badgePop { 0%{transform:scale(0);} 60%{transform:scale(1.35);} 100%{transform:scale(1);} }
.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0; width: 342px; max-width: 92vw;
  background: white; border-radius: 18px; overflow: hidden; z-index: 300;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22); border: 2px solid #F0EEFF;
  animation: notifDrop 0.22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes notifDrop { from{opacity:0;transform:translateY(-8px) scale(0.97);} to{opacity:1;transform:none;} }
/* Điện thoại: panel thông báo bám 2 mép màn hình, nằm dưới thanh trên cùng → không tràn ra ngoài */
@media (max-width:760px){
  .notif-panel{ position:fixed; top:calc(58px + env(safe-area-inset-top,0px)); left:8px; right:8px; width:auto; max-width:none; }
  .notif-list{ max-height:62vh; }
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; background: linear-gradient(135deg,#1FCBA6,#13B392);
  color: white; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 16px;
}
.notif-mark-read {
  background: rgba(255,255,255,0.25); border: none; color: white; cursor: pointer;
  font-family: 'Nunito', Arial; font-size: 11px; font-weight: 800;
  padding: 5px 11px; border-radius: 12px; transition: background 0.15s;
}
.notif-mark-read:hover { background: rgba(255,255,255,0.45); }
.notif-list { max-height: 384px; overflow-y: auto; }
.notif-list::-webkit-scrollbar { width: 6px; }
.notif-list::-webkit-scrollbar-thumb { background: #DDD; border-radius: 10px; }
.notif-item {
  display: flex; gap: 11px; padding: 12px 14px 12px 18px;
  border-bottom: 1px solid #F4F2FB; transition: background 0.15s; position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #FAF9FF; }
.notif-item.unread { background: #F0FBF8; }
.notif-item.unread::before {
  content: ''; position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%; background: var(--teal);
}
.notif-icon {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.notif-body-wrap { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 900; color: var(--text1); line-height: 1.35; }
.notif-text { font-size: 12px; color: var(--text2); font-weight: 600; line-height: 1.45; margin-top: 2px; }
.notif-time { font-size: 10.5px; color: var(--text3); font-weight: 700; margin-top: 4px; }
.notif-empty { text-align: center; padding: 42px 22px; color: var(--text3); }
.notif-panel-foot { padding: 9px 16px; border-top: 1px solid #F0EEFF; text-align: center; }
.notif-clear-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-family: 'Nunito', Arial; font-size: 12px; font-weight: 800; transition: color 0.15s;
}
.notif-clear-btn:hover { color: var(--red); }

/* Modal overlay */
#auth-modal-overlay {
  position: fixed; inset: 0; background: rgba(30,20,60,0.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); padding: 16px;
}
@keyframes authPop { from{opacity:0;transform:scale(0.88) translateY(20px);} to{opacity:1;transform:scale(1) translateY(0);} }
.auth-input {
  width: 100%; padding: 11px 14px; border: 2.5px solid #E0E0F0; border-radius: 12px;
  font-family: 'Nunito', Arial; font-size: 14px; font-weight: 700; color: var(--text1);
  outline: none; background: white; transition: all 0.2s;
}
.auth-input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(165,94,234,0.12); }

/* ── fmt markdown styles ──────────────────────────────── */
.fmt-h2 { font-size:16px; font-weight:900; color:var(--blue); margin:10px 0 4px; font-family:'Baloo 2',cursive; }
.fmt-h3 { font-size:14px; font-weight:900; color:var(--purple); margin:8px 0 3px; }
.fmt-h4 { font-size:13px; font-weight:800; color:var(--orange); margin:6px 0 2px; }
.fmt-h5 { font-size:12px; font-weight:800; color:var(--teal);   margin:5px 0 2px; }
.fmt-list { padding-left:18px; margin:4px 0; }
.fmt-list li { margin-bottom:3px; line-height:1.6; }
.fmt-code { background:rgba(55,66,250,0.08); color:var(--blue); border-radius:5px; padding:1px 5px; font-size:12px; font-family:monospace; }

/* ══ VISUAL MATH AI — New Grade/Topic/Generate UI ══ */
.vm-grade-btn {
  border-radius:16px; padding:14px 10px; text-align:center;
  cursor:pointer; border:3px solid rgba(255,255,255,0.3);
  box-shadow:0 5px 0 rgba(0,0,0,0.15);
  transition:all 0.2s cubic-bezier(.34,1.56,.64,1);
  display:flex; flex-direction:column; align-items:center;
}
.vm-grade-btn:hover { transform:translateY(-4px) scale(1.06); box-shadow:0 9px 0 rgba(0,0,0,0.2); }
.vm-grade-btn.selected { outline:4px solid white; transform:translateY(-3px) scale(1.04); }

.vm-topic-type-card {
  background:white; border-radius:16px; padding:18px 14px; text-align:center;
  border:3px solid #E0F0FF; box-shadow:0 4px 0 rgba(0,0,0,0.07);
  cursor:pointer; transition:all 0.2s cubic-bezier(.34,1.56,.64,1);
}
.vm-topic-type-card:hover { transform:translateY(-4px); box-shadow:0 8px 0 rgba(0,0,0,0.1); }
.vm-topic-type-card.selected { border-width:3px; box-shadow:0 6px 0 rgba(0,0,0,0.12); }

.vm-subtopic-pill {
  background:linear-gradient(135deg,#F0F8FF,#E8F4FF);
  border:2px solid #C0D8FF; border-radius:20px;
  padding:6px 14px; font-size:12px; font-weight:800; color:#1E6FA0;
  cursor:pointer; transition:all 0.15s; white-space:nowrap;
}
.vm-subtopic-pill:hover { background:var(--teal); color:white; border-color:var(--teal); transform:scale(1.05); }
.vm-subtopic-pill.selected { background:var(--teal); color:white; border-color:var(--teal); }

.vm-diff-btn {
  flex:1; padding:10px 14px; border:2.5px solid #E0E0F0; border-radius:12px;
  background:white; cursor:pointer; font-family:'Nunito',Arial; font-size:13px; font-weight:900;
  color:var(--text2); transition:all 0.18s cubic-bezier(.34,1.56,.64,1); text-align:center;
}
.vm-diff-btn#vmd-easy.active { background:#2ED573; color:white; border-color:#2ED573; box-shadow:0 4px 0 rgba(46,213,115,0.3); }
.vm-diff-btn#vmd-medium.active { background:#FFCB45; color:#7A5900; border-color:#FFCB45; box-shadow:0 4px 0 rgba(200,160,0,0.3); }
.vm-diff-btn#vmd-hard.active { background:#FF6B35; color:white; border-color:#FF6B35; box-shadow:0 4px 0 rgba(255,107,53,0.3); }

/* VM Problem Card */
.vm-problem-card {
  background:white; border-radius:18px; padding:20px 22px;
  border:2.5px solid #E0F0FF; box-shadow:0 5px 0 rgba(0,0,0,0.07);
  animation:slideIn .3s cubic-bezier(.34,1.56,.64,1);
}
.vm-problem-num { display:inline-flex; align-items:center; gap:6px; background:linear-gradient(135deg,#1E90FF,#2ED573); color:white; border-radius:10px; padding:3px 12px; font-size:12px; font-weight:900; margin-bottom:10px; }
.vm-problem-text { font-size:14px; font-weight:700; color:var(--text1); line-height:1.75; margin-bottom:12px; }
.vm-problem-svg { width:100%; min-height:160px; background:#F0FAFF; border-radius:14px; border:2px solid #C0E8FF; overflow:hidden; margin-bottom:12px; display:flex; align-items:center; justify-content:center; }
.vm-guide-btn {
  padding:9px 18px; background:linear-gradient(135deg,#F5F0FF,#EEF4FF); color:var(--purple);
  border:2px solid #DDD8FF; border-radius:12px; cursor:pointer;
  font-family:'Nunito',Arial; font-size:12px; font-weight:900;
  transition:all 0.15s; display:flex; align-items:center; gap:6px;
}
.vm-guide-btn:hover { background:var(--purple); color:white; border-color:var(--purple); transform:translateY(-1px); }
.vm-guide-area {
  background:linear-gradient(135deg,#F8F0FF,#F0F4FF);
  border-radius:14px; padding:14px 16px;
  border-left:4px solid var(--purple);
  font-size:13px; color:var(--text1); line-height:1.8; font-weight:600;
  margin-top:10px; display:none; animation:slideIn .25s ease;
}
.vm-guide-area.show { display:block; }
.vm-guide-step { padding:5px 0; border-bottom:1px dashed #DDD8FF; line-height:1.7; }
.vm-guide-step:last-child { border-bottom:none; }

/* ════════════════════════════════════════════════════════════
   🎨 THEME REFRESH — Học sinh RỰC RỠ nhiều màu / Phụ huynh NGHIÊM TÚC
   (đặt cuối stylesheet để ghi đè các rule phía trên)
════════════════════════════════════════════════════════════ */
/* ── Nền vui tươi nhiều màu cho học sinh ── */
body {
  background:
    radial-gradient(circle at 7% 10%, rgba(255,107,107,.12), transparent 40%),
    radial-gradient(circle at 93% 8%, rgba(165,94,234,.13), transparent 44%),
    radial-gradient(circle at 88% 90%, rgba(78,143,255,.12), transparent 46%),
    radial-gradient(circle at 12% 92%, rgba(255,203,69,.13), transparent 46%),
    linear-gradient(160deg,#FFF5FA 0%,#EFFBFF 36%,#F1FFF6 68%,#FFFBEF 100%);
}
/* Bong bóng nổi rõ hơn để nền có chuyển động nhiều màu */
.bubble-shape { opacity:.18; filter:blur(.4px); }

/* Header CẦU VỒNG rực rỡ */
.header {
  background:linear-gradient(110deg,#FF6B6B 0%,#FF9A3C 17%,#FFCB45 34%,#2ED573 52%,#1FCBA6 68%,#4E8FFF 85%,#A55EEA 100%);
  background-size:200% 100%;
  animation:rainbowShift 14s ease infinite;
  box-shadow:0 4px 0 rgba(120,80,200,.22);
}
@keyframes rainbowShift { 0%{background-position:0% 50%;} 50%{background-position:100% 50%;} 100%{background-position:0% 50%;} }

/* Sidebar tươi + nhãn nhóm thành "pill" nhiều màu */
.sidebar { background:linear-gradient(180deg,#FFFFFF 0%,#F3FBFF 50%,#FFF5FB 100%); }

/* Khu nội dung để lộ nền nhiều màu */
.topic-content-panel { background:transparent; }

/* Viền trái nút điều hướng dày & nổi hơn khi chọn */
.topic-btn.active { border-left-width:4px; }

/* ════════ GIAO DIỆN PHỤ HUYNH — sạch, nghiêm túc ════════ */
body.role-parent { background:#EEF2F8; }
body.role-parent .bubbles { display:none; }
body.role-parent .header {
  background:linear-gradient(135deg,#2C3E66 0%,#3F6FB0 55%,#2BB6A6 100%);
  background-size:100% 100%; animation:none;
  box-shadow:0 4px 0 rgba(28,40,72,.30);
}
body.role-parent .sidebar { background:linear-gradient(180deg,#FFFFFF,#F1F5FB); border-right:3px solid #E2E8F2; }
body.role-parent .topic-content-panel { background:#EEF2F8; }

/* ════════════════════════════════════════════════════════════
   🌈🌈 SIÊU SẶC SỠ CHO HỌC SINH (kiểu YouTube Kids)
   — chỉ áp dụng khi KHÔNG phải phụ huynh
════════════════════════════════════════════════════════════ */
/* Nền màu mạnh hơn, các vệt màu to & đậm hơn */
body:not(.role-parent) {
  background:
    radial-gradient(circle at 0% 0%,   rgba(255,107,107,.28), transparent 38%),
    radial-gradient(circle at 100% 0%, rgba(165,94,234,.28),  transparent 40%),
    radial-gradient(circle at 100% 100%,rgba(78,143,255,.26), transparent 42%),
    radial-gradient(circle at 0% 100%, rgba(46,213,115,.26),  transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(255,203,69,.22),  transparent 55%),
    linear-gradient(160deg,#FFEFF6 0%,#E9F7FF 34%,#EAFFF1 66%,#FFF7E2 100%);
}
body:not(.role-parent) .bubble-shape { opacity:.26; filter:blur(.3px); }

/* Sidebar nền trắng để các "pill" màu nổi bật */
body:not(.role-parent) .sidebar { background:linear-gradient(180deg,#FFFFFF,#FBFDFF); }

/* Nhãn nhóm: pill to, đậm, đổ bóng */
body:not(.role-parent) .sidebar-label {
  font-size:11px; padding:6px 13px; margin:10px 8px 4px;
  box-shadow:0 3px 0 rgba(0,0,0,.10); letter-spacing:.08em;
}

/* ⭐ Nút điều hướng thành PILL bo tròn nhiều màu, chunky */
body:not(.role-parent) .sidebar .topic-btn {
  margin:5px 8px; padding:10px 13px;
  border-radius:16px; border:2.5px solid transparent; border-left:none;
  font-size:13.5px; font-weight:800;
  box-shadow:0 3px 0 rgba(0,0,0,.07);
  transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
body:not(.role-parent) .sidebar .topic-btn span:first-child { font-size:17px; }
body:not(.role-parent) .sidebar .topic-btn.sub-btn { margin-left:20px !important; box-shadow:0 2px 0 rgba(0,0,0,.06); }

/* Màu theo nhóm (data-color) — nền tint + chữ đậm cùng tông */
body:not(.role-parent) .topic-btn[data-color="buddy"]  { background:linear-gradient(135deg,#E6FBF4,#CFF6EA); color:#0E8E73 !important; border-color:#B4EEDD; }
body:not(.role-parent) .topic-btn[data-color="blue"]   { background:linear-gradient(135deg,#E6F0FF,#D2E4FF); color:#1763C7 !important; border-color:#BCD7FF; }
body:not(.role-parent) .topic-btn[data-color="green"]  { background:linear-gradient(135deg,#E7FBEC,#D2F4DA); color:#1A8A3E !important; border-color:#BEEDC8; }
body:not(.role-parent) .topic-btn[data-color="orange"] { background:linear-gradient(135deg,#FFF0E2,#FFDFC6); color:#C2570A !important; border-color:#FFCFA6; }

/* Hover & active nảy lên, đậm màu hơn */
body:not(.role-parent) .sidebar .topic-btn:hover { transform:translateY(-2px); box-shadow:0 5px 0 rgba(0,0,0,.10); filter:saturate(1.15); }
body:not(.role-parent) .sidebar .topic-btn.active { transform:translateY(-1px); filter:saturate(1.35) brightness(1.02); box-shadow:0 5px 0 rgba(0,0,0,.12); border-width:3px; }
body:not(.role-parent) .topic-btn[data-color="buddy"].active  { border-color:#1FCBA6; }
body:not(.role-parent) .topic-btn[data-color="blue"].active   { border-color:#1E90FF; }
body:not(.role-parent) .topic-btn[data-color="green"].active  { border-color:#2ED573; }
body:not(.role-parent) .topic-btn[data-color="orange"].active { border-color:#FF8A3C; }

/* ════════════════════════════════════════════════════════════
   📱 RESPONSIVE — Hamburger + sidebar dạng ngăn kéo trên điện thoại
════════════════════════════════════════════════════════════ */
.menu-toggle {
  display:none; flex-direction:column; justify-content:center; gap:4px;
  width:40px; height:40px; padding:0 9px; flex-shrink:0;
  background:rgba(255,255,255,.22); border:none; border-radius:12px; cursor:pointer;
}
.menu-toggle span { display:block; height:3px; border-radius:2px; background:#fff; transition:.2s; }
#sidebar-backdrop { display:none; }

/* ≤ 900px (tablet dọc + điện thoại): sidebar thành ngăn kéo — sidebar cố định 260px+
   sẽ ép vùng nội dung còn ~480px ở 768px, làm thẻ bị bóp và cắt. */
@media (max-width:900px) {
  .menu-toggle { display:flex; }
  .layout { grid-template-columns:minmax(0,1fr); }
  .sidebar {
    position:fixed; top:56px; left:0; bottom:0; width:84%; max-width:300px;
    z-index:120; transform:translateX(-105%);
    transition:transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow:6px 0 40px rgba(0,0,0,.28);
  }
  body.nav-open .sidebar { transform:translateX(0); }

  #sidebar-backdrop {
    display:block; position:fixed; top:56px; left:0; right:0; bottom:0;
    background:rgba(18,28,48,.45); z-index:110;
    opacity:0; visibility:hidden; transition:opacity .25s;
  }
  body.nav-open #sidebar-backdrop { opacity:1; visibility:visible; }

  .main-area { width:100%; }
}

/* ≤ 760px: chế độ điện thoại */
@media (max-width:760px) {
  .header { height:56px; padding:0 10px; gap:8px; }
  .logo-sub { display:none; }
  .score-pill { padding:5px 10px; font-size:12px; }

  /* Nút điều hướng to hơn cho ngón tay bấm */
  body:not(.role-parent) .sidebar .topic-btn { padding:12px 14px; font-size:14.5px; }
  body:not(.role-parent) .sidebar .topic-btn span:first-child { font-size:19px; }

  /* ── KHU CHAT / WELCOME co cỡ cho điện thoại ── */
  .welcome-box { padding:8px; }
  .robot-face { width:60px; height:60px; font-size:32px; border-radius:18px; margin-bottom:10px; }
  .welcome-title { font-size:20px; }
  .welcome-sub { font-size:12.5px; line-height:1.55; margin-bottom:14px; }
  .new-chat-btn { font-size:12px; padding:6px 12px; }

  /* Thanh gợi ý nhanh: cuộn ngang 1 hàng, không chiếm chỗ dọc */
  .quick-prompts { flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:2px; scrollbar-width:none; }
  .qp { flex-shrink:0; font-size:12px; padding:7px 12px; }

  /* Ô nhập + nút gửi/đính kèm vừa tay */
  .input-area { padding:8px 10px 12px; gap:8px; }
  .input-row { gap:8px; }
  .send-btn, .attach-btn { width:46px; height:46px; min-height:46px; }
  /* font 16px để iPhone/Android KHÔNG tự phóng to khi gõ */
  .input-box, textarea, input[type="text"], input[type="email"], input[type="password"] { font-size:16px !important; }
  .input-box { min-height:46px; padding:10px 14px; }

  /* Bong bóng chat rộng hơn cho dễ đọc */
  .msg-row .bubble { max-width:84% !important; }

  /* HEADER gọn — tránh cụm bên phải bị cắt cụt ngoài mép */
  #mascot-mood { display:none !important; }
  .header-right { gap:7px; }
  #user-display-name { max-width:80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .score-pill { padding:5px 9px; font-size:11.5px; }

  /* Thanh nhắc khi bí: cho xuống dòng, không tràn mép */
  .frustration-bar { flex-wrap:wrap; padding:10px 12px; gap:8px 10px; }
  .frust-text { flex:1 1 60%; min-width:0; }
  .frust-actions { flex:1 1 100%; justify-content:flex-end; flex-wrap:wrap; }
  .frust-btn { font-size:11px; padding:7px 11px; }
}

/* ≤ 520px: điện thoại nhỏ — gọn header */
@media (max-width:520px) {
  .badge-pill, #grade-badge { display:none !important; }
  .score-pill { padding:4px 9px; font-size:11px; }
  #user-display-name { max-width:60px; }
}

/* ≤ 430px: chỉ còn avatar + mũi tên ở pill người dùng */
@media (max-width:430px) {
  #user-display-name { display:none; }
  .user-avatar-pill { padding:4px 8px 4px 4px; gap:5px; }
  .notif-bell { width:34px; height:34px; font-size:15px; }
}

/* ≤ 400px: màn rất nhỏ */
@media (max-width:400px) {
  .header { gap:6px; padding:0 8px; }
  .logo > div:last-child > div:first-child { font-size:15px; }
  .welcome-title { font-size:18px; }
}

/* ≤ 360px: màn cực nhỏ (iPhone SE, Galaxy nhỏ) */
@media (max-width:360px) {
  .header { gap:5px; padding:0 7px; }
  .header-right { gap:5px; }
  .logo > div:last-child > div:first-child { font-size:14px; }
  .score-pill { padding:3px 7px; font-size:10.5px; }   /* chỉ còn "⭐ 0" để tiết kiệm chỗ */
}

/* Mobile: chữ nút điều hướng/chọn lớp nhỏ lại để KHÔNG bị xuống dòng */
@media (max-width:760px) {
  body:not(.role-parent) .sidebar .topic-btn { font-size:13.5px; }
  body:not(.role-parent) .sidebar .topic-btn span:first-child { font-size:17px; }
  #intro-welcome-screen .mh-grade-tab,
  #intro-welcome-screen button[onclick^="quickStartGrade"] { font-size:12px !important; min-width:74px !important; padding:10px 6px !important; }
}
@media (max-width:400px) {
  .sidebar .topic-btn { font-size:13px; }
  #intro-welcome-screen button[onclick^="quickStartGrade"] { font-size:11px !important; min-width:62px !important; }
}

/* ════════════════════════════════════════════════════════════
   🛠️ BỎ THANH CUỘN NGANG + NÚT PHỤ HUYNH TO HƠN
════════════════════════════════════════════════════════════ */
/* Nguyên nhân tràn ngang trước đây: .topic-btn width:100% + lề 2 bên → vượt khung.
   Giải pháp chuẩn: width = 100% TRỪ ĐÚNG phần lề → mọi nút đều tăm tắp, lọt gọn. */
.sidebar { overflow-x:hidden; }
.sidebar .topic-btn { width:calc(100% - 16px); box-sizing:border-box; }
.sidebar .topic-btn.sub-btn { width:calc(100% - 28px); }
/* Cột icon cố định 24px để chữ luôn thẳng hàng */
.sidebar .topic-btn > span:first-child { width:24px; min-width:24px; text-align:center; flex-shrink:0; }
/* Mũi tên thả xuống luôn sát mép phải */
.sidebar .topic-btn .expand-arrow { margin-left:auto; flex-shrink:0; }
.subtopic-list { overflow-x:hidden; width:100%; }

/* ── Giao diện PHỤ HUYNH: nút to, dễ bấm, dễ nhìn ── */
body.role-parent .sidebar .topic-btn {
  padding:14px 16px; font-size:15px; font-weight:800;
  margin:5px 8px; border-radius:14px;
  background:#fff; border:2px solid #E2E8F2; border-left:none;
  box-shadow:0 3px 0 rgba(28,40,72,.08);
}
body.role-parent .sidebar .topic-btn span:first-child { font-size:19px; }
body.role-parent .sidebar .topic-btn:hover { background:#F3F7FD; border-color:#9DC0E6; }
body.role-parent .sidebar .topic-btn.active {
  background:linear-gradient(135deg,#3F6FB0,#2BB6A6); color:#fff !important;
  border-color:transparent; box-shadow:0 4px 0 rgba(28,40,72,.18);
}

/* ════════════════════════════════════════════════════════════
   🛡️ PRODUCTION HARDENING — đa nền tảng / đa trình duyệt / a11y
════════════════════════════════════════════════════════════ */
/* Không cho chữ tự phóng to trên iOS khi xoay ngang */
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
/* Chặn cuộn ngang toàn trang ở mọi nơi */
html, body { overflow-x:hidden; max-width:100%; }
/* Chiều cao động chuẩn mobile (tránh nhảy khi thanh URL ẩn/hiện). Trình duyệt cũ tự bỏ qua dvh → giữ 100vh */
body { height:100dvh; }
/* Cho các vùng flex co lại đúng cách (fix tràn do flex item không thu nhỏ) */
.layout, .main-area, .topic-content-panel, .messages, .chat-panel-wrap, .input-area { min-width:0; }
/* Ảnh không méo, không tràn */
img, video, canvas, svg { max-width:100%; height:auto; }
/* Bỏ ánh xanh khi chạm trên mobile */
button, a, .topic-btn, .qp { -webkit-tap-highlight-color:transparent; }

/* Safe-area cho tai thỏ / Dynamic Island / home-indicator (viewport-fit=cover).
   Ưu tiên đáy (home indicator) — không đụng padding ngang header để tránh ảnh hưởng desktop. */
.input-area { padding-bottom:max(14px, env(safe-area-inset-bottom)); }
.frustration-bar { padding-bottom:max(12px, env(safe-area-inset-bottom)); }
.sidebar { padding-bottom:max(14px, env(safe-area-inset-bottom)); }
@media (max-width:760px) {
  .header { padding-left:max(10px, env(safe-area-inset-left)); padding-right:max(10px, env(safe-area-inset-right)); }
}

/* Vùng chạm tối thiểu 44px trên thiết bị cảm ứng (chuẩn WCAG / Apple HIG) */
@media (pointer:coarse) {
  .qp, .practice-type-btn, .advisor-age-btn, .period-btn,
  .auth-grade-pill, .frust-btn, .mh-grade-tab { min-height:44px; }
  .topic-btn { min-height:46px; }
}

/* Hiển thị vòng focus rõ ràng cho điều hướng bàn phím (a11y) */
:focus-visible {
  outline:3px solid #1763C7; outline-offset:2px; border-radius:6px;
}
/* Không hiện outline khi bấm chuột (chỉ khi dùng bàn phím) */
:focus:not(:focus-visible) { outline:none; }

/* Tôn trọng "giảm chuyển động" của hệ điều hành (a11y + tiết kiệm pin/CPU) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:0.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:0.001ms !important;
    scroll-behavior:auto !important;
  }
  .bubbles, .buddy-sprite { animation:none !important; }
}

.header{ background:linear-gradient(120deg,#1FCBA6,#14B39A 60%,#12A88F) !important; }
body{ background:linear-gradient(165deg,#EAF7F4,#F4FBFA 50%,#EEF6FF) !important; }
body:not(.role-parent) .topic-btn.nav-new,
body:not(.role-parent) .topic-btn[data-color]{ background:transparent !important; border:none !important; border-left:none !important; box-shadow:none !important; color:#44586B !important; }
body:not(.role-parent) .topic-btn.nav-new.active{ background:linear-gradient(135deg,#1FCBA6,#13B392) !important; color:#fff !important; box-shadow:0 6px 14px rgba(31,203,166,.28) !important; }

@keyframes sbBootSpin{to{transform:rotate(360deg)}}

/* Math Home panel cards */
.mh-card {
  background: white; border-radius: 16px; padding: 16px 14px;
  cursor: pointer; border: 2px solid rgba(0,0,0,.06);
  transition: all .18s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 5px;
  border-top: 4px solid var(--c);
  position: relative; overflow: hidden;
}
.mh-card::before {
  content:''; position:absolute; top:0; right:0;
  width:60px; height:60px;
  background: radial-gradient(circle at top right, var(--cs), transparent 70%);
  opacity: .15;
}
.mh-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,.12); border-color: var(--c); }
.mh-card-icon { font-size: 24px; }
.mh-card-title { font-family:'Baloo 2',cursive; font-size:15px; font-weight:800; color:var(--c); }
.mh-card-desc { font-size:11px; color:var(--text2); font-weight:600; line-height:1.5; }

:root{ --ink:#14303C; --mint:#1FCBA6; --mint-d:#0E9E86; }
/* Nền dịu, đồng nhất mint */
body{ background:linear-gradient(165deg,#EAF7F4 0%,#F4FBFA 50%,#EEF6FF 100%) !important; }
.bubble-shape{ opacity:.08 !important; }
/* Header mint (bỏ cầu vồng) */
.header{ background:linear-gradient(120deg,#1FCBA6 0%,#14B39A 60%,#12A88F 100%) !important; background-size:auto !important; animation:none !important; box-shadow:0 6px 20px rgba(17,120,105,.22) !important; }
/* Sidebar trắng-mint sạch */
.sidebar{ background:linear-gradient(180deg,#FFFFFF,#F5FBFA) !important; border-right:1px solid rgba(31,203,166,.14) !important; }
/* Nút điều hướng mới — bo tròn, chữ navy, active mint */
/* Nav phẳng, KHÔNG viền/khung, đều nhau — chỉ nút chọn có nền teal (giống mockup) */
body:not(.role-parent) .topic-btn.nav-new{
  background:transparent !important; border:none !important; border-left:none !important; box-shadow:none !important;
  border-radius:12px !important; margin:2px auto !important; width:calc(100% - 24px) !important; align-self:center !important; padding:9px 16px !important;
  color:#44586B !important; font-size:14.5px !important; font-weight:700 !important;
  display:flex !important; align-items:center !important; gap:11px !important; min-height:40px; box-sizing:border-box !important;
}
/* Ẩn thanh cuộn sidebar (không muốn nhìn thấy thanh kéo) */
body:not(.role-parent) .sidebar{ scrollbar-width:none !important; }
body:not(.role-parent) .sidebar::-webkit-scrollbar{ width:0 !important; height:0 !important; }
.topic-btn.nav-new .nav-ic-em{ font-size:19px; width:24px; text-align:center; flex-shrink:0; line-height:1; }
body:not(.role-parent) .topic-btn.nav-new:hover{ background:rgba(31,203,166,.10) !important; color:var(--ink) !important; }
body:not(.role-parent) .topic-btn.nav-new.active{ background:linear-gradient(135deg,#1FCBA6,#13B392) !important; color:#fff !important; box-shadow:0 6px 14px rgba(31,203,166,.28) !important; }
/* Ẩn mũi tên/khung nhóm cũ nếu có */
.topic-btn.nav-new .expand-arrow{ display:none !important; }
/* Tab con Kỹ năng sống — tone mint đồng nhất */
.subtopic-list .sub-btn{ color:var(--ink) !important; }
.subtopic-list .sub-btn:hover, .subtopic-list .sub-btn.active{ background:rgba(31,203,166,.12) !important; color:var(--mint-d) !important; }
/* Đồng bộ header các trang môn học (bỏ xanh/cam/tím) về MINT */
.topic-content-panel div[style*="linear-gradient"][style*="0 6px 0 rgba"]{ background:linear-gradient(135deg,#1FCBA6,#14B39A 55%,#12A88F) !important; box-shadow:0 8px 20px rgba(17,120,105,.20) !important; }
/* Nút lọc/hub đang chọn → mint (đồng bộ) */
.practice-type-btn.active, .diff-btn.active, .hist-filter-btn.active{ background:linear-gradient(135deg,#1FCBA6,#13B392) !important; border-color:#1FCBA6 !important; color:#fff !important; }
/* Bỏ header: đưa logo vào sidebar, controls sang góc phải nội dung (nền sáng) */
.sb-side-logo{ padding:10px 14px 8px; text-align:center; cursor:pointer; border-bottom:1px solid rgba(31,203,166,.12); }
.sb-side-logo img{ max-width:138px; width:80%; height:auto; }
/* Topbar (điểm/chuông/tài khoản) = một HÀNG in-flow ở đỉnh vùng nội dung,
   nhờ order:-1 nên các panel (banner môn học...) tự nằm bên DƯỚI — không còn bị đè,
   và cụm nút "chạy theo" trang khi đổi tab. */
#content-topbar{ order:-1; position:relative; width:100%; box-sizing:border-box; z-index:200; display:flex; align-items:center; justify-content:flex-end; gap:10px; padding:12px 22px 4px; pointer-events:none; flex-shrink:0; }
#content-topbar > *{ pointer-events:auto; }
/* Trang overlay (Thành tích/Hồ sơ/Cài đặt) bắt đầu dưới hàng topbar cho gọn */
#app-generic-panel{ padding-top:60px !important; }
/* ── Chuyển động mượt & ổn định ── */
@keyframes fadeInUp{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:none;} }
.topic-btn{ transition:background .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease !important; }
.notif-bell, .user-avatar-pill, .auth-header-btn, .score-pill, .send-btn, .attach-btn, .qp{ transition:all .16s cubic-bezier(.34,1.56,.64,1); }
@media (prefers-reduced-motion: reduce){ *{ animation-duration:.01ms !important; transition-duration:.01ms !important; } }
#content-topbar .score-pill{ box-shadow:0 4px 10px rgba(200,154,0,.28) !important; }
#content-topbar .notif-bell{ background:#fff !important; color:var(--ink) !important; border:1.5px solid #DDEBE6 !important; box-shadow:0 3px 10px rgba(18,49,74,.08) !important; }
#content-topbar .auth-header-btn{ background:#fff !important; color:var(--mint-d) !important; border:1.5px solid #DDEBE6 !important; box-shadow:0 3px 10px rgba(18,49,74,.08) !important; }
#content-topbar .user-avatar-pill{ background:#fff !important; color:var(--ink) !important; border:1.5px solid #DDEBE6 !important; box-shadow:0 3px 10px rgba(18,49,74,.08) !important; }
#content-topbar #user-avatar-letter{ background:linear-gradient(135deg,#1FCBA6,#13B392) !important; color:#fff !important; }
#content-topbar .user-dropdown{ color:var(--ink); }
@media(max-width:760px){ #content-topbar{ padding:10px 12px 4px; } }
/* ── Nền teal xanh: đậm ở TRÊN, nhạt dần xuống DƯỚI thành TRẮNG (giống mẫu) ── */
body:not(.role-parent){ background:linear-gradient(180deg,#22AD93 0%,#33BFA3 18%,#6FD4BF 42%,#ACE5D9 64%,#DCF3ED 84%,#FFFFFF 100%) !important; background-attachment:fixed !important; }
body:not(.role-parent) .bubbles{ display:none !important; }
body:not(.role-parent) .layout{ padding:10px 10px 0 10px !important; gap:11px !important; background:transparent !important; }
/* Sidebar = thẻ trắng, bo góc TRÊN, kéo thẳng xuống đáy (không bo góc dưới) */
body:not(.role-parent) .sidebar{
  background:#FFFFFF !important; border:none !important; border-radius:24px 24px 0 0 !important;
  box-shadow:0 16px 38px rgba(7,72,58,.22) !important;
}
/* Vùng nội dung = nền XANH MINT trên nhạt dần xuống TRẮNG; bo góc TRÊN, kéo thẳng xuống đáy */
body:not(.role-parent) .main-area{
  background:linear-gradient(180deg,#D6F1E8 0%,#E7F6F1 20%,#F4FBF9 50%,#FFFFFF 100%) !important;
  border-radius:24px 24px 0 0 !important; overflow:hidden !important;
  box-shadow:0 16px 38px rgba(7,72,58,.22) !important;
}
/* Trang chủ trong suốt để lộ nền mint→trắng; cao theo nội dung, màn thấp thì cuộn tự nhiên */
body:not(.role-parent) #intro-welcome-screen{ background:transparent !important; overflow-y:auto !important; scrollbar-width:thin; }

/* ═══════════ TỐI ƯU GIAO DIỆN ĐIỆN THOẠI (gọn · dễ nhìn · mượt) ═══════════ */
@keyframes sbPageIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:none;} }
/* Có ngăn kéo (≤900px): topbar sạch — hamburger BÊN TRÁI · chuông+avatar BÊN PHẢI, không đè nội dung */
@media (max-width:900px){
  #content-topbar{ justify-content:space-between !important; padding:8px 12px 4px !important; gap:8px; }
  #content-topbar .menu-toggle{ order:-1; display:flex !important; width:42px; height:42px; background:#fff !important; border:1.5px solid #DDEBE6 !important; box-shadow:0 3px 10px rgba(18,49,74,.08); border-radius:12px; }
  #content-topbar .menu-toggle span{ background:var(--ink) !important; }
  #content-topbar .header-right{ margin-left:auto; }
  #content-topbar .sb-topbar-brand{ display:flex; }
  /* Trang chủ là lớp absolute → ĐẨY nội dung xuống dưới topbar (hamburger không đè lời chào) */
  body:not(.role-parent) #intro-welcome-screen{ -webkit-overflow-scrolling:touch; padding:58px 14px 18px !important; }
}
@media (max-width:760px){
  /* Ô chat: input giữ 16px (chống iOS tự phóng to), chỉ thu nhỏ placeholder cho gọn */
  .input-box::placeholder{ font-size:13.5px; opacity:.75; }
  .input-area{ padding:8px 10px max(12px, env(safe-area-inset-bottom)) !important; }

  /* Chuyển trang mượt mà */
  .topic-content-panel, #app-generic-panel, #intro-welcome-screen{ animation:sbPageIn .24s cubic-bezier(.22,.61,.36,1) both; }
}
@media (max-width:760px){
  body:not(.role-parent) .bubbles,
  body:not(.role-parent) #sb-mascot-banner{ display:none !important; }
  body:not(.role-parent) #intro-welcome-screen{ background:#F6FAF9 !important; }
}

/* ══════════ TRÒ CHUYỆN GIỌNG NÓI (sb-voice.js) ══════════ */
.voice-btn { width:48px; height:48px; border-radius:16px; background:linear-gradient(135deg,var(--teal),var(--teal-d)); border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; color:white; font-size:20px; flex-shrink:0; box-shadow:0 5px 0 rgba(17,145,122,0.35); transition:all 0.15s; }
.voice-btn:hover { transform:translateY(-2px); box-shadow:0 7px 0 rgba(17,145,122,0.35); }
.voice-btn:active { transform:translateY(2px); box-shadow:0 2px 0 rgba(17,145,122,0.35); }
.voice-btn[hidden] { display:none; }
@media (max-width: 600px) { .voice-btn { width:46px; height:46px; min-height:46px; } }

body.sbv-open { overflow:hidden; }
.sbv-overlay { position:fixed; inset:0; z-index:1300; background:rgba(18,49,74,.55); -webkit-backdrop-filter:blur(4px); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; padding:16px; }
.sbv-overlay[hidden] { display:none; }
.sbv-card { width:min(520px,100%); max-height:calc(100vh - 32px); display:flex; flex-direction:column; gap:12px; background:var(--card); border-radius:26px; padding:18px 20px 16px; box-shadow:0 20px 60px rgba(0,0,0,.25); font-family:'Nunito',Arial,sans-serif; color:var(--text1); overflow:hidden; }
.sbv-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.sbv-kicker { font-size:12px; font-weight:900; color:var(--teal-d); text-transform:uppercase; letter-spacing:.08em; }
.sbv-title { font-family:'Baloo 2','Nunito',sans-serif; font-size:24px; line-height:1.2; margin-top:2px; }
.sbv-x { border:0; background:var(--bg); color:var(--text2); border-radius:50%; width:38px; height:38px; font-size:22px; cursor:pointer; flex-shrink:0; }

.sbv-stage { display:flex; flex-direction:column; align-items:center; gap:10px; padding:6px 0 2px; }
.sbv-orb { --lvl:0; --c:var(--teal); position:relative; width:118px; height:118px; display:grid; place-items:center; }
.sbv-orb img, .sbv-emoji { position:relative; z-index:1; width:92px; height:92px; border-radius:50%; background:#fff; object-fit:contain; box-shadow:0 0 0 4px var(--c); display:grid; place-items:center; font-size:52px; transition:box-shadow .2s; }
.sbv-ring { position:absolute; inset:8px; border-radius:50%; background:var(--c); opacity:.18; transform:scale(calc(1 + var(--lvl) * .35)); transition:transform .08s linear, background .2s; }
.sbv-ring.r2 { inset:0; opacity:.10; transform:scale(calc(1 + var(--lvl) * .6)); }
.sbv-stage[data-state="hearing"] .sbv-orb { --c:var(--green); }
.sbv-stage[data-state="thinking"] .sbv-orb { --c:var(--yellow); }
.sbv-stage[data-state="thinking"] .sbv-ring { animation:sbvPulse 1.1s ease-in-out infinite; }
.sbv-stage[data-state="speaking"] .sbv-orb { --c:var(--purple); }
.sbv-stage[data-state="speaking"] .sbv-ring { animation:sbvPulse .7s ease-in-out infinite; }
.sbv-stage[data-state="connecting"] .sbv-ring, .sbv-stage[data-state="reconnecting"] .sbv-ring { animation:sbvPulse 1.4s ease-in-out infinite; }
.sbv-stage[data-state="reconnecting"] .sbv-orb { --c:var(--orange); }
.sbv-stage[data-state="muted"] .sbv-orb, .sbv-stage[data-state="ended"] .sbv-orb, .sbv-stage[data-state="idle"] .sbv-orb { --c:#C9D3E6; }
.sbv-stage[data-state="error"] .sbv-orb { --c:var(--red); }
@keyframes sbvPulse { 0%,100% { transform:scale(1); } 50% { transform:scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .sbv-ring { animation:none !important; transition:none; } }

.sbv-status { text-align:center; min-height:46px; }
.sbv-label { font-size:18px; font-weight:900; }
.sbv-sub { font-size:13px; font-weight:700; color:var(--text2); margin-top:2px; overflow-wrap:anywhere; }
.sbv-stage[data-state="error"] .sbv-label { color:#D64545; }

.sbv-intro ul { margin:0; padding:10px 14px 10px 30px; background:#F0FBF7; border:1px solid #D7F1E8; border-radius:14px; font-size:13px; font-weight:700; color:var(--text2); line-height:1.6; }
.sbv-intro[hidden] { display:none; }
.sbv-transcript { flex:1 1 auto; min-height:0; max-height:32vh; overflow-y:auto; display:flex; flex-direction:column; gap:8px; }
.sbv-transcript:empty { display:none; }
.sbv-line { max-width:88%; padding:8px 12px; border-radius:16px; font-size:14px; font-weight:700; line-height:1.5; overflow-wrap:anywhere; }
.sbv-line.me { align-self:flex-end; background:linear-gradient(135deg,var(--teal),var(--teal-d)); color:#fff; border-bottom-right-radius:6px; }
.sbv-line.ai { align-self:flex-start; background:var(--bg); border:1px solid #D7F1E8; border-bottom-left-radius:6px; }
.sbv-line.cut { opacity:.75; }
.sbv-who { display:block; font-size:11px; font-weight:900; opacity:.8; text-transform:uppercase; letter-spacing:.06em; }

.sbv-controls { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.sbv-btn { border:0; border-radius:16px; padding:12px 18px; font:900 15px 'Nunito',Arial,sans-serif; cursor:pointer; color:#fff; transition:transform .15s, box-shadow .15s; min-height:48px; }
.sbv-btn[hidden] { display:none; }
.sbv-btn:active { transform:translateY(2px); }
.sbv-btn:focus-visible, .sbv-x:focus-visible, .voice-btn:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }
.sbv-start { background:linear-gradient(135deg,var(--teal),var(--teal-d)); box-shadow:0 5px 0 rgba(17,145,122,.35); }
.sbv-mic { background:linear-gradient(135deg,#A55EEA,#3742FA); box-shadow:0 5px 0 rgba(55,66,250,.3); }
.sbv-mic[aria-pressed="true"] { background:#8A94AD; box-shadow:0 5px 0 rgba(0,0,0,.15); }
.sbv-stop { background:linear-gradient(135deg,#FFCB45,#FF9F1C); color:#5A3B00; box-shadow:0 5px 0 rgba(200,130,20,.3); }
.sbv-end { background:linear-gradient(135deg,#FF6B35,#FF6B6B); box-shadow:0 5px 0 rgba(200,50,30,.35); }

.sbv-privacy { border-top:1px dashed #E3E7F5; padding-top:10px; font-size:12px; font-weight:600; color:var(--text2); line-height:1.5; }
.sbv-privacy p { margin-top:4px; }
.sbv-switch { display:flex; align-items:center; gap:8px; font-weight:800; color:var(--text1); cursor:pointer; }
.sbv-switch input { width:18px; height:18px; accent-color:var(--teal-d); }
.sbv-chat-note { font-size:12px; font-weight:900; color:var(--teal-d); }
@media (max-width: 480px) {
  .sbv-card { padding:14px 14px 12px; border-radius:22px; }
  .sbv-btn { flex:1 1 40%; padding:12px 10px; }
}

/* ══════════ KỸ NĂNG SỐNG: đang trò chuyện → ẩn lưới, chat lấp đầy chiều cao ══════════ */
#panel-life_skills.ls-chatting #life-skills-grid { display:none !important; }
#panel-life_skills.ls-chatting .ls-wrap { height:100%; min-height:0; }
#panel-life_skills.ls-chatting #life-skills-chat { flex:1 1 auto; min-height:0; }
#panel-life_skills.ls-chatting #life-skills-messages { flex:1 1 auto; min-height:120px; }
#panel-life_skills:not(.ls-chatting) #life-skills-messages { max-height:380px; }
@media (max-width: 600px) {
  #panel-life_skills.ls-chatting .ls-wrap { padding:12px !important; gap:10px !important; }
  #panel-life_skills.ls-chatting .ls-wrap > div:first-child { padding:10px 14px !important; }
  #panel-life_skills.ls-chatting .ls-wrap > div:first-child img { width:40px !important; height:40px !important; }
  #panel-life_skills.ls-chatting .ls-wrap > div:first-child div[style*="font-size:15px"] { display:none; }
}

/* ══════════ Thanh nhập chat trên điện thoại: 4 nút + ô nhập vẫn đủ chỗ ══════════ */
@media (max-width: 480px) {
  .input-area .input-row { gap:6px; }
  .input-area .input-row .attach-btn, .input-area .input-row .math-open-btn,
  .input-area .input-row .voice-btn, .input-area .input-row .send-btn {
    width:42px; height:42px; min-height:42px; border-radius:13px; font-size:18px;
  }
  .input-area .input-row .input-box { min-width:0; font-size:16px; padding-left:12px; padding-right:10px; }
  .input-area .input-row .input-box::placeholder { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
}

/* ══════════ Hồ sơ: cột gói rộng hơn để 3 gói nằm 1 hàng (vừa 1 màn hình) ══════════ */
@media (min-width: 1100px) {
  .profile-grid { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.8fr) !important; }
  .profile-plans { flex-wrap: nowrap !important; }
}

/* ══════════ Vừa 1 màn hình: laptop thấp, tablet, điện thoại ══════════ */
/* Tư duy đặt câu hỏi — màn chào trên laptop thấp (vd 1280×720) */
/* Hồ sơ trên tablet: 1 cột để 3 gói học nằm cùng một hàng thay vì 2 + 1 */
@media (min-width: 601px) and (max-width: 1099px) {
  .profile-grid { grid-template-columns: 1fr !important; }
}
/* Kỹ năng sống trên điện thoại: lưới 2 cột, thẻ gọn hơn → cả 8 kỹ năng vừa trong khung */
@media (max-width: 600px) {
  #life-skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap:10px !important; }
  #life-skills-grid .subtopic-card { padding:10px 6px 8px; }
  #life-skills-grid .sc-img { font-size:30px; }
}
@media (max-width: 600px) {
  #panel-life_skills .ls-wrap { gap:12px !important; }
  #panel-life_skills .ls-wrap > div:first-child { padding:12px 14px !important; gap:12px !important; }
  #panel-life_skills .ls-wrap > div:first-child img { width:48px !important; height:48px !important; }
  #panel-life_skills .ls-wrap > div:first-child div[style*="font-size:24px"] { font-size:20px !important; margin-bottom:2px !important; }
  #panel-life_skills .ls-wrap > div:first-child div[style*="font-size:15px"] { font-size:13px !important; line-height:1.45 !important; }
}

/* Chip thương hiệu trên topbar (chỉ điện thoại/tablet ≤900px — máy tính đã có logo ở sidebar) */
.sb-topbar-brand{ display:none; align-items:center; gap:8px; min-width:0; cursor:pointer; }
.sb-topbar-brand img{ width:36px; height:36px; border-radius:11px; flex:none; box-shadow:0 3px 8px rgba(17,145,122,.18); }
.sb-topbar-brand span{ font-family:'Baloo 2',cursive; font-size:19px; font-weight:800; color:#0E8F79; letter-spacing:.2px; white-space:nowrap; }
@media (max-width:389px){ .sb-topbar-brand span{ display:none; } }

/* Bảng giá trên điện thoại: thẻ gói xếp dọc (bảng so sánh rộng 520px+ phải vuốt ngang, cột giá bị khuất) */
.sbp-cards{ display:none; }
@media (max-width:600px){
  .sbp-table-wrap{ display:none; }
  .sbp-cards{ display:grid; gap:12px; }
  .sbp-box{ padding:18px 14px !important; }
  .sbp-card{ position:relative; background:#fff; border:2px solid #E4EEEB; border-radius:16px; padding:14px; }
  .sbp-card.is-hot{ border-color:var(--plan); background:#F7FFFD; margin-top:6px; }
  .sbp-hot{ position:absolute; top:0; left:16px; transform:translateY(-50%); background:var(--plan); color:#fff; font-size:11px; font-weight:900; letter-spacing:.04em; padding:2px 10px; border-radius:20px; }
  .sbp-card-head{ display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-bottom:6px; }
  .sbp-name{ font-family:'Baloo 2',cursive; font-size:19px; color:var(--text1); }
  .sbp-price{ font-family:'Baloo 2',cursive; font-size:20px; font-weight:900; color:var(--plan); white-space:nowrap; }
  .sbp-price small{ font-family:'Nunito',Arial; font-size:12px; color:var(--text3); font-weight:700; }
  .sbp-list{ list-style:none; margin:0 0 12px; padding:0; }
  .sbp-list li{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px solid #F0F5F3; font-size:13px; color:var(--text2); font-weight:700; }
  .sbp-val{ flex:none; text-align:right; max-width:48%; }
  .sbp-val div{ display:inline; margin-left:4px; }
  .sbp-card button{ min-height:44px; }
}

