/* ==========================================================================
   应用外壳：顶栏 / 左导航 / 主内容 / 右栏 / 底栏 / 抽屉
   断点只有一个主断点：980px 以上是桌面三栏，以下切换成移动单栏
   ========================================================================== */

.nz-app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── 顶栏 ─────────────────────────────────────── */
.nz-header {
    position: sticky;
    top: 0;
    z-index: 60;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    background: var(--nz-panel);
    border-bottom: 1px solid var(--nz-border);
}
.nz-header-inner {
    max-width: var(--nz-content-max);
    margin: 0 auto;
    padding: 0 18px;
    height: var(--nz-header-h);
    display: flex;
    align-items: center;
    gap: 14px;
}
.nz-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.nz-brand img { height: 32px; display: block; }
.nz-brand-name {
    font-weight: 800;
    color: var(--nz-text-strong);
    font-size: var(--nz-fs-lg);
    letter-spacing: .01em;
    white-space: nowrap;
}
.nz-brand:hover .nz-brand-name { color: var(--nz-accent-deep); }

[data-mobile-only] { display: none !important; }

.nz-header-search {
    flex: 1 1 auto;
    max-width: 420px;
    position: relative;
}
.nz-header-search input {
    width: 100%;
    height: 38px;
    padding: 0 36px 0 36px;
    border-radius: var(--nz-radius-pill);
    border: 1px solid var(--nz-border);
    background: var(--nz-surface-2);
    transition: border-color var(--nz-dur) var(--nz-ease), box-shadow var(--nz-dur) var(--nz-ease);
}
.nz-header-search input:focus {
    outline: none;
    border-color: var(--nz-accent);
    box-shadow: 0 0 0 4px var(--nz-accent-soft);
}
.nz-header-search .nz-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--nz-text-faint); }

/* 桌面端进了搜索页：顶栏这个入口收起来（那边已经有真输入框了）。
   visibility 而不是 display —— 顶栏的布局一点不动，其他东西不会跟着跳。
   只影响它自己，侧栏 / 右栏 / 顶栏别的东西都照旧 */
@media (min-width: 821px) {
    html.is-search-jump .nz-header-search { visibility: hidden; }
}

/* 搜索框从顶栏飞到搜索页的那一下：一个跟输入框长得一样的影子，
   从旧位置平移到新位置，飞完就换成真输入框 */
.nz-search-ghost {
    position: fixed;
    z-index: 320;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: var(--nz-text-faint);
    border-radius: var(--nz-radius-pill);
    border: 1px solid var(--nz-accent);
    background: var(--nz-surface-2);
    box-shadow: 0 0 0 4px var(--nz-accent-soft), var(--nz-shadow-sm);
    pointer-events: none;
    transition: transform .36s var(--nz-ease-out), width .36s var(--nz-ease-out), height .36s var(--nz-ease-out);
}
@media (prefers-reduced-motion: reduce) {
    .nz-search-ghost { transition-duration: .001ms; }
}

.nz-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* 「下载客户端」入口：只有安卓浏览器才输出这个节点（判据在 zone/index.php，
   客户端本身和桌面端都不给）。它是 .nz-header-inner 的直接子节点，不在
   .nz-header-actions 里面，所以不会被窄屏那条 .nz-btn-primary { display:none } 收走。 */
.nz-download-app { flex: 0 0 auto; white-space: nowrap; }

/* 窄屏上搜索框让它一让，别把"下载APP"压成半截。
   :has() 圈定了"这一页真有下载入口"才生效 —— 桌面、iOS、客户端都没有这个节点，
   拿到的顶栏跟以前一模一样，一个像素都不动。 */
@media (max-width: 560px) {
    .nz-download-app { padding: 0 11px; font-size: var(--nz-fs-xs); }
    .nz-header-inner:has(.nz-download-app) .nz-header-search { min-width: 0; }
}

