:root {
  --blue: #213a8a;
  --blue-mid: #2a49ab;
  --blue-bright: #4a6bcc;
  --blue-soft: #c5dbf2;
  --blue-wash: #e8f2fa;
  --page: #eef3f8;
  --ink: #152033;
  --muted: #5c6b82;
  --line: #d5e2ee;
  --white: #ffffff;
  --font: "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
  overflow-x: hidden;
}
html.nav-open,
html.nav-open body { overflow: hidden; }
a { color: var(--blue-mid); }
button, input { font: inherit; }
button, a.btn, .chip, .top__cta { touch-action: manipulation; }
.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.top {
  position: sticky; top: 0; z-index: 50;
  padding: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--blue);
  transition: padding .55s cubic-bezier(.22, 1, .36, 1), background .55s cubic-bezier(.22, 1, .36, 1);
}
.top__bar {
  width: 100%;
  margin: 0 auto;
  background: var(--blue);
  border: 1px solid transparent;
  border-radius: 0;
  box-shadow: 0 0 0 transparent;
  backdrop-filter: blur(0) saturate(100%);
  -webkit-backdrop-filter: blur(0) saturate(100%);
  transition:
    width .55s cubic-bezier(.22, 1, .36, 1),
    border-radius .55s cubic-bezier(.22, 1, .36, 1),
    background .55s cubic-bezier(.22, 1, .36, 1),
    box-shadow .55s cubic-bezier(.22, 1, .36, 1),
    border-color .55s cubic-bezier(.22, 1, .36, 1);
}
.top.is-glass {
  padding: 10px 0 0;
  background: transparent;
}
.top.is-glass .top__bar {
  width: min(1180px, calc(100% - 24px));
  border-radius: 22px;
  background: rgba(33, 58, 138, .78);
  border-color: rgba(255, 255, 255, .18);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 14px 40px rgba(21, 32, 51, .18);
}
@supports (-webkit-touch-callout: none) {
  .top.is-glass {
    padding: 0;
    padding-top: env(safe-area-inset-top);
    background: var(--blue);
  }
  .top.is-glass .top__bar {
    width: 100%;
    border-radius: 0;
    background: var(--blue);
    border-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 20px rgba(21, 32, 51, .12);
  }
}
.top__inner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; padding: 14px 0;
  position: relative;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.brand__logo {
  width: 64px; height: auto; flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.22));
}
.brand__text { min-width: 0; }
.top.is-glass .brand__logo { display: none; }
.brand__org { margin: 0; font-size: 11px; letter-spacing: .02em; color: rgba(255,255,255,.72); max-width: 52ch; line-height: 1.35; }
.brand__org-short { display: none; }
.top.is-glass .brand__org { max-width: none; }
.top.is-glass .brand__org-full { display: none; }
.top.is-glass .brand__org-short { display: inline; }
.brand__name {
  color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -.02em;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top__nav { display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
.top__nav a { color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; }
.top__cta {
  background: #fff; color: var(--blue) !important;
  border-radius: 999px; padding: 8px 14px;
}
.top__menu {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  padding: 11px 12px;
  background: rgba(255,255,255,.14);
  border-radius: 12px;
  cursor: pointer;
  flex: 0 0 auto;
}
.top__menu span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  margin: 4px 0;
  transition: transform .2s ease, opacity .2s ease;
}
.top.is-menu .top__menu span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.top.is-menu .top__menu span:nth-child(2) { opacity: 0; }
.top.is-menu .top__menu span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.intro {
  background: var(--blue);
  color: #fff;
  padding: 36px 0 48px;
  text-align: center;
}
.intro__inner { max-width: none; }
.intro__kicker {
  margin: 0 0 10px; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--blue-soft); font-weight: 700;
}
.intro h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
}
.intro__lead { margin: 0 auto 18px; max-width: 48ch; color: #d7e4f6; font-size: 17px; }
.intro__facts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.intro__facts span {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

.catalog { padding: 28px 0 64px; }
.filters {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px 20px 14px;
  margin-bottom: 28px;
}
.filters__search input {
  width: 100%; border: 1px solid var(--line); background: var(--page);
  border-radius: 16px; padding: 13px 16px; margin-bottom: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.filters__search input:focus {
  outline: 2px solid var(--blue-bright); outline-offset: 1px; background: #fff;
}
.filter-row {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 10px; align-items: start; margin-bottom: 12px;
  min-width: 0;
}
.filter-label {
  padding-top: 8px; font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  border: 1px solid var(--line); background: var(--page); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600;
  font-size: 13px;
  flex: 0 1 auto;
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  text-align: center;
}
.chip.is-on {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
.chip.is-on::after {
  content: " ✓";
  font-weight: 800;
}
.filter-row--age { align-items: center; }
.age-slider { width: min(460px, 100%); padding-top: 4px; }
.age-slider input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--blue-wash);
  outline: none;
}
.age-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--blue-wash);
}
.age-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  cursor: pointer;
}
.age-slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  cursor: pointer;
}
.age-slider__scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.age-slider__scale b { color: var(--blue); font-size: 14px; }
.time-range {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding-top: 2px;
}
.time-range label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.time-range select {
  min-width: 108px;
  border: 1px solid var(--line); background: var(--page); color: var(--ink);
  border-radius: 12px; padding: 8px 12px; font-weight: 600;
}
.filters__meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; color: var(--muted); font-size: 14px;
}
.reset {
  border: 0; background: none; color: var(--blue-mid); cursor: pointer;
  font-weight: 700;
}

