:root {
  --bg: #0a1422;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #143055 0%, #0a1422 55%);
  --surface: rgba(255,255,255,0.045);
  --surface-solid: #14233a;
  --surface2: rgba(255,255,255,0.07);
  --elevated: #182b47;
  --line: rgba(255,255,255,0.09);
  --line-strong: rgba(255,255,255,0.16);
  --text: #f3f7fc;
  --muted: #92a6c4;
  --muted2: #6e84a4;
  --blue: #3b82f6;
  --blue-bright: #5aa2ff;
  --orange: #f5871f;
  --orange-soft: #ffac4d;
  --gold: #f6c343;
  --green: #2bd07a;
  --red: #ff5d5d;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-sm: 0 4px 14px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { overscroll-behavior-y: contain; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
  letter-spacing: -0.01em;
}

#app { max-width: 540px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,20,34,0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.topbar-role {
  font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, var(--orange), var(--orange-soft));
  color: #2a1500; padding: 5px 11px; border-radius: 999px;
}
.icon-btn {
  background: var(--surface2); border: 1px solid var(--line);
  color: var(--text); width: 38px; height: 38px;
  border-radius: 12px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(0.92); }

.main { flex: 1; padding: 18px; padding-bottom: 108px; }

/* Floating bottom nav */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 28px); max-width: 420px;
  display: flex; gap: 4px; padding: 7px;
  background: rgba(20,35,58,0.86);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-strong);
  border-radius: 999px; box-shadow: var(--shadow); z-index: 100;
}
.nav-item {
  flex: 1; text-align: center; padding: 9px 4px;
  background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; cursor: pointer;
  border-radius: 999px; transition: color .15s, background .2s;
}
.nav-item span { display: block; font-size: 19px; margin-bottom: 1px; }
.nav-item.active { color: #fff; background: linear-gradient(135deg, var(--orange), var(--orange-soft)); box-shadow: 0 4px 12px rgba(245,135,31,0.35); }

.hidden { display: none !important; }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #163059, #0f2240);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 30px 22px; text-align: center; margin-bottom: 18px; box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(245,135,31,0.35), transparent 70%);
}
.hero-logo { font-size: 54px; margin-bottom: 6px; position: relative; }
.hero h2 { font-size: 23px; font-weight: 800; }
.hero-sub { color: var(--orange-soft); font-weight: 600; margin-top: 2px; }
.hero-role {
  display: inline-block; margin-top: 16px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,0.1); padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--line); position: relative;
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
}
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.card p { font-size: 13.5px; color: var(--muted); }

/* Course card — modern banner */
.course-card {
  padding: 0; overflow: hidden; cursor: pointer;
  transition: transform .14s, border-color .2s;
}
.course-card:active { transform: scale(0.985); }
.course-banner {
  position: relative; height: 132px;
  background: linear-gradient(135deg, #1d3a63, #102542);
  display: flex; align-items: flex-end;
}
.course-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.course-banner .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 46px; background: linear-gradient(135deg, #1d3a63, #102542); }
.course-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(8,16,28,0.92) 8%, rgba(8,16,28,0.15) 60%, transparent); }
.course-banner h3 { position: relative; z-index: 1; padding: 14px; font-size: 17px; font-weight: 800; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.pct-pill {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 700;
}
.course-body { padding: 14px; }
.course-body p { margin-bottom: 12px; }

/* Cover (lesson/course detail) */
.card-cover { width: 100%; height: 170px; object-fit: cover; border-radius: var(--r-md); margin-bottom: 14px; background: var(--surface2); }
.card-cover.ph { display: flex; align-items: center; justify-content: center; font-size: 48px; }

/* Progress bar */
.progress-bar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--gold)); border-radius: 999px; transition: width .4s ease; }
.progress-meta { font-size: 12px; margin-top: 7px; color: var(--muted); font-weight: 500; }

/* Progress ring */
.ring-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ring { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface-solid); }
.ring span { position: relative; font-size: 14px; font-weight: 800; }
.ring-label { font-size: 13px; color: var(--muted); }
.ring-label strong { display: block; font-size: 15px; color: var(--text); margin-bottom: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 14px 18px; border: none; border-radius: 14px;
  font-size: 14.5px; font-weight: 700; cursor: pointer; width: 100%; margin-top: 10px;
  font-family: inherit; transition: filter .15s, transform .08s, box-shadow .2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: linear-gradient(135deg, var(--orange), var(--orange-soft)); color: #2a1500; box-shadow: 0 6px 18px rgba(245,135,31,0.3); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: rgba(255,93,93,0.15); color: var(--red); border: 1px solid rgba(255,93,93,0.3); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #ffe08a); color: #4a3500; box-shadow: 0 6px 18px rgba(246,195,67,0.3); }
.btn-sm { padding: 9px 13px; font-size: 12.5px; width: auto; margin-top: 0; border-radius: 11px; }
.row-2 { display: flex; gap: 10px; }
.row-2 .btn { flex: 1; }

/* Lessons */
.lesson-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 9px; cursor: pointer;
  transition: transform .1s, border-color .2s;
}
.lesson-item:active { transform: scale(0.99); }
.lesson-item.done { border-color: rgba(43,208,122,0.35); }
.lesson-item.locked { opacity: 0.55; cursor: not-allowed; }
.lesson-info { flex: 1; min-width: 0; }
.lesson-info strong { font-weight: 600; }
.lesson-badges { margin-top: 4px; display: flex; gap: 5px; flex-wrap: wrap; }
.lesson-num {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--blue-bright);
}
.lesson-num.ok { background: linear-gradient(135deg, var(--green), #4ee59b); border: none; color: #053d20; }
.lesson-title { font-size: 21px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.02em; }
.lesson-desc { color: var(--muted); margin-bottom: 14px; font-size: 14px; }

/* Tags */
.tag { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 7px; text-transform: uppercase; letter-spacing: .03em; }
.tag-hw { background: rgba(245,135,31,.18); color: var(--orange-soft); }
.tag-test { background: rgba(90,162,255,.18); color: var(--blue-bright); }
.tag-free { background: rgba(43,208,122,.18); color: var(--green); }
.tag-pending { background: rgba(246,195,67,.18); color: var(--gold); }
.tag-ok { background: rgba(43,208,122,.18); color: var(--green); }
.tag-rej { background: rgba(255,93,93,.18); color: var(--red); }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
input, textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  font-size: 14.5px; font-family: inherit; transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted2); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); background: var(--surface-solid); }
textarea { min-height: 92px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2392a6c4' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; font-size: 14px; padding: 12px 14px; background: var(--surface2); border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); }

/* Search */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap input { padding-left: 42px; }
.search-wrap::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; }