/* ── 主体三栏 ─────────────────────────────────── */
.nz-body {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--nz-content-max);
    margin: 0 auto;
    padding: 18px;
    display: grid;
    grid-template-columns: var(--nz-sidebar-w) minmax(0, 1fr) var(--nz-aside-w);
    gap: var(--nz-gap);
    align-items: start;
}
.nz-body.is-wide { grid-template-columns: var(--nz-sidebar-w) minmax(0, 1fr); }
.nz-body.is-full { grid-template-columns: minmax(0, 1fr); }

.nz-sidebar, .nz-aside {
    position: sticky;
    top: calc(var(--nz-header-h) + 18px);
    max-height: calc(100vh - var(--nz-header-h) - 36px);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 2px;
}
.nz-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--nz-gap);
    /* 换页那一瞬间新内容还没回来（骨架/加载态很矮），整页高度会先塌再撑，
       滚动条跟着蹦一下，看着就是"闪"。给个下限，把这一下按平 */
    min-height: 62vh;
}

/* ── 左导航 ───────────────────────────────────── */
.nz-nav-group { display: flex; flex-direction: column; gap: 2px; }
.nz-nav-title {
    font-size: var(--nz-fs-xs);
    font-weight: 700;
    color: var(--nz-text-faint);
    padding: 6px 12px 4px;
    letter-spacing: .06em;
}
.nz-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--nz-radius-sm);
    color: var(--nz-text);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--nz-dur) var(--nz-ease), color var(--nz-dur) var(--nz-ease), transform var(--nz-dur-fast) var(--nz-ease);
    position: relative;
    min-width: 0;
}
.nz-nav-item:hover { background: var(--nz-surface-3); color: var(--nz-text-strong); }
.nz-nav-item:active { transform: scale(.985); }
.nz-nav-item.is-active {
    background: var(--nz-accent-soft);
    color: var(--nz-accent-deep);
    border-color: color-mix(in srgb, var(--nz-accent) 30%, transparent);
}
.nz-nav-item.is-active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--nz-accent);
}
.nz-nav-item .nz-icon { color: currentColor; opacity: .92; }
.nz-nav-item .nz-nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nz-nav-item .nz-nav-count {
    flex: 0 0 auto;
    font-size: var(--nz-fs-xs);
    color: var(--nz-text-faint);
    background: var(--nz-surface-3);
    border-radius: var(--nz-radius-pill);
    padding: 1px 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
/* 未读数：红的，一眼能看见 */
.nz-nav-item .nz-nav-count.is-unread {
    background: var(--nz-danger);
    color: #fff;
    font-weight: 800;
    min-width: 18px;
    text-align: center;
    padding: 1px 6px;
}
.nz-nav-sub { padding-left: 10px; border-left: 1px dashed var(--nz-border); margin-left: 18px; }

.nz-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    min-width: 0;
}
.nz-nav-user .nz-avatar { width: 40px; height: 40px; }
.nz-nav-user-name { font-weight: 700; color: var(--nz-text-strong); }
.nz-nav-user-sub { font-size: var(--nz-fs-xs); color: var(--nz-text-faint); }

/* ── 移动端底栏 ───────────────────────────────── */
.nz-bottombar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    height: calc(var(--nz-bottombar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: none;
    align-items: stretch;
    background: var(--nz-panel-strong);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--nz-border);
}
.nz-bottombar-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--nz-text-sub);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    /* 底栏不再整块重建，点亮状态就是这里过渡出来的（以前是 innerHTML 全换，
       等于啪一下换张图，现在才是"拨过去"） */
    transition: color var(--nz-dur) var(--nz-ease), transform var(--nz-dur-fast) var(--nz-ease);
    -webkit-tap-highlight-color: transparent;
}
.nz-bottombar-item .nz-icon { width: 22px; height: 22px; transition: transform var(--nz-dur) var(--nz-ease-out); }
.nz-bottombar-item.is-active { color: var(--nz-accent-deep); }
.nz-bottombar-item.is-active .nz-icon { transform: translateY(-1px) scale(1.06); }
.nz-bottombar-item:active { transform: scale(.94); }
.nz-bottombar-item .nz-badge { position: absolute; top: 6px; left: 50%; margin-left: 4px; }

