:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #0b0b0d;
  --muted: #4b5563;
  --accent: #111111;
  --ok: #15803d;
  --err: #b91c1c;
  --line: #d1d5db;
  --banner-bg: #111111;
  --banner-text: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 5%, #ffffff 0, transparent 35%),
    radial-gradient(circle at 90% 95%, #e5e7eb 0, transparent 30%),
    var(--bg);
  min-height: 100vh;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.auth-card {
  width: min(520px, 96vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.1);
}

.auth-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.age-badge,
.age-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: #111111;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.age-chip {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 50;
}

.logout-btn {
  position: fixed;
  right: 14px;
  top: 76px;
  z-index: 50;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 0;
  background: #111111;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 5vw, 34px);
}

.auth-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  font-weight: 700;
}

.auth-form input {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  min-height: 46px;
  font: inherit;
}

.auth-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-error {
  margin: 12px 0 0;
  color: var(--err);
  font-weight: 700;
}

.auth-exit {
  display: block;
  margin-top: 12px;
  text-align: center;
  text-decoration: none;
  background: #f3f4f6;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: #111827;
  font-weight: 700;
}

.auth-exit:hover {
  background: #e5e7eb;
}

.maintenance-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  padding: 10px 14px;
  background: var(--banner-bg);
  color: var(--banner-text);
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero-logo {
  width: clamp(150px, 23vw, 230px);
  height: auto;
  flex: 0 0 auto;
  margin-top: 2px;
}

.hero h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(24px, 5vw, 40px);
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 3.4vw, 18px);
}

.controls,
.quiz,
.reader,
.mode-switch {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-btn {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--line);
}

.mode-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

select,
button {
  font: inherit;
}

select,
button,
.answer-btn {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  min-height: 46px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: 0;
  font-weight: 700;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 14px;
}

.question-media {
  margin: 0 0 14px;
}

.question-hero {
  width: 100%;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
  aspect-ratio: 12 / 7;
  object-fit: cover;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.hero-credit {
  margin-top: 8px;
}

.hero-credit a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.hero-credit a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.reader-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.reader-card {
  margin-top: 16px;
}

.reader-top {
  display: flex;
  justify-content: flex-start;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 14px;
}

.reader-actions {
  margin-bottom: 12px;
}

.reader-actions button {
  width: 100%;
}

.reader-content {
  font-size: 16px;
  line-height: 1.72;
}

.reader-content section {
  margin-bottom: 22px;
  scroll-margin-top: 16px;
}

.reader-content h3 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.3;
}

.reader-content p {
  margin: 0 0 14px;
}

.reader-content ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

.reader-content li + li {
  margin-top: 8px;
}

.reader-next {
  margin-top: 14px;
}

.reader-next button {
  width: 100%;
}

h2 {
  margin: 6px 0 14px;
  font-size: clamp(20px, 4.6vw, 28px);
  line-height: 1.25;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer-btn {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}

.answer-btn:hover {
  transform: translateY(-1px);
  border-color: #6b7280;
}

.answer-btn.correct {
  background: #dcfce7;
  border-color: var(--ok);
  color: #14532d;
}

.answer-btn.wrong {
  background: #fee2e2;
  border-color: var(--err);
  color: #7f1d1d;
}

.answer-btn.locked {
  cursor: default;
}

.feedback {
  margin-top: 14px;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
}

.feedback.ok {
  background: #dcfce7;
  color: var(--ok);
}

.feedback.err {
  background: #fee2e2;
  color: var(--err);
}

.summary {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #f9fafb;
}

.summary h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.summary p {
  margin: 0 0 10px;
  color: var(--text);
}

.summary ul {
  margin: 0;
  padding-left: 18px;
}

.summary li + li {
  margin-top: 8px;
}

.actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.actions.active {
  position: sticky;
  bottom: 10px;
}

.hidden { display: none; }

@media (max-width: 640px) {
  .auth-card {
    padding: 16px;
    border-radius: 14px;
  }

  .age-chip {
    width: 44px;
    height: 44px;
    font-size: 14px;
    right: 10px;
    top: auto;
    bottom: 56px;
  }

  .logout-btn {
    right: 10px;
    top: auto;
    bottom: 10px;
    min-height: 34px;
    padding: 6px 10px;
  }

  .app {
    padding: 16px 12px 24px;
  }

  .hero-head {
    gap: 10px;
  }

  .hero-logo {
    width: clamp(120px, 36vw, 170px);
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .reader-controls,
  .mode-switch {
    grid-template-columns: 1fr;
  }

  .controls,
  .quiz,
  .reader,
  .mode-switch {
    padding: 14px;
    border-radius: 14px;
  }

  .quiz-top {
    font-size: 13px;
  }

  .question-hero {
    aspect-ratio: 16 / 9;
  }

  .actions.active {
    padding: 10px 0 0;
    background: linear-gradient(to top, var(--card) 80%, rgba(255, 255, 255, 0));
  }

  .actions button {
    width: 100%;
  }
}
