/* ==========================================================================
   Deep Cosmos UI — ธีมอวกาศลึกสำหรับ Astronomy LMS
   ========================================================================== */
:root {
  --bg0: #0B0F19;
  --bg1: #111827;
  --bg2: #1a2235;
  --card: rgba(17, 24, 39, 0.62);
  --card-strong: rgba(17, 24, 39, 0.86);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --nebula: #38BDF8;
  --galaxy: #818CF8;
  --gold: #FBBF24;
  --text: #E5E7EB;
  --text-dim: #CBD5E1;
  --muted: #94A3B8;
  --ok: #34D399;
  --late: #FBBF24;
  --todo: #94A3B8;
  --over: #F87171;
  --review: #C4B5FD;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: 'IBM Plex Sans Thai', 'Sarabun', system-ui, sans-serif;
  --font-head: 'Chakra Petch', 'IBM Plex Sans Thai', sans-serif;
  --header-h: 64px;
  --tabbar-h: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg0);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- พื้นหลังละอองดาว + เนบิวลาจาง ๆ ---------- */
.cosmos-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 45% at 85% 5%, rgba(129, 140, 248, 0.16), transparent 70%),
    radial-gradient(ellipse 55% 40% at 0% 100%, rgba(56, 189, 248, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
}
.cosmos-bg::before, .cosmos-bg::after {
  content: ''; position: absolute; inset: 0;
  background-repeat: repeat;
}
.cosmos-bg::before {
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.55), transparent),
    radial-gradient(1px 1px at 140px 80px, rgba(255,255,255,.35), transparent),
    radial-gradient(1.4px 1.4px at 90px 160px, rgba(186,230,253,.6), transparent),
    radial-gradient(1px 1px at 230px 210px, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 300px 40px, rgba(199,210,254,.45), transparent);
  background-size: 340px 260px;
  opacity: .55;
}
.cosmos-bg::after {
  background-image:
    radial-gradient(1.6px 1.6px at 60px 120px, rgba(251,191,36,.55), transparent),
    radial-gradient(1.2px 1.2px at 400px 300px, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 250px 420px, rgba(186,230,253,.5), transparent);
  background-size: 520px 480px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .25; } to { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .cosmos-bg::after { animation: none; } }

/* ---------- ตัวอักษร ---------- */
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; margin: 0 0 .4em; letter-spacing: .01em; line-height: 1.3; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--nebula); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.mono { font-family: 'Chakra Petch', ui-monospace, monospace; letter-spacing: .06em; }
.icon { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.2em; }
.icon-lg { width: 28px; height: 28px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(11, 15, 25, 0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #7dd3fc, #4f46e5 70%);
  box-shadow: 0 0 18px rgba(56,189,248,.45);
  color: #fff;
}
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-desktop { display: flex; gap: 4px; margin-left: auto; }
.nav-desktop a {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  color: var(--text-dim); font-size: .95rem; transition: background .2s, color .2s;
}
.nav-desktop a:hover { background: rgba(148,163,184,.1); color: var(--text); }
.nav-desktop a.active { background: rgba(56,189,248,.14); color: var(--nebula); }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px;
  background: rgba(129,140,248,.12); border: 1px solid rgba(129,140,248,.3); font-size: .85rem;
  white-space: nowrap;
}
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--galaxy), var(--nebula)); color: #0B0F19; font-weight: 700;
}

