@media (max-width: 900px) {
  body.mobile-nav-open { overflow: hidden; }
  .app-shell { display: block; min-height: 100vh; min-height: 100dvh; min-width: 0; overflow-x: clip; }
  .workspace, #view-container { min-width: 0; }
  .sidebar {
    position: fixed;
    z-index: 41;
    inset: 0 auto 0 0;
    width: min(340px, 88vw);
    height: 100vh;
    height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
    box-shadow: 18px 0 48px #0007;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .24s var(--ease), visibility .24s linear;
  }
  .sidebar.is-mobile-open { transform: translateX(0); visibility: visible; }
  .brand { padding: 4px 8px 18px; }
  .main-nav { display: grid; flex: 1 1 auto; overflow-x: hidden; overflow-y: auto; gap: 9px; }
  .nav-group { display: grid; }
  .nav-section-label { display: block; }
  .nav-link { flex: 0 0 auto; width: 100%; min-height: 46px; gap: 11px; padding: 9px 10px; font-size: 12px; white-space: normal; }
  .nav-link::before { top: 9px; right: auto; bottom: 9px; left: 0; width: 2px; height: auto; }
  .sidebar-profile-nav { display: none; }
  .mobile-nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-control);
    color: var(--text-secondary);
    background: var(--bg-surface);
    cursor: pointer;
    font: 600 11px var(--font-sans);
  }
  .mobile-nav-close .icon { width: 16px; height: 16px; }
  .mobile-nav-backdrop:not([hidden]) {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    background: #0009;
    backdrop-filter: blur(2px);
  }
  .mobile-app-header {
    position: sticky;
    z-index: 22;
    top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: calc(58px + env(safe-area-inset-top));
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
  }
  .mobile-nav-toggle, .mobile-account-button {
    display: grid;
    flex: 0 0 44px;
    place-items: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    cursor: pointer;
  }
  .mobile-nav-toggle .icon { width: 19px; height: 19px; }
  .mobile-account-button { border-color: transparent; background: transparent; }
  .mobile-account-button .sidebar-profile-avatar { flex: 0 0 34px; width: 34px; height: 34px; }
  .mobile-account-button[aria-expanded="true"] { border-color: var(--brand-border); background: var(--brand-soft); }
  .mobile-app-mark { display: grid; flex: 0 0 31px; place-items: center; width: 31px; height: 31px; padding: 3px; overflow: hidden; border-radius: 8px; background: var(--text-primary); }
  .mobile-app-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
  .mobile-app-heading { display: grid; flex: 1 1 auto; min-width: 0; gap: 2px; }
  .mobile-app-heading strong { overflow: hidden; color: var(--text-primary); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-app-heading small { overflow: hidden; color: var(--brand-text); font-size: 9px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { position: static; flex-wrap: nowrap; min-height: 54px; gap: 8px; padding: 6px 12px; }
  .global-search { flex: 1 1 auto; width: auto; min-width: 0; min-height: 40px; gap: 8px; font-size: 11px; }
  .global-search > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .global-search kbd { display: none; }
  .topbar-right { flex: 0 0 auto; width: auto; justify-content: flex-end; gap: 8px; }
  .main-content, .main-content--workspace { width: 100%; min-width: 0; padding: 17px 14px calc(92px + env(safe-area-inset-bottom)); }
  .settings-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    align-items: stretch;
    overflow: visible;
  }
  .settings-nav-heading { grid-column: 1 / -1; flex: initial; }
  .settings-nav-link { min-width: 0; min-height: 48px; white-space: normal; overflow-wrap: anywhere; }
  .settings-nav-index { flex: 0 0 auto; }
  .page-head { align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: clamp(20px, 5vw, 26px); line-height: 1.2; overflow-wrap: anywhere; }
  .page-head > div, .page-actions, .form-grid > *, .section-card, .section-card > * { min-width: 0; }
  .page-actions { flex-wrap: wrap; gap: 8px; }
  .page-actions > .button { max-width: 100%; }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 24;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
    box-shadow: 0 -8px 24px #0003;
  }
  .mobile-bottom-nav-link, .mobile-bottom-nav-more {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    padding: 5px 2px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    font: 600 9px/1.2 var(--font-sans);
    text-align: center;
    touch-action: manipulation;
  }
  .mobile-bottom-nav-link .icon, .mobile-bottom-nav-more .icon { width: 17px; height: 17px; }
  .mobile-bottom-nav-link.is-active, .mobile-bottom-nav-more[aria-pressed="true"] {
    border-color: var(--brand-border);
    color: var(--brand-text);
    background: var(--brand-soft);
  }
  .mobile-bottom-nav-link:focus-visible, .mobile-bottom-nav-more:focus-visible,
  .mobile-nav-toggle:focus-visible, .mobile-account-button:focus-visible, .mobile-nav-close:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
  }
  .live-current-panel, .live-next-panel, .live-technical-panel,
  .task-board, .inbox-section, .backup-section, .rehearsal-workspace,
  .rehearsal-queue, .settings-section { min-width: 0; }
  .live-operator-actions { gap: 9px; }
  .live-operator-button { min-height: 48px; }
  .live-current-title, .live-next-title, .production-sheet-title h1 { overflow-wrap: anywhere; }
  .form-actions, .dialog-actions, .confirmation-dialog-actions { flex-wrap: wrap; }
  .date-picker-popup, .custom-select-popup, .production-action-menu, .account-menu {
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
}

