:root {
  color-scheme: light;
  --paper: #f3efe6;
  --surface: #fffdf8;
  --surface-soft: #ebe4d6;
  --ink: #152c2a;
  --muted: #66706c;
  --line: #d8d1c4;
  --green: #176b5b;
  --green-dark: #0d453c;
  --orange: #dc7046;
  --yellow: #f2c75c;
  --danger: #a33d32;
  --shadow: 0 24px 70px rgba(32, 55, 50, .12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #10201e;
  --surface: #172b28;
  --surface-soft: #203834;
  --ink: #f5f0e6;
  --muted: #b7c3bf;
  --line: #38504b;
  --green: #77d4bd;
  --green-dark: #a6ebda;
  --orange: #ff9870;
  --yellow: #f4d77f;
  --danger: #ff9c90;
  --shadow: 0 24px 70px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 10% 4%, color-mix(in srgb, var(--yellow) 20%, transparent) 0 8rem, transparent 8.1rem), var(--paper);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.7;
}
button, input { font: inherit; }
a { color: inherit; }
form { margin: 0; }
.container { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 100; inset-block-start: .7rem; inset-inline-start: .7rem; padding: .55rem .8rem; border-radius: .65rem; background: var(--ink); color: var(--surface); translate: 0 -160%; }
.skip-link:focus { translate: 0; }
.site-header { border-block-end: 1px solid transparent; padding-block: 1.1rem; }
.header-inner, .footer-inner, .header-actions, .brand, .card-top, .card-footer, .page-title, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { justify-content: flex-start; font-weight: 900; text-decoration: none; }
.brand-mark { display: grid; width: 2.65rem; aspect-ratio: 1; place-items: center; border-radius: .9rem; background: var(--green-dark); color: var(--surface); }
[data-theme="dark"] .brand-mark, [data-theme="dark"] .primary-button { color: #10201e; }
.brand-mark svg { width: 1.35rem; }
.header-actions { justify-content: flex-end; flex-wrap: wrap; }
.nav-link, .text-button { border: 0; background: transparent; color: var(--muted); font-weight: 800; text-decoration: none; cursor: pointer; }
.nav-link:hover, .text-button:hover { color: var(--green); }
.user-chip, .tag, .status { border-radius: 999px; padding: .28rem .7rem; background: var(--surface-soft); color: var(--muted); font-size: .78rem; font-weight: 800; }
.theme-button { display: grid; width: 2.7rem; aspect-ratio: 1; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; }
.flash, .error-summary { margin-block: 1rem; border: 1px solid color-mix(in srgb, var(--green) 40%, var(--line)); border-radius: 1rem; padding: .8rem 1rem; background: color-mix(in srgb, var(--green) 9%, var(--surface)); }
.eyebrow { display: inline-flex; align-items: center; gap: .55rem; color: var(--green); font-size: .84rem; font-weight: 900; }
.eyebrow::before { width: 1.7rem; height: 2px; background: currentColor; content: ""; }
h1, h2, h3, p { margin-block-start: 0; }
h1, h2, h3 { line-height: 1.18; letter-spacing: -.035em; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: .7rem; border: 0; border-radius: 999px; padding: .78rem 1.15rem; background: var(--green-dark); color: var(--surface); font-weight: 900; text-decoration: none; cursor: pointer; box-shadow: 0 10px 28px color-mix(in srgb, var(--green) 18%, transparent); }
.primary-button:hover { translate: 0 -2px; }
.primary-button.full { width: 100%; }
.primary-button.compact { padding: .6rem .85rem; font-size: .84rem; }
.dashboard-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(270px, .8fr); align-items: center; gap: clamp(2rem, 7vw, 6rem); min-height: 58vh; padding-block: clamp(3rem, 7vw, 6rem); }
.dashboard-hero h1 { max-width: 10ch; margin-block: .7rem 1.2rem; font-size: clamp(3.2rem, 8vw, 6.6rem); }
.dashboard-hero p { max-width: 58ch; margin-block-end: 1.8rem; color: var(--muted); font-size: 1.08rem; }
.book-orbit { display: grid; aspect-ratio: 1; place-items: center; border: 1px solid var(--line); border-radius: 50%; }
.book-stack { width: min(270px, 72%); }
.book-stack > span { display: flex; align-items: center; justify-content: space-between; min-height: 4.1rem; margin-block-start: -.25rem; border: 1px solid var(--line); border-radius: .7rem 1.25rem 1.25rem .7rem; padding-inline: 1.2rem; background: var(--surface); box-shadow: var(--shadow); font-size: 1.05rem; font-weight: 900; rotate: -4deg; }
.book-stack > span:nth-child(2) { margin-inline-start: 1rem; rotate: 3deg; }
.book-stack > span:nth-child(3) { background: var(--orange); color: #201610; rotate: -1deg; }
.book-stack small { opacity: .65; }
.courses-section { padding-block: 2rem 6rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-block-end: 2rem; }
.section-head h2 { margin: .35rem 0 0; font-size: clamp(2rem, 5vw, 3.5rem); }
.section-head p { max-width: 38ch; margin: 0; color: var(--muted); }
.course-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.course-card { display: flex; min-height: 25rem; flex-direction: column; border: 1px solid var(--line); border-radius: 2rem; padding: clamp(1.4rem, 4vw, 2.2rem); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.course-card h3 { max-width: 13ch; margin-block: 3rem 1rem; font-size: clamp(2rem, 4vw, 3.1rem); }
.course-card > p { color: var(--muted); }
.card-footer { align-items: end; margin-block-start: auto; border-block-start: 1px solid var(--line); padding-block-start: 1rem; }
.card-footer > div { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--muted); font-size: .85rem; }
.status.allowed { background: color-mix(in srgb, var(--green) 14%, var(--surface)); color: var(--green); }
.course-card.locked { box-shadow: none; }
.course-card.locked h3, .course-card.locked > p { opacity: .7; }
.locked-message { margin-block-start: auto; border-block-start: 1px solid var(--line); padding-block-start: 1rem; color: var(--muted); font-size: .88rem; }
.empty-state { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 2rem; padding: 3rem; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.site-footer { border-block-start: 1px solid var(--line); padding-block: 1.4rem; color: var(--muted); font-size: .84rem; }
.site-footer p { margin: 0; }

.auth-shell { display: grid; grid-template-columns: 1fr minmax(320px, 470px); align-items: center; gap: clamp(2rem, 8vw, 7rem); min-height: calc(100vh - 170px); padding-block: 3rem 5rem; }
.auth-intro h1 { margin-block: .7rem 1rem; font-size: clamp(3rem, 7vw, 6rem); }
.auth-intro > p { max-width: 48ch; color: var(--muted); font-size: 1.08rem; }
.auth-visual { display: flex; gap: .5rem; margin-block-start: 2rem; }
.auth-visual span { border-radius: 999px; padding: .45rem .8rem; background: var(--surface); color: var(--green); font-weight: 800; box-shadow: var(--shadow); }
.auth-card { border: 1px solid var(--line); border-radius: 2rem; padding: clamp(1.5rem, 4vw, 2.3rem); background: var(--surface); box-shadow: var(--shadow); }
.form-heading { display: flex; align-items: center; gap: 1rem; margin-block-end: 1.5rem; }
.form-heading h2, .form-heading p { margin: 0; }
.form-heading p { color: var(--muted); font-size: .88rem; }
.form-icon { display: grid; width: 3rem; aspect-ratio: 1; place-items: center; border-radius: 1rem; background: var(--surface-soft); color: var(--green); font-size: 1.35rem; }
.stack-form { display: grid; gap: 1rem; }
.stack-form label:not(.check-row, .check-card) > span:first-child { display: block; margin-block-end: .35rem; font-size: .86rem; font-weight: 800; }
input { width: 100%; border: 1px solid var(--line); border-radius: .85rem; padding: .72rem .85rem; background: var(--paper); color: var(--ink); }
input:focus { border-color: var(--green); outline: 3px solid color-mix(in srgb, var(--green) 18%, transparent); }
.password-field { position: relative; display: block; }
.password-field input { padding-inline-end: 4.2rem; }
.password-field button { position: absolute; inset-block: 0; inset-inline-end: .4rem; border: 0; background: transparent; color: var(--green); font-size: .8rem; font-weight: 900; cursor: pointer; }
.check-row { display: flex; align-items: flex-start; gap: .55rem; color: var(--muted); font-size: .88rem; cursor: pointer; }
.check-row input, .check-card input { width: auto; margin-block-start: .3rem; accent-color: var(--green); }
.field-error { margin: -.7rem 0 0; color: var(--danger); font-size: .82rem; }

.admin-page { min-height: 70vh; padding-block: 3rem 6rem; }
.page-title { align-items: end; margin-block-end: 2rem; }
.page-title h1 { margin: .4rem 0; font-size: clamp(2.3rem, 5vw, 4rem); }
.page-title p { margin: 0; color: var(--muted); }
.error-summary { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--danger); }
.error-summary ul { margin-block-end: 0; }
.table-shell { border: 1px solid var(--line); border-radius: 1.5rem; overflow-x: auto; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { border-block-end: 1px solid var(--line); padding: .9rem 1rem; text-align: start; vertical-align: middle; }
th { background: var(--surface-soft); color: var(--muted); font-size: .8rem; }
tr:last-child td { border: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); }
.permission-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.muted { color: var(--muted); }
.outline-button { border: 1px solid var(--line); border-radius: 999px; padding: .45rem .8rem; background: var(--surface); color: var(--green); font-weight: 800; cursor: pointer; }
.modal { width: min(610px, calc(100% - 1.2rem)); max-height: calc(100vh - 2rem); border: 1px solid var(--line); border-radius: 1.6rem; padding: 1.5rem; overflow-y: auto; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(8, 20, 18, .68); backdrop-filter: blur(3px); }
.modal-head { align-items: flex-start; }
.modal-head h2, .modal-head p { margin: 0; }
.modal-head p { color: var(--muted); font-size: .86rem; }
.icon-close { display: grid; width: 2.3rem; aspect-ratio: 1; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 1.35rem; cursor: pointer; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
fieldset { border: 1px solid var(--line); border-radius: 1rem; padding: .8rem; }
legend { padding-inline: .4rem; font-size: .85rem; font-weight: 900; }
.permission-options { display: grid; gap: .5rem; }
.check-card { display: flex; align-items: flex-start; gap: .6rem; border: 1px solid var(--line); border-radius: .8rem; padding: .6rem; cursor: pointer; }
.check-card strong, .check-card small { display: block; }
.check-card small { color: var(--muted); }
.error-page { min-height: 72vh; padding-block: 7rem; text-align: center; }
.error-code { color: var(--orange); font-size: 1rem; font-weight: 900; letter-spacing: .25em; }
.error-page h1 { margin-block: .5rem 1rem; font-size: clamp(2.2rem, 5vw, 4rem); }
.error-page p { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

@media (max-width: 800px) {
  .dashboard-hero, .auth-shell { grid-template-columns: 1fr; min-height: auto; }
  .book-orbit { width: min(390px, 88%); margin-inline: auto; }
  .course-grid { grid-template-columns: 1fr; }
  .section-head, .page-title { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .container { width: min(100% - 1rem, 1120px); }
  .header-inner { align-items: flex-start; }
  .brand > span:last-child, .user-chip { display: none; }
  .header-actions { gap: .65rem; }
  .nav-link, .text-button { font-size: .8rem; }
  .dashboard-hero h1 { font-size: clamp(3rem, 17vw, 4.5rem); }
  .course-card { min-height: 22rem; border-radius: 1.35rem; }
  .card-footer { align-items: flex-start; flex-direction: column; }
  .footer-inner, .two-fields { grid-template-columns: 1fr; align-items: flex-start; flex-direction: column; }
  th:nth-child(2), td:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
