:root {
  --bg: #f4f2ec; --card: #fffdf8; --ink: #1c1f1d; --muted: #6a7068; --line: #e2ded4;
  --accent: #1f6f5c; --accent-ink: #f3efe4; --soft: #e6efe9; --danger: #a33a2a;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 6px 18px rgba(20, 30, 25, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --card: #1d2125; --ink: #e9e6de; --muted: #9aa198; --line: #2b3036;
    --accent: #4fb392; --accent-ink: #0f1a16; --soft: #1f2f29; --danger: #e0715f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #14171a; --card: #1d2125; --ink: #e9e6de; --muted: #9aa198; --line: #2b3036;
  --accent: #4fb392; --accent-ink: #0f1a16; --soft: #1f2f29; --danger: #e0715f;
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
a { color: inherit; }
main { max-width: 1080px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 26px; letter-spacing: -.01em; margin: 8px 0 4px; text-wrap: balance; }
h2 { font-size: 19px; margin: 28px 0 12px; display: flex; align-items: baseline; gap: 8px; }
h2 small { color: var(--muted); font-weight: 500; font-size: 14px; }
.muted { color: var(--muted); }
.flash { background: var(--soft); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; }
.err { color: var(--danger); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; }
.mark::after { content: ""; position: absolute; left: 8px; top: 5px; border-left: 9px solid var(--accent-ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
nav { display: flex; gap: 14px; align-items: center; }
nav a { text-decoration: none; color: var(--muted); }
.me summary { cursor: pointer; list-style: none; font-weight: 600; }
.me summary::-webkit-details-marker { display: none; }
.me { position: relative; }
.pop { position: absolute; right: 0; top: 30px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; width: 260px; box-shadow: var(--shadow); display: grid; gap: 12px; }

.stack { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { width: 100%; }
button, .btn { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login { max-width: 360px; margin: 10vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.login h1 { margin-top: 0; }

.hero { margin-bottom: 8px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 14px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { display: grid; grid-template-rows: auto 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-decoration: none; box-shadow: var(--shadow); transition: transform .12s; }
.card:hover { transform: translateY(-2px); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #0d1512; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; max-width: 100%; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 12px; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.tick { position: absolute; left: 8px; top: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.tick.part { background: rgba(0, 0, 0, .6); color: #fff; }
.card.done .thumb img { opacity: .75; }
.meta { padding: 10px 12px 12px; }
.date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card h3 { font-size: 15px; margin: 4px 0 0; line-height: 1.35; font-weight: 600; }

.lesson video { width: 100%; max-height: 72vh; background: #000; border-radius: 12px; margin: 12px 0; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.done { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.done input { width: auto; }
.desc { white-space: pre-wrap; margin-top: 20px; max-width: 70ch; overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.off td { color: var(--muted); }
.acts { display: flex; gap: 6px; flex-wrap: wrap; }
.acts button { padding: 4px 8px; font-size: 13px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.inline input { width: auto; }
.cb { flex-direction: row; align-items: center; gap: 6px; }
.cb input { width: auto; }
.ledit { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.ledit.off { opacity: .6; }
.lhead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lhead select { width: auto; }
.lhead button { padding: 5px 10px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; border-top: 1px solid var(--line); }
@media (max-width: 480px) { h1 { font-size: 22px; } .grid { grid-template-columns: 1fr 1fr; } .card h3 { font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }
