:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel2: #243044;
  --text: #e8eef7;
  --muted: #9fb0c8;
  --accent: #5ec8ff;
  --accent2: #9dff6b;
  --warn: #ffc857;
  --danger: #ff6b6b;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 10% -10%, #1e3a5f 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #2a1f4a 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: #8edcff;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #000;
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(15, 20, 25, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav a[aria-current="page"] {
  color: var(--accent2);
}

.hero {
  padding: 2.25rem 0 1rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 0.6fr 1.4fr;
  gap: 1rem;
  align-items: start;
}

.hero-text {
  min-width: 0;
}

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

.hero .sub {
  color: var(--muted);
  max-width: 62ch;
  margin: 0;
}

.hero-cover {
  margin-top: 0;
  max-width: 62%;
  justify-self: start;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge strong {
  color: var(--accent2);
  font-weight: 600;
}

.meme-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin: 0.25rem 0 1rem;
}

.meme-chip {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 12, 20, 0.65);
  color: #d5e7ff;
  font-size: 0.86rem;
}

.bird-emoji {
  font-size: 1.15rem;
  line-height: 1;
}

.meme-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.panel {
  background: linear-gradient(160deg, rgba(36, 48, 68, 0.95), rgba(26, 35, 50, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin: 1.25rem 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
}

.panel h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  color: #cfe6ff;
}

.panel p,
.panel li {
  color: #d5e2f5;
}

.term-tip {
  position: relative;
  display: inline-block;
  padding: 0 0.1rem;
  border-bottom: 1px dashed rgba(94, 200, 255, 0.75);
  cursor: help;
}

.term-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 180px;
  max-width: 280px;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(5, 10, 18, 0.95);
  color: #e8f2ff;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 25;
}

.term-tip:hover::after,
.term-tip:focus::after {
  opacity: 1;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
}

.level-tabs button {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.level-tabs button:hover {
  border-color: rgba(94, 200, 255, 0.45);
}

.level-tabs button[aria-selected="true"] {
  background: rgba(94, 200, 255, 0.12);
  border-color: var(--accent);
  outline: none;
}

.level-tabs small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

.level-pane {
  display: none;
  margin-top: 1rem;
}

.level-pane.is-active {
  display: block;
}

.callout {
  border-left: 4px solid var(--warn);
  background: rgba(255, 200, 87, 0.08);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
  color: #ffeccc;
}

.callout.ok {
  border-color: var(--accent2);
  background: rgba(157, 255, 107, 0.08);
  color: #e8ffe0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.figure {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b0f14;
}

.figure img,
.figure svg {
  display: block;
  width: 100%;
  height: auto;
}

.figure figcaption {
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.link-card {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s, border-color 0.12s;
}

.link-card:hover {
  border-color: rgba(94, 200, 255, 0.45);
  transform: translateY(-1px);
}

.link-card strong {
  display: block;
  margin-bottom: 0.25rem;
}

.link-card span {
  font-size: 0.85rem;
  color: var(--muted);
}

.video-shell {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-shell iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-fallback {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.cards-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cards-toolbar button {
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--panel);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font: inherit;
}

.cards-toolbar button:hover {
  border-color: rgba(157, 255, 107, 0.45);
}

.flash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.flash-card {
  perspective: 900px;
  min-height: 150px;
}

.flash-card .inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 150px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  border-radius: 12px;
}

.flash-card.is-flipped .inner {
  transform: rotateY(180deg);
}

.flash-card .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.flash-card .front {
  background: linear-gradient(145deg, #243044, #1a2332);
}

.flash-card .back {
  background: linear-gradient(145deg, #1e4d36, #152a22);
  transform: rotateY(180deg);
}

.flash-card .de {
  font-size: 1.05rem;
  font-weight: 700;
}

.flash-card .ru {
  color: #c9e6ff;
  font-size: 0.92rem;
}

.flash-card .hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.quiz-q {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  margin-bottom: 0.75rem;
}

.quiz-q p {
  margin: 0 0 0.65rem;
  font-weight: 600;
}

.quiz-opts {
  display: grid;
  gap: 0.45rem;
}

.quiz-opts label {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}

.quiz-opts label:hover {
  background: rgba(255, 255, 255, 0.04);
}

.quiz-opts input {
  margin-top: 0.2rem;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.quiz-actions button {
  cursor: pointer;
  border: 0;
  border-radius: 11px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent), #8edcff);
  color: #081018;
}

.quiz-actions button.secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.quiz-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  display: none;
}

.quiz-result.is-visible {
  display: block;
}

.mini-quiz-result {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.quiz-meme-box {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.5rem 0 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px dashed rgba(157, 255, 107, 0.4);
  background: rgba(157, 255, 107, 0.06);
  color: #dfffe0;
  font-size: 0.9rem;
}

.site-footer {
  margin-top: 2rem;
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .flash-card .inner {
    transition: none;
  }
}

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-cover {
    max-width: 100%;
  }
}
