/* 公共基座：变量、重置与全局排版 */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --surface-muted: #eef3f9;
    --text: #1f2329;
    --muted: #86909c;
    --line: #e5eaf3;
    --line-strong: #d8e1ee;
    --brand: #1677ff;
    --brand-deep: #0f5ed7;
    --brand-soft: rgba(22, 119, 255, 0.1);
    --success: #00b578;
    --error: #f53f3f;
    --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 38px rgba(15, 23, 42, 0.08);
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --max-width: 1200px;
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(22, 119, 255, 0.06) 0, rgba(22, 119, 255, 0) 240px),
        var(--bg);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.7;
}

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

img {
    display: block;
    max-width: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: none;
}

textarea {
    resize: vertical;
}

summary {
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

[hidden] {
    display: none !important;
}

.container {
    width: min(var(--max-width), calc(100% - 40px));
    margin: 0 auto;
}

/* 头部与页脚 */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(229, 234, 243, 0.9);
    backdrop-filter: blur(18px);
    background: rgba(255, 255, 255, 0.9);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 78px;
}

.header-left {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 28px;
    min-width: 0;
}

.brand {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 10px 24px rgba(22, 119, 255, 0.18);
}

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

.brand-copy strong {
    display: block;
    font-size: 19px;
    line-height: 1.2;
}

.brand-copy span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

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

.site-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 8px;
    color: var(--muted);
    white-space: nowrap;
    transition: color var(--transition);
}

.site-nav a::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 2px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-deep) 100%);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--transition);
}

.site-nav a:hover {
    color: var(--text);
}

.site-nav a.active {
    color: var(--brand-deep);
}

.site-nav a.active::after {
    transform: scaleX(1);
}

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

.header-search {
    width: 320px;
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(247, 249, 252, 0.96);
}

.header-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: none;
    background: transparent;
    color: var(--text);
}

.header-search input:focus {
    outline: none;
}

.header-search button,
.primary-btn {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
    color: #fff;
}

.header-search button {
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}

.header-link,
.header-auth {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: all var(--transition);
}

.header-link {
    color: var(--text);
    background: #fff;
    border-color: var(--line);
}

.header-link:hover {
    color: var(--brand-deep);
    border-color: rgba(22, 119, 255, 0.18);
}

.header-link.muted {
    color: var(--muted);
}

.header-auth {
    color: #fff;
}

.header-message-link {
    position: relative;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.header-message-link:hover {
    transform: translateY(-1px);
    border-color: rgba(22, 119, 255, 0.18);
    box-shadow: var(--shadow-sm);
}

.header-message-icon,
.header-message-icon svg {
    width: 20px;
    height: 20px;
}

.header-message-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(255, 77, 79, 0.24);
}

.header-dropdown {
    position: relative;
}

.header-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 14px 0 8px;
    border: none;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.header-dropdown-toggle img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.header-dropdown-toggle span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-dropdown-arrow {
    width: 8px;
    height: 8px;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--transition);
}

.header-dropdown[open] .header-dropdown-arrow {
    transform: rotate(225deg);
}

.header-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-lg);
}

.header-dropdown-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
}

.header-dropdown-menu a:hover {
    background: var(--surface-soft);
}

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

.flash-banner {
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

.flash-banner.success {
    color: var(--success);
    background: rgba(0, 181, 120, 0.12);
}

.flash-banner.error {
    color: var(--error);
    background: rgba(245, 63, 63, 0.1);
}

.site-footer {
    margin-top: 12px;
    padding: 28px 0 34px;
    border-top: 1px solid rgba(229, 234, 243, 0.9);
    background: rgba(255, 255, 255, 0.88);
}

.footer-copy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
}

.footer-copy p {
    margin: 0;
}

.footer-copy a {
    color: var(--muted);
}

/* 通用组件：标题、卡片、按钮、表单 */
.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--brand-deep);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.panel,
.auth-card,
.agreement-card,
.detail-main,
.detail-side .panel,
.comment-card {
    background: var(--surface);
    border: 1px solid rgba(229, 234, 243, 0.9);
    box-shadow: var(--shadow-sm);
}

