:root {
  --bg: #f8f5ef;
  --surface: #ffffff;
  --text: #143331;
  --muted: #5c716f;
  --border: #e4e0d6;
  --accent: #0a8580;
  --accent-2: #e2648f;
  --gold: #d4a63a;
  --gold-soft: #f7e7bd;
  --accent-soft: #def4f2;
  --gradient: linear-gradient(135deg, #0a8f8a 0%, #16a39b 50%, #e06b98 100%);
  --danger: #c4321f;
  --warn: #9a6200;
  --warn-soft: #fff1d1;
  --ok: #157a42;
  --ok-soft: #e1f5e9;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 51, 49, .04), 0 8px 24px -12px rgba(20, 51, 49, .12);
  --shadow-lg: 0 2px 4px rgba(20, 51, 49, .05), 0 20px 40px -16px rgba(10, 143, 138, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background:
    radial-gradient(900px 400px at 100% -10%, rgba(10, 143, 138, .10), transparent 60%),
    radial-gradient(700px 360px at -10% 0%, rgba(226, 100, 143, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent); }
h1 { font-size: 2rem; margin: 0 0 .5rem; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; font-weight: 700; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code { background: var(--accent-soft); padding: 0 .3em; border-radius: 4px; }

.container { max-width: 960px; margin: 0 auto; padding: 28px 16px 80px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.warn-text { color: var(--warn); }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }
.prose { white-space: pre-wrap; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 2px solid transparent;
  border-image: none; border-bottom-color: var(--accent);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; color: var(--text); text-decoration: none; font-size: 1.1rem;
}
.brand::before {
  content: ''; width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, #0a8f8a, #2cc3b9);
  box-shadow: 0 4px 12px -4px rgba(10, 143, 138, .6);
}
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-weight: 500; transition: background .2s, color .2s;
}
.topbar nav a:hover { color: var(--text); background: rgba(10, 143, 138, .06); }
.topbar nav a.active { background: var(--text); color: #fff; }
.user { display: flex; align-items: center; gap: 8px; }

/* ---- Hero header ---- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: var(--gradient); border-radius: 24px; padding: 32px 28px; margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ''; position: absolute; inset: auto -60px -120px auto; width: 280px; height: 280px;
  border-radius: 50%; background: rgba(227, 176, 75, .28);
}
.hero::before {
  content: ''; position: absolute; top: -80px; left: 20%; width: 180px; height: 180px;
  border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.hero h1 { position: relative; margin: 0; font-size: 2.2rem; }
.hero p { position: relative; margin: 8px 0 0; opacity: .9; font-size: 1.05rem; }
.hero .crumbs, .hero .crumbs a { color: rgba(255, 255, 255, .8); }
.hero .btn.ghost { position: relative; color: #fff; border-color: rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .1); }
.hero-badge {
  position: relative; display: inline-block; margin-bottom: 10px; padding: 4px 12px; border-radius: 999px;
  background: var(--gold-soft); color: #6b4e12; font-size: .85rem; font-weight: 600;
}

/* ---- Layout pieces ---- */
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin: 18px 0; box-shadow: var(--shadow);
}
details.panel summary { cursor: pointer; font-weight: 600; }
.danger-zone { border-color: #f3c9c2; box-shadow: none; background: #fffaf9; }

/* ---- Course cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 8px; }
.card {
  position: relative; display: block; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 0 22px 22px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: translate .25s cubic-bezier(.22, 1, .36, 1), box-shadow .25s, border-color .25s;
}
.card::before {
  content: ''; display: block; height: 96px; margin: 0 -22px 0;
  background: var(--gradient);
}
.card:nth-child(3n+2)::before { background: linear-gradient(135deg, #e7bd57, #c38f2a); }
.card:nth-child(3n+3)::before { background: linear-gradient(135deg, #f08db3, #d9578a); }
.card:hover { translate: 0 -4px; box-shadow: var(--shadow-lg); border-color: transparent; }
.card-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin-top: -28px; margin-bottom: 10px;
  border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow); font-size: 1.6rem; position: relative;
}
.card h2 { margin: 0 0 4px; }
.card p { margin: 0; }
.card .go { display: inline-block; margin-top: 14px; color: var(--accent); font-weight: 600; font-size: .95rem; }

/* ---- Lecture timeline ---- */
.lecture-list { list-style: none; padding: 0; margin: 8px 0; position: relative; display: grid; gap: 12px; }
.lecture-list::before {
  content: ''; position: absolute; top: 24px; bottom: 24px; right: 37px; width: 2px;
  background: linear-gradient(var(--accent), var(--accent-2)); opacity: .25; border-radius: 2px;
}
.lecture-list a {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: translate .25s cubic-bezier(.22, 1, .36, 1), box-shadow .25s, border-color .25s;
}
.lecture-list a:hover { translate: -4px 0; border-color: rgba(10, 143, 138, .35); box-shadow: var(--shadow-lg); }
.lecture-list .num {
  flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--gradient); color: #fff; font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 6px 14px -6px rgba(10, 143, 138, .7);
}
.lecture-list .title { flex: 1; font-weight: 600; }
.lecture-list .arrow { color: var(--muted); transition: translate .25s; }
.lecture-list a:hover .arrow { translate: -4px 0; color: var(--accent); }

/* ---- Manage: lesson rows ---- */
.lecture-list.manage .title { display: grid; gap: 6px; }
.lesson-badges { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }
.badge.muted-badge { background: #f3f0ea; color: var(--muted); }
.lecture-list.manage::before { right: 37px; }
details.panel > summary { list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel > summary::before { content: '›'; display: inline-block; transition: rotate .2s; font-size: 1.3rem; color: var(--muted); }
details.panel[open] > summary::before { rotate: 90deg; }
.details-body { margin-top: 16px; }
.muted-panel { background: transparent; border-style: dashed; box-shadow: none; }
.empty .btn { margin-top: 8px; }

/* ---- Lesson page: the three big buttons ---- */
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 8px 0 12px; }
.action-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 30px 18px 26px; border-radius: 22px; text-decoration: none; color: #fff;
  background: var(--gradient); box-shadow: var(--shadow-lg);
  transition: translate .25s cubic-bezier(.22, 1, .36, 1), box-shadow .25s, filter .25s;
}
.action-card:nth-child(2) { background: linear-gradient(135deg, #deb04c, #b9821f); box-shadow: 0 20px 40px -16px rgba(185, 130, 31, .5); }
.action-card:nth-child(3) { background: linear-gradient(135deg, #f08db3, #d6517f); box-shadow: 0 20px 40px -16px rgba(214, 81, 127, .5); }
.action-card::after {
  content: ''; position: absolute; width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); top: -60px; left: -50px;
}
.action-card:hover { translate: 0 -6px; filter: saturate(1.1) brightness(1.04); }
.action-icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px;
  background: rgba(255, 255, 255, .22); font-size: 1.9rem; margin-bottom: 6px;
}
.action-title { font-size: 1.3rem; font-weight: 800; }
.action-text { font-size: .92rem; opacity: .9; }
.action-card.disabled {
  background: var(--surface); color: var(--muted); border: 2px dashed var(--border); box-shadow: none; cursor: default;
}
.action-card.disabled::after { display: none; }
.action-card.disabled .action-icon { background: #f3f0ea; filter: grayscale(1); opacity: .6; }
.hint.center { text-align: center; }

.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.link-list a {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: #f1faf9; border: 1px solid #d3efec; text-decoration: none; color: var(--text);
  transition: border-color .2s, translate .2s;
}
.link-list a:hover { border-color: var(--accent); translate: -3px 0; }
.link-list a > span:last-child { display: grid; min-width: 0; }
.link-list .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-icon { font-size: 1.3rem; }
.submitted-link { margin: 8px 0; word-break: break-all; }

/* ---- Lecture page ---- */
.video {
  position: relative; aspect-ratio: 16 / 9; background: #0b2a29; border-radius: 14px; overflow: hidden;
  box-shadow: 0 20px 40px -20px rgba(20, 51, 49, .5);
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.hint { display: block; font-size: .85rem; color: var(--muted); margin-top: 8px; font-weight: 400; }

.exercise-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, #0d3b39, #145e5a); color: #fff; border: 0;
}
.exercise-cta h2, .exercise-cta p { margin: 0; }
.exercise-cta .muted { color: rgba(255, 255, 255, .7); }
.exercise-cta .btn.primary { background: #fff; color: var(--text); box-shadow: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 9px 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
  transition: translate .2s, box-shadow .2s, border-color .2s, filter .2s;
}
.btn:hover { border-color: var(--accent); translate: 0 -1px; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.primary {
  background: var(--gradient); border-color: transparent; color: #fff;
  box-shadow: 0 8px 20px -10px rgba(10, 143, 138, .8);
}
.btn.primary:hover { filter: brightness(1.06) saturate(1.1); box-shadow: 0 12px 24px -10px rgba(10, 143, 138, .9); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: #f3c9c2; }
.btn.small { padding: 5px 12px; font-size: .85rem; border-radius: 10px; }
.btn.big { padding: 14px 32px; font-size: 1.1rem; border-radius: 14px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: start; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }

/* ---- Forms ---- */
.form { display: grid; gap: 16px; }
.form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.form label { display: grid; gap: 6px; font-weight: 600; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: start; }
.row > label { flex: 1; min-width: 200px; display: grid; gap: 6px; font-weight: 600; }
.row > label.narrow { flex: 0 1 220px; min-width: 120px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
input:not([type=checkbox]):not([type=file]), textarea, select {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #fdfcfa; color: var(--text); width: 100%; transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px rgba(10, 143, 138, .12);
}
input[type=file] {
  font: inherit; padding: 14px; border: 2px dashed #a6dcd7; border-radius: 14px; background: #f1faf9; width: 100%;
}
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; margin-inline-end: 12px; padding: 6px 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
textarea { resize: vertical; }

/* ---- Tables, lists, badges ---- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f1faf9; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.files, .plain { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #f1faf9; border: 1px solid #d3efec; }
.badge {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.warn, .badge.submitted { background: var(--warn-soft); color: var(--warn); }
.badge.reviewed { background: var(--ok-soft); color: var(--ok); }
.badge.needs_fix { background: #fde6e2; color: var(--danger); }

.submission + .submission { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.submission-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.feedback { background: var(--ok-soft); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.alert { background: var(--warn-soft); border-radius: 12px; padding: 12px 16px; margin-top: 12px; }
.alert ul { margin: 6px 0; padding-inline-start: 20px; }

/* ---- Login / messages ---- */
.login-stage {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow: hidden;
  background: #0b2a29;
}
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .75; }
.blob.b1 { width: 420px; height: 420px; background: #14b3aa; top: -80px; right: -60px; }
.blob.b2 { width: 360px; height: 360px; background: #ec6f9d; bottom: -100px; left: -40px; }
.blob.b3 { width: 260px; height: 260px; background: #e3b04b; top: 40%; left: 40%; opacity: .55; }
.login {
  position: relative; max-width: 460px; width: 100%; text-align: center;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .6); border-radius: 28px; padding: 44px 28px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
}
.login .logo {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 20px; background: var(--gradient);
  display: grid; place-items: center; font-size: 1.9rem; box-shadow: 0 12px 30px -10px rgba(10, 143, 138, .8);
}
.login p { color: var(--muted); }
.login .btn.big { margin-top: 8px; }
.container > .login { margin: 10vh auto 0; }

#toast {
  position: fixed; bottom: 24px; left: 0; right: 0; margin: 0 auto; width: fit-content; opacity: 0; visibility: hidden;
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .4); font-weight: 500;
  transition: opacity .2s, visibility .2s; pointer-events: none; z-index: 20;
}
#toast.show { opacity: 1; visibility: visible; }
#toast.error { background: var(--danger); }
#toast.success { background: var(--ok); }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .hero { padding: 24px 20px; border-radius: 20px; }
  .hero h1 { font-size: 1.6rem; }
  .panel { padding: 16px; }
  .action-grid { grid-template-columns: 1fr; gap: 12px; }
  .action-card { flex-direction: row; text-align: start; padding: 18px; gap: 14px; }
  .action-card .action-icon { margin: 0; width: 52px; height: 52px; flex: none; }
  .action-title { font-size: 1.15rem; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; }
  .user .muted { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
