:root {
  --bg: #f3f0e9;
  --paper: #fffdf8;
  --paper-soft: #faf7ef;
  --ink: #171717;
  --muted: #5d5b55;
  --subtle: #858078;
  --line: rgba(23, 23, 23, .16);
  --line-strong: rgba(23, 23, 23, .28);
  --accent: #7a4b31;
  --accent-soft: #efe4d6;
  --danger: #8c3828;
  --radius: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, serif;
  font-weight: 400;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.page {
  min-height: 100vh;
  position: relative;
}

.shell {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 44px 0 64px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
  margin-bottom: 30px;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 12px;
  height: 42px;
  display: inline-block;
  background: var(--accent);
  flex: 0 0 auto;
  margin-top: 2px;
}

.brand-title {
  display: block;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.25;
}

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-actions form {
  margin: 0;
}

.topbar > .nav-actions > .button,
.topbar > .nav-actions > form > .button {
  width: 94px;
}

.identity {
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 9px 10px;
  background: var(--paper-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.button,
button.button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  padding: 11px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.button.secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button:hover {
  background: #2a2824;
  border-color: #2a2824;
  color: #fff;
}

.button.secondary:hover,
.button.ghost:hover {
  background: var(--paper-soft);
  border-color: var(--ink);
  color: var(--ink);
}

.button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(122, 75, 49, .22);
  outline-offset: 2px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

.panel,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

.panel-pad {
  padding: 28px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.08;
  font-weight: 400;
}

h1,
h2 {
  font-weight: 400;
}

h1 {
  font-size: 72px;
  max-width: 760px;
}

h2 {
  font-size: 42px;
}

h3 {
  font-size: 22px;
}

p {
  color: var(--muted);
  line-height: 1.8;
}

.hero-copy {
  margin: 20px 0 0;
  max-width: 680px;
  font-size: 15px;
}

.dashboard-stack {
  display: grid;
  gap: 36px;
}

.dashboard-course {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

.dashboard-course-title {
  margin-top: 8px;
  font-size: 58px;
  line-height: 1.08;
  letter-spacing: 0;
}

.dashboard-course-entry {
  align-self: start;
}

.dashboard-course-entry .nav-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 154px));
  justify-content: start;
  align-items: stretch;
}

.dashboard-course-entry .nav-actions .button {
  width: 100%;
  text-align: center;
}

.hero .panel .nav-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 154px));
  justify-content: start;
  align-items: stretch;
}

.hero .panel .nav-actions .button {
  width: 100%;
  text-align: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 30px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.metric {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 18px;
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 6px;
}

.login-box {
  align-self: start;
}

.form-row {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.form-row .button {
  width: 100%;
}

label {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0;
  padding: 12px 12px;
  min-height: 44px;
}

.error {
  color: var(--danger);
  background: #f7ece8;
  border: 1px solid rgba(140, 56, 40, .24);
  padding: 10px 12px;
  margin-top: 14px;
}

.notice {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(122, 75, 49, .22);
  padding: 10px 12px;
  margin-top: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  align-items: start;
}

.course-card {
  grid-column: span 8;
}

.side-card {
  grid-column: span 4;
}

.card {
  padding: 22px;
}

.course-entry-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 20px;
}

.course-entry-list.wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.course-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .54);
  padding: 14px;
}

.course-entry-kicker {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .06em;
}

.course-entry h3 {
  margin-top: 4px;
  font-size: 20px;
}

.course-entry p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.6;
}

.side-card > .button {
  width: 100%;
  margin-top: 10px;
}

.course-title-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.tag {
  display: inline-flex;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
  background: var(--paper-soft);
  white-space: nowrap;
}

.lesson-list {
  display: grid;
  gap: 0;
  margin-top: 0;
  border-top: 1px solid var(--line);
}

.lesson-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.lesson-item:hover {
  background: rgba(255, 253, 248, .66);
}

.lesson-index {
  color: var(--accent);
  font-size: 13px;
  font-weight: 400;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
}

.lesson-title {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.35;
}

.lesson-item p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.6;
}

.lesson-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 84px;
  gap: 6px;
  justify-content: flex-end;
}

.lesson-actions .button {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.1;
  background: rgba(255, 253, 248, .58);
  border-color: rgba(23, 23, 23, .26);
  color: var(--ink);
  white-space: nowrap;
}

.lesson-actions .button:first-child {
  background: rgba(23, 23, 23, .07);
  border-color: rgba(23, 23, 23, .42);
}

.lesson-actions .button:hover {
  background: var(--paper-soft);
  border-color: rgba(23, 23, 23, .54);
  color: var(--ink);
}

.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
}

