@layer overrides {
/* ── Mobile nav elements (hidden on desktop) ───────────── */
.mobile-header     { display: none; }
.mobile-nav        { display: none; }
.mobile-search-row { display: none; }

@media (max-width: 700px) {
  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Stack layout vertically */
  .app-shell {
    flex-direction: column;
  }

  /* Mobile top header */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    height: 54px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
  }

  /* Mobile user avatar button */
  .mobile-user {
    position: relative;
    cursor: pointer;
  }
  .mobile-user .user-avatar {
    width: 32px; height: 32px;
    font-size: 12px;
  }

  /* Mobile user menu, drops down from top-right */
  .user-menu--mobile {
    top: calc(100% + 8px);
    bottom: auto;
    left: auto;
    right: 0;
    width: 220px;
    animation: menuDown 0.18s cubic-bezier(.22,.68,0,1.1) both;
  }

  @keyframes menuDown {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
  }

  /* Main content: leave room for the bottom nav (62px tall + safe-area inset),
     plus a small gap so the last card never sits flush under the nav. */
  .main-content {
    padding-bottom: calc(62px + env(safe-area-inset-bottom) + 8px);
  }

  /* Surface Save/Cancel at the top of the long recipe form too */
  .drawer-form-top-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }

  /* Bottom tab bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Lift toasts above the fixed dock (62px tall + safe area) so they
     sit just above it instead of covering the nav. */
  .toast-region {
    bottom: calc(62px + env(safe-area-inset-bottom) + 12px);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--faint);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--t);
    text-decoration: none;
  }
  .mobile-nav-item.active    { color: var(--text); }
  .mobile-nav-item--disabled { opacity: 0.4; cursor: default; }

  .mobile-nav-icon  { font-size: 16px; line-height: 1; }
  .mobile-nav-label { font-size: 10px; letter-spacing: 0.01em; }

  /* Tighten recipe grid on mobile: let .recipes-scroll own the outer
     padding. Horizontal 16px lines the card edges up with the 16px gutter
     used by .toolbar / .mobile-search-row / .filters-bar. */
  .recipes-scroll { padding: 8px 16px; }
  /* Stack cards in a single column so they keep a usable size instead of
     squeezing two narrow cards side by side. min-width keeps each card
     readable if the viewport gets very narrow. */
  .recipe-grid { grid-template-columns: 1fr; gap: 8px; padding: 0; }
  .recipe-card { min-width: 260px; }

  /* List view: the fixed 5-column grid overflows on narrow screens — tags
     spill over and hide the time. Restack so the name + time share the top
     row and the tags wrap onto their own row below, always leaving time
     visible. */
  .list-header { display: none; }
  .recipe-list-row {
    grid-template-columns: 44px minmax(0, 1fr) auto 16px;
    grid-template-areas:
      "thumb name time arrow"
      "thumb tags tags tags";
    column-gap: 8px;
    row-gap: 6px;
  }
  .recipe-list-row .list-thumb { grid-area: thumb; align-self: center; }
  .recipe-list-row .list-name { grid-area: name; padding-left: 0; }
  .recipe-list-row .list-time { grid-area: time; white-space: nowrap; }
  .recipe-list-row .list-arrow { grid-area: arrow; }
  .recipe-list-row .list-tags { grid-area: tags; flex-wrap: wrap; }
  .recipe-list-row .list-tags:empty { display: none; }

  /* Settings / help page padding */
  .settings-page { padding: 20px 16px; }

  /* ── Toolbar: collapse to title + add button ── */
  .toolbar {
    padding: 12px 16px;
    flex-wrap: nowrap;
  }
  .search-form    { display: none; }  /* moved to its own row */
  .layout-toggle  { display: none; }  /* grid only on mobile */

  /* Add Recipe button: keep full label, just tighten sizing */
  .toolbar .btn-primary {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: var(--r-md);
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Mobile search row, full width below toolbar */
  .mobile-search-row {
    display: flex;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }
  .mobile-search-row .search-form { display: flex; flex: 1; }
  .mobile-search-row .search-wrap { flex: 1; }
  .mobile-search-row .search-input { width: 100%; }

  /* Filters: single scrollable row, no wrapping */
  .filters-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 16px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters-bar::-webkit-scrollbar { display: none; }
  .filter-pill { flex-shrink: 0; }

  /* ── Recipe detail page ── */
  .main-content:has(.recipe-detail) { overflow-y: auto; }
  .recipe-detail { height: auto; flex: none; overflow: visible; }
  .detail-bar {
    padding: 10px 14px;
    gap: 7px;
    flex-wrap: nowrap;
  }
  .breadcrumb-sep { display: none; }
  .detail-bar .btn-outline { padding: 5px 10px; font-size: 12px; }
  .detail-bar .btn-accent  { padding: 5px 12px; font-size: 12px; white-space: nowrap; }
  .detail-layout {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .detail-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
    height: auto;
  }
  .detail-right {
    padding: 20px 16px 32px;
    overflow-y: visible;
    height: auto;
  }
  .steps-list { max-width: 100%; }
  .step-row { padding: 16px 16px; gap: 14px; }
  .step-num { width: 30px; height: 30px; font-size: 13px; }
  .step-text { font-size: 16px; }
  .ingredients-section { padding: 16px 18px; }

  /* ── Week view: 1 day at a time ── */
  /* Let the day lane run flush to the bottom dock; the dock-clearance lives
     inside the scroll lane (.week-col) so the last card still clears it. */
  .main-content:has(.week-screen) { padding-bottom: 0; }
  .week-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .week-grid::-webkit-scrollbar { display: none; }
  .week-col {
    min-width: 100%;
    width: 100%;
    flex-shrink: 0;
    scroll-snap-align: start;
    /* Each day scrolls its own meals vertically (you swipe horizontally
       between days). The day header stays pinned via position: sticky. */
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    padding-bottom: calc(62px + env(safe-area-inset-bottom) + 8px);
  }
  .week-col::-webkit-scrollbar { display: none; }
  .week-recipe-name { -webkit-line-clamp: 3; }
  .week-recipe-img  { height: 80px; }

  /* Day picker: bottom sheet on mobile so it can't get clipped by the column */
  .day-picker-popup {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: calc(62px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px oklch(var(--shadow-color) / 0.18);
    z-index: 150;
    animation: daySheetUp 0.24s cubic-bezier(.22,.68,0,1.05) both;
  }
  .day-picker-list { max-height: 50vh; }

  @keyframes daySheetUp {
    from { transform: translateY(calc(100% + 80px)); }
    to   { transform: translateY(0); }
  }
}
}
