.mobile-shell {
  display: none;
}

@media (max-width: 640px) {
  .mobile-shell {
    display: block;
  }

  .mobile-shell ~ .page > .top-bar,
  .mobile-shell ~ .page > .page-header {
    display: none;
  }

  .mobile-shell-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: calc(4px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }

  .mobile-shell-brand a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
  }

  .mobile-shell .mobile-brand-logo {
    display: block;
    width: min(100%, 320px);
    height: auto;
    object-fit: contain;
  }

  .mobile-shell .mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 2px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }

  .mobile-shell .mobile-header .mobile-menu-toggle,
  .mobile-shell .mobile-header .mobile-shell-help {
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--theme-help-toggle-border, #cbbda7);
    border-radius: 12px;
    background: var(--theme-help-toggle-bg, rgba(255, 249, 239, 0.28));
    color: var(--theme-heading, #4a3522);
    cursor: pointer;
  }

  .mobile-shell .mobile-header .mobile-shell-help {
    border-radius: 999px;
    font-family: Arial, sans-serif;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1;
  }

  .mobile-shell .mobile-header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    padding: 4px 2px 5px;
    border-bottom: 0;
    color: var(--theme-accent, #bf6c2f);
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 0 var(--theme-surface, #fffdf8);
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
  }

  .mobile-shell .mobile-shell-header-spacer {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  .mobile-shell .mobile-menu-icon,
  .mobile-shell .mobile-menu-icon::before,
  .mobile-shell .mobile-menu-icon::after {
    display: block;
    width: 22px;
    height: 3px;
    border-radius: 3px;
    background: currentColor;
    content: '';
  }

  .mobile-shell .mobile-menu-icon {
    position: relative;
  }

  .mobile-shell .mobile-menu-icon::before,
  .mobile-shell .mobile-menu-icon::after {
    position: absolute;
    left: 0;
  }

  .mobile-shell .mobile-menu-icon::before {
    top: -8px;
  }

  .mobile-shell .mobile-menu-icon::after {
    top: 8px;
  }

  .mobile-shell .mobile-menu-toggle:focus-visible,
  .mobile-shell .mobile-shell-help:focus-visible,
  .mobile-shell .mobile-drawer-close:focus-visible,
  .mobile-shell .mobile-drawer-link:focus-visible {
    outline: 3px solid var(--theme-accent, #bf6c2f);
    outline-offset: 3px;
  }

  .mobile-shell .mobile-nav-scrim {
    position: fixed;
    z-index: 20;
    inset: 0;
    background: rgba(24, 28, 32, 0.42);
  }

  .mobile-shell .mobile-nav-scrim[hidden] {
    display: none;
  }

  .mobile-shell .mobile-nav-drawer {
    position: fixed;
    z-index: 21;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 360px);
    padding: calc(18px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow-y: auto;
    background: var(--theme-surface, #fffdf8);
    box-shadow: 12px 0 30px rgba(35, 32, 27, 0.2);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    visibility: hidden;
  }

  .mobile-shell .mobile-nav-drawer.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .mobile-shell .mobile-drawer-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    color: var(--theme-heading, #4a3522);
    font-size: 1rem;
    font-weight: 800;
  }

  .mobile-shell .mobile-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    border: 1px solid var(--theme-surface-border, #d8ccb8);
    border-radius: 999px;
    background: var(--theme-secondary-bg, #f3e2c4);
    color: var(--theme-secondary-ink, #5d4327);
    cursor: pointer;
    font-size: 1.2rem;
  }

  .mobile-shell .mobile-drawer-links {
    display: grid;
    gap: 8px;
  }

  .mobile-shell .mobile-drawer-link {
    display: block;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--theme-tab-border, #d2b896);
    border-radius: 12px;
    background: var(--site-tab-bg, #e7e0d4);
    color: var(--site-tab-ink, #4e4030);
    font-size: 0.94rem;
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-shell .mobile-drawer-link.active {
    border-color: var(--theme-accent, #bf6c2f);
    background: var(--theme-accent, #bf6c2f);
    color: var(--theme-accent-contrast, #fff);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-shell .mobile-nav-drawer {
    transition-duration: 0.01ms;
  }
}
