/* ===================================================================
   COMMUNITY LAYOUT
   Page structure, sidebar, content area, thread rows, avatars,
   skeletons, toasts, and responsive breakpoints.
   =================================================================== */

@media (max-width: 767px) { .comm-desktop-only { display: none !important; } }

/* ── Logo sub-label ─────────────────────────────────────────────────── */
.ds-logo-sub {
  color: var(--ds-ash);
  font-size: 13px;
  margin-left: 4px;
}

/* ── Header spacer (pushes search right on desktop, hidden mobile) ───── */
.header-spacer {
  display: none;
}

/* ── Header nav tabs ─────────────────────────────────────────────────── */
.header-nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: max-content;
}

.header-nav-btn {
  background: none;
  border: none;
  font-family: var(--ds-font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-ash);
  padding: 6px 12px;
  border-radius: var(--ds-radius-xs);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--ds-transition), background var(--ds-transition);
}

.header-nav-btn:hover {
  color: var(--ds-ink);
  background: var(--ds-parchment);
}

.header-nav-btn.is-active {
  color: var(--ds-ink);
  background: var(--ds-parchment);
}

/* ── Page wrapper ───────────────────────────────────────────────────── */
#app {
  outline: none;
  /* Prevent browser scroll-anchoring from drifting the page down
     when async content (skeleton → threads) replaces placeholder HTML */
  overflow-anchor: none;
  /* Opaque background so view-transition snapshots never bleed through */
  background: var(--ds-linen);
  /* Scope view transitions to content area only — nav stays static */
  view-transition-name: page-content;
}

/* ── Page transitions (CSS View Transitions API) ────────────────────── */

/* Pin chrome elements so the root cross-fade never covers them */
#mobile-nav    { view-transition-name: mobile-nav; }
#mobile-header { view-transition-name: mobile-header; }

::view-transition-old(mobile-nav),
::view-transition-new(mobile-nav),
::view-transition-old(mobile-header),
::view-transition-new(mobile-header) {
  animation: none;
}

/* Default (tab/section switch): cross-fade */
::view-transition-old(page-content) {
  animation: vt-fade-out 0.16s ease both;
}
::view-transition-new(page-content) {
  animation: vt-fade-in 0.18s ease both;
}

/* Mobile push (list→detail): new slides in on top from right */
@media (max-width: 767px) {
  html[data-nav-type="push"]::view-transition-old(page-content) {
    animation: none;
    z-index: 0;
  }
  html[data-nav-type="push"]::view-transition-new(page-content) {
    animation: vt-slide-in-right 0.24s cubic-bezier(0.4, 0, 0.2, 1) both;
    z-index: 1;
  }
  /* Mobile pop (back): old slides out to right, new revealed beneath */
  html[data-nav-type="pop"]::view-transition-old(page-content) {
    animation: vt-slide-out-right 0.24s cubic-bezier(0.4, 0, 0.2, 1) both;
    z-index: 1;
  }
  html[data-nav-type="pop"]::view-transition-new(page-content) {
    animation: none;
    z-index: 0;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(page-content),
  ::view-transition-new(page-content) {
    animation: none !important;
  }
}

@keyframes vt-slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes vt-slide-out-right {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}
@keyframes vt-fade-out {
  to { opacity: 0; }
}
@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#community-layout {
  display: flex;
  max-width: var(--ds-layout-max);
  margin: 0 auto;
  padding: 0 var(--ds-outer-px);
  gap: 64px;
  min-height: calc(100vh - var(--ds-header-h));
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.comm-sidebar {
  width: var(--ds-sidebar-w);
  min-width: var(--ds-sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--ds-header-h) + env(safe-area-inset-top));
  max-height: calc(100vh - var(--ds-header-h));
  overflow-y: auto;
  padding: 28px 0 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--ds-stone) transparent;
}

.comm-sidebar::-webkit-scrollbar {
  width: 4px;
}
.comm-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.comm-sidebar::-webkit-scrollbar-thumb {
  background: var(--ds-stone);
  border-radius: var(--ds-radius-pill);
}

.comm-sidebar-section {
  margin-bottom: 24px;
}

