/* AG Team. Calm, one column, AgencyGod brand. Light by default, dark via system or toggle. */

:root {
  --bg: #FFFFFF;
  --surface: #F7F7F8;
  --surface-2: #EFEFF1;
  --ink: #0A0A0B;
  --ink-2: #3F3F46;
  --muted: #71717A;
  --line: #E7E7EA;
  --accent: #E52525;
  --accent-ink: #FFFFFF;
  --accent-soft: #FDECEC;
  --green: #16A34A;
  --green-soft: #E8F6EE;
  --warn: #B45309;
  --warn-soft: #FEF3E2;
  --focus: #E52525;
  --radius: 12px;
  --font-head: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --read: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0B;
    --surface: #141416;
    --surface-2: #1C1C1F;
    --ink: #F4F4F5;
    --ink-2: #D4D4D8;
    --muted: #A1A1AA;
    --line: #27272A;
    --accent: #FF3B3B;
    --accent-ink: #0A0A0B;
    --accent-soft: #2A1213;
    --green: #22C55E;
    --green-soft: #10261A;
    --warn: #F59E0B;
    --warn-soft: #2A1E0B;
    --focus: #FF3B3B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0B;
  --surface: #141416;
  --surface-2: #1C1C1F;
  --ink: #F4F4F5;
  --ink-2: #D4D4D8;
  --muted: #A1A1AA;
  --line: #27272A;
  --accent: #FF3B3B;
  --accent-ink: #0A0A0B;
  --accent-soft: #2A1213;
  --green: #22C55E;
  --green-soft: #10261A;
  --warn: #F59E0B;
  --warn-soft: #2A1E0B;
  --focus: #FF3B3B;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.3rem); font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
code { font: 500 .88em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.ic { flex: none; vertical-align: -0.2em; }

/* ---------- header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-in { max-width: var(--read); margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--font-head); font-weight: 750; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: .82rem; letter-spacing: 0; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions form { margin: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--surface); }
.icon-btn .ic-sun { display: none; }
:root[data-theme="dark"] .icon-btn .ic-sun { display: block; }
:root[data-theme="dark"] .icon-btn .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .ic-sun { display: block; }
  :root:not([data-theme="light"]) .icon-btn .ic-moon { display: none; }
}
.link-btn { background: none; border: 0; padding: 6px 8px; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link-btn:hover { color: var(--accent); }
.admin-nav { max-width: var(--read); margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.admin-nav a { padding: 8px 10px 10px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .93rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.admin-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- layout */
.wrap { max-width: var(--read); margin: 0 auto; padding: 36px 16px 80px; }
.wrap-wide { max-width: 1040px; }
.page-head { margin-bottom: 28px; }
.page-head > p:last-child { margin-bottom: 0; }
.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.crumbs { font-size: .9rem; margin-bottom: 22px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.crumbs a { text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { color: var(--muted); }
.crumb-sep::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--line); margin-right: 12px; vertical-align: middle; }

/* ---------- flash, tags, buttons */
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 22px; font-size: .95rem; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.flash-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.tag-ok { background: var(--green-soft); color: var(--green); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-off { background: var(--surface-2); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 600 .95rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-ink); }
.btn-danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.btn-row form { margin: 0; }

/* ---------- forms */
.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input:not([type]), select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 400 16px/1.3 var(--font-body);
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
select:disabled { opacity: .6; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.checks { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.checks legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; padding: 0; }
.form .check, .check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check-row { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.check-row .check-text { flex: 1; }

.auth { max-width: 400px; margin: 6vh auto 0; }
.auth h1 { font-size: 1.9rem; }
.auth-foot { margin-top: 18px; font-size: .92rem; }

/* ---------- cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; background: var(--bg); }
.card h2 { font-size: 1.05rem; margin-bottom: 12px; }
.card .form h2 { margin: 6px 0 0; }
.card-dim { background: var(--surface); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 20px; text-align: center; }
.empty p:last-child { margin: 0; }

/* ---------- dashboard */
.tracks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.track-row { display: flex; align-items: center; gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.track-main { flex: 1; min-width: 0; }
.track-row h2 { font-size: 1.3rem; margin: 0 0 2px; }
.track-row h2 a { text-decoration: none; }
.track-row .muted { margin: 0 0 10px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; min-width: 0; transition: width .3s; }
.bar span.done { background: var(--green); }
.bar-lg { height: 8px; margin: 18px 0 8px; }
.bar-sm { height: 4px; margin-top: 4px; max-width: 120px; }
.slack-note { margin-top: 36px; color: var(--muted); font-size: .9rem; display: flex; align-items: center; gap: 8px; }

/* ---------- track page */
.lessons { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lesson-row { display: flex; align-items: center; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.lesson-row:hover { background: var(--surface); color: var(--ink); }
.lesson-num { width: 20px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; text-align: right; }
.lesson-type { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface); color: var(--ink-2); flex: none; }
.lesson-text { flex: 1; min-width: 0; display: grid; }
.lesson-title { font-weight: 600; }
.lesson-meta { color: var(--muted); font-size: .86rem; }
.lesson-state { color: var(--line); display: inline-grid; }
.is-done .lesson-state { color: var(--green); }

/* ---------- lesson page */
.lesson-head h1 { margin-bottom: .35em; }
.draft-note { margin: 14px 0 0; font-size: .9rem; }
.done-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--green); background: var(--green-soft); padding: 4px 10px; border-radius: 99px; }
.player { border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16 / 9; margin-bottom: 10px; }
.player video { width: 100%; height: 100%; display: block; }
.soon { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 36px 24px; text-align: center; color: var(--muted); }
.soon h2 { color: var(--ink); margin: 10px 0 6px; }
.soon p { max-width: 420px; margin: 0 auto; }
.source { margin: -12px 0 18px; }
.toc { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; margin-bottom: 32px; }
.toc summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style-position: inside; }
.toc ol { margin: 0; padding: 4px 16px 16px 40px; columns: 1; }
.toc li { padding: 3px 0; }
.toc a { text-decoration: none; color: var(--ink-2); }
.toc a:hover { color: var(--accent); }

.lesson-foot { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.lesson-foot form { margin: 0 0 24px; }
.done-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--green); font-weight: 600; margin: 0; }
.done-line .link-btn { font-weight: 400; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager-link { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; font-weight: 600; }
.pager-link:hover { border-color: var(--ink-2); color: var(--ink); }
.pager-link .small { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.pager-next { text-align: right; justify-items: end; grid-column: 2; }

/* ---------- prose (markdown reading view) */
.prose { font-size: 1.04rem; line-height: 1.72; color: var(--ink); overflow-wrap: anywhere; }
.prose h2 { font-size: 1.5rem; margin: 2.2em 0 .6em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: 1.16rem; margin: 1.8em 0 .5em; }
.prose h4 { font-size: 1rem; margin: 1.5em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.prose li { margin: .3em 0; }
.prose li > p { margin: 0 0 .4em; }
.prose strong { font-weight: 700; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: .88rem; line-height: 1.55; }
.prose pre code { background: none; padding: 0; white-space: pre; }
.prose blockquote.say {
  position: relative; margin: 1.2em 0; padding: 30px 18px 14px 18px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-left: 4px solid var(--accent); color: var(--ink);
}
.prose blockquote.say::before {
  content: "SAY THIS"; position: absolute; top: 10px; left: 18px;
  font: 700 .68rem/1 var(--font-body); letter-spacing: .12em; color: var(--accent);
}
.prose blockquote.say p { margin: 0 0 .6em; }
.prose blockquote.say p:last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1.2em 0 1.4em; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .92rem; line-height: 1.5; }
.table-wrap th, .table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 120px; }
.table-wrap th { background: var(--surface); font-weight: 600; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }

/* admin tables reuse .table-wrap */
.table td, .table th { min-width: 0; }
.table tr.is-off td { opacity: .55; }
.progress-table td, .progress-table th { min-width: 110px; }
.cell-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-pct.is-done { color: var(--green); }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.plain-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plain-list .lesson-type { width: 30px; height: 30px; border-radius: 8px; }

.add-person { padding: 0; border: 0; margin-bottom: 26px; }
.add-person > summary { list-style: none; display: inline-flex; }
.add-person > summary::-webkit-details-marker { display: none; }
.add-person[open] { border: 1px solid var(--line); padding: 20px; }
.add-person[open] > summary { margin-bottom: 18px; background: var(--bg); color: var(--ink); border-color: var(--line); }
.add-person[open] > summary::after { content: " (close)"; font-weight: 400; color: var(--muted); }
.invite { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* ---------- library */
.lib-tools { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 12px 0 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.lib-tools input[type="search"] { font-size: 1rem; }
.lib-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.lib-row select { flex: 1; min-width: 0; }
.lib-count { margin: 8px 0 0; }
.lib-group { margin-bottom: 30px; }
.lib-group > h2 { font-size: 1.3rem; margin: 0 0 12px; padding-top: 12px; }
.lib-intro { margin-bottom: 14px; }
.entry { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--bg); }
.entry > summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: baseline; }
.entry > summary::-webkit-details-marker { display: none; }
.entry > summary::before { content: "+"; color: var(--accent); font-weight: 700; width: 12px; flex: none; }
.entry[open] > summary::before { content: "\2212"; }
.entry[open] > summary { border-bottom: 1px solid var(--line); }
.entry-body { padding: 14px 16px 6px; font-size: 1rem; }
.entry-body ul { padding-left: 1.1em; }
.entry mark, .lib mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- small screens */
@media (max-width: 640px) {
  .wrap { padding-top: 26px; }
  .grid-2 { grid-template-columns: 1fr; }
  .track-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .track-cta .btn { width: 100%; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .prose { font-size: 1rem; }
  .prose h2 { font-size: 1.3rem; }
  .copy-row { flex-direction: column; }
  .lesson-num { display: none; }
  .table-wrap th, .table-wrap td { min-width: 140px; }
  .table td:first-child { min-width: 170px; }
  /* People list: stack cells instead of scrolling sideways */
  .table-wrap:has(> .stack) { overflow: visible; }
  .stack thead { display: none; }
  .stack, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack tr { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
  .stack tr:last-child { border-bottom: 0; }
  .table-wrap .stack td { border: 0; padding: 2px 0; min-width: 0; }
  .table-wrap .stack td:first-child { min-width: 0; padding-bottom: 6px; }
}
.form > .btn:not(.btn-block) { justify-self: start; }
