:root {
  --navy: #2c5a7f;
  --navy-dark: #1f4262;
  --navy-soft: #e6eef5;
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #dfe3e8;
  --paper: #f6f4ef;
  --card: #ffffff;
  --done: #2f8f5b;
  --done-soft: #e3f3ea;
  --warn: #b5651d;
  --warn-soft: #fbeedd;
  --bad: #b3413a;
  --bad-soft: #f8e4e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 39, 51, .06), 0 4px 14px rgba(29, 39, 51, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  font-size: 16px;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 650; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
a { color: var(--navy); }
button { font: inherit; }
[hidden] { display: none !important; }

.container { max-width: 1040px; margin: 0 auto; padding: 28px 16px 64px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 8px; background: rgba(255,255,255,.14);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 22V14M14 22V10M20 22V16M26 22V8' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 22px; background-position: center; background-repeat: no-repeat;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-family: Fraunces, Georgia, serif; font-weight: 650; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .74rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a, .topnav button {
  color: #fff; text-decoration: none; background: transparent; border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px; padding: 5px 12px; font-size: .85rem; cursor: pointer; white-space: nowrap;
}
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.12); }
.topnav .who { font-size: .85rem; opacity: .85; margin-right: 4px; }
@media (max-width: 640px) { .topnav .who, .brand-sub { display: none; } }