.comm-sidebar-label {
  display: block;
  padding: 0 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ds-ash);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* Sidebar links — community-specific active state */
.comm-sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin-bottom: 1px;
  font-size: var(--ds-text-sm);
  color: var(--ds-graphite);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.45;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--ds-font-body);
  transition: background var(--ds-transition), color var(--ds-transition);
  position: relative;
}

.comm-sidebar-link:hover {
  color: var(--ds-ink);
  background: var(--ds-parchment);
}

.comm-sidebar-link.is-active {
  color: var(--ds-ink);
  font-weight: 500;
  background: var(--ds-parchment);
  border-radius: 6px;
}

.comm-sidebar-link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--ds-green);
  border-radius: var(--ds-radius-pill);
}

.comm-sidebar-link-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.comm-sidebar-link-inner svg {
  flex-shrink: 0;
  opacity: 0.6;
  width: 14px;
  height: 14px;
}

.comm-sidebar-link.is-active .comm-sidebar-link-inner svg {
  opacity: 1;
}

/* ── Sidebar count ───────────────────────────────────────────────────── */
.comm-sidebar-link .count,
.sidebar-count {
  float: right;
  color: var(--ds-ash);
  font-size: 11px;
  font-weight: 400;
}

.comm-sidebar-link.is-active .count {
  color: var(--ds-graphite);
}

/* ── Sidebar group label ─────────────────────────────────────────────── */
.ds-sidebar-group-label {
  display: flex;
  padding: 18px 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ds-ash);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Sidebar divider ─────────────────────────────────────────────────── */
.comm-sidebar-divider {
  height: 1px;
  background: var(--ds-stone);
  margin: 8px 10px 16px;
}

/* ── Content area ────────────────────────────────────────────────────── */
.comm-content {
  flex: 1;
  min-width: 0;
  max-width: var(--ds-content-max);
  padding: 28px 0 64px;
}

/* ── Tag bar ─────────────────────────────────────────────────────────── */
.comm-tag-bar-wrap {
  position: relative;
  margin-bottom: 16px;
}

.comm-tag-bar {
  overflow-x: auto;
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.comm-tag-bar::-webkit-scrollbar {
  display: none;
}

.comm-tag-bar-wrap::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 8px;
  width: 48px;
  background: linear-gradient(to right, transparent, var(--ds-linen));
  pointer-events: none;
}

/* ── Thread list ─────────────────────────────────────────────────────── */
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 16px;
  padding: 18px 16px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--ds-transition), box-shadow var(--ds-transition);
  align-items: center;
}

.thread-item:hover {
  border-color: var(--ds-stone-dark);
  box-shadow: var(--ds-shadow-sm);
}
.thread-item:hover .thread-title { color: var(--ds-green); }

.thread-item--pinned {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.3);
}
.thread-item--pinned:hover {
  border-color: rgba(245, 158, 11, 0.55);
}

/* ── Thread stats column ─────────────────────────────────────────────── */
.thread-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ds-ash);
}

.thread-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.thread-stat-num {
  font-family: var(--ds-font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--ds-ink);
  line-height: 1;
}

.thread-stat.answered .thread-stat-num {
  color: var(--ds-green);
}

/* ── Thread body column ──────────────────────────────────────────────── */
.thread-body {
  min-width: 0;
}

.thread-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ds-ink);
  margin-bottom: 4px;
  line-height: 1.4;
  transition: color var(--ds-transition);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-excerpt {
  font-size: 13px;
  color: var(--ds-graphite);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.thread-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ── Thread meta column ──────────────────────────────────────────────── */
.thread-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ds-ash);
  white-space: nowrap;
}

/* ── Avatar ──────────────────────────────────────────────────────────── */
.comm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
  line-height: 1;
}

.comm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comm-avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 9px;
}

.comm-avatar-md {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.comm-avatar-lg {
  width: 80px;
  height: 80px;
  font-size: 28px;
}

/* ── Community header ────────────────────────────────────────────────── */
.community-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.community-title {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-3xl);
  font-weight: 400;
  line-height: 1.15;
  color: var(--ds-ink);
  letter-spacing: -0.01em;
}

.community-sub {
  font-size: 14px;
  color: var(--ds-graphite);
  margin-top: 4px;
}

