/* Mobile layout: replace the desktop rail with a bottom tab bar and use the full viewport. */
@media (max-width: 700px) {
  html, body { min-width: 320px; overflow-x: hidden; }
  .app-shell { display: block; min-height: 100vh; min-height: 100dvh; }
  .sidebar {
    position: fixed; z-index: 25; inset: auto 0 0; width: 100%; min-width: 0; min-height: 0; height: auto;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); background: #111216f5;
    border: 0; border-top: 1px solid #292a31; backdrop-filter: blur(16px);
  }
  .brand, .side-label, .categories, .sidebar-bottom { display: none; }
  .side-nav { display: flex; justify-content: space-around; gap: 8px; width: 100%; }
  .nav-item, .nav-item:not(.active), .nav-item.active {
    flex: 1; min-height: 48px; padding: 5px 8px; border-radius: 10px; justify-content: center;
    flex-direction: column; gap: 2px; font-size: 11px; line-height: 1.2; color: #9697a2;
  }
  .nav-item.active { color: #c3adff; background: #22202c; }
  .nav-icon { width: auto; font-size: 19px; line-height: 1.1; }
  .nav-count { display: none; }
  .main-area { width: 100%; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { height: 60px; padding: 0 16px; }
  .breadcrumbs { gap: 7px; font-size: 11px; min-width: 0; white-space: nowrap; }
  .top-actions { gap: 12px; }
  .content { width: 100%; max-width: none; padding: 20px 16px 36px; }
  .hero { min-height: 0; padding: 25px 20px 23px; border-radius: 16px; align-items: flex-start; }
  .hero-copy { max-width: 100%; width: 100%; }
  .hero .eyebrow { font-size: 9px; letter-spacing: 1.4px; }
  .hero h1 { position: relative; max-width: 100%; font-size: clamp(27px, 7.5vw, 34px); line-height: 1.12; letter-spacing: -1.2px; margin: 13px 0 11px; }
  .hero p { position: relative; max-width: 34em; font-size: 13px; line-height: 1.55; }
  .hero-art { right: -76px; bottom: 62px; width: 164px; height: 164px; opacity: .16; pointer-events: none; }
  .hero-art span { font-size: 76px; }
  .hero:after { right: -22px; top: 15px; font-size: 108px; opacity: .35; }
  .hero-actions { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
  .primary-button, .secondary-button { min-height: 44px; padding: 10px 11px; font-size: 11px; line-height: 1.35; }
  .section-head { align-items: flex-start; gap: 10px; margin: 30px 0 14px; }
  .section-title { font-size: 18px; }
  .section-subtitle { font-size: 10px; line-height: 1.4; }
  .text-link { white-space: nowrap; padding: 4px 0; font-size: 10px; }
  .featured-grid { grid-template-columns: 1fr; gap: 10px; }
  .feature-card { min-height: 185px; padding: 16px 15px 76px; }
  .feature-card h3 { font-size: 17px; margin-top: 10px; }
  .feature-card p { font-size: 11px; max-width: calc(100% - 34px); }
  .feature-bottom { left: 15px; right: 15px; bottom: 13px; gap: 8px; }
  .feature-mini { min-width: 0; gap: 8px; }
  .feature-mini > div { min-width: 0; }
  .feature-mini strong, .feature-mini span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 125px; }
  .feature-bottom .small-action { flex: 0 0 auto; min-height: 38px; }
  .catalog-toolbar { gap: 8px; flex-wrap: nowrap; overflow-x: auto; margin: 18px -16px 15px; padding: 0 16px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .catalog-toolbar::-webkit-scrollbar { display: none; }
  .search-box { flex: 0 0 100%; max-width: none; min-height: 42px; }
  .filter-chip { flex: 0 0 auto; min-height: 38px; }
  .app-grid, .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .app-card { min-width: 0; min-height: 177px; padding: 12px; }
  .app-card h3 { font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
  .app-card p { font-size: 10px; min-height: 42px; }
  .app-card-bottom { align-items: flex-end; gap: 5px; }
  .app-category { line-height: 1.3; }
  .small-action { min-height: 36px; padding: 7px 8px; font-size: 10px; white-space: nowrap; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-heading h1 { font-size: 25px; line-height: 1.2; }
  .page-heading .primary-button { width: 100%; }
  .library-banner { align-items: flex-start; gap: 12px; padding: 15px; margin-bottom: 16px; }
  .library-banner .eyebrow { flex: 0 0 auto; font-size: 8px; }
  .library-banner p { font-size: 10px; line-height: 1.45; }
  .library-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px 10px; padding: 12px; }
  .library-info { grid-column: 2; grid-row: 1; align-self: center; }
  .library-row > .app-icon { grid-column: 1; grid-row: 1; }
  .status { display: none; }
  .row-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .row-actions .small-action { min-height: 40px; }
  .auth-modal { max-height: calc(100dvh - 32px); overflow-y: auto; padding: 30px 20px 22px; }
  .social-button { min-height: 46px; font-size: 13px; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); width: max-content; text-align: center; }
}

@media (max-width: 380px) {
  .content { padding-left: 13px; padding-right: 13px; }
  .hero { padding-left: 17px; padding-right: 17px; }
  .hero-actions { grid-template-columns: 1fr; }
  .hero-actions button { width: 100%; }
  .section-head { flex-wrap: wrap; }
  .app-grid, .catalog-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 160px; }
}

/* Visual cleanup and hierarchy for phone-sized screens. */
@media (max-width: 700px) {
  .sidebar {
    inset: auto 12px calc(10px + env(safe-area-inset-bottom));
    width: auto;
    padding: 6px;
    border: 1px solid #34313e;
    border-radius: 18px;
    background: #17161df2;
    box-shadow: 0 12px 36px #0009;
  }
  .side-nav { gap: 5px; }
  .nav-item, .nav-item:not(.active), .nav-item.active {
    min-height: 48px;
    border-radius: 13px;
    font-weight: 600;
  }
  .main-area { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .topbar { height: 54px; border-bottom-color: #ffffff0a; }
  .breadcrumbs > span:first-child, .crumb-sep, .icon-button { display: none; }
  .breadcrumbs strong { font: 700 15px Manrope, sans-serif; letter-spacing: -.25px; }
  .top-actions { margin-left: auto; }
  .avatar { width: 34px; height: 34px; border-radius: 12px; }
  .content { padding-top: 12px; }
  .hero {
    padding: 24px 20px 20px;
    border-color: #3b3349;
    background: radial-gradient(ellipse at 90% 0%, #7652ad25, transparent 45%), linear-gradient(145deg, #1b1823, #14151b 78%);
    box-shadow: inset 0 1px #ffffff0a, 0 12px 35px #0003;
  }
  .hero-art, .hero:after { display: none; }
  .hero:before { right: -140px; top: -175px; width: 300px; height: 300px; opacity: .45; }
  .hero-copy { z-index: 1; }
  .hero h1 { font-size: clamp(29px, 8vw, 35px); letter-spacing: -1.5px; }
  .hero p { color: #b2afbb; font-size: 13px; line-height: 1.6; }
  .hero-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero-actions .primary-button, .hero-actions .secondary-button {
    min-width: 0; min-height: 46px; border-radius: 12px; font-size: 11px;
  }
  .hero-actions .primary-button { border-color: #9873ff; background: linear-gradient(135deg, #7040e8, #5426c5); color: #fff; }
  .hero-actions .secondary-button { border-color: #ffffff14; background: #ffffff08; }
  .section-head { margin-top: 27px; margin-bottom: 13px; }
  .section-title { font-size: 19px; letter-spacing: -.55px; }
  .section-subtitle { margin-top: 4px; }
  .feature-card {
    min-height: 166px;
    padding: 15px 14px 67px;
    border-radius: 15px;
    background: linear-gradient(135deg, #191820, #131419);
    border-color: #2d2a34;
  }
  .feature-card.large { background: radial-gradient(ellipse at 100% 0%, #a785ff14, transparent 48%), linear-gradient(135deg, #1a1820, #131419); }
  .feature-bg { right: -4px; top: -29px; font-size: 115px; opacity: .075; }
  .feature-card h3 { font-size: 18px; }
  .feature-card p { color: #9998a2; }
  .feature-bottom { left: 14px; right: 14px; bottom: 12px; }
  .feature-mini .app-icon { width: 38px; height: 38px; border-radius: 11px; }
  .feature-bottom .small-action { border-radius: 10px; background: #1b2820; }
  .catalog-toolbar { padding-bottom: 5px; }
  .search-box { border-radius: 12px; background: #15161b; }
  .filter-chip { border-radius: 999px; padding-inline: 14px; }
  .filter-chip.selected { background: #2a213b; border-color: #67518b; }
  .app-card { border-radius: 14px; border-color: #2b2c34; background: linear-gradient(145deg, #17181e, #121318); }
  .app-card .small-action { border-radius: 9px; }
  .library-banner, .library-row { border-radius: 14px; }
  .toast { bottom: calc(87px + env(safe-area-inset-bottom)); }
}

/* Liquid Glass treatment for the mobile navigation dock. */
@media (max-width: 700px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "topbar" "nav" "content";
    align-content: start;
  }
  .main-area { display: contents; padding-bottom: 0; }
  .topbar { grid-area: topbar; }
  .sidebar {
    grid-area: nav;
    position: sticky;
    inset: auto;
    top: 0;
    bottom: auto;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: auto;
    margin: 8px 12px 0;
    padding: 6px;
    border-radius: 18px;
  }
  .main-area { padding-bottom: 20px; }
  .catalog-toolbar .filter-chip { display: none; }
  .content { padding-top: 16px; }
}

/* Categories are intentionally omitted from the interface on every screen size. */
.category-label,
.categories,
.catalog-toolbar .filter-chip { display: none !important; }

/* Keep the signed-in state hidden even though social buttons have display:flex. */
.social-button[hidden] { display: none !important; }

.auth-status-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.auth-status-row .auth-note { flex: 1; margin: 16px 0; min-height: 0; }
.logout-icon-button {
  width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center;
  padding: 0; border: 1px solid #ffffff24; border-radius: 13px; cursor: pointer;
  color: #d2c3f4; background: linear-gradient(145deg, #ffffff14, #ffffff06);
  box-shadow: inset 0 1px 0 #ffffff20; transition: .18s ease;
}
.logout-icon-button:hover { color: #fff; border-color: #a78aff88; background: #9a79ff22; }
.logout-icon-button:focus-visible { outline: 2px solid #a78aff; outline-offset: 2px; }
.logout-icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logout-icon-button[hidden] { display: none !important; }

@media (max-width: 700px) {
  .categories,
  .category-label,
  .category-item,
  .catalog-toolbar .filter-chip { display: none !important; }
}

@media (max-width: 700px) {
  .sidebar {
    overflow: hidden;
    border: 1px solid #ffffff32;
    background: linear-gradient(145deg, #ffffff16, #28253078 38%, #111016a8 100%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    backdrop-filter: blur(26px) saturate(180%);
    box-shadow: 0 14px 40px #0009, inset 0 1px 0 #ffffff39, inset 0 -1px 0 #ffffff0a;
  }
  .sidebar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent 3%, #ffffff8a 30%, #ffffff30 72%, transparent 97%);
    pointer-events: none;
  }
  .side-nav { position: relative; z-index: 1; }
  .nav-item, .nav-item:not(.active), .nav-item.active {
    border: 1px solid transparent;
    background: transparent;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
  }
  .nav-item.active {
    border-color: #ffffff25;
    background: linear-gradient(145deg, #ffffff20, #ffffff0b 72%);
    box-shadow: inset 0 1px 0 #ffffff30, 0 3px 12px #0002;
    color: #d4c2ff;
  }
  .nav-item:not(.active) { color: #e3e0e9c7; }
  .nav-item:not(.active):active { background: #ffffff12; }
}

/* Keep the primary tabs at the top and remove the text-heavy category strip on phones. */
@media (max-width: 700px) {
  .sidebar {
    position: sticky;
    inset: auto;
    top: env(safe-area-inset-top);
    bottom: auto;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: auto;
    margin: 8px 12px 0;
  }
  .content { grid-area: content; padding-bottom: 28px; }
  .catalog-toolbar .filter-chip { display: none; }
  .content { padding-top: 16px; }
}
