:root {
  --bg: #0c1613;
  --bg2: #12201b;
  --surface: #182822;
  --surface2: #1f332b;
  --line: rgba(255,255,255,0.08);
  --text: #eef6f1;
  --muted: #9bb0a6;
  --accent: #3dcea0;
  --accent-dim: rgba(61,206,160,0.16);
  --warn: #e8b86d;
  --danger: #ff7b8a;
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.btn, button.btn {
  border: 0; border-radius: 999px; padding: 12px 20px;
  font: 600 0.95rem var(--font-body); cursor: pointer;
}
.btn-primary { background: var(--accent); color: #062018; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; cursor: pointer;
}
.btn-text {
  background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 8px 0; font: 500 0.9rem var(--font-body);
}
.btn-text:hover { color: var(--accent); }

/* ——— Login ——— */
.login-stage {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
  position: relative; overflow: hidden;
}
.login-atmosphere {
  position: absolute; inset: -20%;
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, rgba(61,206,160,0.22), transparent 60%),
    radial-gradient(ellipse 45% 35% at 80% 70%, rgba(110,181,255,0.14), transparent 55%),
    linear-gradient(160deg, #0c1613, #143028 50%, #0c1613);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: scale(1) translate(0,0); }
  to { transform: scale(1.05) translate(-2%, 1%); }
}
.login-panel {
  position: relative; width: min(440px, 100%);
  padding: 36px 32px 28px;
  background: rgba(18,32,27,0.82);
  border: 1px solid var(--line);
  border-radius: 28px;
  backdrop-filter: blur(16px);
  animation: rise 0.7s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.brand-mark {
  font-family: var(--font-display); font-size: 1.15rem; color: var(--accent); margin: 0 0 12px; letter-spacing: 0.02em;
}
.login-panel h1 {
  font-family: var(--font-display); font-weight: 650; font-size: clamp(1.7rem, 4vw, 2.15rem);
  line-height: 1.15; margin: 0 0 10px;
}
.lead { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 0.8rem; color: var(--muted); }
.field input, .field select, .field textarea {
  background: #0f1a16; border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: 500 1rem var(--font-body);
}
.login-panel .btn-primary { width: 100%; margin-top: 6px; }
.hint { font-size: 0.82rem; color: var(--muted); margin: 10px 0 0; }
.hint.err { color: var(--danger); }
.muted { opacity: 0.85; }

/* ——— Shell ——— */
.shell {
  min-height: 100vh; display: grid; grid-template-columns: 250px 1fr;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(61,206,160,0.08), transparent 50%),
    var(--bg);
}
.sidebar {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 24px 18px; border-right: 1px solid var(--line); background: rgba(12,22,19,0.9);
}
.side-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.side-brand .mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); font-weight: 700; font-size: 0.85rem;
}
.side-brand strong { display: block; font-size: 0.95rem; }
.side-brand small { color: var(--muted); font-size: 0.75rem; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  color: var(--muted); text-decoration: none; padding: 11px 14px; border-radius: 12px; font-weight: 600; font-size: 0.95rem;
}
.side-nav a:hover, .side-nav a.active { background: var(--surface); color: var(--text); }
.side-bottom { display: flex; flex-direction: column; gap: 8px; }
.chip {
  font-size: 0.78rem; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: var(--surface); line-height: 1.35;
}

.main { padding: 28px 36px 48px; overflow: auto; }
.page-head { margin-bottom: 22px; animation: rise 0.5s ease both; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; color: var(--accent); margin: 0 0 6px; font-weight: 700; }
.page-head h2 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 0; font-weight: 650;
}
.page-head .sub { color: var(--muted); margin: 8px 0 0; max-width: 52ch; line-height: 1.5; }

.view { animation: rise 0.45s ease both; }
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.8rem; color: var(--accent); }
.stat span { font-size: 0.8rem; color: var(--muted); }

.course-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.course-tile {
  text-align: left; cursor: pointer; border: 1px solid var(--line); border-radius: 22px;
  background: linear-gradient(165deg, var(--surface2), var(--surface));
  padding: 20px; color: inherit; font: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative; overflow: hidden; min-height: 200px;
  display: flex; flex-direction: column; gap: 10px;
}
.course-tile:hover { transform: translateY(-3px); border-color: rgba(61,206,160,0.35); }
.course-tile .bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
}
.course-tile .level {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.course-tile h3 {
  font-family: var(--font-display); font-size: 1.25rem; margin: 0; line-height: 1.25; font-weight: 650;
}
.course-tile p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; flex: 1; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
  font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.progress-track {
  height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden;
}
.progress-track > i {
  display: block; height: 100%; border-radius: inherit; background: var(--accent); width: 0%;
}

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px 22px; margin-bottom: 14px;
}
.panel h3 { font-family: var(--font-display); margin: 0 0 12px; font-size: 1.2rem; }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row button.linkish {
  background: none; border: 0; color: var(--text); font: 600 1rem var(--font-body); cursor: pointer; text-align: left; padding: 0;
}
.list-row button.linkish:hover { color: var(--accent); }
.check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0;
}
.check.on { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--surface); }