.toc {
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.toc h3 {
  margin-top: 8px;
}

.toc a {
  display: block;
  padding: 10px 0;
  color: var(--muted);
  border-bottom: 1px solid rgba(23, 23, 23, .10);
  font-size: 14px;
  line-height: 1.45;
}

.toc a.active {
  color: var(--accent);
  font-weight: 400;
}

.reader-layout article > .card {
  margin-bottom: 18px;
}

.markdown {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 42px;
  font-size: 18px;
  max-width: 880px;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  margin: 32px 0 12px;
  font-weight: 400;
}

.markdown h1:first-child,
.markdown h2:first-child,
.markdown h3:first-child {
  margin-top: 0;
}

.markdown p {
  color: #25231f;
  line-height: 2;
}

.markdown h1 {
  font-size: 42px;
  line-height: 1.12;
}

.markdown h2 {
  font-size: 30px;
}

.markdown h3 {
  font-size: 22px;
}

strong,
b {
  font-weight: 400;
}

.markdown ul,
.markdown ol {
  padding-left: 24px;
  line-height: 1.9;
}

.markdown li {
  margin: 8px 0;
}

.markdown blockquote {
  margin: 24px 0;
  padding: 16px 0 16px 20px;
  border-left: 3px solid var(--accent);
  background: transparent;
  color: var(--muted);
}

.markdown code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--paper-soft);
  border: 1px solid rgba(23, 23, 23, .08);
  padding: 2px 5px;
}

.markdown pre {
  overflow: auto;
  padding: 16px;
  background: #1b1a17;
  color: #fffdf8;
  border-radius: 0;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

.markdown th,
.markdown td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.table-scroll {
  overflow: auto;
  margin-top: 20px;
}

.admin-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--paper);
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  background: var(--paper-soft);
  color: var(--ink);
}

.slide-frame-page {
  height: 100vh;
  overflow: hidden;
  background: #0d0c09;
}

.slide-toolbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  background: #171717;
  color: #fffdf8;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.slide-toolbar a {
  color: #fffdf8;
}

.slide-iframe {
  width: 100vw;
  height: calc(100vh - 50px);
  border: 0;
  background: #fff;
  display: block;
}

.watermark-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483000;
  opacity: 1;
  user-select: none;
  overflow: hidden;
  --wm-shift-x: 0px;
  --wm-shift-y: 0px;
}

.watermark-tile {
  position: absolute;
  width: auto;
  max-width: calc(100vw - 32px);
  color: rgba(96, 96, 96, .56);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  transform: translate(var(--wm-shift-x), var(--wm-shift-y)) rotate(var(--wm-rotate, 0deg));
  white-space: nowrap;
  text-shadow: none;
  mix-blend-mode: normal;
}

.watermark-center {
  max-width: calc(100vw - 48px);
  color: rgba(31, 41, 55, .18);
  font-size: 13px;
  font-weight: 700;
}

.slide-frame-page .watermark-tile {
  letter-spacing: 0;
}

.slide-frame-page.slide-watermark-injected > .watermark-layer {
  display: none;
}

.resource-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.resource-group {
  margin-top: 28px;
}

.resource-group-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.resource-group-title {
  font-size: 22px;
  line-height: 1.2;
}

.resource-group-heading p {
  margin: 6px 0 0;
  font-size: 13px;
}

.resource-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 16px 0;
}

.resource-item p {
  margin: 6px 0 0;
  font-size: 13px;
}

.resource-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.resource-toc-group {
  margin-top: 14px;
}

.resource-toc-heading {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .06em;
  margin: 18px 0 4px;
}

.footer-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .shell {
    width: min(100vw - 24px, 1180px);
    padding: 24px 0 44px;
  }

  .topbar,
  .hero,
  .dashboard-course,
  .reader-layout,
  .grid {
    display: block;
  }

  .nav-actions {
    justify-content: flex-start;
    margin-top: 18px;
  }

  .topbar > .nav-actions > .button,
  .topbar > .nav-actions > form > .button {
    width: 94px;
  }

  .hero .panel .nav-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-course-entry .nav-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-course + .dashboard-course,
  .hero .panel + .panel,
  .side-card,
  .course-card {
    margin-top: 18px;
  }

  h1 {
    font-size: 42px;
  }

  h2 {
    font-size: 28px;
  }

  .dashboard-course-title {
    font-size: 42px;
  }

  .panel-pad,
  .card {
    padding: 20px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .course-title-row {
    display: grid;
  }

  .course-entry-list.wide,
  .course-entry {
    grid-template-columns: 1fr;
  }

  .course-entry .button {
    width: 100%;
  }

  .lesson-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .lesson-actions {
    grid-auto-columns: minmax(0, 1fr);
    justify-content: flex-start;
    width: 100%;
  }

  .toc {
    position: static;
    max-height: none;
    margin-bottom: 18px;
  }

  .markdown {
    max-width: none;
    padding: 24px;
    font-size: 16px;
  }

  .resource-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .resource-group-heading {
    display: grid;
  }

  .resource-actions {
    justify-content: flex-start;
  }

  .slide-toolbar {
    align-items: flex-start;
    height: auto;
    min-height: 58px;
    padding: 10px 12px;
    flex-direction: column;
  }

  .slide-iframe {
    height: calc(100vh - 96px);
  }
}