.panel,
.auth-card,
.agreement-card,
.detail-main {
    padding: 24px;
    border-radius: var(--radius-lg);
}

.section-head,
.panel-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.section-head h1,
.section-head h2,
.panel-title h2 {
    margin: 0;
}

.section-head h2,
.panel-title h2 {
    font-size: 22px;
}

.section-head p,
.panel-title span,
.helper-text,
.inline-hint {
    color: var(--muted);
}

.helper-text,
.inline-hint {
    margin: 0;
    font-size: 13px;
}

.inline-hint.error {
    color: var(--error);
}

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 20px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.primary-btn:hover,
.secondary-btn:hover {
    transform: translateY(-1px);
}

.primary-btn {
    box-shadow: 0 10px 24px rgba(22, 119, 255, 0.2);
}

.secondary-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.secondary-btn.danger {
    color: var(--error);
    border-color: rgba(245, 63, 63, 0.18);
}

.stack-form {
    display: grid;
    gap: 12px;
}

.stack-form label {
    font-size: 14px;
    color: var(--muted);
}

.stack-form input,
.stack-form textarea,
.stack-form select,
.verification-row input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
}

.stack-form input,
.stack-form select,
.verification-row input {
    min-height: 48px;
    padding: 0 16px;
}

.stack-form textarea {
    min-height: 132px;
    padding: 14px 16px;
}

.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus,
.verification-row input:focus {
    outline: none;
    border-color: rgba(22, 119, 255, 0.28);
    box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.08);
}

.verification-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
}

.comment-submit-btn {
    justify-self: start;
    min-width: 120px;
}

.agreement-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
}

.agreement-check input {
    min-height: 16px;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-top: 3px;
    border: none;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    accent-color: var(--brand);
    flex-shrink: 0;
}

.agreement-check span {
    line-height: 1.6;
}

.agreement-check a {
    color: var(--brand-deep);
}

.detail-tag,
.post-chip,
.account-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(22, 119, 255, 0.12);
    background: var(--brand-soft);
    color: var(--brand-deep);
    font-size: 13px;
}

.post-chip {
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--muted);
}

.post-chip-topic {
    background: rgba(15, 23, 42, 0.06);
    border-color: transparent;
    color: #475569;
}

.inline-auth-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.inline-auth-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--tag-color, var(--brand));
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
}

.inline-state-tag {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.5;
}

.inline-state-tag.top {
    color: #b26a00;
    background: #fff3cd;
}

.hero-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
}

/* 通用内容模块 */
.post-grid {
    display: grid;
    gap: 16px;
}

.post-card {
    position: relative;
    border-bottom: 1px solid var(--line);
    background: transparent;
    transition: border-color var(--transition), background-color var(--transition);
}

.post-grid > .post-card:last-child,
.mini-post-list > .mini-post:last-child,
.mini-post-list > .author-card:last-child {
    border-bottom: none;
}

.post-card-link {
    cursor: pointer;
}

.post-card-link:hover,
.post-card-link:focus-visible {
    border-color: rgba(22, 119, 255, 0.18);
    background: rgba(22, 119, 255, 0.02);
}

.post-card-link:focus-visible {
    outline: none;
}

.post-card-layout {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
}

.post-card-avatar img,
.author-card img,
.detail-author img,
.comment-avatar,
.comment-avatar-reply {
    object-fit: cover;
    border-radius: 50%;
}

.post-card-avatar img {
    width: 52px;
    height: 52px;
}

.post-card-main {
    min-width: 0;
}

.post-card-head,
.post-card-footer,
.detail-author,
.comment-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-card-head {
    justify-content: space-between;
}

