/* V36.6.1 — reliable portrait drawer and consistent header action placement. */
.app-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 1800 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  isolation: isolate !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.app-header .header-left {
  display: flex !important;
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
}
.app-header .brand-stack { min-width: 0 !important; flex: 0 1 auto !important; }
.app-header .header-controls {
  display: flex !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 0 !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  margin-left: auto !important;
}
.app-header .notification-center { order: 0 !important; }
.app-header #theme-gallery-toggle {
  order: 1 !important;
  display: inline-flex !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  align-self: auto !important;
  white-space: nowrap !important;
}
.app-header .user-pill { order: 2 !important; flex: 0 1 auto !important; }
.header-action-icon {
  display: block !important;
  width: 17px !important;
  height: 17px !important;
  flex: 0 0 17px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 1.8 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}
#mobile-menu-toggle.mobile-menu-toggle {
  display: inline-flex !important;
  position: relative !important;
  z-index: 1802 !important;
  flex: 0 0 auto !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}
#app-sidebar.app-sidebar { z-index: 1700 !important; }
#sidebar-backdrop, .sidebar-backdrop { z-index: 1600 !important; }
/* The header toggle must remain above the drawer backdrop, which begins below the header. */
@media (max-width: 980px) {
  .app-header { padding: 8px 12px !important; gap: 7px 10px !important; }
  .app-header .header-left { flex: 1 1 100% !important; width: 100% !important; }
  .app-header .header-controls {
    flex: 1 1 100% !important;
    width: 100% !important;
    justify-content: flex-end !important;
    align-items: center !important;
    margin-left: 0 !important;
  }
  .app-header .header-controls .theme-gallery-toggle { order: 1 !important; }
  .app-header .header-controls .user-pill { order: 2 !important; }
}
@media (max-width: 600px) and (orientation: portrait) {
  :root { --v36-header-height: 118px; }
  .app-header { position: sticky !important; z-index: 1800 !important; }
  #app-sidebar.app-sidebar {
    position: fixed !important;
    top: calc(var(--v36-header-height) + 5px) !important;
    left: 6px !important;
    bottom: 6px !important;
    width: min(82vw, 310px) !important;
    max-width: calc(100vw - 12px) !important;
    height: calc(100dvh - var(--v36-header-height) - 11px) !important;
    max-height: calc(100dvh - var(--v36-header-height) - 11px) !important;
    z-index: 1700 !important;
    transform: translateX(calc(-100% - 22px)) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: transform .24s ease, visibility .24s ease !important;
  }
  body.sidebar-expanded #app-sidebar.app-sidebar {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  body.sidebar-collapsed #app-sidebar.app-sidebar {
    transform: translateX(calc(-100% - 22px)) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  #sidebar-backdrop, .sidebar-backdrop {
    position: fixed !important;
    inset: calc(var(--v36-header-height) + 2px) 0 0 !important;
    z-index: 1600 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  body.sidebar-expanded #sidebar-backdrop,
  body.sidebar-expanded .sidebar-backdrop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  body.sidebar-collapsed #sidebar-backdrop,
  body.sidebar-collapsed .sidebar-backdrop {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  #mobile-menu-toggle.mobile-menu-toggle { z-index: 1802 !important; }
  .app-header .header-controls { gap: 6px !important; }
  .app-header .header-controls .theme-gallery-toggle { padding: 6px 9px !important; font-size: 11px !important; }
  .app-header .header-controls .user-pill { max-width: 64vw !important; }
}
@media (min-width: 601px) {
  #app-sidebar.app-sidebar { visibility: visible !important; }
  body.sidebar-expanded #app-sidebar.app-sidebar { transform: translateX(0) !important; pointer-events: auto !important; }
  body.sidebar-collapsed #app-sidebar.app-sidebar { transform: translateX(calc(-100% - 26px)) !important; pointer-events: none !important; }
}
/* Admin navigation icons use the same clean outline language as the primary menu. */
.admin-subnav-btn { display: inline-flex !important; align-items: center !important; gap: 9px !important; }
.admin-nav-icon { display: inline-flex !important; flex: 0 0 23px !important; width: 23px !important; height: 23px !important; align-items: center !important; justify-content: center !important; color: currentColor !important; }
.admin-nav-icon svg { display: block !important; width: 20px !important; height: 20px !important; fill: none !important; stroke: currentColor !important; stroke-width: 1.8 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }
.admin-nav-label { display: inline-block !important; min-width: 0 !important; }