/* ── Filter row (pill buttons) ───────────────────────────────────────── */
.filter-row-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-row-wrap::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: linear-gradient(to left, transparent, var(--ds-linen));
}

.filter-row-wrap.has-left::before { opacity: 1; }

.filter-row {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

/* ── Pill buttons ────────────────────────────────────────────────────── */
.ds-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-pill);
  font-family: var(--ds-font-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ds-graphite);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color var(--ds-transition), color var(--ds-transition), background var(--ds-transition);
  text-decoration: none;
}

.ds-pill-btn:hover {
  border-color: var(--ds-stone-dark);
  color: var(--ds-ink);
}

.ds-pill-btn.is-active {
  color: var(--ds-ink);
  background: var(--ds-parchment);
  border-color: var(--ds-stone-dark);
}

/* ── Filter count badge ──────────────────────────────────────────────── */
.filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ds-stone);
  color: var(--ds-graphite);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--ds-radius-pill);
  min-width: 18px;
  line-height: 1.4;
}

/* ── Sort pill group ─────────────────────────────────────────────────── */
.sort-pill-group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--ds-parchment);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-pill);
  margin-left: auto;
}

.sort-pill-btn {
  background: none;
  border: none;
  font-family: var(--ds-font-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ds-ash);
  padding: 4px 10px;
  border-radius: var(--ds-radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ds-transition), color var(--ds-transition), box-shadow var(--ds-transition);
}

.sort-pill-btn:hover {
  color: var(--ds-ink);
}

.sort-pill-btn.is-active {
  background: var(--ds-white);
  color: var(--ds-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ── Answered badge ──────────────────────────────────────────────────── */
.answered-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #15803d;
  padding: 1px 8px;
  background: var(--ds-mint);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--ds-radius-pill);
}

.answered-badge svg {
  width: 11px;
  height: 11px;
}

/* ── Pinned badge ────────────────────────────────────────────────────── */
.pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
  padding: 1px 8px;
  background: #fef3c7;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--ds-radius-pill);
}

.pinned-badge svg {
  width: 11px;
  height: 11px;
}

/* ── Thread inline meta (mobile-only) ───────────────────────────────── */
.thread-meta-inline {
  display: none;
}

/* ── Tag count dot (legacy) ──────────────────────────────────────────── */
.tag-count {
  margin-left: 4px;
  font-size: var(--ds-text-xs);
  color: var(--ds-ash);
  font-weight: 400;
}

/* ── Tag chips in thread rows ────────────────────────────────────────── */
.tag-chip {
  font-family: var(--ds-font-body);
}

/* ── Skeleton shimmer ────────────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--ds-stone) 25%,
    var(--ds-parchment) 50%,
    var(--ds-stone) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--ds-radius-xs);
}

.skeleton-row {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
}

.skeleton-stats {
  width: 64px;
  flex-shrink: 0;
}

.skeleton-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-meta {
  width: 112px;
  flex-shrink: 0;
}

/* ── Notification badge ──────────────────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: var(--ds-red);
  color: var(--ds-white);
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--ds-radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  border: 2px solid var(--ds-linen);
}

/* ── Notification panel ──────────────────────────────────────────────── */
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow-lg);
  z-index: 200;
  overflow: hidden;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-stone);
}

.notif-panel-footer {
  padding: 8px;
  border-top: 1px solid var(--ds-stone);
}

/* ── User menu ───────────────────────────────────────────────────────── */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-lg);
  z-index: 200;
  overflow: hidden;
  padding: 4px;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  font-size: var(--ds-text-sm);
  font-family: var(--ds-font-body);
  font-weight: 400;
  color: var(--ds-graphite);
  text-decoration: none;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background var(--ds-transition), color var(--ds-transition);
}

.user-menu-item:hover {
  background: var(--ds-parchment);
  color: var(--ds-ink);
}

.user-menu-divider {
  height: 1px;
  background: var(--ds-stone);
  margin: 4px 0;
}

/* ── Toast stack ─────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--ds-void);
  color: var(--ds-white);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-lg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 320px;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success { background: #15803d; }
.toast--error   { background: #b91c1c; }
.toast--warning { background: #92400e; }

/* ── Mobile bottom navigation bar ───────────────────────────────────── */
.mobile-nav-bar {
  display: none;
}