.lesson-layout {
  display: grid; grid-template-columns: 1fr minmax(220px, 280px); gap: 20px; align-items: start;
}
.lesson-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 30px 32px;
}
.lesson-body h1, .lesson-body h2, .lesson-body h3 { font-family: var(--font-display); }
.lesson-body h2 { font-size: 1.45rem; margin: 0 0 14px; }
.lesson-body p, .lesson-body li { color: #d5e6dd; line-height: 1.65; }
.lesson-body ul { padding-left: 1.2rem; }
.lesson-body blockquote {
  margin: 18px 0; padding: 14px 18px; border-left: 3px solid var(--accent);
  background: var(--accent-dim); border-radius: 0 12px 12px 0; color: var(--text);
}
.video-frame {
  aspect-ratio: 16/9; border-radius: 16px; overflow: hidden; margin-bottom: 18px; background: #000; border: 1px solid var(--line);
}
.video-frame iframe { width: 100%; height: 100%; border: 0; }
.toc a {
  display: block; padding: 8px 0; color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
.toc a:hover, .toc a.current { color: var(--accent); }

.quiz-q {
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.quiz-q:last-child { border-bottom: 0; }
.quiz-q p { font-weight: 600; margin: 0 0 10px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 6px;
  border-radius: 12px; border: 1px solid var(--line); cursor: pointer; background: #121f1a;
}
.opt:hover { border-color: rgba(61,206,160,0.4); }
.opt input { margin-top: 3px; }
.opt.ok { border-color: var(--accent); background: var(--accent-dim); }
.opt.bad { border-color: var(--danger); background: rgba(255,123,138,0.1); }
.score-banner {
  padding: 18px 20px; border-radius: 16px; margin-bottom: 16px;
  background: var(--accent-dim); border: 1px solid rgba(61,206,160,0.35);
}
.score-banner.fail { background: rgba(255,123,138,0.12); border-color: rgba(255,123,138,0.35); }
.score-banner strong { font-family: var(--font-display); font-size: 1.5rem; display: block; }

.cert-panel {
  border-color: rgba(61,206,160,0.35);
  background: linear-gradient(145deg, rgba(61,206,160,0.12), var(--surface));
}

.blog-article .md h2 { margin-top: 1.2em; }
.blog-compose-row { margin-top: 8px; }
.blog-thread { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; }
.blog-msg {
  padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: #121f1a;
}
.blog-msg.is-question { border-color: rgba(110,181,255,0.35); background: rgba(110,181,255,0.06); }
.blog-msg-head {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 0.85rem;
}
.blog-msg-head .avatar {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); font-size: 0.7rem; font-weight: 700;
}
.blog-msg > p { margin: 0; line-height: 1.5; white-space: pre-wrap; }
.blog-reply {
  margin: 12px 0 0 18px; padding: 12px 14px; border-left: 2px solid var(--accent);
  background: rgba(255,255,255,0.03); border-radius: 0 12px 12px 0;
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
}
.blog-reply-main { flex: 1; min-width: 0; }
.blog-reply p { margin: 0; line-height: 1.45; white-space: pre-wrap; }
.blog-votes {
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; align-items: stretch;
}
.vote-btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-width: 52px; padding: 6px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: #0f1a16; color: var(--muted);
  cursor: pointer; font: 600 0.8rem var(--font-body);
}
.vote-btn:hover { border-color: rgba(61,206,160,0.4); color: var(--text); }
.vote-btn.on-up { border-color: rgba(61,206,160,0.55); background: var(--accent-dim); color: var(--accent); }
.vote-btn.on-down { border-color: rgba(255,123,138,0.45); background: rgba(255,123,138,0.1); color: var(--danger); }
.vote-ico { font-size: 0.95rem; line-height: 1; }
.vote-n { font-variant-numeric: tabular-nums; min-width: 1ch; }
.blog-reply-form {
  margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.blog-reply-form textarea {
  width: 100%; background: #0f1a16; border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font: 500 0.95rem var(--font-body);
}

.btn-text.danger, .btn-ghost.danger { color: var(--danger); }
.admin-row { margin-top: 6px; padding-left: 8px; }
.blog-card-wrap { display: flex; flex-direction: column; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .lesson-layout { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 40px; }
}