.post-author-block {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.post-author {
    color: var(--text);
    font-weight: 600;
}

.post-card-head em,
.post-stats span,
.post-summary,
.mini-post p,
.mini-post-meta span,
.author-card p,
.author-card span {
    color: var(--muted);
}

.post-card-head em {
    font-style: normal;
    font-size: 13px;
    white-space: nowrap;
}

.post-title {
    display: block;
    margin-top: 10px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.45;
}

.post-summary {
    margin: 10px 0 0;
    font-size: 15px;
}

.post-media {
    display: grid;
    gap: 10px;
    width: min(100%, 620px);
    margin-top: 16px;
}

.post-media img {
    width: 100%;
    border-radius: 14px;
    background: #f1f4f9;
    object-fit: cover;
}

.post-media.single {
    max-width: 460px;
}

.post-media.single img {
    height: 240px;
}

.post-media.double {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-media.double img {
    height: 184px;
}

.post-media.grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.post-media.grid img {
    height: 148px;
}

.post-card-footer {
    flex-wrap: wrap;
    justify-content: space-between;
    margin-top: 16px;
}

.post-card-topic,
.post-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.post-stats {
    font-size: 13px;
}

.mini-post-list,
.comment-list {
    display: grid;
    gap: 14px;
}

.mini-post,
.author-card {
    display: grid;
    gap: 8px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    transition: border-color var(--transition), background-color var(--transition);
}

.mini-post:hover,
.author-card:hover {
    border-color: rgba(22, 119, 255, 0.18);
    background: rgba(22, 119, 255, 0.02);
}

.mini-post strong,
.author-card strong {
    font-size: 17px;
    line-height: 1.5;
}

.mini-post p,
.author-card p {
    margin: 0;
}

.mini-post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
}

.author-card {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.author-card.large {
    grid-template-columns: 68px minmax(0, 1fr);
}

.author-card img {
    width: 54px;
    height: 54px;
}

.author-card.large img {
    width: 68px;
    height: 68px;
}

.empty-state {
    padding: 42px 24px;
    border: 1px dashed rgba(31, 35, 41, 0.14);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    text-align: center;
}

.empty-state.compact {
    padding: 28px 20px;
}

.empty-state h3,
.empty-state p {
    margin: 0;
}

.empty-state h3 + p {
    margin-top: 8px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
}

.pagination a.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
}

.homepage-keyword-hint,
.feed-load-state {
    margin-top: 16px;
    color: var(--muted);
    font-size: 14px;
}

/* 共享的上传卡片与操作样式：首页、话题页都会复用 */
.home-composer-media-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.home-composer-media-list.is-empty {
    display: none;
}

.home-composer-media-item {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: var(--surface-soft);
}

.home-composer-media-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.home-composer-media-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    cursor: pointer;
}

.home-composer-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
}

.home-composer-action:hover,
.home-composer-action.is-active,
.home-composer-action.is-loading {
    color: var(--brand-deep);
    border-color: rgba(22, 119, 255, 0.18);
    background: var(--brand-soft);
}

.home-composer-action-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 119, 255, 0.1);
    color: var(--brand-deep);
    font-size: 12px;
    font-weight: 700;
}

.home-composer-file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* 响应式 */
@media (max-width: 1100px) {
    .header-inner {
        flex-wrap: wrap;
        padding: 12px 0;
    }

    .header-left,
    .header-actions {
        width: 100%;
    }

    .header-actions {
        justify-content: space-between;
        margin-left: 0;
    }

    .header-search {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 720px) {
    .container {
        width: min(var(--max-width), calc(100% - 24px));
    }

    .header-left,
    .header-actions,
    .footer-copy,
    .panel-title,
    .section-head,
    .post-card-head,
    .post-card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .site-nav {
        flex-wrap: wrap;
    }

    .header-actions {
        gap: 10px;
    }

    .header-search {
        min-width: 0;
    }

    .header-link,
    .header-auth {
        flex: 1 1 0;
    }

    .panel,
    .auth-card,
    .agreement-card,
    .detail-main {
        padding: 20px;
    }

    .post-card-layout {
        grid-template-columns: 1fr;
    }

    .post-card-avatar {
        display: none;
    }

    .post-title {
        font-size: 18px;
    }

    .post-media,
    .post-media.single {
        width: 100%;
        max-width: none;
    }

    .post-media.grid,
    .post-media.double,
    .home-composer-media-list,
    .verification-row {
        grid-template-columns: 1fr;
    }

    .post-media.single img,
    .post-media.double img,
    .post-media.grid img,
    .home-composer-media-item img {
        height: 180px;
    }

    .footer-copy {
        align-items: flex-start;
    }
}