/* ── Responsive: tablet (collapse sidebar) ───────────────────────────── */
@media (max-width: 1023px) {
  #community-layout {
    gap: 0;
    padding: 0 24px;
  }

  .comm-sidebar {
    display: none;
  }

  .comm-content {
    max-width: 100%;
    padding: 20px 0 48px;
  }

  .comm-mobile-cat-bar {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 12px 0 4px;
    scrollbar-width: none;
    margin-bottom: 12px;
  }

  .comm-mobile-cat-bar::-webkit-scrollbar {
    display: none;
  }
}

@media (min-width: 1024px) {
  .comm-mobile-cat-bar {
    display: none;
  }
}

/* ── Responsive: mobile ──────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* ── Layout ── */
  #community-layout {
    padding: 0 16px;
  }

  #app {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }

  /* ── Header ── */
  .ds-header-inner {
    padding: 0 16px;
    gap: 8px;
  }

  .header-nav {
    display: none;
  }

  .ds-logo-sub {
    display: none;
  }

  .ds-logo-name,
  .ds-logo-pill {
    display: none;
  }

  .header-spacer {
    display: none;
  }

  .header-search-wrap {
    flex: 1;
    min-width: 0;
    width: auto !important;
  }

  .ds-kbd {
    display: none;
  }

  /* User menu hidden on mobile — accessible via drawer */
  .header-user-wrap {
    display: none;
  }

  /* Enlarge touch targets */
  .ds-icon-btn {
    width: 40px;
    height: 40px;
  }

  /* ── Thread list ── */
  .thread-meta {
    display: none;
  }

  .thread-list {
    gap: 6px;
  }

  .thread-item {
    grid-template-columns: 50px 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .thread-stat-num {
    font-size: 18px;
  }

  .thread-stats {
    gap: 4px;
    font-size: 10px;
  }

  /* Thread body bottom row: show avatar+time inline */
  .thread-meta-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--ds-ash);
  }

  .thread-title {
    font-size: 14.5px;
  }

  .thread-excerpt {
    font-size: 12.5px;
    -webkit-line-clamp: 1;
  }

  /* ── Community header ── */
  .community-header {
    display: none;
  }

  /* ── Filter/sort rows ── */
  .filter-row-wrap {
    display: none;
  }

  .filter-row {
    -webkit-overflow-scrolling: touch;
  }

  .sort-pill-group {
    padding: 2px;
    gap: 1px;
  }

  .sort-pill-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* ── Notification panel ── */
  .notif-panel {
    width: calc(100vw - 32px);
    right: -60px;
  }

  /* ── Toasts above bottom nav ── */
  #toasts {
    bottom: calc(68px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    align-items: center;
  }

  .toast {
    max-width: 100%;
    width: auto;
    text-align: center;
    justify-content: center;
  }

  /* ── Mobile nav bar ── */
  .mobile-nav-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--ds-white);
    border-top: 1px solid var(--ds-stone);
    z-index: 150;
    align-items: stretch;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    background: none;
    border: none;
    color: var(--ds-ash);
    font-size: 10px;
    font-weight: 500;
    font-family: var(--ds-font-body);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .mobile-nav-item.is-active {
    color: var(--ds-green);
  }

  .mobile-nav-item:active {
    opacity: 0.7;
  }

  /* Ask button — center highlight, raised above bar */
  .mobile-nav-ask {
    color: var(--ds-graphite);
    margin-top: -14px;
  }

  .mobile-nav-ask-icon {
    width: 44px;
    height: 44px;
    background: var(--ds-ink);
    border-radius: var(--ds-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ds-white);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  [data-theme="dark"] .mobile-nav-ask-icon {
    background: var(--ds-green);
    color: var(--ds-void);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
  }

  .mobile-nav-ask svg {
    width: 18px;
    height: 18px;
  }

  .mobile-nav-ask span:not(.mobile-nav-ask-icon) {
    margin-top: 2px;
    font-size: 10px;
  }

  /* Notification dot */
  .mobile-notif-dot {
    position: absolute;
    top: 0;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--ds-red);
    border-radius: 50%;
    border: 2px solid var(--ds-white);
  }
}

