:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1a1c21;
  --muted: #646873;
  --line: #e4e1da;
  --brand: #e2580b;
  --brand-ink: #b9450a;
  --brand-soft: #fdeee4;
  --accent: #b9450a;       /* filled buttons and counts: 5.4:1 with white text */
  --accent-hover: #9c3a08;
  --on-accent: #ffffff;
  --side: #14161b;
  --side-ink: #d9d7d2;
  --side-muted: #8b8f98;
  --side-hover: #20232a;
  --ok: #1f7a4d;
  --ok-soft: #e4f3ea;
  --warn: #9a5b00;
  --warn-soft: #fbf0d9;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 27, .05), 0 2px 8px rgba(20, 22, 27, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1c2027; --ink: #ecebe7; --muted: #9a9ea8;
    --line: #2a2e37; --brand: #f26a1f; --brand-ink: #ff8a4a; --brand-soft: #2b1d14; --accent: #f26a1f; --accent-hover: #ff8a4a; --on-accent: #1a1c21;
    --side: #0b0c0f; --side-hover: #171a20; --ok: #4cc38a; --ok-soft: #13271d; --warn: #e3a64a;
    --warn-soft: #2a2213; --bad: #ff7b6e; --bad-soft: #2e1714; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.ai { color: var(--brand-ink); font-weight: 800; } /* AA contrast on light backgrounds */