.dir-block { margin-bottom: 32px; }
.dir-title {
  margin: 0 0 14px; font-size: 22px; font-weight: 800; color: var(--blue);
  display: flex; gap: 8px; align-items: baseline; letter-spacing: -.02em;
}
.dir-title small {
  font-size: 12px; background: var(--blue-wash); color: var(--blue);
  border-radius: 999px; padding: 3px 9px; font-weight: 700;
}
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: transform .16s ease, border-color .16s ease;
  animation: cardIn .58s cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: calc(min(var(--i, 0), 16) * 52ms);
  min-width: 0;
}
.card h3 { margin: 0; font-size: 17px; line-height: 1.3; letter-spacing: -.015em; overflow-wrap: break-word; word-break: break-word; }
.card__top { display: flex; justify-content: flex-start; }
.badge {
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 4px 9px;
}
.badge-free { background: #e7f8ee; color: #146c3c; }
.badge-paid { background: #fff3e4; color: #9a3412; }
.groups { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.groups li {
  background: var(--page); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; display: grid; gap: 2px;
}
.groups li b { color: var(--blue); }
.groups__age { color: var(--muted); font-size: 13px; }
.card__meta, .card__sched { margin: 0; color: var(--muted); font-size: 14px; }
.card__meta b { color: var(--ink); }
.code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--blue-wash); color: var(--blue); border-radius: 8px;
  padding: 2px 6px; font-weight: 700;
}
.card__actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 13px; cursor: pointer; font-weight: 700;
  text-decoration: none; display: inline-flex; justify-content: center; align-items: center;
}
.btn:disabled { opacity: .62; cursor: wait; }
.btn-primary { background: var(--blue); color: #fff; flex: 1; }
.btn-ghost { background: var(--blue-wash); color: var(--blue); }

.empty {
  text-align: center; padding: 32px; color: var(--muted);
  background: #fff; border-radius: 18px; border: 1px dashed var(--line);
}

.how { padding: 0 0 64px; }
.how__title {
  margin: 0 0 16px; color: var(--blue); font-size: 22px; font-weight: 800; letter-spacing: -.02em;
}
.how__steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.how__steps li {
  background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  display: grid; gap: 8px;
}
.how__steps b {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-size: 13px;
}
.how__steps p { margin: 0; color: var(--ink); font-size: 14px; }

.footer {
  position: relative;
  background:
    radial-gradient(900px 240px at 8% -10%, rgba(110, 150, 230, .22), transparent 55%),
    linear-gradient(180deg, #1b3178 0%, #132456 100%);
  color: #c5d4ec;
  padding: 52px 0 0;
  font-size: 14px;
  overflow: hidden;
}
.footer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(196, 219, 255, .2), #d7e6ff, rgba(196, 219, 255, .2), transparent);
}
.footer a { color: #fff; text-decoration: none; }
.footer__brand {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.footer__logo-wrap {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.16);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.footer__logo {
  width: 58px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.28));
}
.footer__kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .01em;
  line-height: 1.4;
  color: #9db0d4;
  max-width: 48ch;
}
.footer__name {
  color: #fff;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -.03em;
  margin: 0 0 6px;
  line-height: 1.15;
}
.footer__lead, .footer__note { margin: 0; color: #b7c6e2; }
.footer__note { margin-bottom: 16px; max-width: 32ch; line-height: 1.45; }
.footer__grid {
  display: grid;
  grid-template-columns: 1.15fr .95fr .9fr;
  gap: 28px 32px;
  align-items: start;
  padding-bottom: 28px;
}
.footer__grid--admin { grid-template-columns: 1fr .9fr; }
.footer__label {
  margin: 0 0 14px;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.footer__campuses,
.footer__contacts,
.footer__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}
.footer__campuses li {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.footer__campuses li:last-child { padding-bottom: 0; border-bottom: 0; }
.footer__campuses b {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.footer__campuses span { color: #9db0d4; font-size: 13px; }
.footer__contacts li { display: grid; gap: 2px; }
.footer__contacts span {
  color: #9db0d4;
  font-size: 12px;
  font-weight: 600;
}
.footer__contacts a {
  font-weight: 700;
  width: fit-content;
}
.footer__cta {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  padding: 20px 20px 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.footer__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--blue) !important;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 800;
  text-decoration: none !important;
  box-shadow: 0 8px 20px rgba(12, 22, 48, .18);
}
.footer__bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 22px;
  border-top: 1px solid rgba(255,255,255,.1);
  color: #8fa2c6;
  font-size: 13px;
}

dialog.modal:not([open]) { display: none; }
dialog.modal[open] { display: block; }
.modal {
  border: 0; border-radius: 22px; padding: 0; width: min(680px, calc(100% - 24px));
}
.modal dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; align-items: start; }
.modal::backdrop { background: rgba(16, 28, 64, .48); }
.modal__inner { padding: 24px; position: relative; }
.modal__close {
  position: absolute; right: 12px; top: 8px; border: 0; background: none;
  font-size: 28px; cursor: pointer; color: var(--muted);
}
.modal h2 { margin: 0 72px 8px 0; color: var(--blue); letter-spacing: -.02em; }
.modal dt { color: var(--muted); }
.modal dd { margin: 0; }
.modal .btn { margin-right: 8px; margin-top: 10px; }

.teacher-form {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  min-width: 0;
}
.teacher-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 13px; color: var(--muted); min-width: 0; }
.teacher-form .full { grid-column: 1 / -1; }
.teacher-form input, .teacher-form select, .teacher-form textarea {
  font-weight: 500; color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; background: var(--page);
  width: 100%; max-width: 100%; min-width: 0;
}
.teacher-form textarea { resize: vertical; }
.teacher-form .btn { width: fit-content; }
.file-field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 13px; color: var(--muted); }
.file-picker { display: grid; gap: 8px; min-width: 0; max-width: 100%; }
.file-picker__box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 148px;
  padding: 18px 16px;
  border: 1px dashed #b7cbe0;
  border-radius: 16px;
  background: var(--page);
  cursor: pointer;
  text-align: center;
}
.file-picker__input {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  opacity: 0;
  cursor: pointer;
  border: 0 !important;
  padding: 0 !important;
  background: none !important;
  font-size: 0 !important;
}
.file-picker__icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(21, 32, 51, .06);
}
.file-picker__preview {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 14px;
  background: #fff;
}
.file-picker__text { min-width: 0; display: grid; gap: 2px; justify-items: center; }
.file-picker__text b {
  color: var(--ink);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.file-picker__text small { font-weight: 600; color: var(--muted); }
.file-picker__btn {
  flex: 0 0 auto;
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}
.file-picker.is-on .file-picker__box {
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  min-height: 72px;
  padding: 12px 14px;
  border-style: solid;
  border-color: #b7cbe0;
  background: #fff;
}
.file-picker.is-on .file-picker__text { justify-items: start; flex: 1; text-align: left; }
.file-picker.is-on .file-picker__text b { white-space: nowrap; }
.file-picker.is-on .file-picker__icon { display: none; }
.file-picker__clear {
  width: fit-content;
  margin: 0 auto;
  border: 0;
  background: none;
  color: var(--blue-mid);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.form-status { grid-column: 1 / -1; margin: 0; padding: 10px 12px; border-radius: 12px; }
.form-status.is-ok { background: #e7f8ee; color: #146c3c; }
.form-status.is-err { background: #fde8ea; color: #9f1239; }
.teacher-form--login {
  max-width: none;
  grid-template-columns: 1fr;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.teacher-form--login .btn { width: 100%; }

body.admin-page.is-login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.admin-page.is-login .footer { display: none; }
.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
}
.login-screen[hidden],
#admin-app[hidden] {
  display: none !important;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: 0 18px 50px rgba(21, 32, 51, .08);
  text-align: center;
}
.login-card__kicker {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--blue-mid);
  font-weight: 700;
}
.login-card h1 {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -.03em;
}
.login-card__lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}
.story-photo { width: 100%; max-height: 220px; object-fit: cover; border-radius: 14px; }
.story-text { white-space: pre-wrap; margin: 8px 0 0; }
.story-from {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.story-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--blue);
}
.top__logout {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--blue-bright); color: var(--blue); background: #fff; }
  .chip.is-on:hover { background: var(--blue-mid); color: #fff; border-color: var(--blue-mid); }
  .card:hover { transform: translateY(-3px); border-color: #b7cbe0; }
  .top__cta:hover { background: var(--blue-wash); }
  .btn-primary:hover { background: var(--blue-mid); }
  .btn-ghost:hover { background: #d7e8f5; }
  .file-picker__box:hover { border-color: var(--blue-bright); background: #fff; }
  .file-picker__clear:hover { color: var(--blue); }
  .footer a:hover { color: #dbe7ff; }
  .footer__btn:hover { background: var(--blue-wash); color: var(--blue) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .top, .top__bar, .top__menu span { transition: none; }
  .card { animation: none; }
}
@media (max-width: 980px) {
  .footer__grid,
  .footer__grid--admin { grid-template-columns: 1fr 1fr; }
  .footer__cta { grid-column: 1 / -1; }
  .how__steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .top__bar { position: relative; }
  .top__menu { display: block; }
  .top__inner {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
  }
  .brand { gap: 10px; }
  .brand__logo { width: 44px; }
  .brand__org { display: none; }
  .brand__name { font-size: 15px; }
  .top.is-glass {
    padding: 0;
    padding-top: env(safe-area-inset-top);
    background: var(--blue);
  }
  .top.is-glass .top__bar {
    width: 100%;
    border-radius: 0;
    background: var(--blue);
    border-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  .top.is-glass .brand__logo { display: block; }
  .top__nav {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    width: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    background: var(--blue);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(21, 32, 51, .28);
    z-index: 60;
  }
  .top.is-menu .top__nav { display: flex; }
  .top__nav a,
  .top__logout {
    display: block;
    width: 100%;
    text-align: center;
    padding: 14px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    border: 0;
    cursor: pointer;
  }
  .top__cta {
    background: #fff !important;
    color: var(--blue) !important;
  }
  .teacher-form { grid-template-columns: 1fr; }
  .teacher-form input, .teacher-form select, .teacher-form textarea { font-size: 16px; }
  .file-picker.is-on .file-picker__box {
    flex-direction: column;
    text-align: center;
    min-height: 0;
  }
  .file-picker.is-on .file-picker__text { justify-items: center; text-align: center; flex: none; }
  .grid { grid-template-columns: 1fr; }
  .login-screen { padding: 20px 12px 32px; align-items: flex-start; }
  .login-card { width: 100%; padding: 22px 16px 20px; }
  .time-range { width: 100%; }
  .time-range label { width: 100%; }
  .time-range select { flex: 1; min-width: 0; width: 100%; font-size: 16px; }
}
@media (max-width: 860px) {
  .how__steps { grid-template-columns: 1fr 1fr; }
  .footer__grid,
  .footer__grid--admin { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .wrap { width: min(1180px, calc(100% - 24px)); }
  .intro { padding: 22px 0 28px; }
  .intro h1 { font-size: clamp(28px, 8vw, 40px); }
  .intro__lead { font-size: 15px; margin-bottom: 14px; }
  .intro__facts { gap: 6px; }
  .intro__facts span { font-size: 12px; padding: 5px 10px; }
  .catalog { padding: 18px 0 40px; }
  .filters {
    border-radius: 18px;
    padding: 14px 14px 10px;
    margin-bottom: 18px;
  }
  .filters__search input {
    font-size: 16px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 14px;
  }
  .filter-row { grid-template-columns: 1fr; gap: 6px; margin-bottom: 12px; }
  .filter-label { padding-top: 0; }
  .chips {
    flex-wrap: wrap;
    overflow: visible;
    gap: 6px;
    padding: 0;
    margin: 0;
  }
  .chip {
    flex: 0 1 auto;
    max-width: 100%;
    white-space: normal;
    padding: 8px 12px;
    font-size: 13px;
  }
  .age-slider { width: 100%; }
  .time-range { width: 100%; }
  .time-range select { font-size: 16px; min-width: 0; flex: 1; }
  .age-slider input[type="range"] { height: 8px; }
  .age-slider input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; }
  .age-slider input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; }
  .filters__meta { gap: 8px; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .dir-title { font-size: 19px; }
  .card { padding: 16px; border-radius: 18px; }
  .card__actions { flex-direction: column; }
  .card__actions .btn { width: 100%; }
  .how { padding: 0 0 28px; }
  .how__steps { grid-template-columns: 1fr; }
  .footer {
    padding: 36px 0 0;
  }
  .footer__brand {
    align-items: center;
    gap: 14px;
    padding-bottom: 20px;
    margin-bottom: 22px;
  }
  .footer__logo-wrap { width: 68px; height: 68px; border-radius: 18px; }
  .footer__logo { width: 46px; }
  .footer__kicker { max-width: none; }
  .footer__name { font-size: 22px; }
  .footer__grid,
  .footer__grid--admin { grid-template-columns: 1fr; gap: 22px; }
  .footer__cta { grid-column: auto; }
  .footer__bottom {
    flex-direction: column;
    padding: 14px 0 max(18px, env(safe-area-inset-bottom));
  }
  .footer__btn { width: 100%; }
  .teacher-form { grid-template-columns: 1fr; padding: 16px; }
  .teacher-form input, .teacher-form select, .teacher-form textarea { font-size: 16px; }
  .modal {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
    margin: auto;
  }
  .modal dl { grid-template-columns: 1fr; gap: 2px 0; }
  .modal dt { font-size: 12px; padding-top: 8px; }
  .modal__inner { padding: 20px 16px 16px; }
  .modal h2 { font-size: 20px; margin-right: 40px; }
  .modal .btn { width: 100%; margin: 8px 0 0; }
}
@media (max-width: 480px) {
  .wrap { width: calc(100% - 16px); }
  .brand__logo { width: 38px; }
  .brand__name { font-size: 14px; }
  .intro__kicker { letter-spacing: .1em; font-size: 11px; }
}

.to-top {
  position: fixed;
  right: 18px;
  bottom: calc(18px + 60px + 10px);
  z-index: 40;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(17, 42, 92, .12);
}
.to-top:hover { background: var(--blue-wash); }
.to-top[hidden] { display: none !important; }
.ai-chat__fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  width: 60px; height: 60px; padding: 0;
  border: 0; background: var(--blue); color: #fff;
  border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
}
.ai-chat__fab:hover { background: var(--blue-mid); }
.ai-chat__dot {
  position: absolute; top: 6px; right: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
}
.ai-chat__panel {
  position: fixed; inset: 0; z-index: 80;
  width: 100%; height: 100%;
  height: 100dvh;
  background: #fff; border: 0; border-radius: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.ai-chat__head {
  position: relative;
  background: var(--blue); color: #fff;
  padding: 10px 64px 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 10px;
  flex: 0 0 auto;
  min-height: 56px;
}
.ai-chat__head-logo {
  width: 40px;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.22));
}
.ai-chat__head > div { min-width: 0; flex: 1; }
.ai-chat__head b { display: block; font-size: 15px; }
.ai-chat__head span { display: block; font-size: 12px; opacity: .85; font-weight: 500; }
.ai-chat__fab[hidden],
.ai-chat__panel[hidden] { display: none !important; }
.ai-chat__close {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  background: #fff;
  color: var(--blue);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 2px 10px rgba(17, 42, 92, .18);
}
.ai-chat__close:hover { background: var(--blue-wash); }
.ai-chat__log {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  background: #f6f9fc;
  -webkit-overflow-scrolling: touch;
}
.ai-chat__msg {
  max-width: 90%; padding: 9px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap;
}
.ai-chat__msg--bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; white-space: normal; }
.ai-chat__msg--user { background: var(--blue); color: #fff; align-self: flex-end; }
.ai-chat__enroll {
  margin: 10px 0 4px;
  border: 1px solid var(--line);
  background: var(--page);
  border-radius: 16px;
  overflow: hidden;
}
.ai-chat__enroll-code {
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-chat__enroll-code span {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.ai-chat__enroll-code b {
  font-size: 22px;
  letter-spacing: .04em;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.ai-chat__enroll-link {
  display: block;
  text-align: center;
  background: var(--blue);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 12px;
}
.ai-chat__enroll-link:hover { background: var(--blue-mid); }
.ai-chat__form {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); background: #fff;
  flex: 0 0 auto;
}
.ai-chat__form input {
  flex: 1 1 auto; min-width: 0; width: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--page);
  font-size: 16px;
}
.ai-chat__send {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.ai-chat__send:hover { background: var(--blue-mid); }
.ai-chat__send:disabled { opacity: .55; cursor: default; }

html.ai-chat-open .top,
html.ai-chat-open .top__bar,
body.ai-chat-open .top {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
}
html.ai-chat-open #ai-chat {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
}
html.ai-chat-open body {
  overflow: hidden !important;
  position: fixed !important;
  left: 0;
  right: 0;
  width: 100% !important;
  height: 100% !important;
  overscroll-behavior: none;
  touch-action: none;
}
.ai-chat__panel {
  overscroll-behavior: none;
}
.ai-chat__log {
  overscroll-behavior: contain;
  touch-action: pan-y;
}

@media (max-width: 760px) {
  .to-top {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px + 10px);
    width: 44px;
    height: 44px;
  }
  .ai-chat__fab {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
  }
  .ai-chat__msg { max-width: 92%; }
  .ai-chat__head span { display: none; }
  .ai-chat__close {
    width: 48px;
    height: 48px;
  }
  .how { padding-bottom: 88px; }
}

.admin-ai {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 18px;
  display: grid;
  gap: 12px;
}
.admin-ai__head h2 {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 22px;
  letter-spacing: -.02em;
}
.admin-ai__head p { margin: 0; color: var(--muted); }
.admin-ai textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--page);
  font: inherit;
  resize: vertical;
  min-height: 120px;
}
.admin-ai__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.admin-ai__result {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.admin-ai__result h3 { margin: 0; font-size: 16px; color: var(--blue); }
.admin-draft {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--page);
  font-weight: 600;
}
.admin-draft span { font-weight: 500; color: var(--muted); }
.admin-draft span b { color: var(--ink); }
.admin-toolbar {
  display: grid;
  grid-template-columns: 1.4fr .9fr .9fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.admin-toolbar label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.admin-toolbar input,
.admin-toolbar select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
}
.admin-count { margin: 0 0 8px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.admin-list { display: grid; gap: 10px; }
.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  cursor: pointer;
}
.admin-row h3 { margin: 0 0 4px; font-size: 17px; color: var(--blue); }
.admin-row p { margin: 0; color: var(--muted); font-size: 14px; }
.admin-row p b { color: var(--ink); }
.admin-row__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.admin-row__side .btn { flex: none; }
.admin-editor { width: min(920px, calc(100% - 16px)); max-height: calc(100dvh - 24px); }
.admin-editor .modal__inner { overflow: auto; max-height: calc(100dvh - 24px); }
.admin-editor__kicker {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--blue-mid);
}
.admin-form { padding: 0; border: 0; background: transparent; }
.admin-form__actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-form__actions .btn { width: auto; flex: none; }
.btn-danger { background: #fde8ea; color: #9f1239; }
.admin-groups { display: grid; gap: 12px; }
.admin-groups__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.admin-groups__head h3 { margin: 0; color: var(--blue); font-size: 16px; }
.group-card {
  border: 1px solid var(--line);
  background: var(--page);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.group-card__top {
  display: grid;
  grid-template-columns: 1.3fr .8fr .6fr .6fr .7fr;
  gap: 8px;
}
.group-card__top label { display: grid; gap: 4px; font-size: 12px; }
.group-card__slots { display: grid; gap: 8px; }
.slot-row {
  display: grid;
  grid-template-columns: 90px 1fr auto 1fr auto;
  gap: 8px;
  align-items: center;
}
.slot-row__to { color: var(--muted); font-weight: 700; }
.slot-row__remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 6px;
}
.group-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.group-card__actions .btn { width: auto; }

@media (hover: hover) and (pointer: fine) {
  .admin-row:hover { border-color: #b7cbe0; }
  .btn-danger:hover { background: #f9cfd5; }
  .slot-row__remove:hover { color: #9f1239; }
}

@media (max-width: 900px) {
  .admin-toolbar { grid-template-columns: 1fr 1fr; }
  .admin-count { grid-column: 1 / -1; }
  .group-card__top { grid-template-columns: 1fr 1fr; }
  .slot-row { grid-template-columns: 1fr 1fr; }
  .slot-row__to, .slot-row__remove { justify-self: start; }
}
@media (max-width: 640px) {
  .admin-toolbar { grid-template-columns: 1fr; }
  .admin-row { flex-direction: column; }
  .admin-row__side { flex-direction: row; align-items: center; width: 100%; }
  .admin-draft { grid-template-columns: auto 1fr; }
  .admin-draft .btn { grid-column: 1 / -1; }
}