/* ---------- Generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 600; color: var(--navy); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 500; font-size: .92rem;
}
.btn:hover { background: var(--navy-dark); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: var(--navy-soft); }
.btn.done { background: var(--done-soft); border-color: var(--done); color: var(--done); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.back { display: inline-block; margin-bottom: 14px; text-decoration: none; font-size: .9rem; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--navy-soft); font-size: .92rem; }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--done-soft); color: var(--done); }

/* ---------- Progress bars ---------- */
.bar { height: 8px; background: #e8ebef; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--navy); border-radius: 99px; transition: width .3s; }
.bar.complete > span { background: var(--done); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 32px 28px; }
.login-card h1 { font-size: 1.6rem; }
.tabs { display: flex; gap: 4px; background: #eef1f4; border-radius: 10px; padding: 4px; margin: 20px 0; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 500; }
.field input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.field input:focus { outline: 2px solid var(--navy-soft); border-color: var(--navy); }
.login-card .btn { width: 100%; padding: 11px; margin-top: 4px; }

/* ---------- Roadmap ---------- */
/* Module accent colours (one per module) */
.m1 { --mod: #2c5a7f; --mod-soft: #e4edf5; }
.m2 { --mod: #23806f; --mod-soft: #e0f1ed; }
.m3 { --mod: #7a4f93; --mod-soft: #efe7f4; }
.m4 { --mod: #b86a17; --mod-soft: #f8ecdc; }
.m5 { --mod: #b2473a; --mod-soft: #f7e3e0; }
.m6 { --mod: #4d7a31; --mod-soft: #e8f0e0; }

.btn.light { background: #fff; color: var(--navy-dark); border-color: #fff; }
.btn.light:hover { background: #eef3f8; }

.hero-band {
  display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 28px; align-items: center;
  background: linear-gradient(135deg, #1f4262 0%, #2c5a7f 55%, #3a7199 100%);
  color: #fff; border-radius: 18px; padding: clamp(22px, 4vw, 38px); margin-bottom: 22px;
  position: relative; overflow: hidden;
}
.hero-band::after { /* soft bar-chart motif */
  content: ""; position: absolute; right: -30px; bottom: -40px; width: 260px; height: 200px; opacity: .07; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 22V14M14 22V10M20 22V16M26 22V8' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
.hero-text h1 { color: #fff; margin: 4px 0 8px; font-size: clamp(1.7rem, 4vw, 2.4rem); }
.hero-text p { margin: 0 0 16px; opacity: .88; max-width: 560px; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; font-weight: 600; opacity: .75; }
.hero-note { font-size: .85rem; opacity: .75; margin: 0 !important; }
.hero-panel { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 14px; padding: 18px 20px; position: relative; z-index: 1; }
.hp-label { font-size: .8rem; opacity: .8; margin-bottom: 6px; }
.hp-num { font-family: Fraunces, Georgia, serif; font-size: 2rem; font-weight: 650; line-height: 1.1; }
.hp-num span { font-size: 1rem; opacity: .65; font-weight: 500; }
.hp-cap { font-size: .8rem; opacity: .8; }
.hp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.bar.on-dark { background: rgba(255,255,255,.2); margin-top: 8px; }
.bar.on-dark > span { background: #fff; }
@media (max-width: 760px) { .hero-band { grid-template-columns: 1fr; } }

/* Course introduction */
.intro { display: grid; grid-template-columns: 1.5fr 1fr; gap: 28px; padding: clamp(18px, 3vw, 26px); margin-bottom: 22px; }
.intro h2 { font-size: 1.15rem; margin-bottom: 6px; }
.intro h3 { font-size: 1rem; margin-bottom: 10px; }
.intro .prose { font-size: .96rem; color: #354250; }
.intro .prose p { margin: 0; }
.evalbar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; }
.evallegend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: .88rem; }
.evallegend li { display: flex; align-items: center; gap: 8px; }
.evallegend li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.evallegend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ev0 { background: #2c5a7f; } .ev1 { background: #23806f; } .ev2 { background: #b86a17; }
.ev3 { background: #7a4f93; } .ev4 { background: #b2473a; } .ev5 { background: #4d7a31; }
@media (max-width: 760px) { .intro { grid-template-columns: 1fr; gap: 18px; } }

/* Module jump chips */
.module-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 26px; }
.mod-chip { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; text-decoration: none; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px 5px 5px; }
.mod-chip b { background: var(--mod); color: #fff; width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; font-size: .72rem; }
.mod-chip:hover { border-color: var(--mod); background: var(--mod-soft); }

.module { margin-bottom: 34px; scroll-margin-top: 80px; }
.module-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.module-head .eyebrow { color: var(--mod); }
.module-head h2 { margin: 0; font-size: 1.25rem; }
.mod-badge { width: 38px; height: 38px; border-radius: 11px; background: var(--mod); color: #fff; display: grid; place-items: center;
  font-family: Fraunces, Georgia, serif; font-weight: 650; font-size: 1.15rem; flex: none; }
.mod-count { margin-left: auto; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

.session-card { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 9px; text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s; border-top: 4px solid var(--mod); }
a.session-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(29,39,51,.12); }
.session-card .num { font-size: .76rem; font-weight: 600; color: var(--mod); display: flex; justify-content: space-between; align-items: center; letter-spacing: .02em; }
.session-card .t { font-weight: 650; font-size: 1.02rem; line-height: 1.3; }
.session-card .q { font-family: Fraunces, Georgia, serif; font-style: italic; color: #4c5968; font-size: .95rem; line-height: 1.4;
  background: var(--mod-soft); border-radius: 8px; padding: 8px 10px; }
.session-card .foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.session-card .foot .bar > span { background: var(--mod); }
.session-card .status { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; }
.session-card.draft { border-style: dashed; border-top-style: solid; opacity: .9; }
.session-card.locked { box-shadow: none; background: rgba(255,255,255,.55); }
.session-card.locked .t, .session-card.locked .q { opacity: .7; }
.session-card.complete .status span:last-child { color: var(--done); font-weight: 600; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; letter-spacing: .02em; }
.t-quiz { background: #fbeedd; color: #8a4b12; }
.t-case { background: #dff1ee; color: #1d6b5d; }
.t-defense { background: #f8e4e2; color: #9b3a30; }
.t-activity { background: #ece6f4; color: #5f3d74; }

/* ---------- Session page ---------- */
.question {
  font-family: Fraunces, Georgia, serif; font-size: clamp(1.15rem, 2.6vw, 1.45rem); font-style: italic;
  border-left: 4px solid var(--navy); padding: 6px 0 6px 16px; margin: 16px 0 24px; color: var(--navy-dark);
}
.session-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.session-progress .bar { flex: 1; max-width: 360px; }

.items { display: flex; flex-direction: column; gap: 12px; }
.item { padding: 16px 18px; display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: start; }
.item.is-done { border-color: #bfe0cc; }
.item-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; background: var(--navy-soft); }
.item.is-done .item-icon { background: var(--done-soft); }
.item-title { font-weight: 600; }
.item-meta { font-size: .84rem; color: var(--muted); }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.item-extra { grid-column: 2 / -1; }
@media (max-width: 640px) {
  .item { grid-template-columns: 36px 1fr; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; margin-top: 6px; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Reading ---------- */
.reading { padding: clamp(20px, 4vw, 40px); max-width: 760px; }
.prose { font-size: 1.02rem; }
.prose h2 { margin-top: 1.4em; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .94rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose th { background: var(--navy-soft); }
.prose img { max-width: 100%; }
.reading-foot { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Quiz ---------- */
.quiz { max-width: 760px; }
.qcard { padding: 18px 20px; margin-bottom: 14px; }
.qnum { font-size: .8rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.qtext { font-weight: 600; margin-bottom: 12px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; background: #fff; }
.opt:hover { border-color: var(--navy); }
.opt input { margin-top: 4px; accent-color: var(--navy); }
.opt.correct { border-color: var(--done); background: var(--done-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.explain { margin-top: 10px; font-size: .92rem; padding: 10px 12px; border-radius: 8px; background: #f4f6f8; }
.score-banner { padding: 18px 20px; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.score-banner .big { font-family: Fraunces, Georgia, serif; font-size: 1.7rem; font-weight: 650; }

/* ---------- Instructor ---------- */
.table-wrap { overflow-x: auto; }
table.grid-table { border-collapse: separate; border-spacing: 0; font-size: .86rem; width: 100%; background: #fff; }
.grid-table th, .grid-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.grid-table th { position: sticky; top: 0; background: #f1f4f7; font-weight: 600; font-size: .78rem; }
.grid-table td.name, .grid-table th.name { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 170px; }
.grid-table th.name { background: #f1f4f7; z-index: 2; }
.cell { display: inline-block; min-width: 38px; padding: 2px 4px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.c0 { background: #f3f4f6; color: #9aa4ae; }
.c1 { background: #fbeedd; color: #8a4b12; }
.c2 { background: #e6eef5; color: var(--navy-dark); }
.c3 { background: var(--done-soft); color: var(--done); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.toolbar select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.section { margin-top: 36px; }
.qstat { padding: 14px 16px; margin-bottom: 10px; }
.qstat .bar { margin-top: 8px; max-width: 420px; }
.pill { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #eef1f4; color: var(--muted); }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 30px; }

/* ---------- Instructor tools ---------- */
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff8ec; border: 1px dashed #d9a95b; border-radius: 12px; padding: 12px 16px; margin: 14px 0 6px; }
.admin-bar.live { background: #eef8f2; border-color: #8cc4a3; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }
.b-private { background: #efe7f4; color: #5f3d74; }
.b-hidden { background: #eef1f4; color: #5d6b7a; }
.item.is-private { background: #fbf9fd; border-style: dashed; border-color: #cdb8dc; }
.item.is-hidden { opacity: .7; }
.item-admin { grid-column: 1 / -1; display: flex; gap: 14px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.linkbtn { background: none; border: 0; color: var(--navy); cursor: pointer; font-size: .82rem; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }
.add-form { padding: 20px 22px; margin-top: 18px; scroll-margin-top: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-top: 10px; }
.form-grid .span2 { grid-column: 1 / -1; }
.field select, .field input[type=number], .field input[type=url], .field input[type=file] { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; margin: 4px 0 6px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: #7a4f93; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Student view (preview) ---------- */
.topnav #preview-toggle.on { background: #fff; color: var(--navy-dark); }
#preview-banner { background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #ecd58f; padding: 8px 16px; font-size: .88rem; text-align: center; position: sticky; top: 52px; z-index: 9; }
#preview-banner button { margin-left: 10px; font-size: .82rem; border: 1px solid #c9a441; background: #fff; color: #6b4a00; border-radius: 99px; padding: 3px 10px; cursor: pointer; }
a.session-card.locked:hover { transform: translateY(-2px); }