/* ── Mobile nav tap feedback ─────────────────────────────────────────── */
@media (max-width: 767px) {
  .mobile-nav-item:active:not(.mobile-nav-ask) {
    transform: scale(0.88);
    transition: transform 0.1s ease;
  }

  .mobile-nav-ask:active .mobile-nav-ask-icon {
    transform: scale(0.88);
    transition: transform 0.1s ease;
  }

  .mobile-nav-item {
    transition: color 0.15s ease;
  }

  /* Thread item press feedback */
  .thread-item:active {
    background: var(--ds-parchment);
  }

  /* Pill/button press feedback */
  .ds-pill-btn:active,
  .sort-pill-btn:active,
  .ds-btn:active {
    transform: scale(0.96);
    transition: transform 0.08s ease;
  }
}

/* ── Nav hamburger (hidden desktop, visible on tablet/mobile) ────────── */
.nav-hamburger {
  display: none;
}

@media (max-width: 1023px) {
  .nav-hamburger {
    display: flex;
    flex-shrink: 0;
  }
}

/* ── Nav drawer backdrop ─────────────────────────────────────────────── */
#nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, 0.4);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#nav-drawer-backdrop.is-open {
  display: block;
  opacity: 1;
}

/* ── Nav drawer ──────────────────────────────────────────────────────── */
#nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 86vw);
  background: var(--ds-linen);
  border-right: 1px solid var(--ds-stone);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#nav-drawer.is-open {
  transform: translateX(0);
}

#nav-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--ds-stone);
  flex-shrink: 0;
}

.nav-drawer-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ds-ash);
}

#nav-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px 0;
}

#nav-drawer-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--ds-stone);
  padding: 8px 8px 24px;
}

.nav-drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 6px;
}

.nav-drawer-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-drawer-user-info {
  min-width: 0;
}

.nav-drawer-user-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-drawer-user-info span {
  display: block;
  font-size: 11.5px;
  color: var(--ds-ash);
}

/* ── Vote button pop animation ───────────────────────────────────────── */
@keyframes vote-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.vote-btn.is-voted {
  animation: vote-pop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Dark theme: mobile nav ──────────────────────────────────────────── */
[data-theme="dark"] .mobile-nav-bar {
  background: var(--ds-white);
  border-top-color: var(--ds-stone);
}

[data-theme="dark"] .mobile-compose-bar {
  background: var(--ds-white);
  border-bottom-color: var(--ds-stone);
}

[data-theme="dark"] .mobile-compose-input {
  background: var(--ds-parchment);
  border-color: var(--ds-stone);
}

[data-theme="dark"] .mobile-notif-dot {
  border-color: var(--ds-white);
}

[data-theme="dark"] .thread-item--pinned {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.2);
}
[data-theme="dark"] .thread-item--pinned:hover {
  border-color: rgba(245, 158, 11, 0.4);
}

/* ── Remove hover effects on touch devices ───────────────────────────── */
@media (hover: none) {
  .thread-item:hover {
    border-color: var(--ds-stone);
    box-shadow: none;
  }
  .thread-item:hover .thread-title {
    color: inherit;
  }
  .ds-btn:hover {
    transform: none;
  }
  .ds-card:hover {
    transform: none;
    box-shadow: none;
  }
  .ds-card:hover::after {
    transform: scaleY(0);
  }
  .comm-sidebar-link:hover,
  .ds-pill-btn:hover,
  .sort-pill-btn:hover,
  .header-nav-btn:hover {
    background: none;
    color: inherit;
    border-color: var(--ds-stone);
  }
}

/* ── Touch-action on all interactive elements ────────────────────────── */
button, a, [role="button"] {
  touch-action: manipulation;
}

