/* Marten Learning content backend — no build step, no CDN. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --border: #dcdcd5;
  --border-strong: #c2c2b8;
  --text: #1c1c1a;
  --muted: #6b6b63;
  --accent: #1f5d50;
  --accent-soft: #e6f0ed;
  --danger: #a3341f;
  --danger-soft: #fbeae6;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --ok: #2b6a3f;
  --ok-soft: #e6f1e8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --surface: #1e2024; --surface-2: #26282d; --border: #34373d;
    --border-strong: #464a52; --text: #e8e8e4; --muted: #9a9a92; --accent: #6dbfa9;
    --accent-soft: #1c2f2b; --danger: #e08a72; --danger-soft: #33211d; --warn: #d7a54a;
    --warn-soft: #322a17; --ok: #7cc48c; --ok-soft: #1d2b21;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
  background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

/* layout */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .6rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.brand { font-weight: 650; color: var(--text); letter-spacing: -.02em; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: .9rem; padding: .2rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.whoami { font-size: .85rem; color: var(--muted); white-space: nowrap; }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.narrow { max-width: 780px; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .grow { flex: 1; min-width: 260px; }
.sub { color: var(--muted); font-size: .9rem; margin: 0; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.card-head {
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 1rem; }
.card-body.tight { padding: .5rem 1rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  font: inherit; font-size: .875rem; font-weight: 500; padding: .42rem .8rem;
  border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { font-size: .8rem; padding: .25rem .55rem; }
.btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* badges */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: .15rem .45rem; border-radius: 4px; background: var(--surface-2);
  color: var(--muted); white-space: nowrap; text-transform: uppercase;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* outline */
.program-head {
  display: flex; align-items: baseline; gap: .6rem; margin: 1.75rem 0 .6rem; flex-wrap: wrap;
}
.program-head:first-child { margin-top: 0; }
.program-head h2 { font-size: 1.1rem; }
.course-block { margin-bottom: .75rem; }
.course-head {
  display: flex; align-items: baseline; gap: .6rem; padding: .5rem 1rem;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap;
}
.course-head .grow { flex: 1; }
.course-block table { background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); }
.seq { width: 2.2rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* stats */
.stats { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .9rem; min-width: 108px; box-shadow: var(--shadow);
}
.stat .n { font-size: 1.45rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat.alert .n { color: var(--danger); }
.stat.warn .n { color: var(--warn); }

/* forms */
label { display: block; font-size: .85rem; font-weight: 550; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  width: 100%; font: inherit; font-size: .92rem; padding: .45rem .55rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.field { margin-bottom: .9rem; }
.field .helptext { display: block; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.field.check { display: flex; gap: .5rem; align-items: flex-start; }
.field.check input { width: auto; margin-top: .2rem; }
.field.check label { font-weight: 400; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger); font-size: .85rem; }

/* editor */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.editor textarea { min-height: 460px; font-size: .95rem; }
.preview {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: .7rem .85rem;
  background: var(--surface-2); min-height: 460px; overflow-y: auto; max-height: 70vh;
}
.preview ul, .preview ol { padding-left: 1.3rem; }
.md-toolbar { display: flex; gap: .35rem; margin-bottom: .4rem; flex-wrap: wrap; }
.md-toolbar button { font-size: .8rem; padding: .2rem .5rem; }
.counter {
  display: flex; gap: 1rem; font-size: .82rem; color: var(--muted);
  padding: .45rem .6rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; margin-top: .5rem; flex-wrap: wrap; font-variant-numeric: tabular-nums;
}
.counter b { color: var(--text); font-weight: 600; }
.counter .short { color: var(--warn); }
.counter .met { color: var(--ok); }

/* prose */
.prose { font-size: 1rem; line-height: 1.65; max-width: 68ch; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: .3rem; }

/* history timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 132px 1fr; gap: .75rem;
  padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .875rem;
}
.timeline li:last-child { border-bottom: none; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; }
.timeline .who { font-weight: 550; }
.timeline .kind {
  display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--border-strong); margin-right: .4rem; vertical-align: middle;
}
.timeline .kind-signed, .timeline .kind-reviewed { background: var(--ok); }
.timeline .kind-created { background: var(--accent); }
.timeline .kind-status { background: var(--warn); }

/* signoff */
.signoff-row {
  display: grid; grid-template-columns: 150px 1fr; gap: .75rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.signoff-row:last-child { border-bottom: none; }
.attest {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.messages li {
  padding: .55rem .8rem; border-radius: 6px; margin-bottom: .5rem; font-size: .9rem;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.messages li.success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.messages li.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.login-wrap { max-width: 360px; margin: 12vh auto; }
.choice-block {
  border: 1px solid var(--border); border-radius: 6px; padding: .7rem;
  margin-bottom: .6rem; background: var(--surface-2);
}
.correct-flag { color: var(--ok); font-weight: 600; }