.section-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 11px; font-weight: 700; }

/* Rich text editor */
.rte { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--surface2); }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--line); }
.rte-toolbar button { background: var(--surface2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; width: auto; margin: 0; }
.rte-toolbar button:active { transform: scale(0.94); }
.rte-area { min-height: 130px; padding: 14px; font-size: 14.5px; outline: none; line-height: 1.6; }
.rte-area:empty:before { content: "Введите текст урока..."; color: var(--muted2); }

/* Video / content */
.video-wrap { width: 100%; border-radius: var(--r-md); overflow: hidden; margin: 14px 0; background: #000; box-shadow: var(--shadow-sm); }
video { width: 100%; max-height: 280px; display: block; }
.lesson-content { font-size: 15.5px; line-height: 1.7; }
.lesson-content img { max-width: 100%; border-radius: 10px; }
.lesson-content a { color: var(--blue-bright); }
.lesson-content h3 { margin: 14px 0 6px; }

/* Homework */
.hw-task { font-size: 14px; margin-bottom: 8px; }
.hw-status { margin: 8px 0; font-size: 13px; }
.hw-feedback { background: var(--surface2); padding: 11px; border-radius: 11px; font-size: 13.5px; margin: 8px 0; border-left: 3px solid var(--blue-bright); }
.hw-score { font-size: 14px; }
.hw-answer { background: var(--surface2); padding: 11px; border-radius: 11px; font-size: 13.5px; margin: 6px 0; white-space: pre-wrap; }

/* Quiz */
.quiz-q { margin-bottom: 18px; }
.quiz-text { font-weight: 600; margin-bottom: 9px; }
.quiz-opt { display: flex; gap: 10px; align-items: center; padding: 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 7px; font-size: 14px; cursor: pointer; transition: border-color .15s; }
.quiz-opt:has(input:checked) { border-color: var(--orange); background: rgba(245,135,31,0.08); }
.quiz-opt input { width: 20px; height: 20px; accent-color: var(--orange); }
.test-pass { color: var(--green); font-weight: 700; margin-top: 12px; text-align: center; padding: 12px; background: rgba(43,208,122,0.1); border-radius: 12px; }
.test-fail { color: var(--red); font-weight: 700; margin-top: 12px; text-align: center; padding: 12px; background: rgba(255,93,93,0.1); border-radius: 12px; }
.q-opts { list-style: none; margin: 8px 0; }
.q-opts li { padding: 7px 11px; background: var(--surface2); border-radius: 8px; margin-bottom: 5px; font-size: 13px; }
.q-opts li.correct { color: var(--green); }

/* Comments */
.comments { margin-bottom: 14px; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 13px; margin-bottom: 10px; }
.comment.staff { border-left: 3px solid var(--blue-bright); }
.comment.reply { margin: 9px 0 0 18px; background: var(--surface2); }
.comment-head { font-size: 12px; color: var(--orange-soft); font-weight: 700; margin-bottom: 4px; }
.comment-body { font-size: 14px; white-space: pre-wrap; }
.comment-form textarea { margin-bottom: 8px; }

/* Stats / tabs */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.stat-box { background: var(--surface); border: 1px solid var(--line); padding: 18px; border-radius: var(--r-md); text-align: center; box-shadow: var(--shadow-sm); }
.stat-box strong { display: block; font-size: 26px; font-weight: 800; background: linear-gradient(135deg, var(--orange), var(--gold)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-box { font-size: 12.5px; color: var(--muted); }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; padding: 5px; background: var(--surface2); border-radius: 14px; }
.tab { flex: 1; padding: 10px 12px; border-radius: 10px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.tab.active { background: var(--elevated); color: var(--text); box-shadow: var(--shadow-sm); }

.user-row { display: flex; justify-content: space-between; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px; }

/* Empty + skeletons */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-icon { font-size: 50px; margin-bottom: 14px; }
.muted-sm { font-size: 12px; color: var(--muted); }

.skeleton-card { height: 92px; border-radius: var(--r-md); margin-bottom: 14px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
.skeleton-card.tall { height: 200px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Toast */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--elevated); color: #fff; padding: 13px 20px;
  border: 1px solid var(--line-strong); border-radius: 14px; font-size: 13.5px; font-weight: 600;
  z-index: 200; box-shadow: var(--shadow); max-width: 90%; text-align: center;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast:not(.hidden) { opacity: 1; transform: translateX(-50%) translateY(0); }
