/* ---------- Телефон (Max 12.10: «компактнее, красивее, ровнее») ----------
   Loaded after theme.css and touches only ≤599px: the computer layout stays as it is. One place for the phone
   pass, so the screen files keep their own sizes and this file only tightens them. */
@media (max-width: 599px) {
  /* Header: content scrolled under a 72% glass and read through it. */
  .db-top, .hw-top, .lib-top, .sc-top,
  .ag-top, .cu-top, .al-top, .subj-top, .pf-top, .st-top, .ad-top, .as-top, .pl-top, .nt-top {
    background: color-mix(in srgb, var(--bg) 92%, transparent);
  }

  /* Page heads: one size for every screen, two lines at most. */
  .ag-main, .cu-main, .al-main, .subj-main, .pf-main, .st-main, .hw-main { padding-top: var(--s-5); }
  .ag-head, .cu-head, .al-head, .subj-head, .st-head, .ad-head, .pl-head { margin-bottom: var(--s-5); }
  .ag-head__title, .cu-head__title, .al-head__title, .subj-head__title, .st-head__title, .ad-head__title,
  .pl-head__title, .hw-head__title, .sc-head__title, .lib-head__title {
    font-size: 2rem;
    line-height: 1.05;
  }
  .ag-head__sub, .cu-head__sub, .al-head__sub, .subj-head__sub, .st-head__sub, .hw-head__sub, .sc-head__sub {
    font-size: var(--fs-16);
  }
  .panel { padding: 20px; }

  /* ---------- Главная ---------- */
  .db-hello { padding: var(--s-5) 0 var(--s-4); }
  .db-hello__title { font-size: 1.75rem; line-height: 1.08; }
  .db-hello__summary { font-size: var(--fs-16); }
  /* Trial banner: one line with a link instead of a card with a button. */
  .db-sub { flex-wrap: nowrap; gap: var(--s-3); padding: 10px 10px 10px 14px; }
  .db-sub__text { font-size: 0.8125rem; line-height: 1.4; }
  .db-sub__actions { flex: none; }
  .db-sub__actions .btn { min-height: 34px; padding: 0 12px; font-size: 0.8125rem; }
  /* The grid column took the widest word: «Партиционирование» in Unbounded pushed the card 17px past the screen. */
  .next { padding: 20px; grid-template-columns: minmax(0, 1fr); }
  .next__subject { font-size: 1.75rem; overflow-wrap: break-word; hyphens: auto; }
  /* Pair buttons: one even column instead of a ragged stack of different widths. */
  .next__actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .next__actions .btn { width: 100%; justify-content: center; }
  .next__actions .next__week { justify-self: start; margin-left: 0; }
  .agent { padding: 20px; }
  .agent__desc { font-size: var(--fs-14); }
  /* «N конспектов за неделю» already stands in the greeting line. */
  .db-stat { display: none; }
  .db-section { padding-top: var(--s-6); }
  /* Note rows: the homework badge goes under the meta, the title gets the whole width. */
  .note { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 12px; padding: 14px 16px; }
  .note + .note::before { left: 36px; }
  .note__dot { margin-top: 0.55em; }
  .note > .badge--hw { grid-column: 2; justify-self: start; margin-top: 4px; position: relative; z-index: 1; }
  .note__chev { display: none; }
  .db-invite { padding: 20px; }

  /* ---------- Домашка ---------- */
  .hw-head { gap: var(--s-4); margin-bottom: var(--s-5); }
  .hw-focus { padding: 20px; }
  /* Unbounded fits 13 letters a line here: a card title in it took four lines. */
  .hw-focus__title { font-family: var(--font-ui); font-size: 1.375rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
  .hw-li { padding: 14px 16px; }
  .list-group { padding: 16px 16px 4px; }

  /* ---------- Конспект ---------- */
  /* Print and theme live elsewhere on a phone (system dialog, profile): five round buttons crowded the bar. */
  .nt-top [data-print],
  .nt-top .theme-switch { display: none; }
  .nt-head__title { font-size: 1.5rem; line-height: 1.12; letter-spacing: -0.04em; }
  .nt-depth__hint { display: none; }
  .nt-hw { padding: 20px; }
  .nt-hw__title { font-size: 1.25rem; }
  .nt-hw__text { line-height: 1.55; }
  .nt-hw__actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .nt-hw__actions .btn { width: 100%; justify-content: center; text-align: center; }
  /* Formats: light chips under the step tabs, not a second grey block; six of them go three and three. */
  .nt-hw .nt-solve__formats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0;
    background: transparent;
  }
  .nt-solve__formats .seg__btn { min-height: 32px; padding: 0 9px; font-size: 0.8125rem; }
  .nt-solve__formats .seg__pill { background: var(--surface); box-shadow: 0 0 0 1px var(--border); }

  /* ---------- Расписание ---------- */
  .sc-head { margin-bottom: var(--s-4); }
  .sc-col { padding: 8px; }
  .sc-slot { padding: 12px 14px; }

  /* ---------- Профиль ---------- */
  .pf-main { padding-top: var(--s-5); }
  .pf-id { margin-bottom: var(--s-5); }
  .pf-id__name { font-size: 1.75rem; line-height: 1.08; }
  .pf-cards { gap: var(--s-3); }
  .pf-card { padding: 20px; }
  .pf-card__title { font-size: 1.125rem; }
  .pen { height: 128px; margin-bottom: var(--s-5); }

  /* ---------- Мастер агента, согласия, политика ---------- */
  .as-step__actions, .cn-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .as-step__actions .btn, .cn-actions .btn { width: 100%; justify-content: center; }
  .agree { padding: 12px 14px; gap: 12px; }
  .agrees > .field__error:empty { display: none; }
  .pv-title { font-family: var(--font-ui); font-size: 1.375rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }

  /* «На доработку»: кнопки карточки в столбик одной ширины, как везде на телефоне. */
  .rw-card { padding: var(--s-4); }
  .rw-actions .btn { flex: 1 1 100%; }
}