/* ---------- Tab bar (มือถือ) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: none; grid-template-columns: repeat(5, 1fr);
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a.active { color: var(--nebula); }
.tabbar a.active .icon { filter: drop-shadow(0 0 6px rgba(56,189,248,.7)); }

/* ---------- Layout ---------- */
.view { max-width: 1120px; margin: 0 auto; padding: 24px 20px 48px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.spacer { flex: 1; }

/* ---------- การ์ด Glassmorphism ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.card-glow { position: relative; overflow: hidden; }
.card-glow::before {
  content: ''; position: absolute; width: 260px; height: 260px; right: -80px; top: -120px;
  background: radial-gradient(circle, rgba(129,140,248,.28), transparent 65%); pointer-events: none;
}
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }
.eyebrow { font-family: var(--font-head); font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--nebula); }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: rgba(148,163,184,.08); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; transition: transform .1s, background .2s, border-color .2s, box-shadow .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: rgba(148,163,184,.16); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #38BDF8, #818CF8); border: none; color: #0B0F19; font-weight: 600;
  box-shadow: 0 6px 24px rgba(56,189,248,.28);
}
.btn-primary:hover { background: linear-gradient(135deg, #7dd3fc, #a5b4fc); box-shadow: 0 6px 28px rgba(56,189,248,.45); }
.btn-gold { background: linear-gradient(135deg, #FBBF24, #f59e0b); color: #1f1300; border: none; font-weight: 600; }
.btn-danger { border-color: rgba(248,113,113,.5); color: #fecaca; background: rgba(248,113,113,.1); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- ฟอร์ม ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .88rem; color: var(--text-dim); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  background: rgba(11,15,25,.6); border: 1px solid var(--line-strong); color: var(--text);
  font: inherit; outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--nebula); box-shadow: 0 0 0 3px rgba(56,189,248,.2); }
.input-xl { font-size: 1.4rem; text-align: center; letter-spacing: .12em; font-family: var(--font-head); }

/* ---------- ชิปสถานะ ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 500; border: 1px solid; white-space: nowrap;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.chip.done { color: var(--ok); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.chip.late { color: var(--late); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.08); }
.chip.todo { color: var(--todo); border-color: rgba(148,163,184,.3); background: rgba(148,163,184,.06); }
.chip.overdue { color: var(--over); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
.chip.review { color: var(--review); border-color: rgba(196,181,253,.35); background: rgba(196,181,253,.08); }
.chip.plain::before { display: none; }
.badge-req { font-size: .7rem; padding: 1px 8px; border-radius: 6px; background: rgba(248,113,113,.14); color: #fca5a5; border: 1px solid rgba(248,113,113,.3); }

/* ---------- Mission Progress ---------- */
.mission { padding: 4px 0 2px; }
.mission-track {
  position: relative; height: 12px; border-radius: 999px; margin: 26px 6px 10px;
  background: repeating-linear-gradient(90deg, rgba(148,163,184,.14) 0 6px, transparent 6px 12px);
  border: 1px solid var(--line);
}
.mission-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 999px;
  background: linear-gradient(90deg, rgba(56,189,248,.4), var(--nebula) 60%, var(--galaxy));
  box-shadow: 0 0 14px rgba(56,189,248,.55);
  transition: width .9s cubic-bezier(.2,.8,.2,1);
}
.mission-rocket {
  position: absolute; top: 50%; transform: translate(-50%, -50%) rotate(45deg);
  width: 30px; height: 30px; color: var(--gold); filter: drop-shadow(0 0 8px rgba(251,191,36,.7));
  transition: left .9s cubic-bezier(.2,.8,.2,1);
}
.mission-goal { position: absolute; right: -6px; top: 50%; transform: translate(50%, -50%); width: 26px; height: 26px; color: var(--galaxy); }
.mission-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.mission-legend b { color: var(--text); }

/* ---------- ไทล์เมนู ---------- */
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.tile:hover { transform: translateY(-2px); border-color: rgba(56,189,248,.4); box-shadow: 0 10px 30px rgba(56,189,248,.12); }
.tile-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; }
.tile-icon .icon { width: 26px; height: 26px; }
.ti-blue { background: rgba(56,189,248,.14); color: var(--nebula); }
.ti-purple { background: rgba(129,140,248,.16); color: var(--galaxy); }
.ti-gold { background: rgba(251,191,36,.14); color: var(--gold); }
.ti-green { background: rgba(52,211,153,.14); color: var(--ok); }
.tile b { font-family: var(--font-head); font-size: 1.02rem; }
.tile small { color: var(--muted); }