@media (max-width: 480px) {
  .mobile-app-header { gap: 6px; padding-right: 8px; padding-left: 8px; }
  .mobile-nav-toggle, .mobile-account-button { flex-basis: 42px; width: 42px; min-width: 42px; }
  .mobile-app-mark { flex-basis: 28px; width: 28px; height: 28px; }
  .mobile-app-heading strong { font-size: 10px; }
  .mobile-app-heading small { font-size: 9px; }
  .main-content, .main-content--workspace { padding-right: 11px; padding-left: 11px; }
  .settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .global-search { min-height: 42px; padding-inline: 9px; }
  .global-search > span { font-size: 10px; }
  .topbar-right .sync-status { display: none; }
  .topbar-connection { padding-inline: 7px; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-attention-list, .dashboard-submission-metrics { grid-template-columns: minmax(0, 1fr); }
  .production-filter-selects, .manual-item-filter-selects, .inbox-filters { grid-template-columns: minmax(0, 1fr); }
  .task-header-actions { align-items: stretch; flex-direction: column; }
  .task-header-actions > .button, .production-create-button { width: 100%; }
  .live-current-panel { padding: 15px 12px; }
  .live-current-timer { font-size: clamp(44px, 14vw, 60px); }
  .live-operator-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .live-operator-button { width: 100%; }
  .live-next-panel { padding-top: 13px; }
  .live-schedule-row { grid-template-columns: 24px minmax(0, 1fr); }
  .live-schedule-duration { grid-column: 2; justify-self: start; }
  .form-actions > .button, .form-actions > button { flex: 1 1 100%; width: 100%; }
  .page-actions > .button { flex: 1 1 auto; }
}

@media (max-width: 360px) {
  .mobile-bottom-nav { gap: 1px; padding-right: 3px; padding-left: 3px; }
  .mobile-bottom-nav-link, .mobile-bottom-nav-more { font-size: 8px; }
  .inbox-summary { grid-template-columns: minmax(0, 1fr); }
  .production-overview { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .backup-page { align-content: start; }
  .backup-section { align-self: start; height: auto; min-height: 0; }
  .backup-create-heading, .backup-create-content { height: auto; min-height: 0; }
  .backup-create-content { flex: 0 1 auto; }
  .backup-create-content > p { flex: 0 1 auto; }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .mobile-app-header { min-height: 52px; padding-top: 4px; }
  .mobile-bottom-nav-link, .mobile-bottom-nav-more { min-height: 46px; }
  .sidebar { padding-top: calc(8px + env(safe-area-inset-top)); }
  .main-nav { gap: 5px; }
  .settings-page { gap: 8px; }
  .settings-page .page-head { padding-bottom: 0; }
  .settings-page .page-head p { display: none; }
  .settings-nav { display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 5px; }
  .settings-nav-heading { display: none; }
  .settings-nav-link { flex: 0 0 auto; max-width: 180px; }
}
