:root {
  --blue: #3685c2;
  --blue-dark: #246394;
  --ink: #12202b;
  --ink-soft: #4a5d6a;
  --paper: #f3f6f9;
  --white: #fff;
  --line: #d5e0e8;
  --header: #0b0b0b;
  --header-text: #f4f4f4;
  --radius: 12px;
  --danger: #b42318;
  --ok: #067647;
  --max: 1120px;
  --font: "Segoe UI", "Source Sans 3", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

img { max-width: 100%; height: auto; }

a { color: var(--blue-dark); }
a:hover { color: var(--blue); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }

.wrap { width: min(var(--max), calc(100% - 32px)); margin-inline: auto; }

.site-header {
  background: var(--header);
  color: var(--header-text);
}
.site-header a { color: var(--header-text); text-decoration: none; }
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}
.logo img { height: 36px; width: auto; display: block; }
.logo span { color: #9ad0f0; font-weight: 500; font-size: 14px; }
.header-nav { display: flex; gap: 16px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.header-nav a { font-size: 14px; opacity: .9; }
.header-nav a:hover, .header-nav a[aria-current] { opacity: 1; color: #fff; }
.search {
  display: flex;
  background: #1b1b1b;
  border: 1px solid #333;
  border-radius: 999px;
  overflow: hidden;
}
.search input {
  background: transparent;
  border: 0;
  color: #fff;
  padding: 8px 14px;
  min-width: 180px;
  font: inherit;
}
.search button {
  background: var(--blue);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}

.hero {
  background: linear-gradient(180deg, #fff, var(--paper));
  padding: 36px 0 12px;
}
.hero p { color: var(--ink-soft); max-width: 62ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 8px 0 48px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 0 rgba(18,32,43,.05);
}
.card:hover { border-color: var(--blue); }
.card h2 { font-size: 1.15rem; margin: 0; }
.card p { margin: 0; color: var(--ink-soft); font-size: 15px; flex: 1; }
.meta { font-size: 13px; color: var(--blue-dark); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 24px 0 56px;
  align-items: start;
}
.side {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 12px;
}
.side h2 { font-size: 1rem; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: block;
  padding: 7px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
}
.side li a:hover, .side li a.active { background: #e8f2fa; color: var(--blue-dark); }

.lesson {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px 40px;
}
.crumbs { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.crumbs a { color: inherit; }
.lesson-body img {
  display: block;
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.related { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.related ul { padding-left: 18px; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 32px;
  color: var(--ink-soft);
  font-size: 14px;
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--blue-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--blue-dark); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); }
.btn-sm { font-size: 13px; padding: 5px 10px; }

.flash {
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0;
}
.flash.ok { background: #e7f8ef; color: var(--ok); }
.flash.error { background: #fdecec; color: var(--danger); }

.admin-body { background: #eef2f6; }
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-side {
  background: var(--header);
  color: #ddd;
  padding: 20px 14px;
}
.admin-side a { color: #ddd; text-decoration: none; display: block; padding: 8px 10px; border-radius: 8px; }
.admin-side a:hover, .admin-side a.active { background: #222; color: #fff; }
.admin-side .brand { color: #fff; font-weight: 700; margin-bottom: 18px; padding: 0 10px; }
.admin-main { padding: 24px 28px 64px; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { background: #f7fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 12px;
  max-width: 920px;
}
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.form input[type=text], .form input[type=number], .form input[type=password], .form textarea, .form select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
}
.form textarea { min-height: 280px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 28px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 28px; }
.login-box {
  max-width: 380px;
  margin: 12vh auto;
  background: #fff;
  padding: 28px;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.muted { color: var(--ink-soft); font-size: 14px; }
.off { opacity: .5; }
.gallery-admin {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.gallery-admin figure {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}
.gallery-admin img { width: 100%; height: 90px; object-fit: contain; background: #fafafa; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 96vw; max-height: 92vh; }

@media (max-width: 860px) {
  .layout, .admin-shell { grid-template-columns: 1fr; }
  .side { position: static; }
  .header-inner { flex-wrap: wrap; }
  .header-nav { margin-left: 0; width: 100%; }
  .lesson { padding: 18px; }
}
