:root {
  --cream: #F6F4F0;
  --paper: #FFFFFF;
  --ink: #212121;
  --ink-2: #5b5752;
  --ink-3: #8c877f;
  --line: #e7e2da;
  --pink: #F883C0;
  --pink-soft: #FEE2F0;
  --brand: #ff6a3d;
  --brand-ink: #212121;
  --ok: #2f7d55;
  --warn: #a8630b;
  --bad: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(33,33,33,.05), 0 6px 24px rgba(33,33,33,.06);
  --font-head: 'Jost', system-ui, sans-serif;
  --font-body: 'Work Sans', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 500; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-color: var(--brand); text-underline-offset: 3px; }
code { background: var(--pink-soft); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 560px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 500 .95rem/1 var(--font-body);
  padding: 12px 18px; min-height: 44px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: #faf8f5; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(.96); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(33,33,33,.05); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: .85rem; }
.btn.icon { width: 36px; min-height: 36px; padding: 0; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 6px; }
.hint { font-size: .82rem; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], textarea, select {
  width: 100%; font: inherit; color: inherit;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input[type=color] { width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; background: #fff; }
.field + .field { margin-top: 16px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--brand); }
.prefix { display: flex; align-items: stretch; }
.prefix span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; background: #faf8f5; color: var(--ink-3); font-size: .85rem; white-space: nowrap; }
.prefix input { border-radius: 0 10px 10px 0; }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: #efebe5; color: var(--ink-2); }
.badge.live { background: #dff2e7; color: var(--ok); }
.badge.pink { background: var(--pink-soft); color: var(--pink-ink, #9c2f68); }
.badge.warn { background: #fdf0dc; color: var(--warn); }

/* ---------- Top bar ---------- */
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.logo { font-family: var(--font-head); font-weight: 500; font-size: 1.15rem; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.logo-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--pink); box-shadow: inset 0 0 0 5px var(--pink-soft); }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a { text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: .92rem; color: var(--ink-2); }
.topnav a.active, .topnav a:hover { background: var(--pink-soft); color: var(--ink); }

main.app { padding: 32px 0 80px; }

/* ---------- Lists ---------- */
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: #fcfaf7; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }
.empty .big { font-family: var(--font-head); font-size: 1.25rem; color: var(--ink); margin-bottom: 6px; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.course-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; font: inherit; padding: 0; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.course-card .cover { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--pink-soft), #fff3e9); display: grid; place-items: center; font-family: var(--font-head); font-size: 2rem; color: var(--pink); }
.course-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.course-card .meta { padding: 14px 16px 16px; }
.course-card h3 { margin: 6px 0 2px; }

/* ---------- Curriculum editor ---------- */
.module { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-top: 12px; }
.module-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; background: #fcfaf7; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.module-head input { border-color: transparent; background: transparent; font-family: var(--font-head); font-size: 1.05rem; padding: 6px 8px; }
.module-head input:hover, .module-head input:focus { border-color: var(--line); background: #fff; }
.lesson-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px; border-top: 1px solid var(--line); }
.lesson-row:first-of-type { border-top: 0; }
.lesson-row .title { flex: 1; min-width: 0; cursor: pointer; padding: 6px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-row .title:hover { text-decoration: underline; text-decoration-color: var(--brand); }
.lesson-actions { display: flex; gap: 2px; }
.module-foot { padding: 10px 12px; border-top: 1px solid var(--line); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0; overflow-x: auto; }
.tabs button { font: 500 .95rem var(--font-body); background: none; border: 0; padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }

/* ---------- Drawer (lesson editor) ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(33,33,33,.35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--cream); z-index: 41; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Video & rich text ---------- */
.video { position: relative; aspect-ratio: 16/9; background: #111; border-radius: 12px; overflow: hidden; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose p, .prose ul { margin: 0 0 1em; }
.prose ul { padding-left: 1.3em; }
.prose li + li { margin-top: .3em; }
.prose a { word-break: break-word; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 100; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

/* ---------- Auth screen ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 440px; padding: 32px; }
.auth .logo { justify-content: center; margin-bottom: 24px; font-size: 1.75rem; gap: 12px; }
/* Photo background on the two login screens (builder access code, student login).
   The player build swaps this url for an embedded copy so downloaded courses keep it. */
.auth.photo { background: linear-gradient(rgba(18, 24, 24, .28), rgba(18, 24, 24, .28)), url(/assets/login-bg.jpg) 62% center / cover no-repeat; }

.notice { padding: 14px 16px; border-radius: 12px; background: var(--pink-soft); font-size: .92rem; }
.notice.warn { background: #fdf0dc; }
.notice.ok { background: #dff2e7; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--pink-soft); border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .card { padding: 18px; }
  .fields-2 { grid-template-columns: 1fr; }
  .topnav a { padding: 8px 9px; font-size: .85rem; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.card + .list { margin-top: 16px; }

/* Login box */
.google-btn { gap: 10px; border-color: #dadce0; font-weight: 500; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-3); font-size: .82rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Leave room for Netlify's "Powered by Netlify" badge (bottom-right) on free sites */
body.has-nl-badge { padding-bottom: 96px; }
body.has-nl-badge .drawer-foot { padding-bottom: 92px; }
body.has-nl-badge .toast { bottom: 100px; }

/* ---------- Lesson content (visual editor output) ---------- */
.prose { font-size: 1.05rem; }
.prose h2 { font-size: 1.55rem; margin: 1.4em 0 .5em; }
.prose h3 { font-size: 1.2rem; margin: 1.2em 0 .4em; }
.prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose img { border-radius: 10px; margin: 1.2em 0; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose blockquote { margin: 1.2em 0; padding: .2em 0 .2em 1.1em; border-left: 3px solid var(--brand); font-style: italic; color: var(--ink-2); }
.prose .callout { background: color-mix(in srgb, var(--brand) 10%, #fff); border: 1px solid color-mix(in srgb, var(--brand) 30%, #fff); border-radius: 12px; padding: 16px 20px; margin: 1.2em 0; }
.prose .callout > :last-child { margin-bottom: 0; }
.prose .video { margin: 1.2em 0; }
.prose a.lesson-btn { display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none; font-weight: 500; padding: 12px 22px; border-radius: 999px; margin: .3em 0; }
.prose a.lesson-btn:hover { filter: brightness(.96); }
