/* ==========================================================================
   软件资源分享站 - 前台样式
   ========================================================================== */

:root {
    --brand: #0f766e;
    --brand-dark: #0b5c56;
    --brand-soft: #e6f4f2;
    --accent: #ea7317;
    --accent-dark: #c25c0d;
    --accent-soft: #fdf1e3;
    --ink: #1b2422;
    --ink-2: #3d4a47;
    --muted: #6d7c79;
    --line: #e3e9e8;
    --line-strong: #d3dcda;
    --bg: #f3f6f5;
    --surface: #ffffff;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(20, 40, 36, .06);
    --shadow-md: 0 6px 18px rgba(20, 40, 36, .09);
    --wrap: 1200px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; letter-spacing: 0; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; letter-spacing: 0; }

svg { flex: 0 0 auto; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 顶部 ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

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

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--brand); color: #fff; box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; }
.brand-text small { font-size: 11px; color: var(--muted); }

.header-search {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 auto; max-width: 460px; margin-left: auto;
    padding: 0 6px 0 12px; height: 40px;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius); color: var(--muted);
    transition: border-color .15s, background .15s;
}
.header-search:focus-within { border-color: var(--brand); background: #fff; }
.header-search input {
    flex: 1 1 auto; min-width: 0; height: 100%;
    border: 0; background: transparent; outline: none; color: var(--ink);
}
.header-search input::-webkit-search-cancel-button { display: none; }
.header-search button {
    height: 30px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
    background: var(--brand); color: #fff; font-size: 13px; font-weight: 600;
}
.header-search button:hover { background: var(--brand-dark); }

.nav-toggle {
    display: none; width: 40px; height: 40px; align-items: center; justify-content: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.nav-toggle .to-close { display: none; }
.site-header.nav-open .nav-toggle .to-open { display: none; }
.site-header.nav-open .nav-toggle .to-close { display: inline-flex; }

.site-nav { border-top: 1px solid var(--line); background: var(--surface); }
.nav-inner { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-link {
    position: relative; flex: 0 0 auto;
    padding: 12px 14px; font-size: 15px; font-weight: 600; color: var(--ink-2);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav-link:hover { color: var(--brand); }
.nav-link.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.notice-bar {
    display: flex; align-items: center; gap: 8px;
    margin-top: 16px; padding: 10px 14px;
    background: var(--accent-soft); border: 1px solid #f6dcc0;
    border-radius: var(--radius); color: #8a4a0c; font-size: 13px;
}

/* ---------- 首页横幅 ---------- */
.banner-zone { margin-top: 16px; }
.home-banner {
    display: block; overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.home-banner img { display: block; width: 100%; height: auto; }

/* ---------- 布局 ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 316px;
    gap: 24px;
    align-items: start;
    padding-top: 20px;
    padding-bottom: 40px;
}
.content-col { min-width: 0; }

/* ---------- 数据条 ---------- */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.stat-item { display: flex; align-items: center; gap: 10px; color: var(--brand); }
.stat-item div { display: flex; flex-direction: column; line-height: 1.25; }
.stat-item strong { font-size: 17px; color: var(--ink); }
.stat-item span { font-size: 12px; color: var(--muted); }

/* ---------- 区块 ---------- */
.block {
    margin-top: 22px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.block-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.block-title { display: flex; align-items: center; gap: 7px; font-size: 17px; color: var(--ink); }
.block-title svg { color: var(--brand); }
.block-sub { font-size: 12px; color: var(--muted); }
.cat-desc { margin: -6px 0 16px; font-size: 13px; color: var(--muted); }

/* ---------- 封面 ---------- */
.cover {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
    display: flex; align-items: center; justify-content: center;
}
.cover-placeholder .ph-letter {
    font-size: 34px; font-weight: 700; color: rgba(255, 255, 255, .95);
}
.tone-a { background: #0f766e; }
.tone-b { background: #b45309; }
.tone-c { background: #4f46e5; }
.tone-d { background: #be123c; }
.tone-e { background: #0369a1; }
.tone-f { background: #15803d; }

.cover-badge {
    position: absolute; left: 8px; top: 8px;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(20, 32, 30, .72); color: #fff;
    font-size: 11px; line-height: 18px;
}

/* ---------- 精选卡片 ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 16px;
}
.card-item {
    display: flex; flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card-item:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-cover-link { position: relative; display: block; }
.card-cover-link .cover { border-radius: 0; aspect-ratio: 16 / 9; }
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.card-title { font-size: 15px; line-height: 1.45; }
.card-title a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-summary {
    font-size: 12.5px; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
    display: flex; align-items: center; gap: 14px; margin-top: auto;
    font-size: 12px; color: var(--muted);
}
.card-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 列表行 ---------- */
.list-stack { display: flex; flex-direction: column; gap: 12px; }
.list-item {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.list-item:last-child { padding-bottom: 0; border-bottom: 0; }
.list-cover-link .cover { aspect-ratio: 16 / 10; }
.list-body { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.list-title { font-size: 16px; }
.list-title a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-item:hover .list-title a { color: var(--brand); }
.list-summary {
    font-size: 13px; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; font-size: 12px; color: var(--muted); }
.chip {
    display: inline-flex; align-items: center;
    padding: 1px 8px; border-radius: 4px;
    background: var(--bg); border: 1px solid var(--line);
    color: var(--ink-2); font-size: 12px; line-height: 19px;
}
.chip-cat { background: var(--brand-soft); border-color: #cfe6e2; color: var(--brand-dark); font-weight: 600; }
a.chip-cat:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.meta-time { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 空状态 ---------- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 40px 20px; color: var(--muted); text-align: center;
}
.empty-state svg { color: var(--line-strong); }
.empty-title { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.empty-desc { font-size: 13px; }

/* ---------- 分页 ---------- */
.pagination {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
}
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.page-link:hover { border-color: var(--brand); color: var(--brand); }
.page-link.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.page-link.disabled { color: #b6c2c0; background: var(--bg); }
.page-link.disabled:hover { border-color: var(--line); color: #b6c2c0; }
.page-dots { padding: 0 4px; color: var(--muted); }

/* ---------- 搜索栏 ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-bar input {
    flex: 1 1 auto; min-width: 0; height: 42px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); outline: none;
}
.search-bar input:focus { border-color: var(--brand); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 600; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-download { background: var(--accent); color: #fff; }
.btn-download:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-copy { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-copy.is-done { border-color: var(--brand); color: var(--brand); }

/* ---------- 面包屑 ---------- */
.breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-bottom: 14px; font-size: 12.5px; color: var(--muted);
}
.breadcrumb a { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumb .sep { display: inline-flex; color: var(--line-strong); }
.breadcrumb .current { color: var(--ink-2); max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 详情 ---------- */
.detail {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.detail-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.detail-title { font-size: 23px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.detail-top {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
    gap: 18px;
    margin-top: 18px;
}
.detail-cover { aspect-ratio: 16 / 9; border: 1px solid var(--line); }
.detail-side { display: flex; flex-direction: column; gap: 12px; }
.spec-list {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px; background: var(--line);
    border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.spec-list > div { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); }
.spec-list dt { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.spec-list dd { font-size: 13px; font-weight: 600; color: var(--ink); margin-left: auto; text-align: right; word-break: break-all; }
.detail-summary {
    padding: 12px; border-radius: var(--radius-sm);
    background: var(--bg); color: var(--ink-2); font-size: 13px;
}

.download-box {
    margin-top: 18px; padding: 16px;
    background: var(--accent-soft);
    border: 1px solid #f4d9b9; border-radius: var(--radius);
}
.download-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.download-head h2 { display: flex; align-items: center; gap: 7px; font-size: 16px; color: #8a4a0c; }
.download-hint { font-size: 12px; color: #a1662f; }
.download-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.download-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--surface);
    border: 1px solid #f0dcc6; border-radius: var(--radius-sm);
}
.download-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.pan-name { font-size: 14px; font-weight: 700; }
.pan-code { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.pan-code code {
    padding: 1px 6px; border-radius: 4px; background: var(--bg);
    border: 1px dashed var(--line-strong); color: var(--ink);
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
}
.pan-note { font-size: 12px; color: var(--muted); }
.download-empty { margin-top: 10px; font-size: 13px; color: #a1662f; }

.detail-content { margin-top: 20px; }
.content-body { font-size: 15px; line-height: 1.85; color: var(--ink-2); }
.content-body > * + * { margin-top: 14px; }
.content-body h2 { font-size: 18px; margin-top: 24px; padding-left: 10px; border-left: 3px solid var(--brand); color: var(--ink); }
.content-body h3 { font-size: 16px; margin-top: 20px; color: var(--ink); }
.content-body p { margin-top: 12px; }
.content-body ul, .content-body ol { margin-top: 12px; padding-left: 22px; list-style: disc; }
.content-body ol { list-style: decimal; }
.content-body li { margin-top: 6px; }
.content-body img { border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 12px auto; }
.content-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.content-body blockquote {
    margin: 14px 0; padding: 10px 14px;
    background: var(--bg); border-left: 3px solid var(--brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2);
}
.content-body code {
    padding: 1px 5px; border-radius: 4px; background: var(--bg);
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px;
}
.content-body pre { padding: 12px; overflow-x: auto; background: #1d2a28; border-radius: var(--radius-sm); }
.content-body pre code { background: transparent; color: #e6f4f2; padding: 0; }
.content-body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.content-body th, .content-body td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }
.content-body th { background: var(--bg); }

.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- 侧边栏 ---------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 82px; }
.widget {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.widget-title {
    display: flex; align-items: center; gap: 7px;
    padding-bottom: 10px; margin-bottom: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
}
.widget-title svg { color: var(--brand); }

.rank-list { display: flex; flex-direction: column; gap: 9px; }
.rank-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.rank-no {
    flex: 0 0 auto; width: 20px; height: 20px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700;
}
.rank-no.top { background: var(--accent); color: #fff; }
.rank-title {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); }

.plain-list { display: flex; flex-direction: column; gap: 8px; }
.plain-list li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.plain-list li a { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-date { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.about-links { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.widget-about p { font-size: 13px; color: var(--muted); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-pill {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 999px;
    background: var(--bg); border: 1px solid var(--line);
    font-size: 12.5px; color: var(--ink-2);
}
.tag-pill:hover { background: var(--brand-soft); border-color: #cfe6e2; color: var(--brand-dark); }

/* ---------- 页脚 ---------- */
.site-footer { margin-top: 8px; background: #1c2b28; color: #b9c8c5; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; padding-top: 28px; padding-bottom: 24px; }
.footer-main { max-width: 520px; }
.footer-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-size: 16px; }
.footer-brand .brand-mark { width: 30px; height: 30px; background: var(--brand); }
.footer-desc { margin-top: 10px; font-size: 13px; line-height: 1.7; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 13px; }
.footer-links a:hover { color: #fff; }
.footer-meta { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.footer-meta span { display: inline-flex; align-items: center; gap: 6px; }
.footer-note { max-width: 420px; color: #8fa3a0; }

/* ---------- 返回顶部 ---------- */
.to-top {
    position: fixed; right: 22px; bottom: 24px; z-index: 30;
    width: 42px; height: 42px; display: none;
    align-items: center; justify-content: center;
    background: var(--surface); color: var(--brand);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.to-top.is-visible { display: inline-flex; }
.to-top:hover { border-color: var(--brand); }

/* ---------- 吐司提示 ---------- */
.toast {
    position: fixed; left: 50%; bottom: 36px; z-index: 60;
    transform: translate(-50%, 12px);
    padding: 9px 18px; border-radius: var(--radius);
    background: #1c2b28; color: #fff; font-size: 13px;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
    .sidebar .widget { flex: 1 1 280px; }
    .detail-top { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .wrap { padding: 0 14px; }
    .header-inner { flex-wrap: wrap; gap: 12px; padding-top: 12px; padding-bottom: 12px; min-height: 0; }
    .brand-text small { display: none; }
    .header-search { order: 3; flex: 1 1 100%; max-width: none; margin-left: 0; }
    .nav-toggle { display: inline-flex; margin-left: auto; }
    .site-nav { display: none; border-top: 0; }
    .site-header.nav-open .site-nav { display: block; }
    .nav-inner { flex-wrap: wrap; padding-bottom: 10px; }
    .nav-link { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; margin-bottom: 0; font-size: 14px; }
    .nav-link.is-active { border-color: var(--brand); background: var(--brand-soft); }
    .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .block, .detail { padding: 14px; }
    .list-item { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .list-cover-link .cover { aspect-ratio: 16 / 9; }
    .detail-title { font-size: 19px; }
    .spec-list { grid-template-columns: minmax(0, 1fr); }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .card-summary { display: none; }
    .download-item { align-items: flex-start; flex-direction: column; }
    .download-item .btn-download { width: 100%; }
    .to-top { right: 14px; bottom: 16px; }
    .footer-inner { flex-direction: column; gap: 16px; }
}