/* ── Site footer ─────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--ds-stone);
  margin-top: 48px;
  padding: 20px var(--ds-outer-px) calc(28px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--ds-ash);
  font-family: var(--ds-font-body);
}

.site-footer:empty {
  display: none;
}

.site-footer-inner {
  max-width: var(--ds-layout-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer-copy {
  color: var(--ds-ash);
}

.site-footer-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-footer-link {
  color: var(--ds-graphite);
  text-decoration: none;
  transition: color var(--ds-transition);
}

.site-footer-link:hover {
  color: var(--ds-ink);
  text-decoration: underline;
}

.site-footer-sep {
  color: var(--ds-stone);
}

/* Hide global footer on phones — drawer carries its own copy. */
@media (max-width: 1023px) {
  #site-footer {
    display: none;
  }
}

/* Drawer variant: compact, no top margin (border-top handled by drawer footer container). */
.site-footer--drawer {
  margin-top: 12px;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--ds-stone);
}

.site-footer--drawer .site-footer-inner {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.site-footer--drawer .site-footer-links {
  gap: 8px;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.ds-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  padding: 0;
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow-lg);
  max-width: min(480px, calc(100vw - 32px));
  max-height: 90dvh;
  overflow-y: auto;
  width: 100%;
  background: var(--ds-white);
  color: var(--ds-ink);
}

.ds-modal--lg {
  max-width: min(680px, calc(100vw - 32px));
}

.ds-modal::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: backdrop-in 0.16s ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ds-modal[open] {
  animation: modal-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ds-modal-box {
  display: flex;
  flex-direction: column;
}

.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--ds-stone);
}

.ds-modal-title {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-xl);
  font-weight: 400;
  color: var(--ds-ink);
  margin: 0;
  line-height: 1.2;
}

.ds-modal-x {
  flex-shrink: 0;
  color: var(--ds-ash);
}

.ds-modal-x:hover {
  color: var(--ds-ink);
}

.ds-modal-body {
  padding: 20px 24px;
}

.ds-modal-message {
  font-size: var(--ds-text-sm);
  color: var(--ds-graphite);
  line-height: 1.65;
  margin: 0;
}

.ds-modal-footer:not(:empty) {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--ds-stone);
}

/* Danger button (used by confirm dialogs for destructive actions) */
.ds-btn-danger {
  background: var(--ds-red);
  border-color: var(--ds-red);
  color: var(--ds-white);
}

.ds-btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: var(--ds-white);
}

/* ── Sort / filter sheet ─────────────────────────────────────────────── */
.ds-sheet-box {
  display: flex;
  flex-direction: column;
}

.ds-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--ds-stone);
  border-radius: 2px;
  margin: 12px auto 4px;
  flex-shrink: 0;
}

.ds-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
}

.ds-sheet-title {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-lg);
  color: var(--ds-ink);
}

.ds-sheet-options {
  display: flex;
  flex-direction: column;
  padding: 0 0 8px;
}

.ds-sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--ds-text-base);
  color: var(--ds-ink);
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}

.ds-sheet-option:active {
  background: var(--ds-stone);
}

.ds-sheet-option.is-active {
  color: var(--ds-green);
  font-weight: 500;
}

.ds-sheet-option-icon {
  color: var(--ds-ash);
  flex-shrink: 0;
  display: flex;
}

.ds-sheet-option.is-active .ds-sheet-option-icon {
  color: var(--ds-green);
}

.ds-sheet-option-label {
  flex: 1;
}

.ds-sheet-option-check {
  color: var(--ds-green);
  display: flex;
  flex-shrink: 0;
}

.filter-active-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-green);
  pointer-events: none;
}

/* ── Modal: bottom sheet on mobile ──────────────────────────────────── */
@media (max-width: 767px) {
  .ds-modal {
    margin: 0;
    inset: auto 0 0 0;
    max-width: 100%;
    width: 100%;
    border-radius: var(--ds-radius) var(--ds-radius) 0 0;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ds-modal[open] {
    animation: modal-in-mobile 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes modal-in-mobile {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .ds-modal-header {
    padding: 16px 20px 12px;
  }

  .ds-modal-body {
    padding: 16px 20px;
  }

  .ds-modal-footer:not(:empty) {
    flex-direction: column-reverse;
    padding: 12px 20px 16px;
  }

  .ds-modal-footer:not(:empty) .ds-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }
}

/* ── Modal close animations ──────────────────────────────────────────── */
@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.97); }
}

.ds-modal.is-closing {
  animation: modal-out 0.18s ease forwards;
  pointer-events: none;
}

