/* 摸鱼吧 - 稳定版布局 v5 */
:root {
    --primary: #ff2442;
    --bg: #f4f4f5;
    --card: #fff;
    --text: #333;
    --sub: #999;
    --line: #eee;
    --header: 48px;
    --nav: 52px;
    --side: 220px;
    --gap: 10px;
    --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: none; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ===== 整体框架 ===== */
.app-body {
    min-height: 100vh;
}

.app-shell {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .app-body.page-home {
        padding-left: var(--side);
    }
    .app-body.page-inner {
        padding-left: var(--side);
    }
}

/* ===== PC 侧栏 ===== */
.app-sidebar {
    display: none;
}

@media (min-width: 900px) {
    .app-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--side);
        background: #fff;
        border-right: 1px solid var(--line);
        padding: 20px 14px;
        z-index: 100;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 24px;
    flex-shrink: 0;
}

.side-nav {
    list-style: none;
    flex-shrink: 0;
}
.side-nav li { margin-bottom: 4px; }
.side-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
    min-width: 0;
}
.side-nav .nav-ico {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 15px;
    line-height: 1;
}
.side-nav .nav-txt {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-nav a:hover, .side-nav a.active {
    background: #fff0f2;
    color: var(--primary);
}

.side-account {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f8f8f8;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 0;
}
.side-account-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    color: #333;
    font-size: 13px;
}
.side-account-user:hover { color: var(--primary); }
.side-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #ff2442);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.side-account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-logout {
    flex-shrink: 0;
    font-size: 12px;
    color: #999;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
    background: #fff;
}
.side-logout:hover {
    color: var(--primary);
    border-color: #ffc9d2;
    background: #fff8f9;
}

.nav-msg-link { position: relative; }
.nav-msg-link .nav-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
}

/* 侧栏板块（电脑端） */
.side-cats {
    margin-top: 12px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.side-cats-title {
    font-size: 12px;
    color: var(--sub);
    padding: 0 8px 8px;
    font-weight: 500;
}

.side-cat-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding-right: 2px;
}

.side-cat-list::-webkit-scrollbar { width: 4px; }
.side-cat-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.side-cat-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #555;
    line-height: 1.3;
}

.side-cat-btn:hover {
    background: #f5f5f5;
}

.side-cat-btn.active {
    background: #fff0f2;
    color: var(--primary);
    font-weight: 600;
}

