:root {
  --ink: #0F172A; --muted: #5B6472; --line: #E7EAEF; --teal: #0F766E; --teal-dark: #0B5B55;
  --teal-soft: #EFFAF8; --paper: #FFFFFF; --wash: #F7F9FA; --radius: 16px;
  --amber: #B45309; --amber-soft: #FEF6E7; --green: #15803D; --green-soft: #EDF9F0; --red: #B42318;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--ink); background: var(--wash); line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1,h2,h3,.serif { font-family: 'Fraunces', Georgia, serif; font-weight: 600; line-height: 1.2; font-variant-ligatures: none; font-feature-settings: "liga" 0, "dlig" 0, "hlig" 0; }
a { color: var(--teal); }
button { font-family: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 18px; }
.brand-logo { display: block; height: 30px; width: auto; }
.top-actions { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.top-actions .who { color: var(--muted); font-weight: 500; }
.linkbtn { background: none; border: none; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.linkbtn:hover { color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--teal); color: #fff; border: none; border-radius: 999px; padding: 11px 22px; font-weight: 600; font-size: 14.5px; text-decoration: none; cursor: pointer; transition: background .15s ease; }
.btn:hover { background: var(--teal-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 8px 16px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.done { background: var(--green-soft); color: var(--green); border: 1.5px solid #CBE9D4; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.notice { padding: 14px 18px; border-radius: 12px; font-size: 14px; }
.notice.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #F5E3BD; }
.notice.err { background: #FDF1F0; color: var(--red); border: 1px solid #F6D2CF; }
.hidden { display: none !important; }

/* login */
.auth { min-height: calc(100vh - 62px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 420px; padding: 36px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card p.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 15px; font-family: inherit; background: #fff; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--teal); }
.form-err { color: var(--red); font-size: 13.5px; margin: 4px 0 12px; min-height: 18px; }
.auth-card .btn { width: 100%; }

/* dashboard */
.page { padding: 32px 0 80px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.dash-head h1 { font-size: 30px; margin-bottom: 4px; }
.dash-head p { color: var(--muted); font-size: 14.5px; }
.progress-shell { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 30px; display: flex; align-items: center; gap: 20px; }
.ring { flex: none; }
.progress-meta { flex: 1; }
.progress-meta b { font-size: 17px; }
.progress-meta p { color: var(--muted); font-size: 13.5px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--teal); border-radius: 99px; transition: width .4s ease; }

.track-sec { margin-bottom: 34px; }
.track-sec > h2 { font-size: 21px; margin-bottom: 4px; }
.track-sec > p { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.mod-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; cursor: pointer; transition: box-shadow .15s ease, transform .15s ease; text-align: left; width: 100%; }
.mod-card:hover { box-shadow: 0 14px 30px -20px rgba(15,23,42,.3); transform: translateY(-2px); }
.mod-card .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mod-card .num { font-size: 12px; font-weight: 700; color: var(--teal); letter-spacing: .05em; text-transform: uppercase; }
.mod-card h3 { font-family: 'Inter', sans-serif; font-size: 15.5px; font-weight: 600; line-height: 1.35; margin-bottom: 8px; }
.mod-card .checks { display: flex; gap: 6px; }
.chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--wash); border: 1px solid var(--line); color: var(--muted); }
.chip.on { background: var(--green-soft); border-color: #CBE9D4; color: var(--green); }

/* module view */
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { text-decoration: none; font-weight: 600; }
.mod-head { margin-bottom: 22px; }
.mod-head .kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); margin-bottom: 6px; }
.mod-head h1 { font-size: 30px; margin-bottom: 6px; }
.mod-head .sum { color: var(--muted); font-size: 15px; }

.video-slot { border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; border: 1px solid var(--line); background: #0B1220; }
.video-slot .frame { position: relative; padding-top: 56.25%; }
.video-slot iframe, .video-slot video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-coming { background: linear-gradient(120deg, #0F2E2B, #134E4A); color: #D7F0EC; padding: 44px 32px; text-align: center; }
.video-coming .cam { font-size: 30px; margin-bottom: 10px; }
.video-coming h3 { color: #fff; font-size: 20px; margin-bottom: 6px; }
.video-coming p { font-size: 14px; color: #A7D8D2; max-width: 420px; margin: 0 auto; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab { border: 1.5px solid var(--line); background: #fff; padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-left: 7px; vertical-align: 1px; }

.lesson-body { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; }
.lesson-body h3 { font-size: 20px; margin: 26px 0 10px; }
.lesson-body h3:first-child { margin-top: 0; }
.lesson-body p { font-size: 15.5px; margin-bottom: 14px; color: #26303E; }
.lesson-body ul { margin: 0 0 14px 4px; padding-left: 20px; }
.lesson-body li { font-size: 15px; margin-bottom: 7px; color: #26303E; }
.lesson-body table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 14px; }
.lesson-body th { text-align: left; background: var(--wash); padding: 10px 12px; border: 1px solid var(--line); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lesson-body td { padding: 10px 12px; border: 1px solid var(--line); vertical-align: top; }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 26px; gap: 12px; flex-wrap: wrap; }

.wb-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 12px; display: flex; gap: 14px; }
.wb-item .n { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--teal-soft); color: var(--teal); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.wb-item p { font-size: 14.5px; color: #26303E; }

.quiz-q { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.quiz-q h4 { font-size: 15px; margin-bottom: 10px; }
.quiz-q textarea { width: 100%; min-height: 74px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14.5px; font-family: inherit; resize: vertical; }
.quiz-q textarea:focus { outline: none; border-color: var(--teal); }
.key { background: var(--green-soft); border: 1px solid #CBE9D4; border-radius: 10px; padding: 12px 14px; margin-top: 10px; font-size: 13.5px; color: #1E4620; }
.key b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--green); margin-bottom: 4px; }
.your-answer { background: var(--wash); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: #26303E; }
.your-answer b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }

/* admin */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.admin { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin th { text-align: left; padding: 12px 16px; background: var(--wash); border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.admin td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.admin tr:last-child td { border-bottom: none; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--wash); color: var(--muted); border: 1px solid var(--line); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-reveal { background: var(--amber-soft); border: 1px solid #F5E3BD; border-radius: 12px; padding: 14px 18px; margin-top: 16px; font-size: 14px; color: var(--amber); }
.pw-reveal code { background: #fff; border: 1px solid #F5E3BD; padding: 3px 10px; border-radius: 8px; font-size: 15px; color: var(--ink); margin: 0 6px; }
.admin-form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 22px; }
.admin-form h3 { font-size: 17px; margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 180px; margin-bottom: 0; }
.video-row { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.video-row:last-child { border-bottom: none; }
.video-row .lbl { flex: none; width: 210px; font-size: 13.5px; font-weight: 600; }
.video-row input { flex: 1; min-width: 200px; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 13.5px; font-family: inherit; }
.video-row input:focus { outline: none; border-color: var(--teal); }
.saved-tag { font-size: 12px; color: var(--green); font-weight: 600; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 100; box-shadow: 0 10px 30px rgba(15,23,42,.3); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
@media (max-width: 640px) {
  .lesson-body { padding: 22px; }
  .dash-head h1 { font-size: 24px; }
  .video-row .lbl { width: 100%; }
  table.admin { font-size: 13px; }
  table.admin th:nth-child(4), table.admin td:nth-child(4) { display: none; }
}

@media (max-width: 560px) { .brand-logo { height: 22px; } }

.wb-body { flex: 1; min-width: 0; }
.wb-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0 6px; }
.wb-field span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.wb-input { display: flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.wb-input:focus-within { border-color: var(--teal); }
.wb-input i { font-style: normal; color: var(--muted); font-weight: 600; }
.wb-input input { flex: 1; min-width: 0; border: none; outline: none; padding: 10px 0; font-size: 15px; font-family: inherit; background: transparent; }
.wb-text { width: 100%; min-height: 84px; margin-top: 12px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14.5px; font-family: inherit; resize: vertical; }
.wb-text:focus { outline: none; border-color: var(--teal); }
.wb-status { min-height: 22px; text-align: right; font-size: 13px; color: var(--muted); margin: 4px 2px 0; }
.wb-status.ok { color: var(--green, #1E7A3C); }
.wb-status.bad { color: var(--red, #B3261E); }
@media (max-width: 560px) { .wb-item { padding: 14px; gap: 10px; } }