.ds-modal.is-closing::backdrop {
  animation: backdrop-out 0.18s ease forwards;
}

@keyframes backdrop-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (max-width: 767px) {
  @keyframes modal-out-mobile {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(100%); }
  }

  .ds-modal.is-closing {
    animation: modal-out-mobile 0.28s cubic-bezier(0.4, 0, 0.8, 0.8) forwards;
  }
}

/* ── Auth modal handle (mobile bottom-sheet affordance) ─────────────── */
.auth-modal-handle {
  display: none;
}

@media (max-width: 767px) {
  .auth-modal-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: var(--ds-stone);
    border-radius: 2px;
    margin: 12px auto 4px;
    flex-shrink: 0;
  }
}

.grecaptcha-badge {
  visibility: hidden;
}

.auth-recaptcha-notice {
  margin: 12px auto 0;
  max-width: 280px;
  color: color-mix(in srgb, var(--ds-ash) 88%, white 12%);
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
  letter-spacing: 0.01em;
}

.auth-recaptcha-notice a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--ds-ash) 26%, transparent 74%);
  transition: color var(--ds-transition), border-color var(--ds-transition);
}

.auth-recaptcha-notice a:hover,
.auth-recaptcha-notice a:focus-visible {
  color: var(--ds-graphite);
  border-color: color-mix(in srgb, var(--ds-graphite) 30%, transparent 70%);
}

.auth-recaptcha-notice--modal {
  max-width: 250px;
}

/* ── List progress bar ───────────────────────────────────────────────── */
.list-progress-bar {
  position: sticky;
  top: calc(var(--ds-header-h) + env(safe-area-inset-top));
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ds-stone);
  z-index: 50;
  overflow: hidden;
}

.list-progress-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: var(--ds-green);
  animation: progress-sweep 0.6s ease-in-out infinite alternate;
}

