.video-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px 14px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1%;
}

/* .one-row class is now a no-op marker (kept on grids for backward compat);
   each grid grows to its natural height and the page scrolls instead. */

.video-card {
    display: block;
    text-decoration: none;
    color: inherit;
}
.video-card:hover .card-title {
    color: #fff;
}
.video-card .thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}
.video-card .card-title {
    font-size: 13px;
    font-weight: 500;
    color: #eee;
    margin-top: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-card .card-meta {
    font-size: 11px;
    color: #aaa;
    margin-top: 3px;
    line-height: 1.4;
}

.textpost-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px 14px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1%;
}
.textpost-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 6px;
}
.textpost-card:hover {
    border-color: #666;
}
.textpost-card .card-title {
    font-size: 13px;
    font-weight: 500;
    color: #eee;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.textpost-card .card-meta {
    font-size: 11px;
    color: #aaa;
    margin-top: 3px;
}
.textpost-card .card-preview {
    font-size: 11px;
    color: #888;
    margin-top: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Tab bar (replaces per-section <h2> headings) ===== */
.tab-bar {
    max-width: 1200px;
    margin: 12px auto;
    padding: 0 1%;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

/* Home page wraps everything in a fixed-position scroll container so the
   body does NOT scroll on home. Body scroll on home was the root cause of
   the "first row covered" bug: iOS WKWebView restored the previous page's
   body scrollY across the hx-boost innerHTML swap, and nothing we did from
   JS (scrollTo, history.scrollRestoration, multi-frame re-pin) reliably
   defeated it. With body scroll removed, there is nothing to restore — the
   container always starts at scrollTop=0. Going through PostVideo/PostText/
   Profile used to "fix" the bug only because those pages were short enough
   to land body at 0 before home read it; this layout removes the dependency.

   The top-navbar (position: fixed in base.html) covers viewport 0 to
   --nav-height. The home container fills the rest of the viewport below it.
   Tab-bar sticks at top:0 of the container (i.e. immediately under the
   navbar); active-panel sort-chips stick at top: --tab-bar-h (immediately
   under the tab-bar). Both are opaque so the scrolling grid doesn't bleed
   through. */
.home-page {
    position: fixed;
    top: var(--nav-height, 0px);
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.home-page .tab-bar {
    position: sticky;
    top: 0;
    background: #000;
    z-index: 900;
}
.home-page .tab-panel.active .sort-chips {
    position: sticky;
    top: var(--tab-bar-h, 0px);
    background: #000;
    z-index: 800;
}

.section-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 9999px;
    background: #272727;
    color: lawngreen;
    font-size: 14px;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
.section-tab:hover { background: #3f3f3f; }
.section-tab.active {
    color: orange;
}

/* ===== Tab panels — only one visible at a time ===== */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.sort-chips {
    max-width: 1200px;
    margin: 0 auto 12px;
    padding: 0 1%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.sort-chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    background: #272727;
    color: lawngreen;
    font-size: 13px;
    text-decoration: none;
    line-height: 1.2;
    border: 1px solid transparent;
}
.sort-chip:hover {
    background: #3f3f3f;
}
.sort-chip.active {
    color: orange;
}
.section-empty {
    color: #888;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1%;
}

.history-card {
    position: relative;
}
.history-menu-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #ccc;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.history-menu-btn:hover { color: #fff; background: rgba(0,0,0,0.8); }
.history-popup {
    display: none;
    position: absolute;
    top: 30px;
    right: 4px;
    background: #222;
    border: 1px solid #555;
    border-radius: 4px;
    z-index: 3;
    min-width: 80px;
}
.history-popup.open { display: block; }
.history-popup-item {
    padding: 6px 12px;
    color: #eee;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}
.history-popup-item:hover { background: #444; }
