/* Quick mobile navigation follows the existing Looply tokens and sidebar routes. */
.bottom-navigation,
.bottom-create-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  .bottom-navigation {
    position: fixed;
    inset: auto 0 0;
    z-index: 44;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: 58px;
    box-sizing: border-box;
    align-items: center;
    min-height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--color-border);
    border-radius: 0;
    background: var(--color-bg);
    box-shadow: none;
    font-family: var(--font-sans);
  }

  .app-shell.bottom-navigation-primary-tab #floatingActionSlot {
    display: none !important;
    visibility: hidden !important;
  }

  .bottom-navigation-group {
    display: contents;
  }

  .bottom-nav-item {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    min-height: 48px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-muted);
    font: 500 10px/12px var(--font-sans);
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item > i[data-lucide] {
    --icon-size: 18px;
  }

  .bottom-nav-item > i[data-lucide] .ph,
  .bottom-nav-item > i[data-lucide] .ph-fill {
    font-size: 18px;
  }

  .bottom-nav-profile-avatar {
    display: grid;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--color-action-primary-soft);
    color: var(--color-muted);
  }

  .bottom-nav-profile-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
  }

  .bottom-nav-profile-avatar > i[data-lucide] {
    --icon-size: 16px;
  }

  .bottom-nav-profile-item.is-active .bottom-nav-profile-avatar {
    color: var(--color-primary);
  }

  .bottom-nav-item.is-active {
    color: var(--color-primary);
  }

  .bottom-nav-create {
    display: flex;
    justify-self: center;
    align-self: center;
    box-sizing: border-box;
    width: 56px;
    height: 58px;
    min-width: 44px;
    min-height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--color-primary);
    color: var(--color-on-brand);
    box-shadow: none;
    transform: translateY(-10px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-create > .ph { font-size: 24px; line-height: 1; }
  .bottom-nav-create { transition: filter 140ms ease; }
  .bottom-nav-create[aria-expanded="true"],
  .bottom-nav-create:active { transform: translateY(-10px); }

  @media (hover: hover) and (pointer: fine) {
    .bottom-nav-create:hover { filter: brightness(0.94); transform: translateY(-10px); }
  }

  .bottom-nav-item:focus-visible,
  .bottom-nav-create:focus-visible,
  .bottom-create-action:focus-visible,
  .bottom-create-close:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  @media (prefers-reduced-motion: reduce) {
    .bottom-nav-create { transition: none; }
  }

  .bottom-create-backdrop {
    position: fixed;
    inset: 0;
    z-index: 47;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    background: rgba(31, 31, 31, 0.28);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .bottom-create-backdrop.open {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  .bottom-create-sheet {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 8px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: var(--color-bg);
    transform: translateY(100%);
    transition: transform 180ms ease;
  }

  .bottom-create-backdrop.open .bottom-create-sheet {
    transform: translateY(var(--bottom-sheet-drag-y, 0px));
  }

  .bottom-create-handle {
    display: grid;
    height: 24px;
    place-items: center;
    touch-action: none;
    cursor: grab;
  }

  .bottom-create-handle:active { cursor: grabbing; }

  .bottom-create-handle span {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--color-border-control);
  }

  .bottom-create-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .bottom-create-header h2 {
    margin: 0;
    color: var(--color-text);
    font: 600 16px/22px var(--font-sans);
  }

  .bottom-create-close {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
  }

  .bottom-create-close > i[data-lucide] { --icon-size: 20px; }

  .bottom-create-actions { display: grid; gap: 8px; }

  .bottom-create-action {
    display: flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--color-action-primary-soft);
    color: var(--color-text);
    font: 500 13px/18px var(--font-sans);
    text-align: left;
    cursor: pointer;
  }

  .bottom-create-action-primary {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-on-brand);
  }

  .bottom-create-action:disabled {
    opacity: 0.48;
    cursor: not-allowed;
  }

  body.bottom-create-open { overflow: hidden; }
  .app-shell.bottom-create-open .page-content { overflow-y: hidden; }

  .bottom-create-action > i[data-lucide] {
    --icon-size: 20px;
    color: var(--color-primary);
  }

  .bottom-create-action.bottom-create-action-primary > i[data-lucide] { color: var(--color-on-brand); }

  body.auth-active .bottom-navigation,
  body.session-loading .bottom-navigation,
  .app-shell.locked ~ .bottom-navigation,
  .app-shell[hidden] ~ .bottom-navigation,
  .app-shell.locked ~ .bottom-create-backdrop,
  .app-shell[hidden] ~ .bottom-create-backdrop {
    display: none !important;
  }

  @media (prefers-reduced-motion: reduce) {
    .bottom-create-backdrop,
    .bottom-create-sheet { transition: none; }
  }
}

@media (max-width: 1024px) {
  .app-shell:has(#dashboard.active) + .bottom-navigation {
    display: none !important;
  }
}

@media (max-width: 760px) {
  .app-shell:has(#dashboard.active) + .bottom-navigation {
    display: none !important;
  }

  .app-shell .page-content:has(> #dashboard.active) {
    padding-bottom: 0 !important;
  }
}

@media (max-width: 1024px) {
  .top-controls {
    position: relative;
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .top-controls #appbarTitle {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    width: max-content;
    max-width: calc(100% - 200px) !important;
    overflow: hidden !important;
    transform: translate(-50%, -50%) !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    pointer-events: none;
  }

  /* The centered title is absolutely positioned, so keep actions explicitly
     in the grid's right column instead of auto-placing them by the hamburger. */
  .top-controls .appbar-actions {
    grid-column: 3 !important;
    justify-self: end !important;
    margin-left: 0 !important;
  }

  .top-controls .appbar-profile-button { display: none !important; }
}

/* Match the existing hamburger drawer behavior on narrow tablets. */
@media (min-width: 981px) and (max-width: 1024px) {
  .app-shell,
  .app-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr) !important; }

  .app-shell .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 60 !important;
    display: flex !important;
    width: min(288px, 86vw) !important;
    height: 100dvh !important;
    flex-direction: column !important;
    padding: 16px !important;
    overflow: hidden !important;
    transform: translateX(-100%) !important;
    transition: transform 180ms ease !important;
  }

  .app-shell.mobile-sidebar-open .sidebar { transform: translateX(0) !important; }
  .app-shell .main-content { grid-column: 1 !important; }
  .app-shell .mobile-sidebar-toggle { display: inline-flex !important; }

  .app-shell .mobile-sidebar-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 55 !important;
    display: block !important;
    border: 0 !important;
    background: rgba(15, 15, 24, 0.48) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 160ms ease !important;
  }

  .app-shell.mobile-sidebar-open .mobile-sidebar-backdrop {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app-shell .page-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .app-shell .page-content:has(> #dashboard.active) {
    padding-bottom: 0 !important;
  }
}
