/* Device modes ---------------------------------------------------------- */
.device-mode-control{display:flex;align-items:center;gap:2px;padding:3px;border:1px solid #dce4df;border-radius:12px;background:#f5f8f6}
.device-mode-control button{border:0;background:transparent;color:#617068;border-radius:9px;padding:7px 9px;font:inherit;font-size:12px;font-weight:700;cursor:pointer;white-space:nowrap}
.device-mode-control button.active{background:#fff;color:#0d6240;box-shadow:0 1px 4px rgba(13,61,42,.12)}
.device-mode-control.compact button{padding:5px 7px;font-size:11px}
.desktop-mode-area{display:flex;align-items:center;gap:8px;margin-left:auto}
.device-mode-badge{font-size:11px;font-weight:800;letter-spacing:.04em;text-transform:uppercase;color:#0d6240;background:#eaf5ef;border:1px solid #d8ebe1;padding:6px 9px;border-radius:999px}

html[data-device-mode="laptop"] .mobile-nav,
html[data-device-mode="tablet"] .mobile-nav{display:none!important}
html[data-device-mode="laptop"] .topbar .nav,
html[data-device-mode="tablet"] .topbar .nav{display:flex!important}

html[data-device-mode="tablet"] .topbar-inner{padding-left:18px;padding-right:18px;gap:16px}
html[data-device-mode="tablet"] .topbar .nav{gap:2px}
html[data-device-mode="tablet"] .topbar .nav button{padding-left:10px;padding-right:10px}
html[data-device-mode="tablet"] .main{padding-left:22px;padding-right:22px}

/* Dedicated mobile shell ----------------------------------------------- */
html[data-device-mode="mobile"] body{background:#f4f7f5;color:#12241c;overflow-x:hidden}
html[data-device-mode="mobile"] .topbar,
html[data-device-mode="mobile"] .mobile-nav{display:none!important}
.mobile-app-shell{min-height:100dvh;padding:0 0 calc(76px + env(safe-area-inset-bottom));background:#f4f7f5}
.mobile-appbar{position:sticky;top:0;z-index:45;min-height:66px;padding:10px 16px;display:flex;align-items:center;justify-content:space-between;gap:12px;background:rgba(255,255,255,.96);backdrop-filter:blur(16px);border-bottom:1px solid #dfe7e2;padding-top:max(10px,env(safe-area-inset-top))}
.mobile-appbar-brand{display:flex;align-items:center;gap:10px;min-width:0}
.mobile-appbar-brand .brand-mark{width:42px;height:42px;border-radius:13px;font-size:20px;flex:0 0 auto}
.mobile-appbar-brand>div:last-child{display:flex;flex-direction:column;min-width:0}
.mobile-appbar-brand strong{font-size:17px;line-height:1.1;white-space:nowrap}
.mobile-appbar-brand small{margin-top:3px;color:#65746d;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}
.mobile-appbar-actions{display:flex;align-items:center;gap:7px}
.mobile-mode-pill{font-size:10px;font-weight:900;text-transform:uppercase;letter-spacing:.07em;color:#0d6844;background:#e9f5ef;border-radius:999px;padding:6px 8px}
.mobile-avatar-btn{width:40px;height:40px;border:0;border-radius:50%;background:#dff1e7;color:#0b6843;font-weight:900;font-size:13px;cursor:pointer}
.mobile-main{padding:18px 14px 22px!important;max-width:none!important;width:100%!important;margin:0!important;box-sizing:border-box}
.mobile-main>*:first-child{margin-top:0}

.mobile-bottom-nav{position:fixed;z-index:50;left:10px;right:10px;bottom:max(8px,env(safe-area-inset-bottom));height:64px;display:grid;grid-template-columns:repeat(4,1fr);align-items:stretch;padding:5px;background:rgba(255,255,255,.97);border:1px solid #dbe5df;border-radius:20px;box-shadow:0 14px 36px rgba(15,52,37,.18);backdrop-filter:blur(18px)}
.mobile-tab{border:0;background:transparent;border-radius:15px;color:#68776f;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font:inherit;font-size:10px;font-weight:700;cursor:pointer;padding:4px 1px;min-width:0}
.mobile-tab-icon{font-size:20px;line-height:1;height:23px;display:flex;align-items:center;justify-content:center}
.mobile-tab.active{background:#eaf5ef;color:#0b6843}
.mobile-tab.active .mobile-tab-icon{transform:translateY(-1px)}

.mobile-more-drawer{position:fixed;inset:0;z-index:80;pointer-events:none;visibility:hidden}
.mobile-more-drawer.open{visibility:visible;pointer-events:auto}
.mobile-drawer-scrim{position:absolute;inset:0;border:0;background:rgba(8,25,18,.42);opacity:0;transition:opacity .2s}
.mobile-more-drawer.open .mobile-drawer-scrim{opacity:1}
.mobile-drawer-sheet{position:absolute;left:0;right:0;bottom:0;max-height:83dvh;overflow:auto;background:#fff;border-radius:26px 26px 0 0;padding:8px 18px calc(20px + env(safe-area-inset-bottom));box-shadow:0 -16px 48px rgba(7,35,24,.22);transform:translateY(104%);transition:transform .24s ease}
.mobile-more-drawer.open .mobile-drawer-sheet{transform:translateY(0)}
.mobile-drawer-handle{width:42px;height:4px;border-radius:999px;background:#d6dfda;margin:2px auto 17px}
.mobile-drawer-profile{display:flex;align-items:center;gap:12px;padding:0 2px 16px;border-bottom:1px solid #e6ece8}
.mobile-drawer-avatar{width:48px;height:48px;display:grid;place-items:center;border-radius:15px;background:#dff1e7;color:#0b6843;font-weight:900}
.mobile-drawer-profile>div:last-child{display:flex;flex-direction:column;gap:3px}
.mobile-drawer-profile strong{font-size:17px}.mobile-drawer-profile small{color:#718078}
.mobile-drawer-links{display:grid;grid-template-columns:1fr 1fr;gap:9px;padding:16px 0}
.mobile-drawer-links button{min-height:50px;border:1px solid #e0e7e3;background:#f8faf9;border-radius:14px;display:flex;align-items:center;gap:9px;padding:10px 12px;color:#1b2d25;font:inherit;font-weight:750;text-align:left;cursor:pointer}
.mobile-drawer-links button span{color:#0c6a44;font-size:18px}
.mobile-display-card{background:#f4f8f5;border:1px solid #e1e9e4;border-radius:17px;padding:14px}
.mobile-display-card p{font-size:12px;line-height:1.45;color:#6d7a73;margin:6px 0 12px}
.mobile-display-card .device-mode-control{display:grid;grid-template-columns:repeat(2,1fr);gap:5px}
.mobile-display-card .device-mode-control button{padding:9px 6px}
.mobile-logout-btn{width:100%;margin-top:12px;min-height:48px}
body.mobile-drawer-open{overflow:hidden}

/* Mobile information hierarchy ---------------------------------------- */
html[data-device-mode="mobile"] h1{font-size:30px;line-height:1.08;letter-spacing:-.025em}
html[data-device-mode="mobile"] h2{font-size:21px;line-height:1.15}
html[data-device-mode="mobile"] h3{font-size:17px}
html[data-device-mode="mobile"] .eyebrow{font-size:10px;letter-spacing:.12em}
html[data-device-mode="mobile"] .page-head{display:block;margin:2px 0 18px;padding:0}
html[data-device-mode="mobile"] .page-head h1{margin-top:6px}
html[data-device-mode="mobile"] .page-head p{font-size:14px;line-height:1.5;margin-top:7px;color:#6a7971}
html[data-device-mode="mobile"] .page-head>.actions{margin-top:12px;display:flex;flex-wrap:wrap;gap:8px}
html[data-device-mode="mobile"] .section{margin-top:16px}
html[data-device-mode="mobile"] .panel{border-radius:18px;padding:17px;border-color:#dfe7e2;box-shadow:0 2px 8px rgba(20,55,40,.03)}
html[data-device-mode="mobile"] .grid.two,
html[data-device-mode="mobile"] .grid.three,
html[data-device-mode="mobile"] .form-grid{grid-template-columns:1fr!important;gap:12px}
html[data-device-mode="mobile"] .kpi-strip{display:grid!important;grid-template-columns:1fr 1fr!important;gap:10px!important}
html[data-device-mode="mobile"] .metric{min-height:105px;padding:14px!important;border-radius:17px!important}
html[data-device-mode="mobile"] .metric strong{font-size:28px!important}
html[data-device-mode="mobile"] .metric span{font-size:12px!important}
html[data-device-mode="mobile"] .section-head{align-items:flex-start;gap:10px}
html[data-device-mode="mobile"] .section-head .actions{flex-wrap:wrap;justify-content:flex-end}
html[data-device-mode="mobile"] .btn{min-height:44px;border-radius:12px;padding:10px 14px}
html[data-device-mode="mobile"] .btn.small{min-height:38px;padding:8px 11px}
html[data-device-mode="mobile"] input,
html[data-device-mode="mobile"] select,
html[data-device-mode="mobile"] textarea{font-size:16px!important;min-height:46px;border-radius:12px}
html[data-device-mode="mobile"] textarea{min-height:110px}

/* Turn desktop tables into touch-friendly scroll cards instead of miniatures. */
html[data-device-mode="mobile"] .table-wrap{margin-left:-5px;margin-right:-5px;overflow-x:auto;padding:0 5px 8px;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch}
html[data-device-mode="mobile"] .data-table{min-width:760px;font-size:13px}
html[data-device-mode="mobile"] .data-table th{font-size:10px;white-space:nowrap}
html[data-device-mode="mobile"] .data-table td{padding-top:13px;padding-bottom:13px}
html[data-device-mode="mobile"] .row{display:grid;grid-template-columns:minmax(0,1fr) auto!important;gap:8px 12px;padding:13px 0;align-items:center}
html[data-device-mode="mobile"] .row>*:nth-child(n+3):not(button):not(.status){grid-column:1/-1}

/* Existing custom student pages: purpose-built mobile composition. */
html[data-device-mode="mobile"] .student-home-hero,
html[data-device-mode="mobile"] .student-attempts-hero,
html[data-device-mode="mobile"] .student-subjects-hero,
html[data-device-mode="mobile"] .student-subject-hero{grid-template-columns:1fr!important;display:grid!important;gap:14px!important;border-radius:20px!important;padding:19px!important}
html[data-device-mode="mobile"] .student-home-hero h1,
html[data-device-mode="mobile"] .student-attempts-hero h1,
html[data-device-mode="mobile"] .student-subjects-hero h1,
html[data-device-mode="mobile"] .student-subject-hero h1{font-size:29px!important}
html[data-device-mode="mobile"] .student-home-quote,
html[data-device-mode="mobile"] .student-attempts-quote,
html[data-device-mode="mobile"] .student-subject-hero-note{display:none!important}
html[data-device-mode="mobile"] .student-home-kpis,
html[data-device-mode="mobile"] .student-attempts-kpis,
html[data-device-mode="mobile"] .student-subjects-kpis{display:flex!important;overflow-x:auto;gap:10px;padding:2px 1px 7px;scroll-snap-type:x mandatory}
html[data-device-mode="mobile"] .student-home-kpi,
html[data-device-mode="mobile"] .student-attempts-kpi,
html[data-device-mode="mobile"] .student-subjects-kpis>div{min-width:190px;scroll-snap-align:start;border-radius:17px!important}
html[data-device-mode="mobile"] .student-home-layout,
html[data-device-mode="mobile"] .student-attempts-layout,
html[data-device-mode="mobile"] .student-subject-top-grid{display:grid!important;grid-template-columns:1fr!important;gap:14px!important}
html[data-device-mode="mobile"] .student-home-sidebar,
html[data-device-mode="mobile"] .student-attempts-sidebar{display:grid!important;grid-template-columns:1fr!important;gap:12px!important}
html[data-device-mode="mobile"] .student-subjects-grid{grid-template-columns:1fr!important}
html[data-device-mode="mobile"] .student-subjects-card{border-radius:18px!important}
html[data-device-mode="mobile"] .student-subjects-metrics{grid-template-columns:repeat(3,1fr)!important;gap:6px!important}
html[data-device-mode="mobile"] .student-subjects-metrics strong{font-size:20px!important}
html[data-device-mode="mobile"] .student-subjects-metrics span{font-size:10px!important}
html[data-device-mode="mobile"] .student-subjects-card-foot{align-items:stretch!important;flex-direction:column!important;gap:10px!important}
html[data-device-mode="mobile"] .student-subjects-card-foot .btn{width:100%}
html[data-device-mode="mobile"] .student-subject-hero-kpis{display:grid!important;grid-template-columns:repeat(3,1fr)!important;gap:6px!important}
html[data-device-mode="mobile"] .student-subject-hero-kpis>div{padding:10px 6px!important}
html[data-device-mode="mobile"] .student-subject-assessment-card{border-radius:16px!important;padding:15px!important}
html[data-device-mode="mobile"] .student-subject-assessment-main{align-items:flex-start!important;gap:8px!important}
html[data-device-mode="mobile"] .student-subject-assessment-meta{display:grid!important;grid-template-columns:1fr 1fr;gap:7px!important;font-size:11px!important}
html[data-device-mode="mobile"] .student-subject-assessment-actions .btn{width:100%}

/* Attempts: desktop table becomes stacked attempt cards. */
html[data-device-mode="mobile"] .student-attempts-toolbar-head{display:block!important}
html[data-device-mode="mobile"] .student-attempts-controls{display:grid!important;grid-template-columns:1fr!important;margin-top:14px;gap:8px!important}
html[data-device-mode="mobile"] .student-attempts-head{display:none!important}
html[data-device-mode="mobile"] .student-attempts-row{display:grid!important;grid-template-columns:36px minmax(0,1fr) auto!important;gap:9px 10px!important;padding:15px 2px!important;border-bottom:1px solid #e4ebe7;align-items:start!important}
html[data-device-mode="mobile"] .student-attempts-row>span:nth-child(3){grid-column:2/4}
html[data-device-mode="mobile"] .student-attempts-row>span:nth-child(4){grid-column:2}
html[data-device-mode="mobile"] .student-attempts-row>span:nth-child(5){grid-column:3;grid-row:3}
html[data-device-mode="mobile"] .student-attempts-row>span:nth-child(6){grid-column:2;grid-row:4;justify-self:start}
html[data-device-mode="mobile"] .student-attempts-row>span:nth-child(7){grid-column:3;grid-row:4}
html[data-device-mode="mobile"] .student-attempts-row .btn{min-height:36px}

/* Assessment taking: one focused question at a time on mobile. */
html[data-device-mode="mobile"] .assessment-exam-top{position:sticky!important;top:0!important}
html[data-device-mode="mobile"] .exam-top-inner{padding:9px 12px!important;gap:8px!important}
html[data-device-mode="mobile"] .assessment-exam-title .brand-mark{display:none!important}
html[data-device-mode="mobile"] .assessment-exam-title strong{font-size:12px!important;max-width:150px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
html[data-device-mode="mobile"] .assessment-exam-title span{display:none!important}
html[data-device-mode="mobile"] .assessment-timer-box{padding:7px 9px!important}
html[data-device-mode="mobile"] .assessment-timer-box span{font-size:9px!important}
html[data-device-mode="mobile"] .assessment-timer-box strong{font-size:11px!important}
html[data-device-mode="mobile"] .assessment-exam-main{padding:12px!important}
html[data-device-mode="mobile"] .assessment-question-layout{display:block!important}
html[data-device-mode="mobile"] .assessment-question-stage{min-width:0}
html[data-device-mode="mobile"] .assessment-question-card{padding:17px!important;border-radius:18px!important}
html[data-device-mode="mobile"] .assessment-question-meta{display:flex!important;flex-wrap:wrap!important;gap:6px!important}
html[data-device-mode="mobile"] .assessment-question-text{font-size:16px!important;line-height:1.6!important}
html[data-device-mode="mobile"] .assessment-options{gap:9px!important}
html[data-device-mode="mobile"] .assessment-options .option{min-height:54px!important;padding:12px!important;text-align:left}
html[data-device-mode="mobile"] .assessment-question-nav{display:none!important}
html[data-device-mode="mobile"] .assessment-bottom-actions{position:sticky;bottom:76px;z-index:8;background:rgba(244,247,245,.96);padding:10px 0 4px;margin-top:14px!important;display:grid!important;grid-template-columns:1fr 1fr;gap:8px}
html[data-device-mode="mobile"] .assessment-bottom-actions .btn{width:100%}
html[data-device-mode="mobile"] .assessment-start-modal,
html[data-device-mode="mobile"] .assessment-review-modal{width:calc(100vw - 20px)!important;max-height:88dvh!important;border-radius:22px!important;padding:18px!important;overflow:auto}
html[data-device-mode="mobile"] .assessment-start-stats,
html[data-device-mode="mobile"] .assessment-review-stats{grid-template-columns:repeat(2,1fr)!important}

/* Result/detail pages */
html[data-device-mode="mobile"] .assessment-result-hero{display:grid!important;grid-template-columns:auto 1fr!important;gap:12px!important}
html[data-device-mode="mobile"] .assessment-result-score{grid-column:1/-1!important;text-align:left!important;margin-top:5px}
html[data-device-mode="mobile"] .stored-question{padding:14px 0!important}
html[data-device-mode="mobile"] .answer-review{border-radius:14px!important;padding:13px!important}

/* Modal and toast ergonomics */
html[data-device-mode="mobile"] .modal-backdrop{align-items:flex-end!important;padding:10px!important}
html[data-device-mode="mobile"] .modal:not(.assessment-start-modal):not(.assessment-review-modal){width:100%!important;max-width:none!important;max-height:88dvh;overflow:auto;border-radius:22px 22px 14px 14px!important;padding:18px!important}
html[data-device-mode="mobile"] .modal-actions{position:sticky;bottom:0;background:#fff;padding-top:12px;display:grid!important;grid-template-columns:1fr 1fr;gap:8px!important}
html[data-device-mode="mobile"] .toast{left:12px!important;right:12px!important;bottom:86px!important;width:auto!important;max-width:none!important}

@media (max-width:390px){
  .mobile-main{padding-left:11px!important;padding-right:11px!important}
  .mobile-appbar{padding-left:12px;padding-right:12px}
  .mobile-mode-pill{display:none}
  .mobile-appbar-brand small{max-width:125px}
  html[data-device-mode="mobile"] .kpi-strip{grid-template-columns:1fr!important}
  html[data-device-mode="mobile"] .student-subject-hero-kpis{grid-template-columns:1fr!important}
}
