.reader-banner-compact { min-height: 115px; padding-block: 19px; }
.reader-banner-compact h1 { font-size: clamp(1.85rem, 4vw, 2.8rem); }
.reader-banner-compact .dashboard-avatar { width: clamp(50px, 7vw, 70px); }
.reader-banner-compact p { overflow-wrap: anywhere; }
.account-preferences .account-device-card { grid-column: 1 / -1; }
.account-preferences .local-note { overflow-wrap: anywhere; }
.reader-workspace-tabs { flex-wrap: wrap; }
.insight-cell-label { display: none; }
.notice-row, .moderation-row { display: grid; min-width: 0; }
.notice-row .badge { justify-self: start; }

@media (max-width: 800px), (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  :root { --mobile-nav-space: calc(56px + max(5px, var(--safe-bottom))); }
  .reader-layout { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: var(--mobile-nav-space); }
  .reader-layout > .main-shell { flex: 1; overflow: auto; }
  .topbar-inner, .content { padding-inline: max(var(--gutter), var(--safe-left)) max(var(--gutter), var(--safe-right)); }
  .topbar-inner { column-gap: 8px; padding-top: max(8px, var(--safe-top)); }
  .top-actions { flex: none; gap: 5px; }
  .top-actions .icon-button, .top-actions .avatar { width: 44px; min-height: 44px; }
  .site-navigation .nav-link { min-height: 51px; white-space: nowrap; font-size: .75rem; }
  .site-navigation .nav-link svg { width: 20px; height: 20px; }
  .content { padding-bottom: calc(var(--mobile-nav-space) + 20px); }
  .reader-layout .content { padding-bottom: 20px; }
  #toast { right: max(22px, var(--safe-right)); bottom: calc(var(--mobile-nav-space) + 8px); }
  .editor-save { bottom: calc(var(--mobile-nav-space) + 6px); }
  .form-panel :is(input:not([type=radio], [type=checkbox], [type=file]), textarea),
  .chapter-search input { min-width: 0; font-size: 1rem; }
  .detail-meta { flex-wrap: wrap; }
  .studio-topbar .topbar-inner { flex-wrap: nowrap; }
  .studio-topbar .top-actions { min-width: 0; flex: 0 1 auto; justify-content: flex-end; flex-wrap: wrap; }
  .studio-topbar .top-actions a { min-height: 36px; text-align: right; }
  .chapter-actions :is(a, button), .profile-actions .button { min-height: 44px; }
  .reader-exit, .reader-tools .icon-button, .page-footer .icon-button { justify-content: center; min-width: 44px; min-height: 44px; }
  .dialog-head .icon-button, .font-control .icon-button { width: 44px; min-height: 44px; }
  dialog {
    inset: max(14px, var(--safe-top)) max(14px, var(--safe-right)) max(14px, var(--safe-bottom)) max(14px, var(--safe-left));
    width: min(100% - max(14px, var(--safe-left)) - max(14px, var(--safe-right)), 450px);
    max-height: calc(100dvh - max(14px, var(--safe-top)) - max(14px, var(--safe-bottom)));
  }
}

@media (max-width: 680px) {
  .insight-books-panel { overflow: visible; border: 0; background: transparent; }
  .insight-books-table, .insight-books-table tbody { display: grid; gap: 9px; }
  .insight-books-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .insight-books-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--line); background: var(--surface); }
  .insight-books-table tr :is(th,td) { min-width: 0; max-width: none; padding: 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .insight-books-table tbody th[scope='row'] { grid-column: 1 / -1; min-width: 0; max-width: none; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .insight-books-table tbody th a { display: inline-flex; min-height: 34px; align-items: center; }
  .insight-books-table td { font-weight: 750; }
  .insight-cell-label { display: block; font-size: .79rem; font-weight: 650; color: var(--muted); }
  .insight-table-panel[aria-label='Чтение по главам'] td { white-space: normal; }
  .notice-row, .moderation-row { align-items: start; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; }
  .notice-row .badge, .moderation-row > :last-child { grid-column: 2; }
}

@media (max-width: 570px) {
  .section-head > .text-link, .catalog-byline > .author-byline { min-height: 24px; }
  .catalog-byline > .author-byline { display: inline-flex; align-items: center; }
  .reader-banner-compact { min-height: 0; padding: 12px 14px; margin-bottom: 12px; }
  .reader-banner-compact h1 { margin: 0 0 3px; font-size: clamp(1.625rem, 7vw, 2.06rem); }
  .reader-banner-compact .dashboard-avatar { width: 42px; margin-inline-end: 1px; }
  .reader-workspace-tabs, .admin-workspace-tabs, .editor-tabs, .studio-view-tabs { display: grid; width: 100%; overflow: visible; }
  .reader-workspace-tabs, .editor-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-workspace-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .studio-view-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace-tabs :is(a, button) { justify-content: center; min-width: 0; min-height: 44px; padding: 4px 3px; text-align: center; }
  .reader-workspace-tabs { margin-bottom: 13px; }
  .account-preferences { gap: 10px; }
  .account-preferences .form-panel { padding: 13px; }
  .push-profile { gap: 12px; }
  .push-heading h2 { font-size: clamp(1.2rem, 6vw, 1.55rem); }
  .push-heading p { font-size: .85rem; }
  .push-profile .push-choice { padding: 10px; gap: 10px; }
  .account-preferences .push-device .button { width: 100%; }
  .dashboard-section .section-head, .form-panel .section-head { flex-wrap: wrap; }
  .history-row .button, .form-panel .file-label, .editor-save .button, .collection-picker .button, .chapter-list :is(a,button), .dropdown-trigger { min-height: 44px; }
  .detail-actions .button { flex: 1 1 8.5rem; }
  .collection-picker .button, .editor-save .button { width: 100%; }
  .editor-save { position: static; padding: 10px; }
  .editor-save .form-actions, .moderation-form .form-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .editor-save .remove-chapter { margin: 0; min-height: 38px; }
  dialog {
    inset: auto 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    max-height: min(90dvh, 100dvh - var(--safe-top) - 12px);
    padding: 15px max(15px, var(--safe-right)) max(18px, var(--safe-bottom) + 8px) max(15px, var(--safe-left));
  }
  .reader-bar-inner { grid-template-columns: minmax(44px,auto) minmax(0, 1fr) auto; min-height: 54px; gap: 4px; }
  .reader-book-title { text-align: left; }
  .reader-tools { gap: 0; }
  .page-footer { min-height: 62px; gap: 6px; }
}

@media (max-width: 430px) {
  .book-card-fields { grid-template-columns: minmax(0, 1fr); }
  .cover-editor { grid-template-columns: 71px minmax(0, 1fr); align-items: center; gap: 5px 12px; }
  #studio-cover { grid-row: 1 / span 3; }
  .cover-editor .text-link { justify-self: start; }
  .cover-editor .local-note { text-align: left; }
  .reader-bar-inner { grid-template-columns: minmax(44px, auto) minmax(0, 1fr) auto; row-gap: 0; }
  .reader-tools { grid-column: 3; grid-row: 1; }
  .reader-book-title { grid-column: 1 / -1; grid-row: 2; padding: 0 6px 5px; text-align: center; }
}

@media (max-width: 355px) {
  .studio-view-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 570px) and (max-height: 440px) {
  .page-footer { min-height: 48px; }
}
