:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --ink: #14213a;
  --muted: #697a92;
  --line: #dbe4ef;
  --primary: #315bd6;
  --primary-2: #7355d8;
  --primary-soft: #eef2ff;
  --success: #14885b;
  --success-soft: #eaf8f1;
  --danger: #c94555;
  --danger-soft: #fff0f2;
  --warning: #a76a09;
  --warning-soft: #fff6df;
  --purple: #6c4ccc;
  --radius: 18px;
  --shadow: 0 16px 45px rgba(35, 52, 80, .10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, "Noto Sans Gujarati", "Nirmala UI", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); min-height: 1.2rem; }
.eyebrow { color: #7183a1; font-size: .72rem; font-weight: 900; letter-spacing: .13em; }
.eyebrow.light { color: rgba(255,255,255,.67); }
.success-text { color: var(--success); font-style: normal; }
.danger-text { color: var(--danger); font-style: normal; }

/* Authentication */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr); }
.auth-visual { position: relative; overflow: hidden; padding: clamp(2rem, 5vw, 5rem); color: white; background: radial-gradient(circle at 80% 15%, rgba(124,150,255,.42), transparent 35%), linear-gradient(145deg, #112449, #244eac 58%, #6545bf); display: flex; flex-direction: column; }
.auth-visual:before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255,255,255,.16); right: -180px; bottom: -170px; box-shadow: 0 0 0 55px rgba(255,255,255,.035), 0 0 0 110px rgba(255,255,255,.02); }
.brand { display: flex; align-items: center; gap: .8rem; font-weight: 850; letter-spacing: -.02em; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); display: grid; place-items: center; color: white; font-weight: 900; }
.auth-copy { margin: auto 0; max-width: 760px; position: relative; z-index: 1; }
.auth-copy h1 { font-size: clamp(2.7rem, 5vw, 5.4rem); line-height: 1.01; letter-spacing: -.06em; margin: .8rem 0 1.2rem; }
.auth-copy p { max-width: 670px; color: rgba(255,255,255,.78); line-height: 1.75; font-size: 1.05rem; }
.auth-features { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.auth-feature { padding: 1rem; border-radius: 16px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(12px); }
.auth-feature strong, .auth-feature span { display: block; }
.auth-feature span { margin-top: .35rem; color: rgba(255,255,255,.68); font-size: .8rem; line-height: 1.45; }
.auth-form-side { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: min(540px, 100%); padding: clamp(1.5rem, 4vw, 2.5rem); border-radius: 28px; background: rgba(255,255,255,.95); border: 1px solid white; box-shadow: var(--shadow); }
.auth-card h2 { margin: .35rem 0 .45rem; font-size: 2rem; letter-spacing: -.04em; }
.demo-note { margin-top: 1rem; }
.tabs { display: flex; gap: .4rem; padding: .35rem; margin: 1.4rem 0; border-radius: 14px; background: #edf2f8; }
.tab { flex: 1; border: 0; padding: .75rem; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 800; }
.tab.active { color: var(--ink); background: white; box-shadow: 0 7px 20px rgba(32,53,82,.09); }

/* Forms and buttons */
.field { display: grid; gap: .42rem; margin-bottom: 1rem; }
.field label { font-size: .86rem; font-weight: 800; }
.field-help { color: var(--muted); font-size: .77rem; line-height: 1.4; }
.input { width: 100%; min-width: 0; border: 1px solid var(--line); background: white; border-radius: 12px; padding: .82rem .92rem; outline: none; transition: .18s; color: var(--ink); }
.input:focus { border-color: #8297eb; box-shadow: 0 0 0 4px rgba(54,88,210,.10); }
textarea.input { min-height: 135px; resize: vertical; line-height: 1.55; }
textarea.small-textarea { min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-span-2 { grid-column: span 2; }
.two-col-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.btn { border: 0; border-radius: 12px; padding: .82rem 1rem; font-weight: 850; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: white; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 11px 25px rgba(57,80,195,.22); }
.btn-secondary { color: var(--ink); background: #edf2f8; }
.btn-success { color: var(--success); background: var(--success-soft); }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-small { padding: .56rem .72rem; border-radius: 10px; font-size: .8rem; }
.text-button { border: 0; padding: .4rem 0 0; background: transparent; color: var(--primary); font-weight: 800; text-align: left; }

/* Main application shell */
.app-layout { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.45rem; display: flex; flex-direction: column; color: white; background: linear-gradient(180deg, #102341, #0e1f38); }
.sidebar .brand { margin-bottom: 2rem; }
.nav { display: grid; gap: .42rem; }
.nav button { width: 100%; border: 0; border-radius: 11px; padding: .82rem .88rem; display: flex; align-items: center; justify-content: space-between; background: transparent; color: #b8c6db; text-align: left; font-weight: 780; }
.nav button:hover, .nav button.active { color: white; background: rgba(255,255,255,.09); }
.nav-count { min-width: 23px; padding: .16rem .42rem; border-radius: 999px; background: rgba(255,255,255,.14); text-align: center; font-size: .7rem; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.10); }
.main { min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 3rem) 4rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.45rem; }
.topbar h1 { margin: .2rem 0 0; font-size: clamp(1.8rem, 3vw, 2.4rem); letter-spacing: -.045em; }
.user-chip { display: flex; align-items: center; gap: .7rem; padding: .54rem .72rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.avatar { width: 37px; height: 37px; border-radius: 11px; display: grid; place-items: center; color: white; font-weight: 900; background: linear-gradient(135deg, #315bd6, #7553d7); }
.card { padding: 1.2rem; border-radius: var(--radius); background: var(--surface); border: 1px solid rgba(216,226,238,.92); box-shadow: 0 8px 27px rgba(35,52,80,.055); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { margin: 1.15rem 0; }
.stat-card { display: flex; align-items: center; gap: .85rem; }
.stat-icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-weight: 900; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 750; }
.stat-value { margin-top: .18rem; font-size: 1.75rem; font-weight: 900; letter-spacing: -.04em; }
.section-head { margin: 1.65rem 0 .8rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.section-head.compact { margin: 0 0 .9rem; }
.section-head h2, .section-head h3 { margin: 0; letter-spacing: -.025em; }
.page-head { align-items: flex-end; }
.hero-card { min-height: 180px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.7rem; background: radial-gradient(circle at 86% 12%, rgba(93,114,235,.12), transparent 32%), linear-gradient(135deg, #fff, #f7f9ff); }
.hero-card h2 { margin: .55rem 0 .45rem; font-size: 1.65rem; letter-spacing: -.035em; }
.analytics-grid { margin-top: 1rem; }

/* Badges and feedback */
.badge { display: inline-flex; align-items: center; padding: .28rem .56rem; border-radius: 999px; font-size: .72rem; font-weight: 900; }
.badge-neutral { color: #52647d; background: #edf2f8; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-purple { color: var(--purple); background: #f0ebff; }

/* Analytics */
.donut-row { display: flex; align-items: center; gap: 1.4rem; }
.donut { --pct: 0; width: 132px; height: 132px; flex: 0 0 132px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--primary) calc(var(--pct) * 1%), #e8edf5 0); }
.donut:after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: white; }
.donut span { position: relative; z-index: 1; font-size: 1.35rem; font-weight: 900; }
.metric-list { display: grid; gap: .6rem; flex: 1; }
.metric-list div { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); }
.metric-list strong { color: var(--ink); }
.metric-list.stacked div { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.analytics-list { display: grid; gap: .9rem; }
.analytics-row { display: grid; gap: .44rem; }
.analytics-row-head, .analytics-row-foot { display: flex; justify-content: space-between; gap: 1rem; }
.analytics-row-head span, .analytics-row-foot { color: var(--muted); font-size: .76rem; }
.dual-progress, .mini-progress { overflow: hidden; border-radius: 999px; background: #e9eef6; }
.dual-progress { height: 8px; }
.dual-progress span, .mini-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.mini-progress { width: 105px; height: 6px; display: inline-block; margin-right: .42rem; vertical-align: middle; }
.mini-progress.large { width: 100%; height: 8px; margin-top: .55rem; }
.analytics-table { padding: .3rem 1.1rem; }
.analytics-table-row { display: grid; grid-template-columns: minmax(230px, 1.5fr) 1fr .65fr .8fr; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.analytics-table-row:last-child { border-bottom: 0; }
.analytics-table-row > span:first-child { display: grid; }
.analytics-table-row small { color: var(--muted); }
.analytics-table-head { color: var(--muted); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.result-metric span, .result-metric strong, .result-metric small { display: block; }
.result-metric > span { color: var(--muted); font-size: .78rem; font-weight: 800; }
.result-metric > strong { margin: .42rem 0; font-size: 1.55rem; letter-spacing: -.035em; }

/* Course folders */
.quiz-builder-bar { position: sticky; top: .7rem; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: var(--shadow); }
.builder-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.compact-input { width: 145px; }
.course-list { display: grid; gap: 1.25rem; margin-top: 1rem; }
.subject-folder { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.62); overflow: hidden; }
.subject-folder-head { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.subject-folder-head > div { display: flex; align-items: center; gap: .8rem; }
.subject-folder-head h3 { margin: 0 0 .2rem; }
.subject-folder-head span { color: var(--muted); font-size: .78rem; }
.folder-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-size: 1.15rem; }
.chapter-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 1rem; }
.chapter-card { position: relative; cursor: pointer; transition: .18s; }
.chapter-card:hover { transform: translateY(-2px); border-color: #b9c7e8; }
.chapter-card > input { position: absolute; top: 1rem; right: 1rem; width: 18px; height: 18px; accent-color: var(--primary); }
.chapter-no { color: var(--primary); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.chapter-card h3 { margin: .48rem 2rem .65rem 0; }
.chapter-meta { display: flex; gap: .8rem; color: var(--muted); font-size: .76rem; }
.disabled-card { opacity: .58; cursor: not-allowed; }
.admin-chapter-card { cursor: default; }
.structure-summary-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.structure-summary-row div { display: grid; gap: .2rem; }
.structure-summary-row span { color: var(--muted); font-size: .78rem; }

/* Tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .82rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .88rem; }
th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; }

/* Quiz */
.modal { position: fixed; inset: 0; z-index: 30; padding: 1rem; display: grid; place-items: center; background: rgba(7,18,36,.64); backdrop-filter: blur(6px); }
.modal-card { width: min(920px, 100%); max-height: 94vh; overflow: auto; border-radius: 24px; padding: 1.25rem; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.quiz-modal-card { width: min(980px, 100%); }
.quiz-head { position: sticky; top: -1.25rem; z-index: 5; margin: -1.25rem -1.25rem 0; padding: 1.25rem; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.quiz-progress-row, .modal-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quiz-progress-row h2, .modal-title-row h2 { margin: .25rem 0 0; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #e9eef6; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.quiz-stat-line { margin-top: .55rem; }
.question-card { margin-top: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 18px; }
.question-card.correct { border-color: #83cfae; background: #f7fcf9; }
.question-card.wrong { border-color: #e8a6af; background: #fff8f8; }
.question-topline { display: flex; justify-content: space-between; align-items: center; gap: .7rem; }
.question-meta { color: var(--muted); font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.question-text { margin: .75rem 0 1rem; white-space: pre-wrap; line-height: 1.68; font-weight: 750; font-size: 1.06rem; }
.option { position: relative; display: flex; align-items: flex-start; gap: .7rem; margin: .55rem 0; padding: .78rem; border-radius: 12px; border: 1px solid var(--line); background: white; }
.option input { margin-top: .22rem; accent-color: var(--primary); }
.option.selected-correct { border-color: #72c59c; background: var(--success-soft); }
.option.selected-wrong { border-color: #e096a1; background: var(--danger-soft); }
.option-sign { margin-left: auto; }
.feedback { margin-top: .9rem; padding: .72rem .85rem; border-radius: 12px; font-weight: 900; }
.feedback.success { color: var(--success); background: var(--success-soft); }
.feedback.error { color: var(--danger); background: var(--danger-soft); }
.answer-box { margin-top: .8rem; padding: 1rem; border-radius: 14px; border: 1px solid #cad8f7; background: #eef4ff; white-space: pre-wrap; line-height: 1.65; }
.quiz-actions { display: flex; gap: .65rem; flex-wrap: wrap; margin-top: 1rem; }
.sticky-actions { position: sticky; bottom: -1.25rem; margin: 1rem -1.25rem -1.25rem; padding: 1rem 1.25rem; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.sticky-actions #finishQuizBtn { margin-left: auto; }
.self-review { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-top: .8rem; }
.self-review span { color: var(--muted); font-size: .8rem; font-weight: 800; }

/* Materials, results, revision */
.reading-modal { width: min(900px, 100%); }
.material-article { padding: 1.2rem 0; border-bottom: 1px solid var(--line); }
.material-article:last-child { border-bottom: 0; }
.material-meta { color: var(--primary); font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; }
.material-article h3 { margin: .45rem 0 .7rem; }
.material-body { white-space: pre-wrap; line-height: 1.85; color: #30415a; }
.result-hero { display: flex; align-items: center; gap: 1.25rem; padding: 1rem 0; }
.result-hero h3 { margin: .55rem 0 .2rem; font-size: 1.45rem; }
.result-hero p { color: var(--muted); }
.result-summary-grid { padding: 1rem 0; }
.result-summary-grid > div { padding: 1rem; border-radius: 14px; background: var(--surface-soft); }
.result-summary-grid span, .result-summary-grid strong { display: block; }
.result-summary-grid span { color: var(--muted); font-size: .75rem; }
.result-summary-grid strong { margin-top: .35rem; font-size: 1.35rem; }
.result-chapter { display: grid; grid-template-columns: minmax(210px, 1.3fr) repeat(3, .7fr); gap: .8rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.result-chapter div { display: grid; }
.result-chapter small { color: var(--muted); }
.answer-review { display: grid; gap: .8rem; }
.review-item { padding: 1rem; border: 1px solid var(--line); border-radius: 15px; }
.review-correct { border-left: 4px solid var(--success); }
.review-wrong { border-left: 4px solid var(--danger); }
.review-heading { display: flex; justify-content: space-between; gap: .8rem; font-size: .78rem; }
.review-item p { margin: .7rem 0; line-height: 1.55; }
.review-item small { color: var(--muted); }
.review-answer { margin: .25rem 0 .65rem; padding: .65rem .75rem; border-radius: 10px; background: #f3f6fa; white-space: pre-wrap; }
.review-answer.correct-answer { background: #eef4ff; }
.revision-list { display: grid; gap: .8rem; }
.revision-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.revision-card h3 { margin: .65rem 0 .35rem; font-size: 1rem; line-height: 1.5; }
.revision-card p { margin: 0; color: var(--muted); font-size: .8rem; }
.revision-count { min-width: 90px; padding: .7rem; border-radius: 13px; text-align: center; background: var(--danger-soft); }
.revision-count strong, .revision-count span { display: block; }
.revision-count strong { color: var(--danger); font-size: 1.4rem; }
.revision-count span { color: var(--muted); font-size: .7rem; }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.profile-grid > div { padding: .9rem; border-radius: 13px; background: var(--surface-soft); }
.profile-grid span, .profile-grid strong { display: block; }
.profile-grid span { color: var(--muted); font-size: .74rem; }
.profile-grid strong { margin-top: .35rem; }

/* Admin import */
.action-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.inline-status { min-height: 1.2rem; }
.status-working { color: var(--purple); font-weight: 800; }
.status-success { color: var(--success); font-weight: 800; }
.status-error { color: var(--danger); font-weight: 800; }
.notice { display: grid; gap: .35rem; margin: .7rem 0; padding: .9rem 1rem; border-radius: 14px; border: 1px solid var(--line); }
.notice-warning { color: #6f571f; background: #fff9ea; border-color: #ead9a6; }
.notice span { display: block; font-size: .8rem; }
.preview-item { margin: .8rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: white; }
.preview-heading { display: flex; justify-content: space-between; gap: 1rem; }
.preview-heading > div { display: flex; gap: .35rem; flex-wrap: wrap; }
.format-preview { margin: .55rem 0 .85rem; color: var(--muted); font-size: .78rem; }
.preview-item textarea { min-height: 85px; }
.detected-options { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.2rem 0 .8rem; }
.detected-options span { padding: .35rem .55rem; border-radius: 9px; background: #f0f4f9; font-size: .76rem; }
.empty-state { display: grid; place-items: center; gap: .35rem; min-height: 100px; padding: 1rem; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 80; max-width: 380px; padding: .85rem 1rem; border-radius: 12px; color: white; background: #10213d; box-shadow: var(--shadow); }
.toast.error { background: #9f3140; }
.toast.success { background: #146f4d; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-table-row { grid-template-columns: minmax(190px, 1.3fr) 1fr .6fr .8fr; }
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { min-height: 430px; }
  .auth-features { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 1rem; }
  .sidebar .brand { margin-bottom: .8rem; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { white-space: nowrap; width: auto; }
  .sidebar-footer { display: none; }
  .quiz-builder-bar { top: 0; }
}
@media (max-width: 700px) {
  .main { padding: 1rem 1rem 3rem; }
  .grid-2, .grid-3, .grid-4, .two-col-form, .form-grid, .profile-grid { grid-template-columns: 1fr; }
  .form-span-2 { grid-column: auto; }
  .chapter-list { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .user-meta { display: none; }
  .hero-card, .quiz-builder-bar, .revision-card { align-items: flex-start; flex-direction: column; }
  .builder-actions { width: 100%; }
  .builder-actions .btn, .compact-input { flex: 1; width: auto; }
  .donut-row, .result-hero { align-items: flex-start; flex-direction: column; }
  .analytics-table-row { grid-template-columns: 1fr; gap: .4rem; }
  .analytics-table-head { display: none; }
  .result-chapter { grid-template-columns: 1fr 1fr; }
  .quiz-progress-row, .modal-title-row, .question-topline { align-items: flex-start; flex-direction: column; }
  .sticky-actions #finishQuizBtn { margin-left: 0; }
  .modal { padding: .4rem; }
  .modal-card { border-radius: 18px; }
}

/* First-page authentication upgrade v1.3. Other application pages are unchanged. */
.auth-card-v13 { width: min(620px, 100%); }
.auth-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.auth-heading-row h2 { margin-bottom: .35rem; }
.access-badge { flex: 0 0 auto; padding: .42rem .7rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .7rem; font-weight: 900; }
.access-badge.admin-badge { background: #fff1e7; color: #a74f13; }
.access-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; padding: .4rem; margin: 1.35rem 0; border-radius: 15px; background: #edf2f8; }
.access-tab { min-width: 0; border: 0; padding: .78rem .5rem; border-radius: 11px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 850; }
.access-tab.active { color: var(--ink); background: white; box-shadow: 0 7px 20px rgba(32,53,82,.09); }
.admin-access-tab.active { color: #8b4217; background: #fff8f3; }
.auth-panel { animation: authPanelIn .22s ease both; }
@keyframes authPanelIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.auth-alert { margin: 0 0 1rem; padding: .85rem 1rem; border-radius: 13px; font-size: .84rem; font-weight: 750; line-height: 1.5; }
.auth-alert-success { color: #126642; background: var(--success-soft); border: 1px solid #c7ebd9; }
.password-field { position: relative; }
.password-field .input { padding-right: 4.2rem; }
.password-toggle { position: absolute; top: 50%; right: .55rem; transform: translateY(-50%); border: 0; padding: .38rem .55rem; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: .7rem; font-weight: 900; }
.password-toggle:hover { transform: translateY(-50%); }
.forgot-link, .back-link { display: block; border: 0; background: transparent; color: var(--primary); font-weight: 850; }
.forgot-link { margin: .8rem auto 0; padding: .3rem; font-size: .82rem; }
.back-link { margin: -.2rem 0 1rem; padding: .2rem 0; }
.account-type-label { margin-bottom: .55rem; font-size: .78rem; font-weight: 850; color: var(--muted); }
.account-type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1.1rem; }
.account-type { display: flex; align-items: center; gap: .7rem; min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; color: var(--ink); }
.account-type.active { border-color: #8297eb; background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(54,88,210,.08); }
.account-type-icon, .admin-shield { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; color: white; background: linear-gradient(135deg, var(--primary), var(--primary-2)); font-weight: 900; }
.account-type span:last-child, .account-type strong, .account-type small { display: block; }
.account-type small { margin-top: .15rem; color: var(--muted); font-size: .68rem; }
.compact-form-grid .field { margin-bottom: .8rem; }
.admin-optional-field label:after { content: " (optional)"; color: var(--muted); font-weight: 500; }
.login-after-create-note { margin: .85rem 0 0; color: var(--muted); font-size: .76rem; text-align: center; line-height: 1.5; }
.admin-login-note { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; padding: .8rem; border: 1px solid #f1d8c4; border-radius: 14px; background: #fff8f3; }
.admin-login-note strong, .admin-login-note small { display: block; }
.admin-login-note small { margin-top: .2rem; color: var(--muted); font-size: .72rem; }
.admin-shield { background: linear-gradient(135deg, #b65b1c, #7e3512); }
.forgot-heading { margin-bottom: 1rem; }
.forgot-heading h3 { margin-bottom: .3rem; font-size: 1.25rem; }
.demo-note strong { color: var(--ink); }
@media (max-width: 700px) {
  .auth-card-v13 { padding: 1.3rem; border-radius: 22px; }
  .auth-heading-row { display: block; }
  .access-badge { display: inline-flex; margin-top: .25rem; }
  .access-tabs { grid-template-columns: 1fr; }
  .access-tab { padding: .7rem; }
  .account-type-switch { grid-template-columns: 1fr; }
}


/* v1.5 responsive layout + student course selection reliability.
   No visual module or workflow redesign: only adaptive sizing/stacking and enabled chapter cards. */
img, svg, video, canvas { max-width: 100%; height: auto; }
.app-layout, .main, .card, .student-view, .admin-section, .subject-folder, .chapter-card { min-width: 0; }
.main { width: 100%; overflow-x: hidden; }
.chapter-card.selected-card { border-color: #8fa6ef; box-shadow: 0 0 0 3px rgba(49,91,214,.09), 0 8px 27px rgba(35,52,80,.055); background: #fbfcff; }
.chapter-card.selected-card > input { outline: 3px solid rgba(49,91,214,.10); outline-offset: 2px; }
.table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 760px; }
.modal-card { max-width: calc(100vw - 2rem); }
.question-text, .review-answer, .material-body, td, th { overflow-wrap: anywhere; word-break: normal; }

@media (max-width: 1200px) {
  .app-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .main { padding-left: 1.25rem; padding-right: 1.25rem; }
  .chapter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-layout { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; min-height: 0; }
  .nav { width: 100%; padding-bottom: .2rem; scrollbar-width: thin; }
  .nav button { flex: 0 0 auto; }
  .main { width: 100%; }
  .section-head.page-head { align-items: flex-start; }
  .quiz-builder-bar { position: relative; top: auto; }
  .modal { align-items: flex-start; overflow-y: auto; }
  .modal-card { width: 100%; max-height: none; margin: .5rem auto; }
}

@media (max-width: 720px) {
  .main { padding: .9rem .8rem 2.5rem; }
  .card { padding: 1rem; border-radius: 15px; }
  .topbar, .section-head, .section-head.page-head, .subject-folder-head, .preview-heading, .modal-title-row, .quiz-progress-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar { margin-bottom: 1rem; }
  .user-chip { max-width: 100%; }
  .hero-card { min-height: 0; }
  .chapter-list { grid-template-columns: 1fr; padding: .75rem; }
  .subject-folder-head { padding: .85rem; }
  .subject-folder-head > div { width: 100%; }
  .subject-folder-head > .btn { width: 100%; }
  .builder-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .builder-actions .compact-input { grid-column: 1 / -1; width: 100%; }
  .builder-actions .btn { width: 100%; }
  .action-row { align-items: stretch; flex-direction: column; }
  .action-row .btn { width: 100%; }
  .quiz-actions.sticky-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
  .quiz-actions.sticky-actions #finishQuizBtn { grid-column: 1 / -1; width: 100%; }
  .options-list .option { align-items: flex-start; }
  .result-chapter { grid-template-columns: 1fr; gap: .35rem; }
  .profile-grid { grid-template-columns: 1fr; }
  .donut { width: 112px; height: 112px; flex-basis: 112px; }
  .filter-select { width: 100%; }
  .two-col-form, .form-grid { gap: 0; }
  .modal { padding: .3rem; }
  .modal-card { max-width: calc(100vw - .6rem); padding: .9rem; border-radius: 15px; }
  .toast { left: .7rem; right: .7rem; bottom: .7rem; max-width: none; }
}

@media (max-width: 480px) {
  .sidebar { padding: .8rem; }
  .sidebar .brand { margin-bottom: .65rem; }
  .brand-mark { width: 36px; height: 36px; }
  .nav button { padding: .7rem .72rem; font-size: .8rem; }
  .main { padding: .75rem .65rem 2rem; }
  .topbar h1 { font-size: 1.55rem; }
  .section-head h2 { font-size: 1.25rem; }
  .grid { gap: .75rem; }
  .stats { margin: .8rem 0; }
  .stat-value { font-size: 1.45rem; }
  .builder-actions { grid-template-columns: 1fr; }
  .builder-actions .compact-input, .builder-actions .btn { grid-column: auto; }
  .btn { min-height: 44px; }
  .question-card { padding: .9rem; }
  .question-text { font-size: 1rem; line-height: 1.55; }
  .quiz-actions.sticky-actions { grid-template-columns: 1fr; }
  .quiz-actions.sticky-actions #finishQuizBtn { grid-column: auto; }
  .result-summary-grid { grid-template-columns: 1fr 1fr !important; }
  .table-wrap table { min-width: 680px; }
}

/* v1.6 student quiz interaction refinements */
.written-input-wrap { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .65rem; align-items: start; margin-top: 1rem; }
.written-input-wrap textarea { min-height: 150px; }
.mic-btn { min-width: 74px; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: #f4f7fb; color: var(--ink); font-weight: 850; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.mic-btn:hover { border-color: #9aabe0; background: var(--primary-soft); }
.mic-btn.listening { color: #fff; background: var(--danger); border-color: var(--danger); animation: micPulse 1s ease-in-out infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 7px rgba(201,69,85,.13); } }
.autosave-status, .auto-check-note, .structured-help { margin: .45rem 0 .85rem; color: var(--muted); font-size: .78rem; }
.sortable-list { display: grid; gap: .6rem; margin: 1rem 0; }
.sortable-item, .match-fixed { min-width: 0; min-height: 58px; padding: .75rem .8rem; border: 1px solid var(--line); border-radius: 13px; background: #fff; display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; align-items: center; gap: .7rem; }
.sortable-item[draggable="true"] { cursor: grab; }
.sortable-item[draggable="true"]:active { cursor: grabbing; }
.drag-handle { color: #8190a7; font-weight: 900; letter-spacing: -2px; }
.sort-index, .match-key, .match-fixed > span { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: .76rem; font-weight: 900; }
.sort-actions { display: inline-flex; gap: .3rem; }
.sort-actions button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: #edf2f8; color: var(--ink); font-weight: 900; }
.sort-actions button:disabled { opacity: .35; }
.match-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .75rem; margin: 1rem 0; }
.match-col { display: grid; gap: .6rem; align-content: start; }
.match-fixed { grid-template-columns: auto minmax(0,1fr); }
.match-sort { grid-template-columns: auto auto minmax(0,1fr) auto; margin: 0; }
.result-chapter-head { color: var(--muted); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
#resultModal .modal-title-row { position: sticky; top: -.9rem; z-index: 3; padding: .9rem 0 .65rem; background: #fff; }
#resultModal #closeResultBtn { margin-left: auto; flex: 0 0 auto; }

@media (max-width: 720px) {
  #resultModal .modal-title-row { flex-direction: row; align-items: flex-start; gap: .6rem; top: -.9rem; }
  #resultModal .modal-title-row > div { min-width: 0; flex: 1; }
  #resultModal #closeResultBtn { width: auto; min-width: 72px; margin-left: auto; }
  .match-grid { grid-template-columns: 1fr; }
  .match-col:first-child { counter-reset: matchrow; }
  .written-input-wrap { grid-template-columns: 1fr; }
  .mic-btn { width: 100%; }
  .sortable-item { grid-template-columns: auto auto minmax(0,1fr); }
  .sortable-item .sort-actions { grid-column: 1 / -1; justify-self: end; }
  .match-sort { grid-template-columns: auto auto minmax(0,1fr); }
  .result-chapter-head { display: none; }
}

@media (max-width: 480px) {
  .sortable-item, .match-fixed { padding: .65rem; gap: .5rem; }
  .sort-index, .match-key, .match-fixed > span { width: 28px; height: 28px; }
  #resultModal .modal-card { padding-top: .75rem; }
  #resultModal .modal-title-row h2 { font-size: 1.2rem; }
}

/* v1.7 Match/Sequence + quiz history refinements */
.results-page-head { align-items: flex-end; }
.results-filter-control { margin-left: auto; min-width: 190px; display: flex; justify-content: flex-end; }
.results-filter-control .filter-select { width: 190px; }

.structured-help { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .75rem; margin-top: 1rem; padding: .72rem .85rem; border-radius: 12px; background: #f5f8fd; border: 1px solid var(--line); }
.structured-help strong { color: var(--ink); }
.structured-help span { color: var(--muted); }
.structured-card { transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.structured-card.dragging { transform: scale(.985); opacity: .84; box-shadow: 0 12px 30px rgba(29,54,104,.18); border-color: #7c98df; }
.structured-verify { margin-top: .9rem; }
.drag-handle { border: 0; border-radius: 8px; min-width: 34px; min-height: 34px; background: rgba(255,255,255,.72); color: #596a84; font-weight: 950; letter-spacing: -2px; cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle:disabled { cursor: default; opacity: .4; }

/* Arrange in Correct Sequence: movable box board inspired by the supplied card reference. */
.sequence-board { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .75rem; margin: 1rem 0; counter-reset: sequence; }
.sequence-card { position: relative; min-height: 132px; padding: .9rem 1rem; border: 1px solid rgba(29,48,82,.12); border-radius: 16px; display: grid; grid-template-rows: auto 1fr auto; gap: .65rem; align-items: center; color: #17233a; box-shadow: 0 5px 16px rgba(22,42,77,.07); cursor: grab; }
.sequence-card strong { align-self: center; text-align: center; line-height: 1.45; overflow-wrap: anywhere; }
.sequence-card-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sequence-number { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.72); font-size: .76rem; font-weight: 950; }
.sequence-card .sort-actions { justify-self: end; }
.sequence-color-0 { background: #ffe8ec; border-color: #f1b6bf; }
.sequence-color-1 { background: #e8f2ff; border-color: #b6d1f2; }
.sequence-color-2 { background: #fff3cf; border-color: #ead394; }
.sequence-color-3 { background: #e8f6e3; border-color: #b9d9ad; }

/* Match the Following: Part A fixed, only Part B is reorderable. */
.match-board { margin: 1rem 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.match-board-head, .match-board-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.match-board-head > div { padding: .72rem .9rem; font-size: .76rem; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; background: #f2f5f9; border-bottom: 1px solid var(--line); }
.match-board-head > div + div { border-left: 1px solid var(--line); }
.match-board-head span { margin-left: .4rem; color: var(--primary); font-size: .68rem; text-transform: none; letter-spacing: 0; }
.match-board-row + .match-board-row { border-top: 1px solid var(--line); }
.match-a-card, .match-b-card { min-width: 0; min-height: 66px; padding: .78rem .85rem; display: grid; align-items: center; gap: .65rem; }
.match-a-card { grid-template-columns: auto minmax(0,1fr); background: #f7fbfd; }
.match-b-card { grid-template-columns: auto minmax(0,1fr) auto; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: #fff9df; cursor: grab; }
.match-a-card strong, .match-b-card strong { line-height: 1.4; overflow-wrap: anywhere; }
.match-row-number { width: 30px; height: 30px; border-radius: 9px; background: #dceff6; color: #234d64; display: grid; place-items: center; font-size: .76rem; font-weight: 950; }
.match-b-card .sort-actions { justify-self: end; }

/* Requested quiz-history columns and responsive card layout. */
.quiz-history-table { min-width: 850px; }
.quiz-history-table td:first-child { min-width: 190px; }
.quiz-history-table td:nth-child(6) { white-space: nowrap; }
.quiz-history-table td:last-child { white-space: nowrap; }

@media (max-width: 900px) {
  .sequence-board { grid-template-columns: 1fr 1fr; }
  .match-a-card, .match-b-card { min-height: 72px; }
}

@media (max-width: 720px) {
  .results-page-head { align-items: flex-start; }
  .results-filter-control { margin-left: auto; min-width: 150px; }
  .results-filter-control .filter-select { width: min(170px, 42vw); }
  .sequence-board { grid-template-columns: 1fr; }
  .sequence-card { min-height: 112px; }
  .match-board { overflow: visible; border: 0; background: transparent; display: grid; gap: .65rem; }
  .match-board-head { display: none; }
  .match-board-row { grid-template-columns: 1fr; gap: .35rem; border: 0 !important; }
  .match-a-card, .match-b-card { min-height: 58px; border: 1px solid var(--line); border-radius: 12px; }
  .match-a-card { background: #f5fbfd; }
  .match-b-card { background: #fff8d9; grid-template-columns: auto minmax(0,1fr) auto; }
  .match-a-card::before { content: "Part A"; grid-column: 1 / -1; color: var(--muted); font-size: .64rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
  .match-b-card::before { content: "Part B • move"; grid-column: 1 / -1; color: #7a661f; font-size: .64rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }

  .quiz-history-wrap { overflow: visible; padding: .2rem; background: transparent; box-shadow: none; border: 0; }
  .quiz-history-table, .quiz-history-table tbody, .quiz-history-table tr, .quiz-history-table td { display: block; width: 100%; min-width: 0 !important; }
  .quiz-history-table thead { display: none; }
  .quiz-history-table tbody { display: grid; gap: .75rem; }
  .quiz-history-table tr { padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 6px 18px rgba(20,42,80,.05); }
  .quiz-history-table td { display: grid; grid-template-columns: minmax(96px,.65fr) minmax(0,1fr); align-items: center; gap: .65rem; padding: .48rem 0; border-bottom: 1px solid #eef1f5; white-space: normal !important; }
  .quiz-history-table td:last-child { border-bottom: 0; }
  .quiz-history-table td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
  .quiz-history-table td .btn { justify-self: start; }
}

@media (max-width: 480px) {
  .results-page-head { flex-direction: row; gap: .55rem; }
  .results-page-head > div:first-child { min-width: 0; flex: 1; }
  .results-filter-control { flex: 0 0 auto; min-width: 126px; }
  .results-filter-control .filter-select { width: 126px; padding-left: .6rem; padding-right: .5rem; font-size: .76rem; }
  .sequence-card { min-height: 104px; padding: .75rem; }
  .match-b-card { grid-template-columns: auto minmax(0,1fr); }
  .match-b-card .sort-actions { grid-column: 1 / -1; justify-self: end; }
  .quiz-history-table td { grid-template-columns: 88px minmax(0,1fr); }
}

/* v1.9 admin management additions */
.btn-sm { padding: .56rem .72rem; border-radius: 10px; font-size: .8rem; }
.admin-folder-actions,
.chapter-title-row,
.chapter-admin-actions,
.table-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
}
.chapter-title-row { justify-content: space-between; align-items: flex-start; }
.chapter-admin-actions { margin-top: .9rem; }
.chapter-remark {
  margin-top: .8rem;
  padding: .7rem .8rem;
  border-radius: 12px;
  background: var(--surface-2, #f5f7fb);
  color: var(--text-muted, #60708a);
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.question-manager-head { margin-top: 1.25rem; }
.managed-question-table td { vertical-align: top; }
.managed-question-table td:nth-child(2) { min-width: 280px; }
.managed-question-table td:nth-child(4) { min-width: 180px; white-space: pre-wrap; }

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .56);
  backdrop-filter: blur(6px);
}
.admin-modal-backdrop.hidden { display: none !important; }
.admin-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
  padding: 22px;
}
.admin-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.admin-modal-head h3 { margin: .2rem 0 0; }
.icon-close {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: #eef2f7;
  color: #17233c;
  font: inherit;
  font-size: 1.55rem;
  cursor: pointer;
}
.modal-actions { justify-content: flex-end; margin-top: 18px; }
.modal-open { overflow: hidden; }
.student-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.student-edit-grid .field { margin: 0; }
.student-edit-grid .full-span { grid-column: 1 / -1; }

@media (max-width: 820px) {
  .subject-folder-head { align-items: flex-start; gap: 12px; }
  .admin-folder-actions { width: 100%; justify-content: flex-start; }
  .chapter-admin-actions .btn { flex: 1 1 140px; }
  .question-manager-head { align-items: flex-start; }
  .admin-modal-backdrop { padding: 10px; align-items: end; }
  .admin-modal { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 18px; }
  .student-edit-grid { grid-template-columns: 1fr; }
  .student-edit-grid .full-span { grid-column: auto; }
  .modal-actions { position: sticky; bottom: -18px; background: #fff; padding: 12px 0 4px; }
}

@media (max-width: 560px) {
  .chapter-title-row { gap: 10px; }
  .chapter-title-row .btn { width: auto; }
  .chapter-admin-actions { display: grid; grid-template-columns: 1fr; }
  .chapter-admin-actions .btn { width: 100%; }
  .table-actions { flex-direction: column; align-items: stretch; min-width: 92px; }
  .table-actions .btn { width: 100%; }
}


/* v2.0 admin responsive refinement. Admin UI only. */
html:has(body.admin-page),
body.admin-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.admin-page .app-layout,
.admin-page .main,
.admin-page .admin-section,
.admin-page .card,
.admin-page .table-wrap {
  max-width: 100%;
  min-width: 0;
}
.admin-page .main { overflow-x: clip; }
.admin-page .table-wrap {
  overflow-x: visible;
  overflow-y: visible;
}
.admin-page table.admin-responsive-table {
  width: 100%;
  min-width: 0 !important;
  max-width: 100%;
  table-layout: fixed;
}
.admin-page table.admin-responsive-table th,
.admin-page table.admin-responsive-table td {
  min-width: 0 !important;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}

/* Question manager keeps Type, Answer and Action in one clean desktop row. */
.admin-page .managed-question-table .mq-col-number { width: 4%; }
.admin-page .managed-question-table .mq-col-question { width: 51%; }
.admin-page .managed-question-table .mq-col-type { width: 13%; }
.admin-page .managed-question-table .mq-col-answer { width: 19%; }
.admin-page .managed-question-table .mq-col-action { width: 13%; }
.admin-page .managed-question-table th,
.admin-page .managed-question-table td { padding-left: .7rem; padding-right: .7rem; }
.admin-page .managed-question-table td:nth-child(2),
.admin-page .managed-question-table td:nth-child(4) { min-width: 0; }
.admin-page .managed-question-table .question-type-badge {
  display: inline-flex;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
  line-height: 1.25;
  text-align: center;
  justify-content: center;
}
.admin-page .managed-question-table .question-answer-cell {
  white-space: pre-wrap;
  line-height: 1.45;
}
.admin-page .question-source { margin-top: .18rem; }
.admin-page .question-actions,
.admin-page .managed-question-table .table-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
  width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
}
.admin-page .question-actions .btn,
.admin-page .managed-question-table .table-actions .btn {
  width: 100%;
  min-width: 0;
  padding-left: .55rem;
  padding-right: .55rem;
}

/* Admin navigation wraps instead of creating left/right scrolling. */
@media (max-width: 900px) {
  .admin-page .nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    overflow: visible;
    gap: .45rem;
  }
  .admin-page .nav button {
    width: 100%;
    min-width: 0;
    white-space: normal;
    justify-content: center;
    text-align: center;
  }
}

/* Tablet and mobile: admin tables become responsive cards, never horizontal pages. */
@media (max-width: 1050px) {
  .admin-page .table-wrap {
    padding: .65rem;
    overflow: visible !important;
    background: transparent;
    box-shadow: none;
    border: 0;
  }
  .admin-page table.admin-responsive-table,
  .admin-page table.admin-responsive-table tbody,
  .admin-page table.admin-responsive-table tr,
  .admin-page table.admin-responsive-table td {
    display: block;
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
  }
  .admin-page table.admin-responsive-table colgroup,
  .admin-page table.admin-responsive-table thead { display: none; }
  .admin-page table.admin-responsive-table tbody {
    display: grid;
    gap: .75rem;
  }
  .admin-page table.admin-responsive-table tr {
    padding: .7rem .85rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(20,42,80,.05);
  }
  .admin-page table.admin-responsive-table td {
    display: grid;
    grid-template-columns: minmax(105px, .34fr) minmax(0, 1fr);
    align-items: start;
    gap: .7rem;
    padding: .55rem 0;
    border-bottom: 1px solid #edf1f6;
  }
  .admin-page table.admin-responsive-table td:last-child { border-bottom: 0; }
  .admin-page table.admin-responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  .admin-page table.admin-responsive-table td[colspan]::before { display: none; }
  .admin-page .managed-question-table .question-type-badge { justify-self: start; }
  .admin-page .managed-question-table .question-actions {
    width: min(260px, 100%);
    justify-self: start;
  }
}

@media (max-width: 700px) {
  .admin-page .main { padding-left: .75rem; padding-right: .75rem; }
  .admin-page .card { padding: 1rem; }
  .admin-page .topbar { flex-wrap: wrap; }
  .admin-page .section-head,
  .admin-page .question-manager-head { min-width: 0; }
  .admin-page table.admin-responsive-table td {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: .55rem;
  }
}

@media (max-width: 480px) {
  .admin-page .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-page table.admin-responsive-table td {
    grid-template-columns: 1fr;
    gap: .22rem;
  }
  .admin-page table.admin-responsive-table td::before { margin-bottom: .12rem; }
  .admin-page .managed-question-table .question-actions,
  .admin-page .managed-question-table .table-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
  }
}

/* v2.1 fixed admin navigation only.
   Desktop: sidebar stays fixed while only the content area scrolls.
   Tablet/mobile: admin navigation stays sticky at the top and remains responsive. */
@media (min-width: 901px) {
  body.admin-page {
    height: 100dvh;
    overflow: hidden;
  }
  .admin-page .app-layout {
    display: block;
    min-height: 100dvh;
  }
  .admin-page .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: 280px;
    height: 100dvh;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .admin-page .main {
    width: auto;
    height: 100dvh;
    min-height: 100dvh;
    margin-left: 280px;
    overflow-y: auto;
    overflow-x: clip;
    overscroll-behavior: contain;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .admin-page .sidebar { width: 230px; }
  .admin-page .main { margin-left: 230px; }
}

@media (max-width: 900px) {
  body.admin-page {
    height: auto;
    overflow-y: auto;
  }
  .admin-page .app-layout {
    display: block;
    min-height: 100dvh;
  }
  .admin-page .sidebar {
    position: sticky !important;
    top: 0;
    z-index: 100;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    box-shadow: 0 8px 24px rgba(10, 29, 54, .14);
  }
  .admin-page .main {
    width: 100%;
    height: auto;
    min-height: 0;
    margin-left: 0;
    overflow: visible;
  }
}


/* v2.4 student quiz question-type filter and bilingual written-answer support */
.question-type-filter { margin: 1rem 0 1.25rem; padding: 1rem 1.1rem; }
.question-filter-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.8rem; }
.question-type-options { display:flex; flex-wrap:wrap; gap:.55rem; }
.question-type-option { display:inline-flex; align-items:center; gap:.45rem; padding:.58rem .75rem; border:1px solid var(--line); border-radius:12px; background:#fff; cursor:pointer; font-size:.86rem; font-weight:700; color:var(--ink); user-select:none; }
.question-type-option:has(input:checked) { border-color:#8ea7ff; background:#f0f4ff; color:#2748c7; }
.question-type-option input { accent-color:#4164e8; width:16px; height:16px; margin:0; }
.written-language-note { margin-top:.7rem; padding:.65rem .8rem; border-radius:10px; background:#f6f8fc; color:var(--muted); font-size:.78rem; line-height:1.45; }
@media (max-width: 700px) {
  .question-type-filter { padding:.85rem; }
  .question-filter-head { align-items:flex-start; }
  .question-type-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
  .question-type-option { min-width:0; white-space:normal; }
}
@media (max-width: 420px) {
  .question-type-options { grid-template-columns:1fr; }
}

/* v2.6 Super Admin additions */
.super-admin-page .sidebar { background: linear-gradient(180deg,#111b3d,#1f2a5c); }
.super-admin-page .brand-mark { background: linear-gradient(135deg,#4f46e5,#7c3aed); }
.super-admin-list { display:grid; gap:14px; }
.super-approval-card { display:flex; align-items:center; justify-content:space-between; gap:18px; }
.super-approval-main { display:flex; align-items:center; gap:14px; min-width:0; }
.super-approval-main h3 { margin:0 0 4px; }
.super-approval-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.badge-danger { background:#fee2e2; color:#b91c1c; }
.super-admin-page .sidebar-footer { display:grid; gap:8px; }
.super-admin-page .sidebar-footer a { text-decoration:none; text-align:center; }
@media (max-width: 860px) {
  .super-approval-card { align-items:flex-start; flex-direction:column; }
  .super-approval-actions { width:100%; }
  .super-approval-actions .btn { flex:1; }
}

/* v2.7 Super Admin analytics and responsive charts */
.super-chart-grid { margin-top: 1rem; align-items: stretch; }
.chart-panel { min-height: 190px; display: flex; align-items: center; width: 100%; }
.sa-bars { width: 100%; display: grid; gap: .95rem; }
.sa-bar-row { display: grid; gap: .42rem; min-width: 0; }
.sa-bar-label { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .88rem; }
.sa-bar-label span { min-width: 0; overflow-wrap: anywhere; }
.sa-bar-track { height: 12px; border-radius: 999px; background: #edf2f8; overflow: hidden; }
.sa-bar-track i { display: block; height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg,#345fe8,#7352df); transition: width .25s ease; }
.local-user-analytics-table td { vertical-align: top; }
.super-admin-page .page-head > .btn { flex: 0 0 auto; }

@media (max-width: 900px) {
  .super-chart-grid { grid-template-columns: 1fr; }
  .super-admin-page .page-head { align-items: stretch; }
  .super-admin-page .page-head > .btn { width: 100%; text-align: center; }
  .chart-panel { min-height: 160px; }
}

@media (max-width: 640px) {
  .chart-panel { min-height: auto; }
  .sa-bar-label { font-size: .82rem; }
  .sa-bar-track { height: 10px; }
  #adminAnalyticsCards.grid-4,
  #localUserAnalyticsCards.grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  #adminAnalyticsCards.grid-4,
  #localUserAnalyticsCards.grid-4 { grid-template-columns: 1fr; }
}