/* ---------- Телефон как приложение (ROADMAP-26.09 §45) ---------- */
@media (max-width: 599px) {
  /* The next-pair card was ~30px wider than the screen: its grid column took the width of the longest line. */
  .panel.next, .next__head { grid-template-columns: minmax(0, 1fr); }
  .next__top > *, .next__head > * { min-width: 0; }
  .tl__cap { flex-wrap: wrap; row-gap: 2px; }
  /* «Партиционирование» alone is wider than the card at 1.9rem: smaller, and a long word breaks with a hyphen. */
  .next__subject { font-size: 1.625rem; max-width: none; hyphens: auto; overflow-wrap: break-word; }

  /* Top bar: back, logo, search, avatar. Five round buttons did not fit 360px and pushed the avatar off the
     edge; the theme lives in the profile. */
  [class*="-top__right"] .theme-switch { display: none; }

  /* «Кто ты» in settings and the onboarding: the «из ЛК» badge took a column and squeezed the name and email into
     one word a line. It goes under the text. */
  .st-id, .ob-lxp { grid-template-columns: auto minmax(0, 1fr); }
  .st-id > .badge, .ob-lxp > .badge { grid-column: 2; justify-self: start; }
  .st-id__meta { overflow-wrap: anywhere; }

  /* Room under the last block for the «Спросить» button, so it never sits on a screen's last button. */
  body.has-tabbar #app > :first-child { padding-bottom: 76px; }

  /* Small text links (teacher, subject, «Все →»): the look stays, the finger gets a 44px target. */
  .who-link, .db-links__link, .hw-li__link, .lib-shelf__link, .nt-links__link, .hw-feed__src {
    padding-block: 10px;
    margin-block: -10px;
  }
}

/* Touch: no grey flash on tap, no 300ms double-tap wait on buttons. */
@media (pointer: coarse) {
  html { -webkit-tap-highlight-color: transparent; }
  a, button, [role="button"], label { touch-action: manipulation; }
}
