.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); }
  .form-panel :is(input:not([type=radio], [type=checkbox], [type=file]), textarea) { 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; }
  .dialog-head .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: var(--weight-strong); }
  .insight-cell-label { display: block; font-size: .79rem; font-weight: var(--weight-label); 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; }
  .admin-workspace-tabs, .studio-view-tabs { display: grid; width: 100%; overflow: visible; }
  .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; }
  .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; }
  .collection-picker .button, .editor-save .button { width: 100%; }
  .editor-save .form-actions, .moderation-form .form-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  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));
  }
}

@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; }
}

@media (max-width: 355px) {
  .studio-view-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
