:root {
  --page: #f3f6f8;
  --paper: #fff;
  --ink: #172638;
  --muted: #536476;
  --line: #dbe4e9;
  --primary: #175c70;
  --nav: #142d40;
  --nav-hover: #244657;
  --on-dark: #c8dce4;
  --soft: #e7eff3;
  --notice: #eef5f7;
  --control-border: #bfcdd5;
  --serif: Georgia, "Times New Roman", serif;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: .6rem; left: .6rem; z-index: 2; padding: .75rem; background: var(--paper); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.sidebar { background: var(--nav); color: var(--paper); position: fixed; inset: 0 auto 0 0; width: 244px; padding: 2rem 1rem 1.25rem; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-family: var(--serif); font-size: 1.05rem; line-height: 1.2; margin-inline: .5rem; }
.brand-mark { display: grid; place-items: center; flex: 0 0 2.65rem; height: 2.65rem; border-radius: .6rem; border: 1px solid var(--on-dark); color: var(--on-dark); font-size: 1.65rem; }
.sidebar nav { margin-top: 2.6rem; display: grid; gap: .25rem; }
.nav-link { display: flex; align-items: center; gap: .65rem; min-height: 44px; border-radius: .55rem; padding: .56rem .7rem; font-size: .89rem; text-decoration: none; color: var(--on-dark); }
.nav-link:hover { background: var(--nav-hover); }
.nav-link[aria-current] { background: var(--primary); color: var(--paper); font-weight: 650; }
.nav-icon { display: grid; place-items: center; width: 1.45rem; height: 1.45rem; color: var(--on-dark); font-size: 1.08rem; }
.sidebar-footer { margin: auto .5rem 0; padding-top: 1.25rem; color: var(--on-dark); font-size: .72rem; }
.sidebar-footer span { margin-left: .25rem; }
.sidebar :focus-visible, .hero :focus-visible { outline-color: var(--on-dark); }
.menu-toggle { display: none; background: transparent; color: inherit; border: 1px solid var(--on-dark); border-radius: .5rem; min-height: 44px; padding: .4rem .75rem; }

.workspace { margin-left: 244px; }
.topbar { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem clamp(1rem, 4vw, 3.5rem); background: var(--paper); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.demo-label { display: inline-flex; gap: .45rem; align-items: center; color: var(--nav-hover); background: var(--soft); border-radius: 2rem; padding: .35rem .72rem; white-space: nowrap; font-size: .78rem; font-weight: 650; }
.demo-label span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--primary); }
main { max-width: 1300px; margin: 0 auto; padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 3.5rem) 3rem; }
main:focus { outline: none; }
.page-head { margin-bottom: 1.55rem; }
.page-head h1 { font: 500 clamp(2rem, 4.7vw, 3.75rem)/1.04 var(--serif); letter-spacing: -.045em; margin: 0 0 .65rem; overflow-wrap: anywhere; }
.page-head p, .muted { color: var(--muted); }
.page-head p { margin: 0; line-height: 1.55; max-width: 56ch; }
h2 { margin: 0; font: 500 1.48rem/1.15 var(--serif); }
h3 { margin: 0; font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
p { line-height: 1.55; }
p:last-child { margin-bottom: 0; }
.small { font-size: .85rem; }
.notice { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--notice); font-size: .86rem; line-height: 1.5; margin-bottom: 1rem; }
.card, .metric { min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: .85rem; }
.card { padding: clamp(1rem, 2.5vw, 1.5rem); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .35rem 1rem; margin-bottom: 1rem; }
.grid, .metrics { display: grid; gap: 1rem; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-top { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.stack { display: grid; gap: 1rem; }
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { padding: .95rem 1.1rem; }
.metric strong { display: block; font: 500 1.75rem/1.1 var(--serif); margin-bottom: .25rem; }
.metric span { color: var(--muted); font-size: .8rem; display: block; }
.hero { background: linear-gradient(115deg, var(--nav), var(--nav-hover)); color: var(--paper); border-color: var(--primary); display: flex; flex-direction: column; align-items: start; justify-content: center; min-height: 221px; }
.hero .overline { color: var(--on-dark); margin: 0 0 .7rem; font-weight: 650; font-size: .8rem; }
.hero h2 { font-size: clamp(1.6rem, 3.1vw, 2.45rem); max-width: 21ch; }
.hero p { color: var(--on-dark); margin: .55rem 0 .9rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; border: 1px solid var(--primary); border-radius: .5rem; padding: .48rem .85rem; color: #fff; background: var(--primary); text-decoration: none; font-size: .85rem; font-weight: 650; }
.button:hover { background: var(--nav); }
.button-light { background: var(--on-dark); color: var(--nav); border-color: var(--on-dark); }
.button-light:hover { background: var(--notice); }
.button-secondary { background: transparent; color: var(--primary); border-color: var(--control-border); }
.button-secondary:hover { background: var(--soft); }
.button:disabled { color: var(--muted); background: var(--soft); border-color: var(--line); }
.text-link { display: inline-flex; align-items: center; min-height: 32px; color: var(--primary); font-size: .85rem; font-weight: 650; text-underline-offset: .2em; }
.row-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--primary); font-weight: 650; text-underline-offset: .16em; }
.entries { margin: 0; padding: 0; list-style: none; }
.entries li { display: flex; gap: .75rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--line); min-width: 0; }
.entries li:first-child { padding-top: .15rem; }
.entries li:last-child { border-bottom: 0; padding-bottom: .1rem; }
.entries li > div { min-width: 0; }
.entries p { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; overflow-wrap: anywhere; }
.entry-time, .file-type { display: inline-flex; align-items: center; justify-content: center; text-align: center; flex: 0 0 auto; min-width: 3.15rem; border-radius: .4rem; color: var(--primary); background: var(--soft); padding: .35rem .42rem; font-size: .76rem; font-weight: 650; }
.tag { display: inline-block; border-radius: 2rem; background: var(--soft); color: var(--primary); padding: .25rem .6rem; font-size: .76rem; }
.module summary { display: flex; align-items: center; gap: .55rem; min-height: 44px; cursor: pointer; font-weight: 650; }
.module summary::before { content: "›"; color: var(--primary); font-size: 1.4rem; }
.module[open] summary::before { transform: rotate(90deg); }
.module .entries { border-top: 1px solid var(--line); padding-top: .4rem; }
.module .entries li { align-items: center; justify-content: space-between; flex-wrap: wrap; }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: .9rem 0; }
.field { display: grid; min-width: 0; gap: .35rem; flex: 1 1 10rem; color: var(--ink); font-size: .88rem; }
.field label, .field > span { font-weight: 650; }
input, select, textarea { min-width: 0; width: 100%; border-radius: .45rem; border: 1px solid var(--control-border); padding: .58rem .65rem; background: #fff; color: var(--ink); min-height: 44px; }
textarea { line-height: 1.5; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: var(--page); opacity: 1; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.week-day { min-width: 0; padding: .6rem; min-height: 6.6rem; border-radius: .45rem; background: var(--page); font-size: .8rem; overflow-wrap: anywhere; }
.week-day p { margin: .55rem 0 0; }
.section-gap { margin-top: 1rem; }
.breadcrumb { display: inline-flex; min-height: 44px; align-items: center; margin-bottom: .4rem; color: var(--primary); font-size: .88rem; text-underline-offset: .2em; }
.lesson-tags { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .8rem; }
.lesson-columns { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.fact-list { display: grid; gap: .65rem; margin: .8rem 0 0; }
.fact-list div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; }
select, textarea, .notice, .fact-list dd { overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .sidebar { width: 204px; }
  .workspace { margin-left: 204px; }
  .week { grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); }
}
@media (max-width: 820px) {
  .sidebar { position: static; width: auto; padding: .7rem 1rem; overflow: visible; }
  .sidebar-top { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
  .brand { margin: 0; font-size: .95rem; }
  .brand-mark { flex-basis: 2.3rem; height: 2.3rem; }
  .menu-toggle { display: block; }
  .sidebar nav { display: none; margin-top: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar nav.is-open { display: grid; }
  .sidebar-footer { display: none; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 48px; }
}
@media (max-width: 570px) {
  .grid, .dashboard-top, .lesson-columns { grid-template-columns: minmax(0, 1fr); }
  .hero { min-height: 0; }
  .metrics { gap: .45rem; }
  .metric { padding: .7rem .55rem; }
  .metric strong { font-size: 1.4rem; }
  .metric span { font-size: .74rem; }
  .topbar { gap: .4rem; }
}

.button[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.lesson-columns > .stack { align-content: start; }

.program-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.program-actions .button { padding-inline: .6rem; }
.program-feedback { color: var(--nav-hover); font-size: .88rem; overflow-wrap: anywhere; }
.program-feedback:empty { margin: 0; }
.module > .program-actions { margin: .35rem 0 .7rem; }
.module > .button { margin-top: .65rem; }
.program-actions, .row-link, .module summary { overflow-wrap: anywhere; }

.auth-gate { width: min(31rem, calc(100% - 2rem)); margin: clamp(1rem, 8vw, 5rem) auto; }
.auth-gate h1 { font: 500 clamp(1.7rem, 6vw, 2.6rem)/1.1 var(--serif); margin: 0 0 1rem; }
.topbar-actions { display: flex; align-items: center; justify-content: end; gap: .5rem; flex-wrap: wrap; }
.topbar-actions button { flex: 0 0 auto; }
.conflict { white-space: pre-wrap; overflow-wrap: anywhere; }