/* ---------- รายการงาน ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 14px 16px; border-radius: 14px; background: rgba(17,24,39,.55); border: 1px solid var(--line);
  border-left: 4px solid var(--todo);
}
.task.done { border-left-color: var(--ok); }
.task.late { border-left-color: var(--late); }
.task.overdue { border-left-color: var(--over); }
.task-icon { color: var(--muted); }
.task.done .task-icon { color: var(--ok); }
.task.late .task-icon { color: var(--late); }
.task.overdue .task-icon { color: var(--over); }
.task-title { font-weight: 500; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .82rem; color: var(--muted); margin-top: 2px; align-items: center; }
.lesson-head { font-family: var(--font-head); color: var(--galaxy); font-size: .95rem; margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text-dim); font: inherit; font-size: .88rem; cursor: pointer; }
.filter-btn.active { background: rgba(56,189,248,.14); border-color: rgba(56,189,248,.5); color: var(--nebula); }

/* ---------- เช็คอิน ---------- */
.code-boxes { display: flex; gap: 10px; justify-content: center; margin: 22px 0; }
.code-boxes input {
  width: 54px; height: 66px; text-align: center; font-size: 1.8rem; font-family: var(--font-head); font-weight: 700;
  border-radius: 14px; background: rgba(11,15,25,.7); border: 1.5px solid var(--line-strong); color: var(--gold);
  text-transform: uppercase; outline: none; caret-color: var(--nebula);
}
.code-boxes input:focus { border-color: var(--nebula); box-shadow: 0 0 0 4px rgba(56,189,248,.2); }
.success-orb {
  width: 110px; height: 110px; border-radius: 50%; margin: 8px auto 16px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, rgba(52,211,153,.5), rgba(52,211,153,.08) 70%);
  box-shadow: 0 0 50px rgba(52,211,153,.35); color: var(--ok); animation: pop .5s cubic-bezier(.2,1.6,.4,1);
}
.success-orb .icon { width: 54px; height: 54px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- ผลการเรียน ---------- */
.grade-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; }
.grade-ring {
  --p: 0; width: 220px; height: 220px; border-radius: 50%; margin: 0 auto; position: relative;
  background: conic-gradient(var(--nebula) calc(var(--p) * 1%), var(--galaxy) calc(var(--p) * 1%), rgba(148,163,184,.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%); mask: radial-gradient(circle, transparent 62%, #000 63%);
}
.grade-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.grade-box { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.grade-value { font-family: var(--font-head); font-size: 4.2rem; font-weight: 700; line-height: 1; background: linear-gradient(135deg, #fde68a, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grade-value.r { background: linear-gradient(135deg, #fecaca, var(--over)); -webkit-background-clip: text; background-clip: text; }
.score-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.score-table th, .score-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.score-table th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.score-table td.num, .score-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.score-table tfoot td { font-weight: 600; color: var(--gold); border-bottom: none; }
.alert {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; font-size: .93rem;
  background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35); color: #fecaca;
}
.alert.info { background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.3); color: #bae6fd; }
.alert.warn { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.3); color: #fde68a; }

/* ---------- Worksheet Shell (Sidebar + Accordion) ---------- */
.ws-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.ws-sidebar {
  position: sticky; top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px); overflow: auto;
  padding: 14px; border-radius: var(--radius); background: var(--card-strong); border: 1px solid var(--line);
}
.ws-sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 6px 12px; }
.acc { border-radius: 12px; margin-bottom: 6px; }
.acc-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 10px; border: none; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; font-family: var(--font-head); font-size: .95rem; text-align: left; cursor: pointer;
}
.acc-btn:hover { background: rgba(148,163,184,.08); }
.acc-btn .chev { margin-left: auto; transition: transform .2s; color: var(--muted); }
.acc.open .acc-btn .chev { transform: rotate(90deg); }
.acc-count { font-size: .72rem; color: var(--muted); font-family: var(--font); }
.acc-body { display: none; padding: 2px 0 6px 6px; }
.acc.open .acc-body { display: block; }
.ws-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-dim); font-size: .9rem;
  border: 1px solid transparent;
}
.ws-link:hover { background: rgba(148,163,184,.08); color: var(--text); }
.ws-link.active { background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.35); color: var(--text); }
.ws-link .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--todo); }
.ws-link .dot.done { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.ws-link .dot.late { background: var(--late); box-shadow: 0 0 8px var(--late); }
.ws-link .dot.overdue { background: var(--over); box-shadow: 0 0 8px var(--over); }
.ws-main { min-width: 0; }
.ws-head { margin-bottom: 14px; }
.ws-frame-wrap { position: relative; border-radius: var(--radius); background: rgba(11,15,25,.45); border: 1px solid var(--line); overflow: hidden; }
.ws-frame { display: block; width: 100%; min-height: 480px; border: 0; background: transparent; }
.ws-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11,15,25,.7); }
.ws-toolbar {
  position: sticky; bottom: 12px; z-index: 5; margin-top: 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 16px; background: rgba(17,24,39,.92); border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.ws-toolbar .draft-note { font-size: .8rem; color: var(--muted); }
.ws-toggle { display: none; }
.ws-overlay { display: none; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .icon { width: 60px; height: 60px; color: var(--galaxy); opacity: .8; margin-bottom: 10px; }

/* ---------- Modal / Toast / Splash ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(3,6,12,.7); backdrop-filter: blur(4px); animation: fade .2s;
}
.modal { width: min(460px, 100%); max-height: 86vh; overflow: auto; background: var(--bg1); border: 1px solid var(--line-strong); border-radius: 20px; padding: 24px; box-shadow: 0 20px 70px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 24px); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: .92rem; animation: rise .25s; max-width: 90vw; }
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(248,113,113,.6); color: #fecaca; }
.splash { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.orbit { width: 84px; height: 84px; position: relative; margin: 0 auto 18px; }
.orbit::before { content: ''; position: absolute; inset: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b); box-shadow: 0 0 30px rgba(251,191,36,.6); }
.orbit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px dashed rgba(56,189,248,.4); }
.orbit i { position: absolute; inset: 0; animation: spin 1.6s linear infinite; }
.orbit i::before { content: ''; position: absolute; top: -5px; left: 50%; width: 11px; height: 11px; margin-left: -5px; border-radius: 50%; background: var(--nebula); box-shadow: 0 0 12px var(--nebula); }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(148,163,184,.3); border-top-color: var(--nebula); animation: spin .8s linear infinite; }
.mock-banner { position: fixed; top: var(--header-h); right: 12px; z-index: 50; padding: 2px 12px; border-radius: 0 0 10px 10px; background: var(--gold); color: #1f1300; font-size: .72rem; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-layout { grid-template-columns: 1fr; }
  .ws-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(320px, 86vw);
    max-height: none; border-radius: 0 20px 20px 0; transform: translateX(-105%); transition: transform .28s ease;
    padding-top: 18px;
  }
  .ws-sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.6); }
  .ws-overlay.open { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3,6,12,.6); }
  .ws-toggle { display: inline-flex; }
  .grade-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  :root { --header-h: 58px; }
  body { font-size: 15.5px; }
  .nav-desktop { display: none; }
  .tabbar { display: grid; }
  .view { padding: 16px 14px calc(var(--tabbar-h) + 30px); }
  .app-header { padding: 0 14px; }
  .user-chip .name { display: none; }
  .brand-sub { max-width: 52vw; }
  .user-chip { margin-left: auto; padding-right: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 16px; }
  .ws-toolbar { bottom: calc(var(--tabbar-h) + 10px); }
  .code-boxes input { width: 48px; height: 60px; font-size: 1.6rem; }
  .task { grid-template-columns: auto 1fr; }
  .task > .task-action { grid-column: 1 / -1; }
  .task > .task-action .btn { width: 100%; }
  h1 { font-size: 1.35rem; }
}
