:root {
  --red: #d7141f; --red-dk: #a80f18; --red-bg: #fdecec;
  --ink: #111; --ink-2: #3a3a3a; --muted: #6b6b6b; --line: #e4e4e4; --bg: #f6f5f3; --card: #fff;
  --ok: #1f7a3a; --ok-bg: #e8f5ec; --warn: #8a5a00; --warn-bg: #fff4dc;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--red-dk); }
img { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 28px; padding-bottom: 56px; min-height: 70vh; }

/* Header */
.top { background: #000; color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; margin-right: auto; }
.brand img { height: 30px; width: auto; }
.brand-sub { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; border-left: 1px solid #444; padding-left: 12px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #ddd; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 15px; }
.nav a:hover { background: #1d1d1d; color: #fff; }
.nav-user { color: #fff !important; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: #000; flex-direction: column; padding: 8px 16px 16px; }
  .nav-open .nav { display: flex; }
  .brand-sub { display: none; }
}

/* Type */
h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 32px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 20px 0 8px; }
.kicker { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 700; color: var(--red); margin-bottom: 6px; }
.lead { font-size: 18px; color: var(--ink-2); max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* Cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; font-size: 15px; }
.btn:hover { background: #2a2a2a; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: var(--red-dk); }
.btn-ghost { background: transparent; color: var(--ink); border-color: #ccc; }
.btn-ghost:hover { background: #fff; border-color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--red-dk); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* Forms */
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 15px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfcfcf; border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.form-narrow { max-width: 440px; margin: 0 auto; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; }
.check input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--red); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--red-bg); color: var(--red-dk); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* Hero */
.hero { background: #000 linear-gradient(135deg, #000 55%, #2a0306); color: #fff; border-radius: 18px; padding: clamp(28px, 6vw, 56px); margin-bottom: 24px; }
.hero h1 { color: #fff; font-size: clamp(30px, 5vw, 48px); }
.hero .lead { color: #d6d6d6; }
.hero .kicker { color: #ff5a62; }

/* Pills, progress */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eee; color: var(--ink-2); white-space: nowrap; }
.pill-red { background: var(--red-bg); color: var(--red-dk); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.bar { height: 8px; background: #ececec; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--red); border-radius: 99px; }

/* Module cards */
.mod { position: relative; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.mod-num { font-size: 13px; font-weight: 800; color: var(--red); letter-spacing: .08em; text-transform: uppercase; }
.mod h3 { margin: 0; font-size: 19px; }
.mod.locked { opacity: .55; }
a.mod:hover { border-color: var(--ink); }

/* Checklist */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #ccc; flex: none; display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.steps .done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps a { font-weight: 600; text-decoration: none; color: var(--ink); }
.steps a:hover { color: var(--red-dk); }
.steps .meta { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Lesson */
.video { position: relative; padding-top: 56.25%; background: #000; border-radius: var(--radius); overflow: hidden; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-ph { background: #111; color: #eee; border-radius: var(--radius); padding: 28px; }
.video-ph strong { color: #fff; }
.prose { font-size: 17px; max-width: 760px; }
.prose p { margin: 0 0 14px; }
.callout { border-left: 4px solid var(--red); background: #fff; padding: 14px 18px; border-radius: 0 10px 10px 0; }

/* Tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 15px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fafafa; }
.ws-table td { padding: 6px; }
.ws-table input, .ws-table textarea { padding: 8px; border-radius: 6px; min-width: 120px; }
.ws-table td.fixed { font-weight: 600; background: #fafafa; }
.grid-prog td, .grid-prog th { text-align: center; white-space: nowrap; }
.grid-prog td:first-child, .grid-prog th:first-child { text-align: left; }
.cell { display: inline-block; min-width: 38px; padding: 2px 6px; border-radius: 6px; font-size: 13px; font-weight: 700; }
.c0 { background: #f1f1f1; color: #999; } .c1 { background: var(--warn-bg); color: var(--warn); } .c2 { background: var(--ok-bg); color: var(--ok); } .cL { background: transparent; color: #bbb; }

/* Scale */
.scale { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 14px; }
.scale label { margin: 0; font-weight: 600; }
.scale input { position: absolute; opacity: 0; }
.scale span { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #ccc; border-radius: 10px; cursor: pointer; background: #fff; }
.scale input:checked + span { background: var(--red); color: #fff; border-color: var(--red); }
.scale input:focus-visible + span { outline: 2px solid var(--ink); }

/* Quiz */
.qz { margin-bottom: 22px; }
.qz .opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; font-weight: 400; cursor: pointer; background: #fff; }
.qz .opt input { margin-top: 4px; accent-color: var(--red); }
.qz .right { border-color: var(--ok); background: var(--ok-bg); }
.qz .wrong { border-color: var(--red); background: var(--red-bg); }
.score { font-size: 44px; font-weight: 800; }

/* Code */
.code { font: 800 34px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; background: #000; color: #fff; border-radius: 12px; padding: 14px 20px; display: inline-block; }
.copy { font-family: ui-monospace, Menlo, monospace; font-size: 14px; background: #f1f1f1; padding: 10px 12px; border-radius: 8px; word-break: break-all; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--red); }

.foot { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 14px; }
.foot a { color: var(--muted); }
.answer { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.say { margin: 4px 0; }
.say b { color: var(--red-dk); font-size: 12px; letter-spacing: .06em; }
details summary { cursor: pointer; font-weight: 600; }
@media print { .top, .foot, .btn, .nav-toggle { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
.grid > .card, .grid-2 > .card, .grid-2 > div > .card:first-child { margin-top: 0; }
/* Sticky save bar (sits below content, never on top of it) */
.savebar { position: sticky; bottom: 0; z-index: 5; margin: 24px -16px 0; padding: 12px 16px; background: rgba(246,245,243,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
.savebar .wrap { padding: 0; }
.pager .btn { max-width: 48%; white-space: normal; text-align: center; }
@media (max-width: 600px) { .pager { flex-direction: column-reverse; align-items: stretch; } .pager .btn { max-width: none; } .code { font-size: 26px; } .hero { padding: 24px 18px; } }
.lv { margin-top: 16px; }
.cert-actions { margin-bottom: 16px; }
@media (max-width: 600px) { .ws-table input, .ws-table textarea { min-width: 84px; } .tabs a { padding: 10px 10px; } }
/* Worksheet tables stack into labeled rows on phones */
@media (max-width: 600px) {
  .ws-table thead { display: none; }
  .ws-table, .ws-table tbody, .ws-table tr, .ws-table td { display: block; width: 100%; }
  .ws-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 10px; background: #fff; }
  .ws-table td { border: 0; padding: 4px 2px; }
  .ws-table td.fixed { background: transparent; font-size: 16px; padding-bottom: 2px; }
  .ws-table td:not(.fixed)[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  .ws-table input, .ws-table textarea { min-width: 0; width: 100%; }
  .tbl-wrap:has(.ws-table) { overflow: visible; }
}
