:root {
  --purple: #7357d9;
  --purple-dark: #563cb9;
  --purple-soft: #eee9ff;
  --green: #19a77b;
  --green-dark: #0d8862;
  --green-soft: #e6f8f1;
  --yellow: #ffc94a;
  --orange: #f28c38;
  --red: #e9586f;
  --red-soft: #fff0f2;
  --ink: #27324a;
  --muted: #738097;
  --line: #e5e9f1;
  --surface: #ffffff;
  --bg: #f6f7fb;
  --shadow-sm: 0 3px 12px rgba(38, 43, 78, .06);
  --shadow: 0 12px 35px rgba(52, 45, 99, .10);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: "Nunito", "Avenir Next", "Segoe UI", Arial, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; }
svg { display: block; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* Shared controls */
.btn { min-height: 44px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn-primary { color: #fff; background: var(--purple); box-shadow: 0 5px 0 var(--purple-dark); }
.btn-primary:hover:not(:disabled) { background: #8065e2; box-shadow: 0 7px 0 var(--purple-dark); }
.btn-green { color: #fff; background: var(--green); box-shadow: 0 5px 0 var(--green-dark); }
.btn-green:hover:not(:disabled) { background: #1db689; box-shadow: 0 7px 0 var(--green-dark); }
.btn-yellow { color: #59400d; background: var(--yellow); box-shadow: 0 5px 0 #dca729; }
.btn-secondary { color: var(--purple); background: var(--purple-soft); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover { color: var(--ink); background: #f0f2f7; }
.btn-outline { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.btn-danger { color: #ce3e55; background: var(--red-soft); }
.btn-sm { min-height: 36px; padding: 7px 12px; border-radius: 10px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 14px 25px; border-radius: 14px; font-size: 16px; }
.icon-btn { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; background: #fff; color: var(--muted); border: 1px solid var(--line); border-radius: 11px; }
.icon-btn:hover { color: var(--purple); border-color: #cfc3f4; background: var(--purple-soft); }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field label { font-size: 13px; font-weight: 800; color: #4d5870; }
.field input, .field select, .search-box input { width: 100%; min-height: 47px; border: 1.5px solid #dfe4ed; background: #fff; border-radius: 12px; color: var(--ink); padding: 11px 14px; outline: none; transition: border .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .search-box input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(115, 87, 217, .10); }
.field small { color: var(--muted); font-size: 12px; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 14px; top: 14px; color: #98a2b5; pointer-events: none; }
.input-wrap input { padding-left: 44px; }
.input-action { position: absolute; right: 7px; top: 5px; width: 37px; height: 37px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; border-radius: 9px; }
.input-action:hover { background: #f1f2f7; }
.error-banner { padding: 12px 14px; color: #b83248; background: var(--red-soft); border: 1px solid #ffd6dd; border-radius: 12px; font-size: 13px; font-weight: 700; margin-bottom: 16px; }

/* Login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.08fr) minmax(420px, .92fr); background: #fff; }
.login-showcase { position: relative; overflow: hidden; color: #fff; padding: 45px clamp(40px, 6vw, 90px); background: linear-gradient(145deg, #6750cc 0%, #8064df 55%, #9274e7 100%); display: flex; flex-direction: column; }
.login-showcase::before { content: ''; position: absolute; width: 500px; height: 500px; border: 1px solid rgba(255,255,255,.10); border-radius: 50%; top: 15%; left: -210px; box-shadow: 0 0 0 70px rgba(255,255,255,.035), 0 0 0 140px rgba(255,255,255,.025); }
.login-showcase::after { content: ''; position: absolute; width: 300px; height: 300px; background: rgba(255, 209, 90, .12); transform: rotate(35deg); border-radius: 55px; right: -180px; bottom: -90px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 900; font-size: 24px; letter-spacing: -.6px; position: relative; z-index: 1; }
.brand-mark { width: 43px; height: 43px; border-radius: 13px; display: grid; place-items: center; color: var(--purple); background: #fff; box-shadow: 0 5px 0 rgba(52, 33, 119, .2); }
.brand-mark svg { width: 28px; height: 28px; }
.brand small { display: block; font-size: 9px; letter-spacing: 1.6px; opacity: .72; text-transform: uppercase; line-height: 1; margin-top: 1px; }
.showcase-copy { position: relative; z-index: 2; margin-top: clamp(65px, 11vh, 125px); max-width: 520px; }
.eyebrow-pill { display: inline-flex; gap: 7px; align-items: center; padding: 7px 12px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.10); border-radius: 999px; font-size: 12px; font-weight: 800; }
.showcase-copy h1 { font-size: clamp(37px, 4.2vw, 59px); line-height: 1.07; letter-spacing: -2px; margin: 22px 0 17px; }
.showcase-copy h1 span { color: #ffdc72; }
.showcase-copy p { margin: 0; color: rgba(255,255,255,.80); font-size: 17px; max-width: 430px; }
.showcase-art { position: relative; z-index: 2; margin-top: 36px; display: flex; align-items: flex-end; gap: 24px; }
.robot-wrap { width: 160px; height: 146px; position: relative; flex: 0 0 auto; }
.robot { position: absolute; left: 21px; bottom: 0; width: 118px; height: 103px; background: #fff; border-radius: 24px 24px 30px 30px; box-shadow: 0 10px 0 rgba(47, 29, 112, .15); }
.robot::before { content: ''; position: absolute; width: 4px; height: 29px; background: #fff; top: -25px; left: 57px; }
.robot::after { content: ''; position: absolute; width: 14px; height: 14px; background: #ffdc72; border-radius: 50%; top: -34px; left: 52px; box-shadow: 0 0 0 5px rgba(255,255,255,.18); }
.robot-face { position: absolute; left: 17px; top: 19px; right: 17px; height: 48px; background: #353060; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 24px; }
.robot-face i { width: 10px; height: 15px; border-radius: 50%; background: #91f0cd; }
.robot-smile { position: absolute; width: 20px; height: 8px; border-bottom: 3px solid #91f0cd; border-radius: 50%; bottom: 8px; left: 32px; }
.robot-grid { position: absolute; bottom: 12px; left: 41px; width: 36px; height: 19px; background: repeating-linear-gradient(90deg, transparent 0 10px, #d8d1f5 10px 12px), repeating-linear-gradient(0deg, transparent 0 7px, #d8d1f5 7px 9px); border: 2px solid #d8d1f5; }
.robot-arm { position: absolute; width: 17px; height: 64px; border-radius: 12px; background: #fff; bottom: 5px; }
.robot-arm.left { left: 8px; transform: rotate(16deg); }
.robot-arm.right { right: 7px; transform: rotate(-28deg); bottom: 29px; }
.mini-features { display: grid; gap: 11px; padding-bottom: 10px; }
.mini-feature { display: flex; align-items: center; gap: 10px; font-weight: 700; color: rgba(255,255,255,.90); font-size: 13px; }
.mini-feature b { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #ffdc72; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px clamp(30px, 6vw, 85px); position: relative; }
.login-box { width: 100%; max-width: 420px; }
.mobile-brand { display: none; color: var(--purple); margin-bottom: 45px; }
.mobile-brand .brand-mark { color: #fff; background: var(--purple); }
.login-box h2 { font-size: 31px; line-height: 1.2; letter-spacing: -.8px; margin: 0 0 8px; }
.login-box > p { color: var(--muted); margin: 0 0 30px; }
.role-label { font-size: 12px; font-weight: 800; color: var(--muted); margin: 0 0 8px; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; background: #f2f3f8; padding: 5px; border-radius: 13px; margin-bottom: 24px; }
.role-switch button { min-height: 41px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 7px; }
.role-switch button.active { color: var(--purple); background: #fff; box-shadow: var(--shadow-sm); }
.login-submit { width: 100%; margin-top: 4px; }
.login-foot { text-align: center; font-size: 12px; color: #a1a9b8; margin-top: 25px; }

/* App shell */
.app-shell { min-height: 100vh; }
.app-header { height: 76px; padding: 0 clamp(20px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.app-header .brand { color: var(--ink); font-size: 21px; }
.app-header .brand-mark { width: 38px; height: 38px; color: #fff; background: var(--purple); box-shadow: none; }
.app-header .brand small { color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 13px; }
.header-chip { display: flex; gap: 8px; align-items: center; border-radius: 12px; padding: 7px 12px; background: #fff9e9; color: #8b6411; font-size: 13px; font-weight: 900; }
.header-chip.purple { color: var(--purple); background: var(--purple-soft); }
.user-menu { display: flex; align-items: center; gap: 10px; padding-left: 13px; border-left: 1px solid var(--line); }
.avatar { width: 39px; height: 39px; border-radius: 12px; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); font-weight: 900; text-transform: uppercase; }
.user-meta { line-height: 1.25; }
.user-meta strong { display: block; font-size: 13px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { color: var(--muted); font-size: 11px; }
.page { max-width: 1240px; padding: 32px 30px 60px; margin: 0 auto; }

/* Student dashboard */
.welcome-card { position: relative; overflow: hidden; min-height: 195px; padding: 30px 35px; border-radius: 24px; color: #fff; background: linear-gradient(115deg, #6a4fc9, #8669df); display: flex; align-items: center; justify-content: space-between; box-shadow: 0 12px 30px rgba(100, 76, 192, .18); }
.welcome-card::before { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; right: -55px; top: -100px; border: 45px solid rgba(255,255,255,.06); }
.welcome-card::after { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 35px; left: 48%; bottom: -95px; transform: rotate(35deg); background: rgba(255,255,255,.05); }
.welcome-copy { position: relative; z-index: 2; }
.welcome-copy .overline { color: #ded5ff; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
.welcome-copy h1 { font-size: clamp(26px, 3vw, 35px); letter-spacing: -1px; margin: 7px 0 8px; }
.welcome-copy p { color: rgba(255,255,255,.78); margin: 0; }
.welcome-progress { margin-top: 22px; max-width: 490px; display: flex; align-items: center; gap: 12px; }
.welcome-progress .progress-track { background: rgba(255,255,255,.18); }
.welcome-progress strong { font-size: 12px; white-space: nowrap; }
.welcome-stats { position: relative; z-index: 2; display: flex; gap: 12px; margin-right: 15px; }
.welcome-stat { min-width: 105px; padding: 15px 16px; border-radius: 17px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(6px); text-align: center; }
.welcome-stat b { display: block; font-size: 24px; color: #ffdf7d; line-height: 1.2; }
.welcome-stat span { font-size: 11px; color: rgba(255,255,255,.75); font-weight: 700; }
.progress-track { height: 9px; border-radius: 99px; background: #e9ecf2; overflow: hidden; flex: 1; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--green); transition: width .5s ease; }
.welcome-progress .progress-fill { background: #ffdc72; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 275px; gap: 27px; margin-top: 31px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.5px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.legend span:last-child i { background: #cdd3df; }
.world-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.world-tab { min-width: 0; min-height: 65px; display: flex; align-items: center; gap: 7px; position: relative; padding: 9px; text-align: left; color: var(--muted); background: #fff; border: 1.5px solid var(--line); border-radius: 12px; transition: border .15s, transform .15s, background .15s; }
.world-tab:hover { transform: translateY(-2px); border-color: var(--world-color); }
.world-tab.active { color: var(--world-color); border-color: var(--world-color); background: color-mix(in srgb, var(--world-color) 7%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--world-color) 8%, transparent); }
.world-tab > span:first-child { font-size: 20px; flex: 0 0 auto; }
.world-tab > span:nth-child(2) { min-width: 0; }
.world-tab b { display: block; color: var(--ink); font-size: 10px; line-height: 1.2; }
.world-tab small { display: block; max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; margin-top: 3px; }
.world-tab em { position: absolute; right: 6px; top: 5px; padding: 1px 4px; border-radius: 5px; background: #f0f2f6; color: var(--muted); font-size: 8px; font-style: normal; font-weight: 900; }
.world-tab.active em { color: var(--world-color); background: #fff; }
.world-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 1px 13px; }
.world-heading h3 { margin: 2px 0 0; font-size: 18px; }
.world-heading > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.level-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.level-card { position: relative; border: 1.5px solid var(--line); border-radius: 18px; padding: 18px; background: #fff; text-align: left; min-height: 166px; transition: transform .18s, border-color .18s, box-shadow .18s; overflow: hidden; }
.level-card:not(:disabled):hover { transform: translateY(-4px); border-color: var(--level-color); box-shadow: var(--shadow); }
.level-card.current { border-color: var(--level-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--level-color) 10%, transparent); }
.level-card.locked { background: #fafbfc; }
.level-card.locked .level-icon, .level-card.locked .level-info { opacity: .5; filter: grayscale(1); }
.level-top { display: flex; justify-content: space-between; align-items: flex-start; }
.level-icon { width: 47px; height: 47px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--level-color) 12%, white); font-size: 25px; }
.level-number { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 900; }
.level-state { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; color: #a5aebd; background: #f0f2f6; }
.level-state.done { background: var(--green-soft); color: var(--green); }
.level-state.play { background: var(--level-color); color: #fff; }
.level-info h3 { font-size: 16px; margin: 12px 0 3px; letter-spacing: -.2px; }
.level-info p { font-size: 12px; color: var(--muted); margin: 0; }
.level-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; }
.stars { display: flex; gap: 3px; color: #dfe3ea; font-size: 17px; letter-spacing: -2px; }
.stars .earned { color: #ffc442; }
.level-xp { font-size: 11px; font-weight: 900; color: var(--level-color); }
.current-tag { position: absolute; right: 16px; bottom: 16px; font-size: 10px; padding: 4px 8px; color: var(--level-color); background: color-mix(in srgb, var(--level-color) 10%, white); border-radius: 6px; font-weight: 900; }
.side-stack { display: grid; gap: 17px; align-content: start; }
.side-card { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 20px; }
.side-card h3 { margin: 0 0 15px; font-size: 15px; }
.mission-illustration { height: 100px; display: grid; place-items: center; font-size: 54px; border-radius: 14px; background: linear-gradient(135deg, #f0ebff, #f8f5ff); margin-bottom: 15px; }
.next-mission h3 { font-size: 17px; margin-bottom: 4px; }
.next-mission p { color: var(--muted); font-size: 12px; margin: 0 0 15px; }
.next-mission .btn { width: 100%; }
.achievement { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.achievement:last-child { border: 0; padding-bottom: 0; }
.achievement-icon { width: 38px; height: 38px; border-radius: 11px; background: #fff6dd; display: grid; place-items: center; font-size: 20px; }
.achievement.locked { opacity: .45; filter: grayscale(1); }
.achievement strong { display: block; font-size: 12px; }
.achievement span { font-size: 10px; color: var(--muted); }
.help-card { background: #eef8ff; border-color: #d9effb; }
.help-card h3 { color: #34728e; }
.help-card p { font-size: 12px; color: #638497; margin: 0; }

/* Mission */
.mission-page { max-width: 1180px; }
.breadcrumb { display: flex; align-items: center; gap: 9px; margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.breadcrumb button { border: 0; background: transparent; color: var(--purple); font-weight: 800; padding: 0; }
.mission-heading { display: flex; align-items: center; gap: 17px; margin-bottom: 23px; }
.mission-heading .level-icon { width: 60px; height: 60px; font-size: 31px; border-radius: 18px; }
.mission-heading h1 { margin: 0 0 3px; font-size: 27px; letter-spacing: -.7px; }
.mission-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.mission-heading .xp-pill { margin-left: auto; align-self: flex-start; border-radius: 99px; padding: 7px 12px; background: #fff7df; color: #99701c; font-size: 12px; font-weight: 900; }
.story-card { display: flex; align-items: center; gap: 15px; padding: 16px 20px; border: 1px solid #ddd4fb; background: var(--purple-soft); border-radius: 16px; margin-bottom: 22px; }
.story-robot { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center; background: #fff; border-radius: 12px; font-size: 21px; }
.story-card p { margin: 0; color: #574a81; font-size: 13px; }
.story-card strong { color: var(--purple-dark); }
.mission-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(350px, .9fr); gap: 22px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm); }
.panel-head { min-height: 57px; padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 900; }
.panel-title .icon { color: var(--green); }
.save-status { font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.save-status i { width: 6px; height: 6px; background: var(--green); border-radius: 50%; }
.sheet-wrap { padding: 18px; overflow-x: auto; }
.formula-bar { display: flex; align-items: center; min-width: 350px; height: 37px; border: 1px solid #dce2e9; border-bottom: 0; border-radius: 8px 8px 0 0; overflow: hidden; font-size: 12px; }
.cell-name { width: 55px; height: 100%; display: grid; place-items: center; border-right: 1px solid #dce2e9; font-weight: 800; color: #566175; background: #fafbfc; }
.fx { padding: 0 12px; color: #8b95a5; font-style: italic; font-weight: 900; }
.formula-value { color: #4d586b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.excel-sheet { border-collapse: collapse; table-layout: fixed; min-width: 350px; width: 100%; font-family: Arial, sans-serif; font-size: 12px; }
.excel-sheet th, .excel-sheet td { border: 1px solid #dce2e9; height: 35px; padding: 5px 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.excel-sheet th { height: 27px; background: #f1f3f6; color: #6c7686; text-align: center; font-weight: 500; }
.excel-sheet th.row-head, .excel-sheet td.row-head { width: 31px; min-width: 31px; padding: 0; background: #f1f3f6; color: #6c7686; text-align: center; }
.excel-sheet td:not(.row-head) { cursor: cell; background: #fff; }
.excel-sheet td.header-data { font-weight: 700; background: #f3faf7; }
.excel-sheet td.highlight { background: #fffaea; }
.excel-sheet td.selected { outline: 2px solid var(--green); outline-offset: -2px; }
.excel-sheet td.number { text-align: right; }
.sheet-tabs { display: flex; align-items: center; min-width: 350px; background: #f5f6f8; border: 1px solid #dce2e9; border-top: 0; height: 32px; border-radius: 0 0 8px 8px; }
.sheet-tab { margin-left: 8px; padding: 3px 18px; background: #fff; color: var(--green); border-bottom: 2px solid var(--green); font-size: 11px; }
.sheet-help { margin: 12px 18px 17px; display: flex; gap: 7px; color: var(--muted); font-size: 11px; }
.mission-tip { margin: 0 18px 18px; padding: 12px 13px; background: #f5f7fb; border-radius: 11px; color: #68758c; font-size: 11px; display: flex; gap: 8px; }
.mission-tip b { color: var(--purple); }
.tasks-panel { padding-bottom: 17px; }
.tasks-head-right { color: var(--muted); font-size: 11px; }
.task-list { padding: 5px 18px 0; }
.task { padding: 14px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task label { display: flex; gap: 9px; align-items: flex-start; font-size: 12px; font-weight: 800; margin-bottom: 9px; line-height: 1.45; }
.task-number { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); border-radius: 7px; font-size: 10px; }
.task.correct label { color: var(--green-dark); }
.task.wrong label { color: #c23c52; }
.answer-row { display: flex; gap: 7px; }
.answer-input { min-width: 0; flex: 1; height: 42px; border: 1.5px solid #dfe4ec; border-radius: 10px; padding: 9px 11px; outline: 0; color: var(--ink); font-size: 13px; font-weight: 700; background: #fff; }
.answer-input.formula { font-family: "SFMono-Regular", Consolas, monospace; color: #286d56; }
.answer-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(115, 87, 217, .09); }
.task.correct .answer-input { border-color: #82d3b7; background: #f3fcf8; }
.task.wrong .answer-input { border-color: #ee9caa; background: #fff8f9; }
.hint-btn { width: 36px; height: 42px; border: 0; border-radius: 10px; color: #ad7a13; background: #fff6dc; display: grid; place-items: center; flex: 0 0 auto; }
.hint-btn:hover { background: #ffefbf; }
.task-hint { margin: 8px 0 0; padding: 9px 11px; background: #fff8e7; border-radius: 8px; color: #896924; font-size: 11px; animation: fadeIn .2s; }
.task-feedback { margin: 6px 0 0; font-size: 10px; font-weight: 800; }
.task.correct .task-feedback { color: var(--green); }
.task.wrong .task-feedback { color: var(--red); }
.submit-area { padding: 13px 18px 0; }
.submit-area .btn { width: 100%; }
.submit-note { text-align: center; color: var(--muted); font-size: 10px; margin: 11px 0 0; }

/* Admin */
.admin-shell { background: #f6f7fb; min-height: 100vh; }
.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.admin-sidebar { background: #fff; border-right: 1px solid var(--line); padding: 27px 16px; }
.admin-sidebar-label { padding: 0 12px; color: #a2aabb; font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px; }
.admin-nav { display: grid; gap: 6px; }
.admin-nav button { min-height: 45px; padding: 11px 13px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); display: flex; gap: 11px; align-items: center; font-weight: 800; text-align: left; }
.admin-nav button:hover { background: #f6f4fc; color: var(--purple); }
.admin-nav button.active { background: var(--purple-soft); color: var(--purple); }
.admin-nav button .icon { width: 19px; }
.sidebar-bottom { margin-top: 30px; padding: 17px; border-radius: 14px; background: #f6f4ff; }
.sidebar-bottom b { font-size: 12px; color: var(--purple); }
.sidebar-bottom p { font-size: 10px; color: var(--muted); margin: 5px 0 0; }
.admin-main { padding: 31px clamp(20px, 3vw, 40px) 55px; min-width: 0; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 25px; }
.admin-title h1 { font-size: 26px; margin: 0; letter-spacing: -.6px; }
.admin-title p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stat-icon { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 13px; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); }
.stat-card:nth-child(2) .stat-icon { background: var(--green-soft); color: var(--green); }
.stat-card:nth-child(3) .stat-icon { background: #fff6df; color: #d79921; }
.stat-card:nth-child(4) .stat-icon { background: #eaf4ff; color: #4186d8; }
.stat-copy b { display: block; font-size: 24px; line-height: 1.1; }
.stat-copy span { color: var(--muted); font-size: 11px; font-weight: 700; }
.table-panel { background: #fff; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.table-toolbar h2 { margin: 0; font-size: 16px; }
.search-box { position: relative; width: min(290px, 100%); }
.search-box input { min-height: 39px; padding: 8px 12px 8px 37px; font-size: 12px; }
.search-box .icon { position: absolute; left: 12px; top: 10px; width: 17px; color: #9ca5b4; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 12px 18px; background: #fafbfc; color: #8c96a8; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.data-table td { padding: 14px 18px; border-top: 1px solid #edf0f4; vertical-align: middle; }
.data-table tbody tr:hover { background: #fdfcff; }
.student-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.student-cell .avatar { width: 35px; height: 35px; border-radius: 10px; font-size: 12px; }
.student-cell strong { display: block; font-size: 12px; }
.student-cell span { display: block; color: var(--muted); font-size: 10px; }
.progress-cell { min-width: 135px; }
.progress-cell-top { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 10px; color: var(--muted); }
.progress-cell .progress-track { height: 6px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 5px 8px; background: var(--green-soft); color: var(--green-dark); font-size: 10px; font-weight: 900; white-space: nowrap; }
.status-pill.new { background: #f0f2f6; color: var(--muted); }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.row-actions .icon { width: 15px; height: 15px; }
.empty-state { padding: 45px 20px; text-align: center; color: var(--muted); }
.empty-state b { display: block; font-size: 40px; margin-bottom: 10px; }
.empty-state h3 { color: var(--ink); margin: 0 0 5px; }
.empty-state p { margin: 0; font-size: 12px; }
.answer-toolbar { background: #fff; border: 1px solid var(--line); border-radius: 15px; margin-bottom: 18px; }
.answer-toolbar h2 { font-size: 14px; }
#answer-grid-wrap > .empty-state { background: #fff; border: 1px solid var(--line); border-radius: 17px; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.answer-card { background: #fff; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.answer-card-head { padding: 16px 18px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--level-color) 5%, white); }
.answer-card-head .level-icon { width: 39px; height: 39px; border-radius: 11px; font-size: 21px; }
.answer-card-head h3 { font-size: 14px; margin: 0; }
.answer-card-head span { color: var(--muted); font-size: 10px; }
.answer-list { padding: 9px 18px 14px; }
.answer-item { padding: 10px 0; border-bottom: 1px solid #edf0f4; }
.answer-item:last-child { border: 0; }
.answer-item p { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.answer-key { display: inline-block; padding: 5px 9px; border-radius: 7px; color: #22684f; background: #edf9f4; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; font-weight: 800; }
.activity-list { padding: 5px 20px 15px; }
.activity-item { display: flex; gap: 13px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border: 0; }
.activity-dot { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: var(--green-soft); color: var(--green); }
.activity-dot.fail { background: var(--red-soft); color: var(--red); }
.activity-copy { min-width: 0; flex: 1; }
.activity-copy p { margin: 0; font-size: 12px; }
.activity-copy span { color: var(--muted); font-size: 10px; }
.activity-score { text-align: right; font-size: 11px; font-weight: 900; white-space: nowrap; }
.activity-score small { display: block; color: var(--muted); font-weight: 500; }

/* Modals and feedback */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(28, 31, 48, .52); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; animation: fadeIn .18s; }
.modal { width: min(480px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: #fff; border-radius: 22px; box-shadow: 0 25px 80px rgba(25, 24, 50, .25); animation: popIn .24s ease; }
.modal-lg { width: min(620px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 23px 0; }
.modal-head h2 { font-size: 21px; margin: 0; letter-spacing: -.4px; }
.modal-head p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.modal-close { width: 34px; height: 34px; border: 0; background: #f2f3f7; color: var(--muted); border-radius: 10px; display: grid; place-items: center; }
.modal-body { padding: 22px 23px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 0 23px 23px; }
.danger-copy { padding: 23px; color: var(--muted); font-size: 13px; }
.danger-copy strong { color: var(--ink); }
.success-modal { text-align: center; padding: 32px 28px 27px; overflow: hidden; position: relative; }
.success-badge { width: 83px; height: 83px; display: grid; place-items: center; margin: 0 auto 17px; border-radius: 50%; background: var(--green-soft); font-size: 43px; animation: bounce .7s ease; }
.success-modal h2 { font-size: 27px; letter-spacing: -.7px; margin: 0 0 6px; }
.success-modal > p { color: var(--muted); font-size: 13px; margin: 0 auto 17px; max-width: 360px; }
.reward-stars { display: flex; justify-content: center; gap: 5px; font-size: 36px; color: #e1e5ec; margin: 12px 0; }
.reward-stars .earned { color: #ffc442; animation: starIn .4s backwards; }
.reward-stars .earned:nth-child(2) { animation-delay: .13s; }
.reward-stars .earned:nth-child(3) { animation-delay: .26s; }
.xp-reward { display: inline-flex; gap: 7px; align-items: center; border-radius: 99px; background: #fff6df; color: #9b6b0c; padding: 8px 14px; font-weight: 900; font-size: 13px; }
.success-actions { display: flex; gap: 10px; margin-top: 25px; }
.success-actions .btn { flex: 1; }
.confetti { position: absolute; width: 8px; height: 13px; top: -20px; background: var(--c); left: var(--x); transform: rotate(var(--r)); animation: confettiFall 2.2s var(--d) ease-in forwards; pointer-events: none; }
.detail-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; max-height: 310px; overflow-y: auto; padding-right: 3px; }
.detail-level { padding: 10px 5px; border-radius: 10px; background: #f4f5f8; text-align: center; font-size: 10px; color: var(--muted); }
.detail-level.done { color: var(--green-dark); background: var(--green-soft); }
.detail-level b { display: block; font-size: 16px; }
.attempt-history { border-top: 1px solid var(--line); padding-top: 14px; }
.attempt-history h3 { font-size: 13px; }
.attempt-row { display: flex; justify-content: space-between; font-size: 11px; padding: 7px 0; color: var(--muted); }
.toast-root { position: fixed; z-index: 200; top: 20px; right: 20px; display: grid; gap: 9px; pointer-events: none; }
.toast { max-width: 360px; display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 13px; color: #fff; background: #30394d; box-shadow: 0 10px 30px rgba(20,25,40,.2); font-size: 12px; font-weight: 700; animation: toastIn .25s ease; }
.toast.success { background: var(--green-dark); }
.toast.error { background: #c83e54; }
.loading-screen { min-height: 100vh; display: grid; place-items: center; background: #f7f6fc; }
.loader { text-align: center; color: var(--muted); }
.loader .brand { color: var(--purple); justify-content: center; margin-bottom: 20px; }
.spinner { width: 30px; height: 30px; border: 3px solid #e0daf6; border-top-color: var(--purple); border-radius: 50%; margin: 0 auto 10px; animation: spin .8s linear infinite; }

/* Lesson introduction */
.lesson-page { max-width: 980px; }
.lesson-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.lesson-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 29px 32px 22px; background: linear-gradient(135deg, #f0ebff, #faf8ff); border-bottom: 1px solid #e4ddf8; }
.lesson-label { display: inline-block; margin-bottom: 9px; color: var(--purple); font-size: 10px; font-weight: 900; letter-spacing: .8px; }
.lesson-card-head h1 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.7px; }
.lesson-card-head p { margin: 0; color: var(--muted); font-size: 13px; }
.lesson-level-icon { width: 62px; height: 62px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; background: #fff; box-shadow: var(--shadow-sm); font-size: 33px; }
.lesson-progress-row { display: flex; align-items: center; gap: 12px; padding: 16px 32px 0; color: var(--muted); font-size: 10px; font-weight: 800; }
.lesson-progress-row .progress-track { height: 6px; }
.lesson-dots { display: flex; justify-content: center; gap: 6px; padding-top: 14px; }
.lesson-dots i { width: 7px; height: 7px; border-radius: 99px; background: #dfe3eb; transition: width .2s, background .2s; }
.lesson-dots i.active { width: 24px; background: var(--purple); }
.lesson-dots i.done { background: var(--green); }
.lesson-step { position: relative; padding: 25px 42px 27px; text-align: center; }
.lesson-step-number { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 11px; color: var(--purple); background: var(--purple-soft); font-weight: 900; }
.lesson-step h2 { margin: 0 0 9px; font-size: 23px; letter-spacing: -.4px; }
.lesson-step > p { max-width: 690px; margin: 0 auto 20px; color: #68758b; font-size: 15px; line-height: 1.7; }
.lesson-example { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 9px 13px; border-radius: 10px; background: #f5f3fb; }
.lesson-example span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .8px; }
.lesson-example code { color: var(--purple-dark); font-size: 18px; font-weight: 900; }
.visual-caption { margin-top: 10px; color: var(--muted); font-size: 11px; }
.lesson-grid { width: min(380px, 100%); margin: 15px auto 0; border: 1px solid #cdd5e1; border-radius: 10px; overflow: hidden; background: #fff; }
.lesson-grid-row { display: grid; grid-template-columns: 30px repeat(4, 1fr); }
.lesson-grid-row > b, .lesson-grid-row > span { height: 35px; display: grid; place-items: center; border-right: 1px solid #dce2e9; border-bottom: 1px solid #dce2e9; font-size: 11px; font-weight: 500; }
.lesson-grid-row > *:last-child { border-right: 0; }
.lesson-grid-row:last-child > * { border-bottom: 0; }
.lesson-grid-row > b { background: #f1f3f6; color: var(--muted); }
.lesson-grid-row > span.active { color: #fff; background: var(--green); font-weight: 900; outline: 2px solid var(--green-dark); outline-offset: -2px; }
.lesson-formula-visual { max-width: 650px; margin: 8px auto 0; padding: 24px 20px 16px; border-radius: 15px; background: #26334a; }
.lesson-formula-visual code { color: #a5f3cf; font-size: clamp(17px, 3.2vw, 26px); font-weight: 800; word-break: break-word; }
.lesson-formula-visual .visual-caption { color: #b9c3d4; }
.lesson-flow { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 20px auto 0; }
.lesson-flow span { padding: 11px 14px; border: 1px solid #dcd4f6; border-radius: 10px; color: #594b83; background: #f5f2ff; font-size: 12px; font-weight: 800; }
.lesson-flow i { color: var(--purple); font-style: normal; font-weight: 900; }
.lesson-mini-table { max-width: 520px; margin: 15px auto 0; }
.lesson-mini-table table { width: 100%; border-collapse: collapse; border-radius: 10px; overflow: hidden; font-size: 12px; }
.lesson-mini-table th, .lesson-mini-table td { padding: 10px 13px; border: 1px solid var(--line); text-align: left; }
.lesson-mini-table th { color: var(--purple); background: var(--purple-soft); }
.lesson-note { max-width: 640px; display: flex; align-items: flex-start; gap: 8px; margin: 18px auto 0; padding: 10px 12px; border-radius: 10px; color: #7b6428; background: #fff7e3; text-align: left; font-size: 11px; }
.lesson-note .icon { width: 16px; height: 16px; flex: 0 0 auto; }
.lesson-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 32px 24px; border-top: 1px solid var(--line); }
.lesson-once { color: var(--muted); font-size: 10px; }
/* Admin profile */
.profile-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card { padding: 28px 22px; text-align: center; }
.profile-avatar { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, var(--purple), #9b82e8); font-size: 25px; font-weight: 900; }
.profile-card h2 { margin: 0 0 3px; font-size: 20px; }
.profile-card > p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.profile-security { margin-top: 23px; padding: 14px; border-radius: 12px; background: #f5f3fb; text-align: left; }
.profile-security b { color: var(--purple); font-size: 12px; }
.profile-security p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.form-divider { height: 1px; border: 0; background: var(--line); margin: 22px 0; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(15px); } to { opacity: 1; transform: translateX(0); } }
@keyframes bounce { 0%,100% { transform: scale(1); } 45% { transform: scale(1.13) rotate(-5deg); } }
@keyframes starIn { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes confettiFall { to { transform: translateY(430px) rotate(500deg); opacity: 0; } }

@media (max-width: 1000px) {
  .login-page { grid-template-columns: 1fr 1fr; }
  .login-showcase { padding: 35px; }
  .showcase-copy h1 { font-size: 39px; }
  .showcase-art .mini-features { display: none; }
  .welcome-stats { margin: 0; }
  .welcome-stat { min-width: 85px; padding: 13px 10px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2, 1fr); }
  .help-card { display: none; }
  .mission-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .answer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-page { display: block; }
  .login-showcase { display: none; }
  .login-panel { min-height: 100vh; padding: 35px 24px; }
  .mobile-brand { display: inline-flex; }
  .app-header { height: 66px; padding: 0 16px; }
  .app-header .brand { font-size: 18px; }
  .app-header .brand small { display: none; }
  .app-header .brand-mark { width: 34px; height: 34px; }
  .header-chip { display: none; }
  .user-meta { display: none; }
  .user-menu { border: 0; padding-left: 0; gap: 6px; }
  .page { padding: 22px 16px 45px; }
  .welcome-card { padding: 25px; display: block; }
  .welcome-stats { margin-top: 23px; }
  .welcome-stat { flex: 1; }
  .level-grid { grid-template-columns: 1fr; }
  .world-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .world-tab small { max-width: 120px; }
  .side-stack { grid-template-columns: 1fr; }
  .next-mission { display: none; }
  .legend { display: none; }
  .mission-heading { align-items: flex-start; }
  .mission-heading h1 { font-size: 22px; }
  .mission-heading .xp-pill { display: none; }
  .mission-layout { display: block; }
  .sheet-panel { margin-bottom: 18px; }
  .lesson-card-head { padding: 22px 20px 18px; }
  .lesson-card-head h1 { font-size: 23px; }
  .lesson-level-icon { width: 48px; height: 48px; font-size: 25px; border-radius: 14px; }
  .lesson-progress-row { padding-left: 20px; padding-right: 20px; }
  .lesson-step { padding: 22px 20px; }
  .lesson-step > p { font-size: 14px; }
  .lesson-actions { padding: 16px 20px 20px; align-items: stretch; flex-direction: column; }
  .lesson-actions > div { order: 2; text-align: center; }
  .lesson-actions .btn { width: 100%; }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-card { display: none; }
  .admin-layout { display: block; }
  .admin-sidebar { padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); position: sticky; top: 66px; z-index: 15; }
  .admin-sidebar-label, .sidebar-bottom { display: none; }
  .admin-nav { display: flex; overflow-x: auto; }
  .admin-nav button { white-space: nowrap; min-height: 39px; padding: 8px 12px; font-size: 12px; }
  .admin-main { padding: 23px 15px 40px; }
  .admin-title { align-items: flex-start; }
  .admin-title h1 { font-size: 22px; }
  .admin-title .btn { padding: 9px 12px; font-size: 12px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 13px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-copy b { font-size: 20px; }
  .table-toolbar { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .answer-grid { gap: 12px; }
  .success-actions { flex-direction: column-reverse; }
  .modal-backdrop { padding: 12px; }
  .toast-root { left: 15px; right: 15px; top: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { display: block; }
  .stat-icon { margin-bottom: 9px; }
  .welcome-card { padding: 22px; }
  .welcome-copy h1 { font-size: 25px; }
  .welcome-stats { gap: 7px; }
  .welcome-stat b { font-size: 20px; }
  .welcome-stat span { font-size: 9px; }
}
