/* Sheeto - he thong thiet ke dung chung
 * Bang mau: xanh "bang tinh" (khong phai xanh non), xanh chon o, ho phach, tim goi Pro,
 * san hoi (khong dung do thuan) va bo trung tinh nga xanh nhe cho khoi vo tri.
 */
:root {
  /* Lay dung tu file logo goc: than bieu tuong #06D14E, chu "o" #20D455 */
  --green:      #10CF51;
  --green-d:    #0BB246;
  --green-dd:   #08913A;
  --green-soft: #DFF7E9;
  --green-tint: #F2FBF6;

  --blue:       #2B7FFF;   /* mau vien chon o trong bang tinh */
  --blue-d:     #1560D8;
  --blue-soft:  #EAF2FF;

  --amber:      #FFB020;
  --amber-d:    #D98800;
  --amber-soft: #FFF6E3;

  --violet:     #7C5CFF;
  --violet-d:   #5B38E0;
  --violet-soft:#F1EDFF;

  --coral:      #FF5A5F;
  --coral-d:    #D93B44;
  --coral-soft: #FFEDED;

  --ink:    #0A1120;   /* mau chu trong logo goc: #070F22 */
  --ink-2:  #334155;
  --muted:  #64748B;
  --line:   #E6EAF0;
  --line-2: #CBD5E1;
  --bg:     #FFFFFF;
  --bg-2:   #F2FBF6;
  --bg-3:   #E6EAF0;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --r-xl: 34px;

  --fh: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  --fb: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --fm: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;

  --shadow-sm: 0 1px 2px rgba(12,26,21,.06), 0 2px 8px rgba(12,26,21,.05);
  --shadow:    0 6px 20px rgba(12,26,21,.08);
  --shadow-lg: 0 22px 60px rgba(12,26,21,.16);

  --ease: cubic-bezier(.2,.8,.25,1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--fb);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.62;
}
h1, h2, h3, h4 {
  font-family: var(--fh); font-weight: 800; line-height: 1.14;
  margin: 0 0 .4em; letter-spacing: -.015em; text-wrap: balance;
}
h1 { font-size: clamp(33px, 5.2vw, 60px); }
h2 { font-size: clamp(27px, 3.6vw, 42px); }
h3 { font-size: clamp(19px, 2vw, 25px); }
p  { margin: 0 0 1em; color: var(--ink-2); }
a  { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: fixed; z-index: 10000; top: 10px; left: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: #fff; font-weight: 800;
  transform: translateY(-160%); transition: transform .15s var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.wrap { width: min(1180px, 92vw); margin-inline: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------- logo */
.logo { display: inline-flex; align-items: center; gap: 9px; }
.logo__mark {
  width: 38px; height: auto; flex: 0 0 auto; display: block;
  transition: transform .3s var(--ease);
}
.logo:hover .logo__mark { transform: rotate(-5deg) scale(1.07); }
.logo__word { height: 25px; width: auto; display: block; flex: 0 0 auto; }
@media (max-width: 520px) {
  .logo__mark { width: 32px; }
  .logo__word { height: 21px; }
}

/* ---------------------------------------------------------- nut bam 3D */
.btn {
  --c: var(--green);
  --cd: var(--green-dd);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--fb); font-weight: 800; font-size: 15.5px; letter-spacing: .02em;
  padding: 14px 26px; border: 0; border-radius: var(--r);
  background: var(--c); color: #fff; cursor: pointer;
  box-shadow: 0 5px 0 var(--cd);
  transition: transform .09s var(--ease), box-shadow .09s var(--ease), filter .18s;
  text-transform: uppercase; white-space: nowrap; line-height: 1.2;
}
.btn:hover { filter: brightness(1.06); }
.btn:active, .btn.is-down { transform: translateY(5px); box-shadow: 0 0 0 var(--cd); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--cd); }
.btn--lg { font-size: 17px; padding: 18px 36px; border-radius: 20px; }
.btn--sm { font-size: 13.5px; padding: 10px 16px; border-radius: 12px; box-shadow: 0 4px 0 var(--cd); }
.btn--blue   { --c: var(--blue);   --cd: var(--blue-d); }
.btn--amber  { --c: var(--amber);  --cd: var(--amber-d); color: #4A3200; }
.btn--violet { --c: var(--violet); --cd: var(--violet-d); }
.btn--coral  { --c: var(--coral);  --cd: var(--coral-d); }
.btn--ghost {
  background: #fff; color: var(--ink); border: 2px solid var(--line-2);
  border-bottom-width: 0; box-shadow: 0 5px 0 var(--line-2);
}
.btn--ghost:hover { background: var(--bg-2); filter: none; }
.btn--ghost:active { box-shadow: 0 0 0 var(--line-2); }
.btn--wide { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: var(--bg-3); color: var(--ink-2); line-height: 1.5;
}
.chip--green  { background: var(--green-soft);  color: var(--green-dd); }
.chip--blue   { background: var(--blue-soft);   color: var(--blue-d); }
.chip--amber  { background: var(--amber-soft);  color: #8A5D00; }
.chip--violet { background: var(--violet-soft); color: var(--violet-d); }
.chip--coral  { background: var(--coral-soft);  color: var(--coral-d); }

/* ---------------------------------------------------------- bang tinh */
.ms { --ms-h: 40px; font-family: var(--fb); position: relative; }
.ms--compact { --ms-h: 32px; }

.ms-fbar {
  display: flex; align-items: center;
  background: #fff; border: 2px solid var(--line); border-bottom: 0;
  border-radius: var(--r) var(--r) 0 0; padding: 7px 9px;
}
.ms-fbar__ref {
  font-family: var(--fm); font-size: 13px; font-weight: 700; color: var(--ink-2);
  min-width: 58px; text-align: center; background: var(--bg-2);
  border-radius: 8px; padding: 6px;
}
.ms-fbar__fx { font-style: italic; font-weight: 700; color: var(--muted); padding: 0 13px; font-family: var(--fm); }

/* Thanh cong thuc gom hai lop chong khit: lop duoi ve chu da to mau,
   lop tren la o nhap that voi chu trong suot - giong cach Google Sheets lam. */
.ms-fbar__box { position: relative; flex: 1; min-width: 0; display: block; }
.ms-fbar__hl, .ms-fbar__in {
  font-family: var(--fm); font-size: 14.5px; line-height: 22px;
  padding: 6px 4px; letter-spacing: 0;
}
.ms-fbar__hl {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  white-space: pre; color: var(--ink); display: flex; align-items: center;
}
.ms-fbar__in {
  position: relative; display: block; width: 100%; border: 0; outline: 0;
  background: transparent; color: transparent; caret-color: var(--ink);
}
.ms-fbar__in::placeholder { color: #94A3B8; }
.ms-fbar__in:focus::placeholder { color: #CBD5E1; }

.ms-wrap {
  position: relative; overflow: auto; background: #fff;
  border: 2px solid var(--line); border-radius: 0 0 var(--r) var(--r);
  outline: none; max-height: 70vh;
}
.ms-fbar + .ms-wrap { border-top: 2px solid var(--line); }

.ms-tbl { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 15px; }
.ms-tbl th, .ms-tbl td { height: var(--ms-h); }
.ms-tbl thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--bg-3); color: var(--muted);
  font-size: 12px; font-weight: 700; font-family: var(--fm);
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  text-align: center; user-select: none;
}
.ms-tbl thead th.is-on { background: #D8E6FF; color: var(--blue-d); }
.ms-rowh {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg-3); color: var(--muted);
  font-size: 12px; font-weight: 700; font-family: var(--fm); width: 46px;
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line);
  text-align: center; user-select: none;
}
.ms-rowh.is-on { background: #D8E6FF; color: var(--blue-d); }
.ms-corner { position: sticky; left: 0; z-index: 4; background: var(--bg-3); }

.ms-tbl td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 0 10px; color: var(--ink); cursor: cell; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
  background: #fff;
}
.ms-tbl td.is-num  { text-align: right; font-variant-numeric: tabular-nums; }
.ms-tbl td.is-head { background: var(--bg-2); font-weight: 700; }
.ms-tbl td.is-lock { color: var(--ink-2); }
.ms-tbl td.is-err  { color: var(--coral-d); font-weight: 700; }
.ms-tbl td.is-sel    { background: var(--blue-soft); }
.ms-tbl td.is-active { box-shadow: inset 0 0 0 2.5px var(--blue); background: #fff; }
.ms-tbl td.is-fill   { background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-d); }
/* O can lam: co dau but chi va phan hoi ro rang khi re chuot vao,
   de nguoi hoc biet chac day la o minh duoc go. */
.ms-tbl td.is-target {
  position: relative; background: #FFFCF4;
  box-shadow: inset 0 0 0 2px var(--amber);
}
.ms-tbl td.is-target::after {
  content: '✎'; position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--amber-d); opacity: .5; pointer-events: none;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.ms-tbl td.is-target:hover {
  background: #FFF6DC;
  box-shadow: inset 0 0 0 2.5px var(--amber-d), 0 0 0 3px rgba(255,176,32,.28);
  cursor: cell;
}
.ms-tbl td.is-target:hover::after { opacity: 1; transform: translateY(-50%) scale(1.15); }
.ms-tbl td.is-target.is-active { box-shadow: inset 0 0 0 2.5px var(--blue); }
.ms-tbl td.is-target.is-active::after,
.ms-tbl td.is-editing::after { opacity: 0; }

/* O mo khoa nhung chua phai muc tieu: van co phan hoi nhe khi re chuot */
.ms-tbl td:not(.is-lock):not(.is-target):not(.is-active):hover {
  box-shadow: inset 0 0 0 1.5px var(--line-2); cursor: cell;
}
.ms-tbl td.is-lock { cursor: default; }
.ms-tbl td.is-pulse { animation: msPulse 1.05s var(--ease) 2; }
@keyframes msPulse {
  0%,100% { box-shadow: inset 0 0 0 2px var(--amber); }
  50%     { box-shadow: inset 0 0 0 4px var(--amber), 0 0 0 7px rgba(255,176,32,.32); }
}

/* O soan thao trong bang cung dung hai lop nhu thanh cong thuc */
.ms-hl, .ms-editor {
  position: absolute; font-family: var(--fm); font-size: 14.5px;
  padding: 0 8px; border: 2.5px solid transparent; box-sizing: border-box;
}
.ms-hl {
  z-index: 6; pointer-events: none; overflow: hidden; white-space: pre;
  background: #fff; color: var(--ink); align-items: center;
  box-shadow: 0 8px 22px rgba(12,26,21,.18);
}
.ms-editor {
  z-index: 7; border-color: var(--blue); outline: none;
  background: transparent; color: transparent; caret-color: var(--ink);
}

/* mau tung thanh phan trong cong thuc */
.ms-hl i, .ms-fbar__hl i { font-style: normal; }
.fx-eq    { color: #94A3B8; }
.fx-fn    { color: #7C3AED; font-weight: 600; }
.fx-str   { color: #3F6212; }
.fx-num   { color: #0A1120; }
.fx-op, .fx-sep { color: #64748B; }
.fx-paren { color: #334155; font-weight: 600; }
.fx-name  { color: var(--coral-d); text-decoration: underline wavy var(--coral); }
.fx-ref   { font-weight: 600; }

/* khung mau bao quanh o / vung dang duoc cong thuc tham chieu */
.ms-ref {
  position: absolute; z-index: 4; pointer-events: none;
  border: 2px solid var(--rc); border-radius: 3px;
  animation: shRefIn .16s var(--ease);
}
.ms-ref::before {
  content: ''; position: absolute; inset: 0;
  background: var(--rc); opacity: .1; border-radius: 2px;
}
@keyframes shRefIn { from { opacity: 0; transform: scale(1.04) } to { opacity: 1; transform: none } }
.ms-tbl thead th.is-ref { color: var(--rc); box-shadow: inset 0 -3px 0 var(--rc); }
.ms-rowh.is-ref { color: var(--rc); box-shadow: inset -3px 0 0 var(--rc); }
.ms-fill {
  position: absolute; z-index: 5; width: 10px; height: 10px;
  background: var(--blue); border: 2px solid #fff; border-radius: 3px;
  cursor: crosshair; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.ms-status {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 12.5px; color: var(--muted); padding: 9px 4px 0; flex-wrap: wrap;
}
.ms-status b { color: var(--ink-2); }
.ms-toast {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 16px);
  background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: .24s var(--ease); z-index: 20; white-space: nowrap;
  box-shadow: var(--shadow);
}
.ms-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------- linh vat */
.mascot { display: block; height: auto; }
.mascot--float { animation: shFloat 4.2s ease-in-out infinite; }
@keyframes shFloat { 0%,100% { transform: translateY(0) rotate(0) } 50% { transform: translateY(-9px) rotate(-1.5deg) } }

/* ---------------------------------------------------------- hoat anh dung chung */
.reveal {
  opacity: 0; transform: translateY(20px);
  transition: opacity .65s var(--ease), transform .65s var(--ease);
  transition-delay: var(--d, 0s);
}
.reveal.in { opacity: 1; transform: none; }
.reveal--left  { transform: translateX(-24px); }
.reveal--right { transform: translateX(24px); }
.reveal--pop   { transform: scale(.9); }

@keyframes shPop { 0% { transform: scale(.86); opacity: 0 } 60% { transform: scale(1.03) } 100% { transform: scale(1); opacity: 1 } }
@keyframes shShake {
  0%,100% { transform: translateX(0) }
  15% { transform: translateX(-11px) } 30% { transform: translateX(9px) }
  45% { transform: translateX(-7px) }  60% { transform: translateX(5px) }
  75% { transform: translateX(-3px) }
}
.shake { animation: shShake .5s var(--ease); }

/* luoi o chay nen - hoa tiet rieng cua Sheeto */
.gridbg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.gridbg::before {
  content: ''; position: absolute; inset: -60px;
  background-image:
    linear-gradient(to right, rgba(12,26,21,.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(12,26,21,.055) 1px, transparent 1px);
  background-size: 46px 46px;
  animation: shDrift 26s linear infinite;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 30%, transparent 100%);
          mask-image: radial-gradient(70% 60% at 50% 40%, #000 30%, transparent 100%);
}
@keyframes shDrift { to { transform: translate(46px, 46px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- tinh chinh trai nghiem */
.ms-tbl td { transition: background .12s ease; }
/* Nut phu dung o ca trang gioi thieu, trang bai hoc va trang luyen tap.
   Truoc day chi nam trong lesson.css nen ra trang chu la mat het dinh dang. */
.tool {
  border: 2px solid var(--line-2); background: #fff; border-radius: 11px;
  font-family: var(--fb); font-size: 13px; font-weight: 700; color: var(--ink-2);
  padding: 8px 13px; cursor: pointer; transition: .14s var(--ease);
}
.tool:hover { border-color: var(--muted); background: var(--bg-2); }
.tool.is-down { animation: shPop .3s var(--ease) 2; border-color: var(--amber); }

.tool, .btn, .qopt, .card, .faq details { will-change: auto; }
.ms-wrap { scroll-behavior: smooth; }
.fx-bool { color: #B45309; font-weight: 600; }
.fx-bad  { text-decoration: underline wavy var(--coral); text-underline-offset: 3px; }
