/* ============================================================
   ACC 101 — Principles of Financial Accounting
   Academic theme: deep navy + warm gold, serif display,
   clean sans body. Mobile-first.
   ============================================================ */

:root {
  --navy: #14365e;
  --navy-deep: #0e2542;
  --navy-soft: #eef3f9;
  --gold: #c9a227;
  --gold-deep: #8a6d15;
  --gold-soft: #faf3df;
  --ink: #1e2a38;
  --muted: #5b6b7f;
  --line: #d9e2ec;
  --card: #ffffff;
  --ok: #1f7a4d;
  --bad: #b3261e;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(14, 37, 66, 0.10);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: #f7f9fc;
  line-height: 1.65;
  font-size: 1rem;
}

h1, h2, h3, h4 { font-family: var(--serif); color: var(--navy); line-height: 1.25; margin: 1.2em 0 0.5em; }
h1 { font-size: 1.9rem; margin-top: 0; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0.7em 0; }
a { color: var(--navy); }
a:hover { color: var(--gold-deep); }

.container { max-width: 1080px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 620px; margin: 2rem auto; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--navy); color: #fff; padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- header / nav ---------------- */

.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.header-inner { max-width: 1080px; margin: 0 auto; padding: 0.6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; text-decoration: none; margin-right: auto; }
.brand:hover { color: #fff; }
.brand-mark {
  min-width: 2.2rem; height: 2.2rem; padding: 0 0.5rem; border-radius: 8px; background: var(--gold); color: var(--navy-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: bold; font-size: 0.95rem; letter-spacing: 0.03em; flex: none;
}
.brand-text { font-family: var(--serif); font-weight: bold; font-size: 1.05rem; line-height: 1.2; }
.brand-text em { display: block; font-style: normal; font-family: var(--sans); font-weight: normal; font-size: 0.72rem; color: #cdd9e8; }
.brand-mark-img { width: 2.2rem; height: 2.2rem; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); flex: none; }
.hero-logo { display: block; max-width: 620px; width: 100%; height: auto; margin: 0 0 1.2rem; }
/* The badge logo is square (not a wide banner), so it renders smaller and
   centered on the navy hero instead of stretching full-width. */
.hero-logo-badge { max-width: 300px; margin-left: auto; margin-right: auto; }

.nav-toggle { background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff; border-radius: 6px; padding: 0.35rem 0.6rem; font-size: 1.1rem; cursor: pointer; min-width: 44px; min-height: 44px; }
.main-nav { display: none; width: 100%; flex-direction: column; gap: 0.1rem; }
.main-nav.open { display: flex; }
.main-nav a { color: #e6edf6; text-decoration: none; padding: 0.7rem 0.2rem; border-top: 1px solid rgba(255,255,255,0.12); }
.main-nav a:hover { color: var(--gold); }
.main-nav a.nav-cta { color: var(--navy-deep); background: var(--gold); border-radius: 6px; padding: 0.7rem 0.9rem; text-align: center; font-weight: 700; border-top: none; margin-top: 0.4rem; }
.main-nav a.is-current { color: var(--gold); font-weight: 700; }

/* course cards (home + landing) */
.course-list { display: grid; gap: 1.2rem; grid-template-columns: 1fr; margin-bottom: 3rem; }
.course-card h2, .course-card h3 { margin-top: 0; }
.course-card h2 a { color: var(--navy); text-decoration: none; }
.course-card h2 a:hover { text-decoration: underline; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; color: #e6edf6; }
.username { font-weight: 700; }
.inline-form { display: inline; margin: 0; }
.link-btn { background: none; border: none; color: var(--gold); cursor: pointer; font-size: 0.9rem; text-decoration: underline; padding: 0.5rem; min-height: 44px; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  border: 1px solid var(--navy); background: #fff; color: var(--navy);
  border-radius: 8px; padding: 0.6rem 1.1rem; font-size: 1rem; font-weight: 600; text-decoration: none;
  cursor: pointer; line-height: 1.4; text-align: center;
}
.btn:hover { background: var(--navy-soft); color: var(--navy); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold-deep); color: var(--navy-deep); }
.btn-gold:hover { background: var(--gold-deep); color: #fff; }
.btn-outline { border-color: #fff; color: #fff; background: transparent; }
.btn-outline:hover { background: rgba(255,255,255,0.15); color: #fff; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1.1rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.toggle-btn, .tutor-btn {
  border-radius: 6px; padding: 0.4rem 0.8rem; font-size: 0.88rem; cursor: pointer; font-weight: 600;
  min-height: 44px; display: inline-flex; align-items: center;
}
.toggle-btn { background: var(--navy-soft); border: 1px solid var(--navy); color: var(--navy); }
.tutor-btn { background: #fff; border: 1px dashed var(--gold-deep); color: var(--gold-deep); }
.tutor-btn:hover { background: var(--gold-soft); }

/* ---------------- hero / landing ---------------- */

.hero { background: linear-gradient(135deg, var(--navy-deep), var(--navy) 60%, #1d4a80); color: #fff; border-radius: 0 0 var(--radius) var(--radius); margin: 0 -1rem; padding: 0 1rem; }
.hero-inner { max-width: 1080px; margin: 0 auto; padding: 3rem 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; color: var(--gold-deep); font-weight: 700; margin: 0 0 0.6rem; }
.hero .eyebrow { color: var(--gold); }
.hero h1 { color: #fff; font-size: 2.2rem; margin: 0 0 0.8rem; }
.lede { font-size: 1.1rem; color: #d7e2f0; max-width: 44rem; }
.cta-row { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.5rem; }

.how-it-works { padding: 2.5rem 0 1rem; }
.steps { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.step-num { display: inline-flex; width: 2rem; height: 2rem; border-radius: 50%; background: var(--navy); color: #fff; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 0.5rem; }
.step h3 { margin-top: 0.2rem; }
.step p { color: var(--muted); margin-bottom: 0; }

.roadmap { padding: 1.5rem 0; }
.section-sub { color: var(--muted); }
.card-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }

.module-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); position: relative; }
.module-card.is-done { border-left: 5px solid var(--ok); }
.module-num {
  position: absolute; top: 0.9rem; right: 1rem; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.module-card h3 { margin: 0 2.6rem 0.3rem 0; font-size: 1.1rem; }
.module-card h3 a { color: var(--navy); text-decoration: none; }
.module-card h3 a:hover { text-decoration: underline; }
.module-meta { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0 0.6rem; }
.mini-stats { display: flex; gap: 1.2rem; margin: 0.4rem 0 0.8rem; }
.mini-stats div { margin: 0; }
.mini-stats dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.mini-stats dd { margin: 0; font-weight: 700; color: var(--navy); }
.done-mark { color: var(--ok); font-weight: 700; }

.teaser { background: var(--gold-soft); border: 1px solid #e8d48a; border-radius: var(--radius); padding: 1.8rem; margin: 2rem 0 3rem; text-align: center; }
.teaser h2 { margin-top: 0; }

/* ---------------- auth ---------------- */

.auth-wrap { display: flex; justify-content: center; padding: 3rem 0; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 420px; }
.auth-card h1 { margin-top: 0; font-size: 1.6rem; }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.form-group input { width: 100%; padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: 6px; font-size: 1rem; }
.form-group input:focus { outline: 2px solid var(--gold); border-color: var(--gold-deep); }
.hint { color: var(--muted); font-size: 0.85rem; }
.auth-switch { text-align: center; margin-top: 1.2rem; color: var(--muted); }

.alert { border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1.2rem; }
.alert-error { background: #fdecea; border: 1px solid #f5c6c2; color: var(--bad); }

/* ---------------- generic page bits ---------------- */

.page-head { margin: 2rem 0 1.2rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card h2:first-child { margin-top: 0; }
.two-col { display: grid; gap: 1.2rem; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
.card-links { margin-bottom: 0; }

.grade-summary-main { display: flex; flex-direction: column; gap: 1rem; }
.grade-line { font-size: 1.3rem; display: flex; align-items: center; gap: 0.6rem; }
.grade-badge {
  display: inline-flex; width: 3rem; height: 3rem; border-radius: 50%; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 1.5rem; font-weight: bold; color: #fff; background: var(--muted); flex: none;
}
.grade-A { background: #1f7a4d; } .grade-B { background: #2f6db3; }
.grade-C { background: #8a6d15; } .grade-D { background: #b35a1e; } .grade-F { background: #b3261e; }
.grade-components { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin: 0; }
.grade-components div { background: var(--navy-soft); border-radius: 8px; padding: 0.6rem 0.8rem; }
.grade-components dt { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.grade-components dd { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--navy); }

.progress-bar { background: #e3eaf3; border-radius: 999px; height: 0.7rem; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, var(--navy), #2f6db3); height: 100%; border-radius: 999px; transition: width 0.4s ease; }

/* ---------------- module page ---------------- */

.module-head { margin: 2rem 0 0; }
.objectives-box { background: var(--navy-soft); border-left: 5px solid var(--gold); border-radius: 0 var(--radius) var(--radius) 0; padding: 1.2rem 1.4rem; margin: 1.2rem 0; }
.objectives-box h2 { margin-top: 0; font-size: 1.2rem; }
.objectives-box ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.objectives-box li { margin-bottom: 0.35rem; }

.sticky-subnav {
  position: sticky; top: 57px; z-index: 40; background: var(--navy-deep); border-radius: var(--radius);
  display: flex; gap: 0.2rem; overflow-x: auto; padding: 0.4rem; margin: 1rem 0 0;
}
.sticky-subnav a { color: #e6edf6; text-decoration: none; padding: 0.45rem 0.8rem; white-space: nowrap; font-size: 0.92rem; border-radius: 6px; }
.sticky-subnav a:hover { background: rgba(255,255,255,0.12); color: #fff; }

.module-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; margin: 1.2rem 0; box-shadow: var(--shadow); scroll-margin-top: 130px; }
.module-section > h2:first-child { margin-top: 0; border-bottom: 3px solid var(--gold); padding-bottom: 0.4rem; display: inline-block; }

.lecture-section h3 { border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
.lecture-body img { max-width: 100%; height: auto; }

.terms { margin: 0; }
.term { margin-bottom: 0.9rem; }
.term dt { font-weight: 700; color: var(--navy); font-family: var(--serif); font-size: 1.05rem; }
.term dd { margin: 0.15rem 0 0; color: var(--ink); }

.video-embed { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius); margin: 1rem 0; background: #000; }
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.video-note { color: var(--muted); font-style: italic; }
.watch-next { padding-left: 1.2rem; }

/* callouts */
.formula, .callout, .mistake { border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.2rem 0; }
.formula { background: var(--navy-soft); border: 1px solid var(--navy); border-left: 6px solid var(--navy); text-align: center; font-family: var(--serif); font-size: 1.2rem; color: var(--navy); }
.callout { background: var(--gold-soft); border: 1px solid #e8d48a; border-left: 6px solid var(--gold); }
.mistake { background: #fdecea; border: 1px solid #f5c6c2; border-left: 6px solid var(--bad); }
.formula p, .callout p, .mistake p { margin: 0.4em 0; }
.formula p:first-child, .callout p:first-child, .mistake p:first-child { margin-top: 0; }

/* journal entry + T-account tables (also usable by authored content) */
table.jentry, table.taccount { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; background: #fff; }
table.jentry caption, table.taccount caption { font-family: var(--serif); font-weight: bold; color: var(--navy); text-align: left; padding-bottom: 0.4rem; }
table.jentry th, table.jentry td, table.taccount th, table.taccount td { border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; }
table.jentry thead th, table.taccount thead th { background: var(--navy); color: #fff; }
table.jentry td.num, table.taccount td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.jentry tr.total td, table.taccount tr.total td { font-weight: 700; border-top: 2px solid var(--navy); }
table.taccount .t-head { text-align: center; font-weight: 700; background: var(--navy-soft); }

/* assignment */
.problem { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; background: #fcfdff; }
.problem h4 { margin-top: 0; color: var(--navy); }
.problem-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.8rem 0; }
.solution { background: var(--navy-soft); border-radius: 8px; padding: 1rem 1.2rem; margin: 0.8rem 0; border: 1px dashed var(--navy); }
.solution h5 { margin: 0 0 0.5rem; color: var(--navy); font-family: var(--serif); }
.self-check { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.95rem; cursor: pointer; margin-top: 0.6rem; }
.self-check input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--navy); flex: none; }
.save-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem; }
.save-status { color: var(--ok); font-weight: 600; }

/* quiz */
.quiz-question { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; background: #fcfdff; }
.quiz-question legend { font-weight: 600; padding: 0 0.4rem; }
.choice { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: 6px; cursor: pointer; margin: 0.25rem 0; }
.choice:hover { background: var(--navy-soft); }
.choice input { margin-top: 0.25rem; accent-color: var(--navy); flex: none; width: 1.1rem; height: 1.1rem; }
.choice-letter { font-weight: 700; color: var(--navy); flex: none; }
.question-feedback { margin-top: 0.8rem; border-radius: 8px; padding: 0.9rem 1rem; }
.question-feedback.is-correct { background: #e7f4ec; border: 1px solid #bfe3cd; }
.question-feedback.is-wrong { background: #fdecea; border: 1px solid #f5c6c2; }
.feedback-head { font-weight: 700; margin: 0 0 0.4rem; }
.is-correct .feedback-head { color: var(--ok); }
.is-wrong .feedback-head { color: var(--bad); }
.quiz-results { margin-top: 1.5rem; }
.quiz-score-banner { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }
.quiz-score-banner strong { color: var(--gold); font-size: 1.4rem; }
.q-module-tag { font-size: 0.8rem; color: var(--muted); margin: 0.1rem 0 0.4rem; }

.study-guide-body { background: #fcfdff; }
.ask-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; font-size: 1rem; font-family: var(--sans); margin-bottom: 0.8rem; }
.ask-box textarea:focus { outline: 2px solid var(--gold); }
.complete-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.done-note { margin: 0; font-weight: 600; color: var(--ok); }

.prev-next { display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; margin: 2rem 0 3rem; }

/* ---------------- exams ---------------- */

.exam-card .exam-meta { display: flex; gap: 1.4rem; margin: 0.6rem 0; }
.exam-card .exam-meta div { margin: 0; }
.exam-card .exam-meta dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.exam-card .exam-meta dd { margin: 0; font-weight: 700; font-size: 1.15rem; color: var(--navy); }
.exam-timer-wrap {
  position: sticky; top: 57px; z-index: 40; background: var(--navy-deep); color: #fff; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; gap: 0.8rem; padding: 0.6rem; margin: 1rem 0;
}
.exam-timer-label { font-size: 0.9rem; color: #cdd9e8; }
.exam-timer { font-family: var(--serif); font-size: 1.6rem; font-weight: bold; color: var(--gold); font-variant-numeric: tabular-nums; }
.exam-timer.danger { color: #ff8a80; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------------- labs ---------------- */

.lab-list { padding-left: 1.2rem; margin: 0.6rem 0 1rem; }
.table-scroll { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
table.lab-table { border-collapse: collapse; width: 100%; min-width: 560px; background: #fff; }
table.lab-table th, table.lab-table td { border: 1px solid var(--line); padding: 0.55rem 0.7rem; text-align: left; }
table.lab-table thead th { background: var(--navy); color: #fff; }
table.lab-table tbody th[scope="row"] { background: var(--navy-soft); font-weight: 600; white-space: nowrap; }
.lab-input { width: 100%; min-width: 7rem; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.lab-input:focus { outline: 2px solid var(--gold); border-color: var(--gold-deep); }
.lab-input-cell { background: #fffdf4; }
.lab-results { margin-top: 1.2rem; }
.check-row { display: flex; gap: 0.7rem; align-items: baseline; padding: 0.5rem 0.7rem; border-radius: 6px; margin-bottom: 0.4rem; }
.check-row.ok { background: #e7f4ec; }
.check-row.bad { background: #fdecea; }
.check-row .mark { font-weight: 700; flex: none; }
.check-row.ok .mark { color: var(--ok); } .check-row.bad .mark { color: var(--bad); }
.check-row .hint { color: var(--muted); font-size: 0.9rem; }

/* ---------------- gradebook ---------------- */

.final-grade-main { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1.2rem; }
.final-total { font-size: 2.4rem; font-weight: 800; color: var(--navy); margin: 0; font-family: var(--serif); }
.weights { list-style: none; padding: 0; margin: 1rem 0; }
.weights li { margin-bottom: 0.9rem; }
.weights li > div { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.weights span { color: var(--muted); font-size: 0.92rem; }
table.grade-table { border-collapse: collapse; width: 100%; background: #fff; }
table.grade-table th, table.grade-table td { border: 1px solid var(--line); padding: 0.55rem 0.7rem; text-align: left; }
table.grade-table thead th { background: var(--navy); color: #fff; }
table.grade-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.grade-table td.center { text-align: center; }

/* ---------------- videos ---------------- */

.video-list { display: grid; gap: 1.2rem; grid-template-columns: 1fr; margin-bottom: 3rem; }
.video-card h2 { margin-top: 0; font-size: 1.25rem; }
.video-byline { color: var(--muted); font-size: 0.9rem; margin-top: -0.4rem; }

/* ---------------- toast / footer ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(150%);
  background: var(--navy-deep); color: #fff; padding: 0.8rem 1.2rem; border-radius: 8px;
  box-shadow: var(--shadow); max-width: min(92vw, 480px); text-align: center; z-index: 200;
  transition: transform 0.25s ease; font-size: 0.95rem;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.site-footer { background: var(--navy-deep); color: #cdd9e8; margin-top: 3rem; }
.footer-inner { padding: 2rem 1rem; font-size: 0.9rem; }
.footer-inner strong { color: #fff; }
.footer-note { color: #93a7c0; font-style: italic; }

/* ---------------- breakpoints ---------------- */

@media (min-width: 640px) {
  h1 { font-size: 2.3rem; }
  .hero h1 { font-size: 2.8rem; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: repeat(2, 1fr); }
  .grade-summary-main { flex-direction: row; align-items: center; }
  .grade-summary-main > div:first-child { flex: 1; }
  .grade-components { flex: 1; }
  .video-list { grid-template-columns: repeat(2, 1fr); }
  .course-list { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .main-nav { display: flex; width: auto; flex-direction: row; align-items: center; gap: 1.1rem; }
  .main-nav a { border-top: none; padding: 0.3rem 0; }
  .main-nav a.nav-cta { margin-top: 0; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .module-section { padding: 2rem; }
}

/* ---------------- print (study guides) ---------------- */

@media print {
  .site-header, .site-footer, .sticky-subnav, .exam-timer-wrap,
  .problem-actions, .save-row, .complete-row, #ask, .prev-next, #toast,
  .no-print, .btn, button { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .container { max-width: none; padding: 0; }
  .module-section, .card { box-shadow: none; border: none; padding: 0; margin: 1rem 0; }
  .solution { display: block !important; border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
  h1, h2, h3 { color: #000; }
}

/* ============================================================
   Course Tutor — floating button, chat page, ask buttons
   ============================================================ */

/* Floating "Course Tutor" button (bottom-right, large touch target). */
.tutor-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 56px;
  padding: 0.6rem 1.1rem;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(14, 37, 66, 0.35);
  border: 2px solid var(--gold);
}
.tutor-fab:hover { color: #fff; background: var(--navy-deep); }
.tutor-fab:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tutor-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy-deep);
  font-family: var(--serif);
  font-weight: bold;
  font-size: 1.25rem;
  flex: none;
}

/* "Ask the Course Tutor" companion button next to "Help me understand". */
.tutor-ask-btn {
  display: inline-block;
  margin: 0.35rem 0 0.35rem 0.35rem;
  padding: 0.45rem 0.9rem;
  min-height: 44px;
  border-radius: 6px;
  border: 2px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.tutor-ask-btn:hover { background: var(--navy-deep); color: #fff; }
.tutor-ask-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Chat page layout. */
.tutor-chat {
  max-width: 760px;
  margin: 0 auto;
}
.tutor-log {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: 60vh;
  min-height: 40vh;
  overflow-y: auto;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tutor-msg { display: flex; flex-direction: column; max-width: 88%; }
.tutor-user { align-self: flex-end; align-items: flex-end; }
.tutor-assistant { align-self: flex-start; align-items: flex-start; }
.tutor-who {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.tutor-bubble {
  padding: 0.65rem 0.95rem;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.55;
}
.tutor-user .tutor-bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.tutor-assistant .tutor-bubble {
  background: var(--navy-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

/* Typing indicator dots. */
.tutor-typing .tutor-bubble { display: inline-flex; gap: 0.3rem; padding: 0.9rem 1.1rem; }
.tutor-typing .dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--muted);
  animation: tutor-blink 1.2s infinite;
}
.tutor-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.tutor-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tutor-blink {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}

/* Pre-attached question context chip. */
.tutor-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  padding: 0.5rem 0.8rem;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--ink);
}
.chip-tag { flex: 1; }
.chip-x {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.4rem;
  min-width: 44px;
  min-height: 44px;
}

/* Chat input row. */
.tutor-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  align-items: flex-end;
}
.tutor-form textarea {
  flex: 1;
  min-height: 56px;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 1rem;
  resize: vertical;
}
.tutor-form textarea:focus { border-color: var(--navy); outline: none; }
.tutor-form .btn { min-height: 56px; white-space: nowrap; }
.tutor-note { font-size: 0.85rem; color: var(--muted); margin-top: 0.7rem; }

.tutor-unavailable { border-left: 4px solid var(--gold); }

@media (min-width: 700px) {
  .tutor-log { max-height: 65vh; }
  .tutor-msg { max-width: 78%; }
}

@media print {
  .tutor-fab, .tutor-form, .tutor-ask-btn { display: none !important; }
}

/* ============================================================
   UX overhaul — nav, course sidebar, onboarding, progress rings
   ============================================================ */

/* ---- course layout: sidebar + main column (wide screens) ---- */

.course-layout { display: block; }
.course-main-col { min-width: 0; }

/* Mobile: collapsible top-of-page stepper (a <details> element). */
.course-stepper {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 1rem 0 0;
}
.course-stepper summary {
  list-style: none; cursor: pointer; padding: 0.8rem 1rem; min-height: 44px;
  display: flex; flex-direction: column; gap: 0.1rem; border-radius: var(--radius);
}
.course-stepper summary::-webkit-details-marker { display: none; }
.course-stepper summary::after {
  content: "\25BE"; position: absolute; right: 1rem; color: var(--muted); font-size: 1.2rem;
  transition: transform 0.2s ease;
}
.course-stepper { position: relative; }
.course-stepper[open] summary::after { transform: rotate(180deg); }
.course-stepper summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.stepper-main { font-weight: 700; color: var(--navy); padding-right: 1.8rem; }
.stepper-sub { color: var(--muted); font-size: 0.9rem; padding-right: 1.8rem; }
.course-stepper nav { padding: 0 0.5rem 0.6rem; }

/* Desktop: full sticky sidebar; the mobile stepper is hidden instead. */
.course-sidebar { display: none; }

.module-nav-list { list-style: none; margin: 0; padding: 0; }
.m-link {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.55rem;
  border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 0.93rem;
  min-height: 44px; line-height: 1.35;
}
a.m-link:hover { background: var(--navy-soft); }
a.m-link:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.m-num {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--navy-soft); color: var(--navy); font-size: 0.8rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.m-check { flex: none; width: 1.25rem; color: var(--ok); font-weight: 700; text-align: center; }
.m-title { flex: 1; }
.module-nav-item.is-done .m-num { background: var(--ok); color: #fff; }
.module-nav-item.is-current .m-link { background: var(--navy); color: #fff; font-weight: 700; }
.module-nav-item.is-current .m-num { background: var(--gold); color: var(--navy-deep); }
.module-nav-item.is-current .m-check { color: var(--gold); }

.sidebar-heading {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700; margin: 1.1rem 0 0.4rem;
}
.sidebar-heading:first-child { margin-top: 0; }
.sidebar-links { list-style: none; margin: 0; padding: 0; }
.sidebar-links a, .sidebar-links span[aria-current] {
  display: flex; align-items: center; padding: 0.45rem 0.55rem; min-height: 44px;
  border-radius: 8px; text-decoration: none; color: var(--navy); font-weight: 600; font-size: 0.95rem;
}
.sidebar-links a:hover { background: var(--navy-soft); }
.sidebar-links .is-current a, .sidebar-links .is-current span[aria-current] {
  background: var(--gold-soft); border: 1px solid #e8d48a;
}

@media (min-width: 900px) {
  .course-stepper { display: none; }
  .course-layout {
    display: grid; grid-template-columns: 17rem minmax(0, 1fr);
    gap: 1.5rem; align-items: start;
  }
  .course-sidebar {
    display: block; position: sticky; top: 76px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem 1.1rem;
    max-height: calc(100vh - 96px); overflow-y: auto;
  }
}

/* ---- module page step numbers ---- */

.module-section > h2 .step-num {
  display: inline-flex; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--navy); color: #fff; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; font-family: var(--sans); vertical-align: 0.15rem;
  margin-right: 0.45rem;
}
.subnav-num {
  display: inline-flex; width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: rgba(255,255,255,0.18); color: #fff; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; margin-right: 0.25rem; vertical-align: 0.1rem;
}

/* ---- home: onboarding, course cards, progress rings ---- */

.onboard { border-left: 6px solid var(--gold); margin-bottom: 1.5rem; }
.onboard h2 { margin-top: 0; }
.onboard-steps { margin: 0.6rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.7rem; }
.onboard-steps li::marker { color: var(--gold-deep); font-weight: 700; }

.course-card-top { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.course-card-top > div { min-width: 0; }

.progress-ring { width: 88px; height: 88px; flex: none; }
.ring-bg { fill: none; stroke: #e3eaf3; stroke-width: 9; }
.ring-fill {
  fill: none; stroke: var(--navy); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.ring-text {
  font-size: 17px; font-weight: 800; fill: var(--navy);
  text-anchor: middle; dominant-baseline: central; font-family: var(--sans);
}

.continue-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 0; }
.continue-note { color: var(--muted); font-size: 0.92rem; }

/* ---- account page ---- */

.kv-list { margin: 0 0 1.2rem; }
.kv-list div { display: flex; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.kv-list dt { font-weight: 700; color: var(--navy); min-width: 8rem; flex: none; }
.kv-list dd { margin: 0; }
.account-courses { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.account-courses li { padding: 0.55rem 0.7rem; background: var(--navy-soft); border-radius: 8px; }
.account-courses a { font-weight: 600; }

/* ---- motion: smooth anchor scrolling, full stop for reduced motion ---- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

/* Read-aloud controls + sentence highlighting (speechSynthesis) */
.ra-controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  background: var(--gold-soft); border: 1px solid var(--gold);
  border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0 0 1rem;
}
.ra-controls .ra-speed {
  font-weight: 600; color: var(--navy);
  display: inline-flex; gap: 0.4rem; align-items: center;
}
.ra-controls select {
  font: inherit; padding: 0.3rem; border-radius: 6px;
  border: 1px solid var(--navy); background: #fff; color: var(--navy-deep);
}
.ra-controls .ra-note { color: var(--navy); font-size: 0.9rem; }
.ra-sentence.ra-active {
  background: #ffe9a8; color: var(--navy-deep);
  border-radius: 3px; box-shadow: 0 0 0 2px #ffe9a8;
}
@media print { .ra-controls { display: none !important; } }