/* ── 抽屉（移动端导航） ───────────────────────── */
.nz-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(47, 74, 99, .34);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--nz-dur) var(--nz-ease), visibility var(--nz-dur);
}
.nz-drawer-backdrop.is-open { opacity: 1; visibility: visible; }
.nz-drawer {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(84vw, 320px);
    z-index: 91;
    background: var(--nz-surface);
    box-shadow: var(--nz-shadow-modal);
    transform: translateX(-102%);
    transition: transform var(--nz-dur-slow) var(--nz-ease-out);
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
    overflow-y: auto;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
}
.nz-drawer.is-open { transform: none; }

/* ── 页面头部（面包屑 + 标题 + 操作） ─────────── */
.nz-page-head { display: flex; flex-direction: column; gap: 6px; }
.nz-crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--nz-fs-sm); color: var(--nz-text-faint); flex-wrap: wrap; }
.nz-crumbs a { color: var(--nz-text-sub); }
.nz-crumbs a:hover { color: var(--nz-accent-deep); }
.nz-page-title { font-size: var(--nz-fs-2xl); font-weight: 800; color: var(--nz-text-strong); letter-spacing: -.01em; }
.nz-page-sub { color: var(--nz-text-sub); font-size: var(--nz-fs-sm); }

/* ── 响应式 ───────────────────────────────────── */
@media (max-width: 1200px) {
    .nz-body { grid-template-columns: var(--nz-sidebar-w) minmax(0, 1fr); }
    .nz-aside { display: none; }
}
/* 顶部宣传位带 */
#nz-hero {
    width: 100%;
    max-width: var(--nz-content-max);
    margin: 14px auto 0;
    padding: 0 18px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

@media (max-width: 980px) {
    /* 注意：这里千万不要给 html / body 加 overflow-x: hidden。
       那会让 body 变成滚动容器，整页的纵向滚动直接失效（已踩过）。
       页面本身没有横向溢出，问题只是横滑的惯性会带着页面晃，用 overscroll-behavior 就够了。 */
    html { overscroll-behavior-x: none; }
    body { overscroll-behavior-x: none; }
    [data-mobile-only] { display: inline-flex !important; }
    #nz-hero { margin-top: 10px; padding: 0 12px; }
    :root { --nz-header-h: 56px; }
    /* 横向滚动的条子自己滚自己的，别把整页带着走 */
    .nz-tabs, .nz-msg-nav, .nz-toolbar, .nz-mobile-toolbar, .nz-dm-threads { overscroll-behavior-x: contain; }
    .nz-body,
    .nz-body.is-wide,
    .nz-body.is-full {
        grid-template-columns: minmax(0, 1fr);
        padding: 12px 12px calc(var(--nz-bottombar-h) + 24px);
        gap: 12px;
    }
    .nz-body.is-wide .nz-sidebar, .nz-body.is-full .nz-sidebar { display: none; }
    .nz-sidebar { display: none; }
    .nz-bottombar { display: flex; }
    .nz-brand-name { display: none; }
    .nz-header-inner { padding: 0 12px; gap: 8px; }
    .nz-page-title { font-size: var(--nz-fs-xl); }
}
@media (max-width: 560px) {
    .nz-body { padding: 10px 10px calc(var(--nz-bottombar-h) + 20px); }
    .nz-header-search { max-width: none; }
    /* 顶栏太挤了：发帖和昵称都收掉（底栏有发帖，头像就是入口） */
    .nz-header-actions .nz-btn-primary { display: none; }
    .nz-header-actions .nz-small.nz-strong { display: none; }
    body.is-dm .nz-body { padding-top: 0; }
    body.is-dm { overflow: hidden; }
}
