:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --card-soft: #f8fbff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d9e2ec;
    --brand: #1678d3;
    --brand-dark: #0f5ea8;
    --brand-soft: #e7f1fb;
    --accent: #00a88f;
    --danger: #d83b01;
    --shadow: 0 8px 24px rgba(15, 23, 42, .08);
    --radius: 4px;
    --maxw: 780px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding: 68px 0 calc(92px + env(safe-area-inset-bottom));
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.hidden {
    display: none !important;
}

.site-app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    width: 100%;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid rgba(229, 231, 235, .88);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.site-app-header-inner {
    max-width: var(--maxw);
    min-height: 62px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-app-logo {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-app-logo-box {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    overflow: hidden;
    background: var(--brand);
    border-radius: var(--radius);
}

.site-app-logo-box img {
    width: 100%;
    height: 100%;
    display: block;
}

.site-app-logo-text {
    min-width: 0;
    display: block;
}

.site-app-logo-text strong,
.site-app-logo-text small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.site-app-logo-text strong {
    font-size: 16px;
    line-height: 1.1;
    font-weight: 900;
}

.site-app-logo-text small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.site-app-header-actions {
    flex: 0 0 auto;
}

.site-app-menu {
    position: relative;
    z-index: 20;
}

.site-app-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #cde1f7;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    border-radius: var(--radius);
}

.site-app-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    width: 154px;
    padding: 6px;
    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(217, 226, 236, .95);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
    border-radius: var(--radius);
}

.site-app-menu-item {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 10px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--radius);
}

.site-app-menu-item:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.app {
    max-width: var(--maxw);
    margin: 0 auto;
    min-height: 100vh;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.toolbar,
.topic-card,
.loading,
.empty,
.error {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.hero-titlebar {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-titlebar svg {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    color: var(--brand-dark);
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hero-titlebar strong {
    min-width: 0;
    color: var(--text);
    font-size: 20px;
    line-height: 1.25;
    font-weight: 900;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hero-count {
    flex: 0 0 auto;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    background: var(--brand-soft);
    border: 1px solid #cde1f7;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 800;
    border-radius: var(--radius);
}

.section {
    padding-bottom: 12px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
}

.search-box {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.search-box svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke: var(--brand);
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.toolbar-info {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.topic-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.topic-card {
    min-width: 0;
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.topic-card:hover {
    border-color: #b8d4ef;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .10);
}

.topic-card:active {
    transform: scale(.996);
}

.topic-cover {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #e9eef5;
    border-bottom: 1px solid var(--line);
}

.topic-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.topic-cover-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #6b7b8d;
    font-size: 13px;
    font-weight: 900;
    background:
        linear-gradient(135deg, rgba(22, 120, 211, .14), rgba(0, 168, 143, .12)),
        #edf3f9;
}

.topic-body {
    padding: 12px;
}

.topic-title {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.35;
    font-weight: 900;
}

.topic-summary {
    min-height: 43px;
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.topic-meta {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-chip {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    background: var(--card-soft);
    border: 1px solid var(--line);
    color: #526172;
    font-size: 12px;
    font-weight: 800;
    border-radius: var(--radius);
}

.topic-action {
    margin-top: 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    border-radius: var(--radius);
}

.loading,
.empty,
.error {
    grid-column: 1 / -1;
    padding: 32px 16px;
    text-align: center;
    color: var(--muted);
    line-height: 1.7;
}

.error {
    color: var(--danger);
}

.footer-space {
    height: 12px;
}

.app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    width: 100%;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid rgba(229, 231, 235, .95);
    box-shadow: 0 -12px 30px rgba(15, 23, 42, .10);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.app-tabbar-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}

.app-tab {
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    border-radius: var(--radius);
}

.app-tab svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-tab.active {
    color: var(--brand-dark);
    background: var(--brand-soft);
}

@media (max-width: 680px) {
    body {
        padding-top: 64px;
    }

    .site-app-header-inner {
        min-height: 56px;
        padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 8px;
        gap: 8px;
    }

    .site-app-logo-box {
        width: 34px;
        height: 34px;
    }

    .site-app-logo-text small {
        max-width: 180px;
    }

    .site-app-menu-panel {
        width: 146px;
    }

    .hero {
        padding: 12px 10px;
        gap: 10px;
        margin-bottom: 8px;
    }

    .hero-titlebar strong {
        font-size: 18px;
    }

    .hero-count {
        font-size: 12px;
    }

    .section {
        padding-bottom: 8px;
    }

    .toolbar {
        display: block;
        padding: 10px;
    }

    .toolbar-info {
        margin-top: 8px;
        white-space: normal;
    }

    .topic-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .topic-title {
        font-size: 17px;
    }

    .app-tabbar-inner {
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
        gap: 2px;
    }

    .app-tab {
        min-height: 50px;
    }
}