.side-search {
    flex-shrink: 0;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.side-search input {
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: 18px;
    background: #f5f5f5;
    font-size: 13px;
}
.side-search input:focus { outline: none; background: #eee; }

/* ===== 顶栏（内页） ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 90;
    background: #fff;
    border-bottom: 1px solid var(--line);
    height: var(--header);
}

/* ===== 手机端：固定板块栏 ===== */
.feed-tabs-fixed {
    display: none;
}

@media (max-width: 899px) {
    .feed-tabs-fixed {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        height: var(--header);
        padding-top: env(safe-area-inset-top, 0px);
        background: #fff;
        border-bottom: 1px solid var(--line);
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
    }

    .feed-tabs-fixed .tab-bar {
        height: var(--header);
        align-items: center;
        padding: 0 10px;
    }

    .page-home .feed-page {
        padding-top: calc(var(--header) + env(safe-area-inset-top, 0px) + var(--gap));
    }
}

/* 电脑端：不显示板块栏 */
@media (min-width: 900px) {
    .feed-tabs-fixed {
        display: none !important;
    }

    .page-home .feed-page {
        padding-top: 16px;
    }
}

.header-bar {
    height: var(--header);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.header-back {
    font-size: 18px;
    padding: 4px 8px;
    flex-shrink: 0;
}

.header-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-spacer { width: 32px; flex-shrink: 0; }

/* 分类 Tab（手机横向滑动） */
.tab-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 6px 14px;
    font-size: 14px;
    color: var(--sub);
    border-radius: 16px;
    white-space: nowrap;
    line-height: 1.2;
}
.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
    background: #fff0f2;
}

/* ===== Feed 区域 ===== */
.feed-page {
    padding: var(--gap);
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

@media (min-width: 900px) {
    .feed-page {
        padding: 16px 20px 32px;
    }
}

@media (max-width: 899px) {
    .feed-page {
        padding-left: var(--gap);
        padding-right: var(--gap);
        padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

/* 不规则瀑布流容器（卡片位置由 masonry.js 计算） */
.waterfall {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.waterfall.profile-feed {
    position: relative;
}

/* ===== 卡片 ===== */
.note-card {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: box-shadow .2s;
}

.note-card-nav {
    display: block;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

a.note-user.note-card-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    .note-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
}

.note-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    min-height: 96px;
    max-height: 140px;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
}

.note-cover.has-img {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    max-height: none;
    padding: 0;
    background-color: #e8e8e8;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    box-sizing: border-box;
}

.note-cover-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    display: block;
    z-index: 0;
}

.note-cover.has-img::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    pointer-events: none;
    z-index: 1;
}

.note-cover.has-img .note-tag,
.note-cover.has-img .note-cover-title {
    position: relative;
    z-index: 2;
}

.note-cover.has-img .note-tag {
    position: absolute;
    top: 8px;
    left: 8px;
}

.note-cover .note-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 10px;
    color: #fff;
    background: rgba(0,0,0,.3);
    padding: 2px 8px;
    border-radius: 8px;
}

.note-cover.has-img .note-cover-title {
    padding: 0 10px;
    box-sizing: border-box;
    max-width: 100%;
}

.note-cover .note-cover-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    padding: 0 8px;
    width: 100%;
    max-height: 4.2em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.note-body {
    padding: 10px 12px 12px;
    background: var(--card);
    border-radius: 0 0 var(--radius) var(--radius);
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

.note-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.note-desc {
    font-size: 12px;
    color: var(--sub);
    line-height: 1.45;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
    position: relative;
    z-index: 2;
    padding-right: 2px;
}

.note-user {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.note-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.note-name {
    font-size: 11px;
    color: var(--sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-like {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    flex: 0 0 auto;
    flex-shrink: 0;
    padding: 5px 8px;
    white-space: nowrap;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
    min-width: 42px;
    touch-action: manipulation;
}
.note-like svg { width: 14px; height: 14px; flex-shrink: 0; pointer-events: none; }
.note-like-num {
    display: inline-block;
    min-width: 14px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: #333;
    pointer-events: none;
}
.note-like.is-liked { color: var(--primary); background: #fff0f2; }
.note-like.is-liked .note-like-num { color: var(--primary); }

/* ===== 骨架屏 ===== */
.feed-loading {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--gap);
}
@media (min-width: 600px)  { .feed-loading { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px)  { .feed-loading { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .feed-loading { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.feed-loading.is-hidden { display: none; }

.sk-item {
    margin-bottom: 0;
    height: 180px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, #ececec 25%, #e2e2e2 50%, #ececec 75%);
    background-size: 200% 100%;
    animation: sk 1.2s ease infinite;
}

@keyframes sk {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== 底部状态 ===== */
.feed-status {
    text-align: center;
    padding: 20px 0 8px;
    min-height: 48px;
}

.feed-status .spinner {
    width: 22px;
    height: 22px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.feed-status .tip {
    font-size: 13px;
    color: var(--sub);
    padding: 8px;
}

.feed-sentinel {
    height: 1px;
    width: 100%;
    pointer-events: none;
    visibility: hidden;
}

.empty-feed {
    width: 100%;
    text-align: center;
    padding: 80px 20px;
    color: var(--sub);
    font-size: 14px;
}
.empty-feed a { color: var(--primary); }

.btn-refresh-feed {
    margin-top: 16px;
    padding: 10px 28px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}
.btn-refresh-feed:hover { opacity: 0.9; }

/* ===== 手机底栏 ===== */
.app-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid var(--line);
    z-index: 90;
}

@media (min-width: 900px) {
    .app-tabbar { display: none; }
}

.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    color: var(--sub);
}
.tabbar-item.is-active { color: var(--text); font-weight: 600; }

.tabbar-plus { margin-top: -10px; }
.tabbar-plus span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 30px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-size: 22px;
    line-height: 1;
}

.tabbar-icon-wrap { position: relative; display: inline-flex; }
.tabbar-badge, .nav-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ff2442;
    color: #fff;
    font-size: 10px;
    font-style: normal;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
}
.nav-badge {
    position: static;
    display: inline-block;
    margin-left: 4px;
    vertical-align: middle;
}

/* ===== 手机端板块面板 ===== */
.cat-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
}
.cat-panel.is-open {
    pointer-events: auto;
    visibility: visible;
}
.cat-panel-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s;
}
.cat-panel.is-open .cat-panel-mask { opacity: 1; }
.cat-panel-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.28s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    flex-direction: column;
}
.cat-panel.is-open .cat-panel-sheet { transform: translateY(0); }
.cat-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}
.cat-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #666;
    font-size: 16px;
    line-height: 1;
}
.cat-panel-list {
    overflow-y: auto;
    padding: 12px 12px 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.cat-panel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: #f8f8f8;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text);
    text-align: center;
    min-height: 68px;
}
.cat-panel-item:active { background: #fff0f2; }
.cat-panel-item.is-active {
    background: #fff0f2;
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--primary);
}
.cat-panel-item .cat-icon { font-size: 24px; line-height: 1; }
.cat-panel-item .cat-name { line-height: 1.3; word-break: break-all; }
.cat-panel-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px;
    color: var(--sub);
    font-size: 14px;
}
@media (min-width: 900px) {
    .cat-panel { display: none; }
}

/* ===== 内页 ===== */
.inner-page {
    padding: 16px;
    background: #fff;
    min-height: 50vh;
}

@media (max-width: 899px) {
    .inner-page {
        padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px) + 16px);
    }
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.78);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
}
