/* medimail — one stylesheet. Quiet on purpose: the people reading it are
   teachers writing lessons and students about to sit, and neither needs the
   page competing for attention. Contrast and tap targets come first. */
:root {
  color-scheme: light dark;
  --bg: #f6f3ec;
  --panel: #fffdf8;
  --panel-2: #efeadf;
  --line: #ddd5c4;
  --ink: #23302b;
  --muted: #5f6b65;
  --accent: #3f6b5a;
  --accent-ink: #ffffff;
  --sand: #e8c37a;
  --good: #2f7a55;
  --bad: #b5463b;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917; --panel: #1b221f; --panel-2: #232c28; --line: #33403a;
    --ink: #e9eee9; --muted: #a2b0a8; --accent: #8cc3a8; --accent-ink: #0f1a15; --sand: #e0bb73; --good: #7fd0a4; --bad: #f08a7e;
  }
}

* { box-sizing: border-box; }
/* Components set display; `hidden` must still win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { max-width: 780px; width: 100%; margin: 0 auto; padding: 36px 20px 72px; flex: 1; }
main.wide { max-width: 1100px; }
h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 14px; font-weight: 700; }
h2 { font-size: clamp(21px, 3vw, 26px); letter-spacing: -0.01em; margin: 38px 0 10px; line-height: 1.25; font-weight: 700; }
h3 { font-size: 18px; margin: 22px 0 8px; }
a { color: var(--accent); }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 50; }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }

/* Header & footer */
.site-header { display: flex; align-items: center; gap: 18px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; letter-spacing: -0.02em; font-size: 19px; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { color: var(--ink); text-decoration: none; padding: 6px 12px; border-radius: 99px; font-weight: 600; font-size: 15px; }
.site-header nav a:hover { background: var(--panel-2); }
.site-header nav a[aria-current="page"] { background: var(--panel-2); color: var(--accent); }
.account { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.account a:not(.btn) { color: var(--muted); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.sync-dot[data-state="synced"] { background: var(--good); }
.sync-dot[data-state="syncing"] { background: var(--sand); animation: pulse 1s infinite alternate; }
.sync-dot[data-state="error"], .sync-dot[data-state="offline"] { background: var(--bad); }
@keyframes pulse { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sync-dot { animation: none !important; } }
.claim { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 20px; background: var(--sand); color: #2b2210; font-weight: 600; }
.claim .btn { background: #2b2210; color: var(--sand); }
.site-footer { border-top: 1px solid var(--line); padding: 22px 20px; display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--ink); }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 11px 18px; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
input[type=number] { width: 110px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.check-label { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 10px 0; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { color: var(--bad); font-weight: 600; }
.ok { color: var(--good); font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warn { color: var(--bad); border-color: var(--bad); }
.honeypot { position: absolute; left: -5000px; }
.notice { background: color-mix(in srgb, var(--sand) 22%, var(--panel)); border: 1px solid var(--sand); border-radius: 12px; padding: 12px 14px; margin: 14px 0; }

/* Landing */
.hero { padding: 28px 0 10px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); }
.hero .lede { font-size: 20px; color: var(--muted); max-width: 42ch; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 12px 54px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.example { list-style: none; padding: 0; margin: 0; }
.example li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.example li:last-child { border-bottom: 0; }
.example .when { color: var(--muted); font-size: 14px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .plans { grid-template-columns: 1fr; } }
.plans ul { padding-left: 20px; }

/* Course list and builder */
.course-card { display: flex; flex-direction: column; gap: 6px; }
.course-card h3 { margin: 0; }
.course-card .actions { margin-top: auto; padding-top: 10px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; }
.lesson-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lesson-head .num { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; flex: none; }
.lesson-head input[type=text] { flex: 1; min-width: 200px; font-weight: 600; }
.lesson-when { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 14px; }
.lesson-when label { margin: 0; }
.audio-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.audio-row audio { max-width: 100%; }
.conflict { background: color-mix(in srgb, var(--sand) 22%, var(--panel)); border: 1px solid var(--sand); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.publish { position: sticky; bottom: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-top: 22px; box-shadow: 0 -6px 20px rgba(0,0,0,.05); }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share input { flex: 1; min-width: 220px; font-family: ui-monospace, monospace; font-size: 14px; }
ul.problems { margin: 6px 0 0; padding-left: 20px; color: var(--bad); font-size: 14px; }

/* Progress */
.table-wrap { overflow-x: auto; }
table.students { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.students th, table.students td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: middle; }
table.students th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dots i { width: 12px; height: 12px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); }
.dots i.out { background: color-mix(in srgb, var(--sand) 55%, var(--panel)); border-color: var(--sand); }
.dots i.done { background: var(--good); border-color: var(--good); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0; }
.legend .dots { display: inline-flex; vertical-align: middle; margin-right: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.stats .card { padding: 14px; }
.stats .n { font-size: 26px; font-weight: 750; }
.stats .k { color: var(--muted); font-size: 13px; }

/* Student */
.meter { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.learn-lesson { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; }
.learn-lesson.locked { background: transparent; border-style: dashed; color: var(--muted); padding: 12px 18px; }
.learn-lesson h3 { margin: 0 0 4px; }
.learn-lesson .body { margin-top: 12px; }
.learn-lesson audio { width: 100%; margin: 6px 0 12px; }
.learn-lesson.done h3::after { content: " ✓"; color: var(--good); }

/* Certificate */
.certificate { background: #fffdf8; color: #23302b; border: 10px double #3f6b5a; border-radius: 6px; padding: 48px 36px; text-align: center; margin: 12px 0 24px; }
.certificate .kicker { letter-spacing: .25em; text-transform: uppercase; font-size: 13px; color: #5f6b65; }
.certificate .who { font-size: clamp(28px, 5vw, 44px); font-family: Georgia, "Times New Roman", serif; margin: 18px 0 6px; }
.certificate .what { font-size: 20px; font-family: Georgia, "Times New Roman", serif; font-style: italic; margin: 6px 0 18px; }
.certificate .meta { font-size: 14px; color: #5f6b65; margin-top: 28px; }

@media print {
  .site-header, .site-footer, .claim, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .certificate { margin: 0; }
}
