/* Mobile-only overrides */

:root { --topbar-h: calc(56px + env(safe-area-inset-top, 0px)); --acc: #4c8dff; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
}

/* fixed full-width top bar with safe-area */
.topbar {
  position: fixed !important;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: rgba(17,17,17,0.9);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar .left { display: flex; align-items: center; gap: 10px; }
.topbar .right { display: none !important; }

.hamburger {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 6px 16px rgba(0,0,0,0.35);
}

.topbar .center { width: 100%; flex: 1 0 100%; }
.topbar .center .tabs,
.topbar .center .search { display: none !important; }

.tabs { touch-action: pan-x pinch-zoom; }

/* mobile menu */
.menu-backdrop[hidden],
.menu-panel[hidden] { display: none !important; }

.menu-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  touch-action: none;
}

.menu-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 10px; right: 10px;
  z-index: 1300;
  width: auto; max-width: 440px;
  max-height: calc(100vh - var(--topbar-h) - 30px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(26,26,28,0.92), rgba(18,18,20,0.92));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 2px 0 rgba(255,255,255,0.04) inset;
  touch-action: pan-y;
}

.menu-title { font-weight: 700; letter-spacing: 0.2px; opacity: 0.95; margin: 8px 6px 6px 6px; }
.menu-section + .menu-section { margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }

.menu-item {
  --bg: rgba(255,255,255,0.06);
  --bd: rgba(255,255,255,0.12);
  --bg-pressed: rgba(255,255,255,0.10);
  position: relative;
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  padding: 14px 14px 14px 46px;
  margin: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--bd);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), var(--bg));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 6px 16px rgba(0,0,0,0.25);
  min-height: 48px;
}
.menu-item:active { background: var(--bg-pressed); transform: translateY(1px); }

.menu-search { display: flex; gap: 8px; margin: 8px 4px 4px; }
.menu-search input {
  flex: 1 1 auto; min-width: 0; height: 44px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
.menu-search input::placeholder { color: rgba(255,255,255,0.5); }
.menu-search input:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc) 32%, transparent); }
.menu-search button {
  flex: 0 0 auto; height: 44px; padding: 0 14px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 6px 16px rgba(0,0,0,0.25);
}
.menu-search button:active { transform: translateY(1px); }

/* feed */
#feed { touch-action: pan-y; }

/* tappable image */
.card .thumb img { touch-action: pan-y; user-select: none; -webkit-user-drag: none; }

/* grid density */
.grid {
  padding: 8px;
  grid-gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* safe-area bottom */
body { padding-bottom: env(safe-area-inset-bottom, 0px); }