@keyframes progress-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE HEADER  (≤767px only — desktop #topnav untouched above)
   ═══════════════════════════════════════════════════════════════════ */

/* Hidden on desktop by default */
.mobile-header,
.mobile-swipe-indicator,
.mobile-cat-strip,
.mobile-compose-bar { display: none; }

@media (max-width: 767px) {
  /* Suppress desktop header */
  #topnav { display: none !important; }

  /* ── Compose bar ── */
  .mobile-compose-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--ds-white);
    border-bottom: 1px solid var(--ds-stone);
    margin-left: -16px;
    margin-right: -16px;
    margin-bottom: 20px;
  }

  .mobile-compose-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .mobile-compose-avatar .comm-avatar {
    width: 38px !important;
    height: 38px !important;
    font-size: 14px !important;
  }

  .mobile-compose-input {
    flex: 1;
    background: var(--ds-parchment);
    border: 1px solid var(--ds-stone);
    border-radius: 20px;
    padding: 9px 16px;
    text-align: left;
    color: var(--ds-ash);
    font-size: 14px;
    font-family: var(--ds-font-body);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-compose-input:active {
    opacity: 0.7;
  }

  /* ── Header bar ── */
  .mobile-header {
    display: flex;
    align-items: center;
    height: var(--ds-header-h);
    background: rgba(245, 243, 240, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--ds-stone);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 6px;
    flex-shrink: 0;
    overflow: visible;
  }

  .mobile-header-left,
  .mobile-header-right {
    width: 80px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  .mobile-header-right { justify-content: flex-end; gap: 2px; }

  .mobile-header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-header-logo {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--ds-font-serif);
    font-size: 17px;
    color: var(--ds-ink);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-header-section:empty { display: none; }

  /* ── Inline search overlay ── */
  .mobile-search-overlay {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: var(--ds-header-h);
    background: rgba(245, 243, 240, 0.95);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 8px;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
    z-index: 1;
  }

  .mobile-search-overlay.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  .mobile-search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ds-white);
    border: 1.5px solid var(--ds-stone);
    border-radius: var(--ds-radius-pill);
    padding: 0 12px;
    height: 34px;
    position: relative;
  }

  .mobile-search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    font-family: var(--ds-font-body);
    color: var(--ds-ink);
    outline: none;
    min-width: 0;
    -webkit-appearance: none;
  }
  .mobile-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
  .mobile-search-input::placeholder { color: var(--ds-ash); }

  .mobile-search-cancel {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--ds-graphite);
    white-space: nowrap;
    padding: 4px 2px;
    font-family: var(--ds-font-body);
    -webkit-tap-highlight-color: transparent;
  }

  /* Dropdown positioned below the search pill */
  #mobile-search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: -14px;
    right: -14px;
    max-height: 60dvh;
  }

  /* ── Swipe-to-back indicator ── */
  .mobile-swipe-indicator {
    display: flex;
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%) translateX(-40px);
    width: 40px;
    height: 40px;
    background: var(--ds-white);
    border-radius: 0 var(--ds-radius-sm) var(--ds-radius-sm) 0;
    box-shadow: var(--ds-shadow-md);
    align-items: center;
    justify-content: center;
    z-index: 300;
    color: var(--ds-graphite);
    opacity: 0;
    pointer-events: none;
  }

  /* ── Category chip strip (threads list only) ── */
  .mobile-cat-strip {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    background: var(--ds-white);
    border-bottom: 1px solid var(--ds-stone);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    position: sticky;
    top: var(--ds-header-h);
    z-index: 99;
    /* break out of #community-layout's 16px horizontal padding */
    margin-left: -16px;
    margin-right: -16px;
    /* also pull up to remove the .comm-content top padding gap */
    margin-top: -20px;
    margin-bottom: 0;
  }
  .mobile-cat-strip::-webkit-scrollbar { display: none; }

  .mobile-cat-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: var(--ds-radius-pill);
    border: 1.5px solid var(--ds-stone);
    font-size: 12px;
    font-weight: 500;
    color: var(--ds-graphite);
    white-space: nowrap;
    cursor: pointer;
    background: var(--ds-white);
    font-family: var(--ds-font-body);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .mobile-cat-chip.is-active {
    background: var(--ds-ink);
    border-color: var(--ds-ink);
    color: var(--ds-white);
  }

  .mobile-cat-chip:active:not(.is-active) { background: var(--ds-parchment); }

  /* ── Dark mode overrides ── */
  [data-theme="dark"] .mobile-header,
  [data-theme="dark"] .mobile-search-overlay {
    background: var(--ds-white);
    border-bottom-color: var(--ds-stone);
  }
  [data-theme="dark"] .mobile-search-input-wrap { background: var(--ds-parchment); }
  [data-theme="dark"] .mobile-swipe-indicator { background: var(--ds-white); }
}

/* ── PWA / homescreen standalone mode (iOS + Android) ─────────────────────── */
/*
 * iOS WebKit has a bug where position:sticky breaks after window.scrollTo(0,0)
 * is called in a standalone WKWebView. Switch to position:fixed in standalone
 * mode and compensate with padding-top on #app so content isn't hidden.
 * Also accounts for env(safe-area-inset-top) (the transparent status bar height
 * in black-translucent PWA mode) which would otherwise overlap the header.
 */
@media (max-width: 767px) and (display-mode: standalone) {
  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--ds-header-h) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  /* Search overlay spans the full header height including the status-bar inset */
  .mobile-search-overlay {
    height: calc(var(--ds-header-h) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  /* Push main content down so it starts below the now-fixed header */
  #app {
    padding-top: calc(var(--ds-header-h) + env(safe-area-inset-top));
  }

  /* Category strip: fix below the header, clear its flow margins */
  .mobile-cat-strip {
    position: fixed;
    top: calc(var(--ds-header-h) + env(safe-area-inset-top));
    left: 0;
    right: 0;
    margin: 0;
    z-index: 98;
  }

  /*
   * .comm-content normally has padding-top:20px and the cat strip uses
   * margin-top:-20px to sit flush at the top. With the strip now fixed
   * (out of flow), push content down by just the strip's height (≈48px)
   * so the thread list isn't hidden behind it. Don't add the original
   * 20px on top — the compose bar has its own internal padding and adding
   * 20px here creates a visible gap between the cat strip and compose bar.
   */
  .comm-content {
    padding-top: 48px; /* ~cat strip height only */
  }
}