.admin-section-heading { display:flex !important; align-items:center !important; gap:9px !important; }
.admin-section-icon { display:inline-block !important; width:21px !important; height:21px !important; flex:0 0 21px !important; fill:none !important; stroke:currentColor !important; stroke-width:1.8 !important; stroke-linecap:round !important; stroke-linejoin:round !important; }
.ai-copilot-title .admin-nav-icon { vertical-align:middle !important; }


/* V36.6.2: desktop/tablet sidebar stays above the footer instead of touching the viewport edge. */
@media (min-width: 601px) {
  #app-sidebar.app-sidebar {
    top: calc(var(--v36-header-height, 92px) + 10px) !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100dvh - var(--v36-header-height, 92px) - 54px) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }
}
#app-sidebar #main-tabs-nav.tabs-nav { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; overscroll-behavior: contain !important; }
#app-sidebar .sidebar-foot { flex: 0 0 auto !important; position: static !important; }
.admin-subnav { display:flex !important; flex-wrap:wrap !important; align-items:stretch !important; gap:8px !important; }
.admin-subnav-btn { min-height:42px !important; max-width:100% !important; }
.admin-inline-section { margin-top:16px; padding:16px; border:1px solid rgba(148,163,184,.2); border-radius:14px; background:rgba(8,19,43,.24); }
.admin-inline-section > h3 { margin-top:0; }
.admin-toolbar { display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; margin:10px 0; }
.admin-table-wrap { width:100%; overflow:auto; }
.admin-action-menu { display:inline-flex; position:relative; flex-wrap:wrap; align-items:center; justify-content:flex-start; gap:6px; min-width:94px; }
.admin-action-menu > .admin-action-toggle { min-width:92px; min-height:34px; padding:6px 10px; border:1px solid rgba(148,163,184,.32); border-radius:9px; background:rgba(55,74,118,.28); color:var(--text-main,#f8fafc); font:inherit; font-size:11px; font-weight:700; cursor:pointer; }
.admin-action-menu > .admin-action-items { display:none; width:100%; flex-wrap:wrap; gap:6px; padding-top:5px; }
.admin-action-menu.open > .admin-action-items { display:flex; }
.admin-action-menu .btn-copy, .admin-action-menu .btn-convert { min-height:34px; padding:6px 10px !important; margin:0 !important; white-space:normal; }
.theme-file-input { min-height:44px; padding:8px 10px !important; border:1px dashed rgba(145,177,220,.52) !important; border-radius:11px !important; background:rgba(10,23,49,.62) !important; color:var(--text-main,#f8fafc) !important; }
input[type=file]::file-selector-button { margin-right:10px; min-height:30px; padding:5px 11px; border:1px solid rgba(145,177,220,.42); border-radius:8px; background:rgba(75,97,151,.35); color:inherit; font-weight:700; cursor:pointer; }
#admin-pane-themes .custom-table button, #admin-pane-backups .custom-table button, #admin-pane-updates button { border-radius:9px !important; min-height:34px; }
#admin-pane-themes input[type=checkbox] { accent-color:#8b7cff; width:18px; height:18px; vertical-align:middle; }
#admin-pane-themes .btn-convert, #admin-pane-themes .btn-copy, #admin-pane-backups .btn-convert, #admin-pane-backups .btn-copy, #admin-pane-updates .btn-convert, #admin-pane-updates .btn-copy { display:inline-flex; justify-content:center; align-items:center; gap:7px; }
@media (max-width:600px) {
  #app-sidebar.app-sidebar { max-height:calc(100dvh - var(--v36-header-height, 118px) - 18px) !important; }
  .admin-action-menu { min-width:100px; }
  .admin-inline-section { padding:12px; }
  .admin-subnav-btn { flex:1 1 145px; }
}
