/* Адаптивная раскладка: телефон → планшет → компьютер */

/* ---------- Телефон (< 768px) — как во Flutter ---------- */
#app {
  padding: calc(12px + var(--safe-t)) max(var(--gutter), env(safe-area-inset-right)) calc(24px + var(--safe-b)) max(var(--gutter), env(safe-area-inset-left));
  min-height: 100dvh;
}
body[data-chrome="tabs"] #app { padding-bottom: calc(108px + var(--safe-b)); }
body[data-chrome="tabs"] { --toast-b: 100px; }
.page { width: 100%; margin: 0 auto; }

.grid-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* Нижнее меню */
.bottom-nav {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  display: flex; padding: 10px 10px calc(10px + var(--safe-b));
  background: #fff; border-radius: 28px 28px 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, .07);
}
.bottom-nav a {
  flex: 1 1 0; min-width: 0; margin: 0 2px; padding: 8px 2px; border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
  font-size: clamp(9px, 2.9vw, 12px); font-weight: 700; transition: background-color .22s, color .22s, transform .11s;
}
.bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav a.is-active { background: var(--blue-soft); color: var(--primary); font-weight: 800; }
body:not([data-chrome="tabs"]) .bottom-nav { display: none; }

/* Боковое меню скрыто на телефоне и планшете */
.sidebar { display: none; }
.sidebar-install { display: none; }

/* Онбординг: узкая колонка по центру */
body[data-chrome="bare"] .page { max-width: 520px; }

@media (max-width: 359px) {
  :root { --gutter: 16px; }
  .banner-text { padding-right: 130px; }
  .banner-title { font-size: 17px; }
  .therapist-tile { gap: 10px; padding: 12px; }
  .info-tiles { gap: 8px; }
  .tp-head { gap: 10px; }
}

/* ---------- Планшет (768–1023px) ---------- */
@media (min-width: 768px) {
  .page { max-width: 720px; }
  .grid-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip-row { margin: 0; padding: 4px 0; flex-wrap: wrap; overflow: visible; }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .bottom-nav { left: 50%; right: auto; width: min(560px, 100%); transform: translateX(-50%); }
  .reviews-strip { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}

/* ---------- Компьютер (≥ 1024px) ---------- */
@media (min-width: 1024px) {
  body { --toast-b: 32px !important; }
  #app, body[data-chrome="tabs"] #app { margin-left: 240px; padding: 32px 40px 48px; }
  body[data-chrome="bare"] #app { margin-left: 0; padding-top: 48px; }
  .page { max-width: 1100px; }
  .toast { left: calc(50% + 120px); }
  body[data-chrome="bare"] .toast { left: 50%; }

  .bottom-nav { display: none !important; }

  .sidebar {
    display: flex; flex-direction: column; position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 240px;
    padding: 24px 16px; background: #fff; box-shadow: 4px 0 24px rgba(0, 0, 0, .05); border-radius: 0 28px 28px 0;
  }
  body[data-chrome="bare"] .sidebar { display: none; }
  .sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
  .sidebar-logo .home-avatar { width: 48px; height: 48px; }
  .logo-name { display: block; font-size: 20px; font-weight: 900; color: var(--primary); line-height: 1.1; }
  .side-nav { display: flex; flex-direction: column; gap: 6px; }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px;
    color: var(--muted); font-size: 16px; font-weight: 700;
  }
  .side-nav a.is-active { background: var(--blue-soft); color: var(--primary); font-weight: 800; }
  body.can-install .sidebar-install { display: inline-flex; margin-top: auto; width: 100%; }

  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
  .grid-rows { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

  /* Главная */
  .home-header .home-avatar { display: none; }
  .banner { height: 220px; }
  .banner-boy { height: 200px; }
  .banner-text { padding: 32px 260px 28px 32px; }
  .banner-title { font-size: 28px; max-width: 520px; }

  /* Урок: видео слева, задания справа */
  .lesson-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: 24px; }
  .lesson-side { position: sticky; top: 24px; }

  /* Профиль логопеда: 2 колонки */
  .tp-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
  .tp-left, .tp-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .tp-left { position: sticky; top: 24px; }
  .tp-head { flex-direction: column; text-align: center; padding: 28px 20px 20px; }
  .tp-head .tp-rating { justify-content: center; }
  .tp-head .avatar { --s: 128px !important; }
  .tp-price { flex-direction: row; gap: 6px; align-items: baseline; padding: 10px 16px; }
  .tp-price br { display: none; }
  .tp-actions { margin-top: 0; }
  .tp-reviews { margin-top: 10px; }
  .reviews-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); overflow: visible; padding-bottom: 0; }
  .reviews-strip .review { flex: none; }

  /* Профиль */
  .profile-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }

  /* Шторка → центрированный диалог */
  .overlay-sheet { align-items: center; padding: 24px; }
  .sheet { border-radius: 28px; max-height: 80vh; padding-bottom: 24px; transform: scale(.94); opacity: 0; transition: transform .2s, opacity .2s; }
  .overlay.open .sheet { transform: none; opacity: 1; }
}

@media (min-width: 1400px) {
  #app, body[data-chrome="tabs"] #app { padding-left: 56px; padding-right: 56px; }
}
