:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #18202e;
  --muted: #5d677a;
  --line: #e1e5ee;
  --soft: #f6f8fc;
  --accent: #2f5fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --done: #1f9254;
  --done-soft: #e3f5ea;
  --warn-bg: #fff5d6;
  --warn-ink: #6a4f00;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 14px rgba(20, 30, 60, .06);
  --LL: #f08a24;
  --KG: #d6457a;
  --EE: #14a3a8;
  --LE: #7a4fb5;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a;
    --card: #1b2029;
    --ink: #eceff5;
    --muted: #9aa3b5;
    --line: #2b3240;
    --soft: #161a22;
    --accent: #7ba3ff;
    --accent-ink: #0c1322;
    --accent-soft: #1f2b47;
    --done: #4cc98a;
    --done-soft: #16301f;
    --warn-bg: #3a3214;
    --warn-ink: #f1dc94;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 30px 0 10px; }
small { font-size: .84rem; color: var(--muted); }
code { font-size: .85rem; word-break: break-all; background: var(--soft); padding: 4px 8px; border-radius: 6px; }

/* Header */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.bar { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.logo { width: 36px; height: 36px; flex: none; }
img.logo { object-fit: contain; }
.logo rect { fill: var(--accent); }
.logo path { fill: none; stroke: var(--accent-ink); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-size: 1.02rem; }
.brand-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: .92rem; }
.account a { padding: 8px 12px; border-radius: 999px; text-decoration: none; font-weight: 600; }
.account a:hover { background: var(--accent-soft); }
.account span { color: var(--muted); padding: 0 8px; }

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 96px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.crumbs { margin-bottom: 12px; }
.crumbs a { display: inline-block; padding: 6px 0; text-decoration: none; font-weight: 600; }
.hero { margin-bottom: 20px; }
.eyebrow { display: block; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; min-height: 4px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.grid.classes { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: inherit; text-decoration: none; box-shadow: var(--shadow); border-left: 6px solid var(--tone, var(--line)); transition: transform .12s ease, box-shadow .12s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(20, 30, 60, .12); }
a.card:focus-visible, .btn:focus-visible, button:focus-visible, .upnext:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card .num { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tone, var(--muted)); }
.card .title { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.card .meta { font-size: .84rem; color: var(--muted); margin-top: auto; }
.card.done { background: var(--soft); box-shadow: none; }
.card.done .title { color: var(--muted); }
.class-card { padding: 20px; gap: 12px; }
.class-card .title { font-size: 1.3rem; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.next small { display: block; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .74rem; }
.chip { font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--tone, var(--done)); border-radius: 4px; }
.upnext { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 18px 20px; margin: 4px 0 8px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--tone); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.upnext small { display: block; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .76rem; color: var(--tone); }
.upnext b { font-size: 1.2rem; line-height: 1.3; }

.badge { display: inline-flex; align-items: center; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; align-self: flex-start; }
.badge.done { background: var(--done-soft); color: var(--done); }
.badge.next { background: var(--accent); color: var(--accent-ink); }
.badge.ready { background: var(--accent-soft); color: var(--accent); }

/* Buttons and fields */
button, .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 16px; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { min-height: 54px; padding: 12px 26px; font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 6px; }
input[type=text], input[type=number], input[type=password], select { min-height: 44px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); max-width: 100%; }
input[type=number] { width: 76px; }
input[type=text] { width: 190px; }
input.wide, input[type=password], select { width: min(320px, 100%); }
input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); min-height: 60px; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row small { display: block; }
.row small a { color: inherit; }
label.row { cursor: pointer; }
.row.add { flex-wrap: wrap; background: var(--soft); }
.row.focus { outline: 3px solid var(--accent); outline-offset: -3px; }
#addlink { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
#addlink input[name=url] { flex: 1 1 240px; width: auto; }
.tag { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--soft); color: var(--muted); white-space: nowrap; text-decoration: none; }
.tag.youtube { background: #e23b3b; color: #fff; }
.tag.vimeo { background: #17a7d6; color: #fff; }
.tag.rumble { background: #6fae2c; color: #fff; }
.tag.slides { background: var(--accent-soft); color: var(--accent); }
.tag.mp3, .tag.mp4, .tag.m4a { background: var(--done-soft); color: var(--done); }
.note { background: var(--warn-bg); color: var(--warn-ink); padding: 12px 14px; border-radius: 10px; font-size: .92rem; margin: 12px 0; }
.positions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .9rem; }
.positions label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
#settings .row { flex-wrap: wrap; }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 36px 24px; box-shadow: var(--shadow); }
.login .logo { width: 64px; height: 64px; margin-bottom: 12px; }
.login .btn { width: 100%; margin: 10px 0 14px; }

/* Lesson prep dialog */
dialog { border: 0; border-radius: 18px; background: var(--card); color: var(--ink); width: min(700px, calc(100vw - 24px)); max-height: 90vh; padding: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 15, 30, .55); }
dialog form { padding: 22px; }
dialog h2:first-child { font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0 0 4px; }
dialog .list { box-shadow: none; }
.foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin: 18px -22px -22px; padding: 14px 22px; background: var(--card); border-top: 1px solid var(--line); }

/* Phones */
@media (max-width: 640px) {
  main { padding: 18px 12px 110px; }
  .bar { padding: 8px 12px; }
  .account { width: 100%; margin-left: 0; overflow-x: auto; }
  .account:empty { display: none; }
  .account a { padding: 6px 10px; }
  .grid, .grid.classes { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; padding: 12px 14px; }
  .row .grow { flex-basis: 60%; }
  #settings .row > input, #settings .row > select, #settings .row > code { flex-basis: 100%; width: 100%; }
  .upnext .btn { width: 100%; }
  /* Keep the main lesson buttons within thumb reach. */
  .main-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; margin: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
  .main-actions button { flex: 1; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .foot button { flex: 1; }
}

/* Website / church computer pairing */
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.15em; letter-spacing: .08em; color: var(--ink); }
#setupform { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
#setupform input { width: 100%; text-align: center; font-size: 1.1rem; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 8px; }
.status-dot.on { background: var(--done); }

[hidden] { display: none !important; }
