/* 应用骨架与布局（v2 编辑部学习手册） */

#app {
    min-height: 100vh;
}

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

/* ------------------------------ 侧边栏 ------------------------------ */

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    padding: 26px 18px 20px;
    border-right: 1px solid var(--line);
    background: var(--surface);
    z-index: var(--z-nav);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 8px 10px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: var(--brand);
    background-image: url("../img/brand.svg"), linear-gradient(150deg, var(--brand), var(--brand-strong));
    background-size: 56%, 100%;
    background-position: center, center;
    background-repeat: no-repeat;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    flex: none;
}

.brand-text { min-width: 0; }

.brand-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.brand-sub {
    font-size: 10.5px;
    letter-spacing: 0.04em;
    color: var(--muted-2);
    margin-top: 2px;
    text-transform: none;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-label {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.06em;
    color: var(--muted-2);
    padding: 0 10px 8px;
    text-transform: none;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 10px;
    border-radius: var(--r-sm);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: var(--weight-medium);
    transition: background var(--dur-2) var(--ease), color var(--dur-2);
}

.nav-item svg {
    width: 17px;
    height: 17px;
    flex: none;
    opacity: 0.72;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--ink-2);
}

.nav-item.is-active {
    background: var(--surface-2);
    color: var(--brand-strong);
    font-weight: var(--weight-semibold);
    box-shadow: none;
    border: 0;
}

[data-theme="dark"] .nav-item.is-active { color: var(--brand); }

.nav-item.is-active svg { opacity: 1; }

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 16px;
    border-radius: 2px;
    background: var(--brand);
}

.nav-item .nav-badge {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: var(--weight-medium);
    color: var(--muted-2);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    padding: 0 6px;
    font-variant-numeric: tabular-nums;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.sidebar-tip {
    display: none;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px;
    border-radius: var(--r-sm);
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: color var(--dur-2);
    width: 100%;
    text-align: left;
}

.user-card:hover { color: var(--brand-strong); }

.user-card .name {
    font-size: 12.5px;
    font-weight: var(--weight-semibold);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card .role {
    font-size: 10.5px;
    color: var(--muted-2);
    letter-spacing: 0.02em;
}

.user-card .more {
    margin-left: auto;
    color: var(--muted-2);
}

/* ------------------------------ 主区域 ------------------------------ */

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 clamp(20px, 4vw, 44px);
    border-bottom: 1px solid transparent;
    background: var(--bg);
    transition: border-color var(--dur-2), background var(--dur-2);
}

.topbar.is-scrolled {
    border-bottom-color: var(--line);
    background: var(--surface);
}

.topbar-crumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted-2);
    min-width: 0;
}

.topbar-crumb .current {
    color: var(--ink-2);
    font-weight: var(--weight-semibold);
}

.topbar-crumb .sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--muted-2);
    opacity: 0.55;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-mobile-brand {
    display: none;
}

.view {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 28px clamp(20px, 4vw, 44px) 96px;
}

/* 页面标题 */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-6);
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.page-head-main { min-width: 0; }

.page-title {
    font-family: var(--font-display);
    font-size: var(--text-h1);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.03em;
    line-height: var(--leading-h1);
}

.page-desc {
    margin-top: 8px;
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.7;
    max-width: 620px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ------------------------------ 底部导航（移动端） ------------------------------ */

.tabbar {
    display: none;
}

/* ------------------------------ 通用网格 ------------------------------ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--sp-6);
}

.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}

.stack-lg > * + * {
    margin-top: var(--sp-5);
}

/* ------------------------------ 列表行（编辑部式） ------------------------------ */

.list-row {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
    transition: background var(--dur-2), padding var(--dur-2);
    cursor: pointer;
}

.list-row:last-child { border-bottom: 0; }

.list-row:hover {
    background: var(--surface-2);
    padding-left: 10px;
    padding-right: 10px;
}

.list-row .row-index {
    width: 34px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-2);
    flex: none;
    text-align: right;
}

.list-row .row-main { flex: 1; min-width: 0; }

.list-row .row-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: var(--weight-semibold);
    letter-spacing: -0.02em;
    line-height: 1.4;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.list-row .row-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--muted);
    flex-wrap: wrap;
}

.list-row .row-right,
.row-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}

.row-arrow {
    width: 30px;
    height: 30px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-2);
    background: transparent;
    transition: color var(--dur-2), transform var(--dur-2);
}

.list-row:hover .row-arrow {
    background: transparent;
    color: var(--brand-strong);
    transform: translateX(3px);
}

[data-theme="dark"] .list-row:hover .row-arrow { color: var(--brand); }

/* 难度点 */

.diff {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.diff i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--line-strong);
    display: block;
}

.diff i.on { background: var(--accent); }

/* 页面切换 */

.view-enter {
    animation: fade-up var(--dur-3) var(--ease-out) both;
}

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1080px) {
    .home-grid,
    .split-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 40px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-w: 0px;
        --topbar-h: 54px;
    }
    .shell {
        grid-template-columns: minmax(0, 1fr);
    }
    .sidebar {
        display: none;
    }
    .topbar {
        padding: 0 18px;
        border-bottom-color: var(--line);
        background: var(--bg);
    }
    .topbar-crumb { display: none; }
    .topbar-mobile-brand {
        display: flex;
        align-items: center;
        gap: 9px;
        font-family: var(--font-display);
        font-weight: var(--weight-semibold);
        font-size: 16px;
        letter-spacing: 0.01em;
    }
    .topbar-mobile-brand .brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }
    .topbar-mobile-brand .brand-mark svg { width: 18px; height: 18px; }
    .view {
        padding: 18px 18px calc(96px + env(safe-area-inset-bottom));
    }
    .page-head {
        margin-bottom: 28px;
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }
    .page-actions { width: 100%; }
    .page-desc { font-size: 13px; }

    .tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: var(--z-nav);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: var(--surface);
    }

    .tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 5px 0 3px;
        border-radius: 10px;
        color: var(--muted-2);
        font-size: 10px;
        font-weight: var(--weight-medium);
        transition: color var(--dur-2);
        position: relative;
    }

    .tabbar a svg {
        width: 20px;
        height: 20px;
    }

    .tabbar a.is-active {
        color: var(--brand-strong);
        font-weight: var(--weight-semibold);
    }

    [data-theme="dark"] .tabbar a.is-active { color: var(--brand); }

    .tabbar a.is-active::after {
        content: "";
        position: absolute;
        top: 0;
        width: 18px;
        height: 2px;
        border-radius: 0 0 2px 2px;
        background: var(--brand);
    }
}

@media (max-width: 560px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .page-title { font-size: 27px; }
    .list-row {
        padding: 16px 0;
        gap: 12px;
    }
    .list-row .row-title { font-size: 17px; }
    .list-row .row-meta { font-size: 12px; }
    .list-row .row-index { width: 26px; font-size: 11px; }
}
