/* ───────────────────────────────────────────────
   Мобильная версия «Центра программ» (телефоны и узкие окна)
   ─────────────────────────────────────────────── */
html { -webkit-tap-highlight-color: transparent; }
button, a, .btn, .chip, .card { touch-action: manipulation; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom); }

  /* верхняя панель: компактная, без подсказки */
  .topbar { height: auto; min-height: 52px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 8px; }
  .topbar .hint, .topbar .spacer { display: none; }
  .topbar .back { padding: 8px 12px; font-size: 14px; flex: none; }
  .topbar .back .bt { display: none; }
  .topbar .ttl { font-size: 16px; min-width: 0; flex: 1; gap: 8px; }
  .topbar .ttl .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .ttl .ic { font-size: 20px; flex: none; }

  /* поля — 16px, чтобы iPhone не увеличивал страницу при вводе */
  input, select, textarea, input[type="text"], input[type="number"], input[type="url"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"] { font-size: 16px !important; min-height: 42px; }
  textarea { min-height: 80px; }
  .btn { min-height: 42px; padding: 10px 14px; }
  .btn.small { min-height: 36px; }
  .check input { width: 22px; height: 22px; }
  .chip, .seg button { padding-top: 8px; padding-bottom: 8px; }

  /* вкладки и сегменты прокручиваются, а не вылезают за экран */
  .tabs, .seg, .subtabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
  .tabs > *, .seg > * { flex: none; }

  /* строки с полями и кнопками переносятся */
  .row { flex-wrap: wrap; }
  .panel { padding: 14px; max-width: 100%; min-width: 0; border-radius: 16px; }
  .panel table, .panel .tbl, .table-wrap { display: block; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  pre, code, .log, .out { max-width: 100%; overflow-x: auto; }
  img, video, canvas, svg { max-width: 100%; }
  video { height: auto; }

  /* окна и диалоги */
  dialog, .modal > *, .dlg, .popup { max-width: 94vw !important; max-height: 90vh; overflow: auto; }

  /* многоколоночные раскладки превращаем в одну колонку */
  .two, .cols, .split, .layout, .grid2, .grid3, .g2, .g3, .stack-m { grid-template-columns: minmax(0, 1fr) !important; }
  .stack-m { display: grid; }

  /* главная */
  .home { padding: 18px 14px; padding-top: calc(18px + env(safe-area-inset-top)); }
  .home header { flex-wrap: nowrap; gap: 8px; }
  .home header .logo { width: 46px; height: 46px; font-size: 24px; flex: none; }
  .home header > div:nth-child(2) { min-width: 0; flex: 1; }
  .home .btn.icon { width: 40px; height: 40px; margin-left: 0; flex: none; }
  .home h1 { font-size: 22px; }
  .home #who { margin-left: auto; flex-basis: auto; order: 0; }
  .toast { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: none; transform: translateY(20px); }
  .toast.show { transform: none; }
}
@media (max-width: 480px) {
  .home .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .home .card { min-height: 150px; padding: 14px; border-radius: 18px; }
  .home .card .desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; }
  .home .card .name { font-size: 15px; }
  .home .card .ico { font-size: 26px; }
  .home footer { font-size: 11px; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
}