.side .ai, .wordmark .ai { color: var(--brand); }
img { max-width: 100%; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--side) 248px, transparent 248px); }
.side {
  background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
}
.wordmark { font-weight: 800; letter-spacing: .02em; font-size: 1.15rem; color: #fff; padding: 4px 10px; display: block; }
.wordmark small { display: block; font-weight: 500; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); }
.wordmark:hover { text-decoration: none; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--side-muted); padding: 0 10px; margin-bottom: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 7px 10px;
  border-radius: 8px; font-size: .93rem;
}
.nav a:hover { background: var(--side-hover); text-decoration: none; }
.nav a.active { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--side-muted); flex: none; }
.nav a.active .dot { background: var(--brand); }
.side-foot { margin-top: auto; font-size: .85rem; }
.side-foot .who { display: flex; gap: 10px; align-items: center; padding: 8px 10px; }
.side-foot .who b { color: #fff; font-weight: 600; display: block; }
.side-foot form button { background: none; border: 0; color: var(--side-muted); padding: 7px 10px; cursor: pointer; font: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar .crumbs { color: var(--muted); font-size: .9rem; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.bell { position: relative; display: inline-flex; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: .85rem; }
.bell .count { background: var(--accent); color: var(--on-accent); border-radius: 999px; font-size: .7rem; padding: 0 6px; margin-left: 6px; font-weight: 700; }
.btn.menu-btn { display: none; }

main { padding: 26px 28px 60px; max-width: 1180px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.stack > * + * { margin-top: 14px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 18px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* ---------- posts ---------- */
.post-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
.post-card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.post-card h3 a { color: var(--ink); }
.post-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post-excerpt { color: var(--ink); opacity: .85; margin: 6px 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-actions { display: flex; gap: 14px; align-items: center; font-size: .85rem; color: var(--muted); }
.pin { font-size: .7rem; font-weight: 700; color: var(--brand-ink); background: var(--brand-soft); padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }
.body p:last-child { margin-bottom: 0; }
.comment { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.replies { margin-left: 44px; }
.replies .comment { border-top: 0; padding: 8px 0; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700;
  font-size: .85rem; flex: none; background: hsl(var(--hue, 20) 45% 42%);
}
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }

/* ---------- badges / tiers ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.slate { color: var(--muted); }
.badge.orange { color: var(--brand-ink); border-color: transparent; background: var(--brand-soft); }
.badge.blue { color: #2459b8; background: #e6eefc; border-color: transparent; }
.badge.green { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.gold { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.purple { color: #6b3fb8; background: #efe8fb; border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.blue { color: #8fb3ff; background: #16213a; } .badge.purple { color: #c3a6ff; background: #241a38; }
}
.level { font-size: .72rem; font-weight: 700; color: var(--brand-ink); }
.status { font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.status.ok { color: var(--ok); background: var(--ok-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.bad { color: var(--bad); background: var(--bad-soft); }

/* ---------- forms / buttons ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
.field { margin-bottom: 14px; }
.field .help, .helptext { font-size: .8rem; color: var(--muted); }
.errorlist { color: var(--bad); font-size: .85rem; margin: 4px 0; padding-left: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 6px; }
.btn.ghost:hover { color: var(--ink); }
.btn.ghost.on { color: var(--brand-ink); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.inline { display: inline; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); }
.messages .success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.messages .error { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.messages .info { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.messages .warning { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* ---------- courses ---------- */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.course-card { display: flex; flex-direction: column; gap: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.module { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.module + .module { margin-top: 12px; }
.module-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); gap: 10px; }
.module-head .step { font-size: .72rem; font-weight: 700; color: var(--brand-ink); text-transform: uppercase; letter-spacing: .1em; }
.module.locked .lesson-row { opacity: .55; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line); }
.lesson-row:first-of-type { border-top: 0; }
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: .7rem; color: #fff; }
.check.done { background: var(--ok); border-color: var(--ok); }
.tag { font-size: .7rem; font-weight: 600; color: var(--muted); border: 1px dashed var(--line); padding: 1px 6px; border-radius: 6px; }
.video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-placeholder { aspect-ratio: 16 / 9; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.milestone { border-left: 3px solid var(--brand); }

/* ---------- events ---------- */
.event-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.date-chip { text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; background: var(--surface-2); }
.date-chip b { display: block; font-size: 1.2rem; line-height: 1.1; }
.date-chip span { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-ink); font-weight: 700; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stat { font-size: 1.7rem; font-weight: 750; letter-spacing: -.02em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------- directory ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.person { display: flex; gap: 12px; align-items: flex-start; }
.person h3 { margin: 0; font-size: .98rem; }
.person h3 a { color: var(--ink); }

/* ---------- public pages ---------- */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-top { padding: 18px 28px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface); }
.public-top .wordmark { color: var(--ink); padding: 0; }
.public main { margin: 0 auto; width: 100%; }
.auth { max-width: 420px; margin: 7vh auto; }
.hero { padding: 40px 0 26px; max-width: 760px; }
.hero h1 { font-size: 2.2rem; }
.hero p { font-size: 1.08rem; color: var(--muted); }
.tier-block + .tier-block { margin-top: 34px; }
.offer { display: flex; flex-direction: column; gap: 12px; }
.offer .price { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.offer .price small { display: block; font-size: .85rem; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-top: 2px; }
.offer form { margin-top: auto; }
.seats { font-size: .82rem; font-weight: 600; color: var(--brand-ink); }

/* ---------- responsive ---------- */
@media (max-width: 980px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  .shell.open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .btn.menu-btn { display: inline-flex; }
  .shell { background: none; }
  .topbar { padding: 12px 16px; }
  main { padding: 18px 16px 50px; }
  .public-top { padding: 14px 16px; }
  .hero h1 { font-size: 1.7rem; }
  .event-row { grid-template-columns: 52px minmax(0, 1fr); }
  .event-row > :last-child { grid-column: 2; }
  table { display: block; overflow-x: auto; }
}

/* ---------- upgrade: accessibility, footer, messages, onboarding ---------- */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: 8px; border: 2px solid var(--brand); font-weight: 600; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
main:focus { outline: none; }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.main-col main { flex: 1; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 18px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.public .site-footer { margin-top: auto; }
.nav-count { margin-left: auto; background: var(--brand); color: #14161b; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 0 7px; line-height: 1.6; }
.legal { max-width: 760px; margin: 30px auto; }
.legal h2 { margin-top: 22px; }
.legal ul { padding-left: 20px; }
.danger-zone { border-color: var(--bad-soft); }
.btn.danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn.danger:hover { filter: brightness(.92); }

.convo-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; color: var(--ink); }
.convo-row:hover { text-decoration: none; }
.convo-row:hover b { text-decoration: underline; }
.convo-main { display: flex; flex-direction: column; min-width: 0; }
.convo-preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-row.unread .convo-preview { color: var(--ink); font-weight: 600; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.thread-wrap { max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.thread-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
.thread { max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: 78%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 9px 13px; }
.bubble-row.mine .bubble { background: var(--brand-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble small { color: var(--muted); font-size: .75rem; }
.bubble .body p { margin-bottom: .3rem; }

.onboarding { border-left: 3px solid var(--brand); }
.checklist { list-style: none; padding: 0; margin: 8px 0 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist li.done a, .checklist li.done span.label { color: var(--muted); text-decoration: line-through; }

@media (max-width: 760px) {
  .site-footer { padding: 16px; }
  .bubble { max-width: 90%; }
}
.checkout-note { font-size: .78rem; color: var(--muted); text-align: center; margin: 8px 0 0; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
