/* 全站视觉打磨：统一样式、配色与交互细节 */

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
    --primary: #15803d;
    --primary-light: #22c55e;
    --primary-dark: #166534;
    --bg: #f0fdf4;
    --card: #ffffff;
    --text: #14532d;
    --text-light: #4b7a55;
    --border: #d1fae5;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(21,128,61,.06), 0 1px 2px rgba(21,128,61,.04);
    --shadow-hover: 0 8px 24px rgba(21,128,61,.12);
    scroll-behavior: smooth;
    scroll-padding-top: 84px;
}

::selection { background: #bbf7d0; color: #064e3b; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #ecfdf5; }
::-webkit-scrollbar-thumb { background: #86efac; border-radius: 6px; border: 2px solid #ecfdf5; }
::-webkit-scrollbar-thumb:hover { background: #4ade80; }

/* 页头、导航、页脚 */
body header { position: relative; overflow: hidden; }
body header::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 36px 36px; opacity: .55;
}
body .main-nav.scrolled { box-shadow: 0 4px 18px rgba(6,78,59,.12); }
body .logo a::before { filter: drop-shadow(0 2px 4px rgba(0,0,0,.2)); }
body footer { position: relative; }
body footer::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(167,243,208,.55), transparent);
}

/* 通用标题与卡片 */
body .section-title { font-size: 1.35rem; color: var(--text); margin-bottom: 24px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
body .section-title::before { content: ''; display: inline-block; width: 4px; height: 1.2em; background: var(--primary); border-radius: 2px; }
body .article-card {
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); transition: all .25s ease;
}
body .article-card:hover { box-shadow: var(--shadow-hover); border-color: var(--primary-light); }
body .article-title a { color: inherit; text-decoration: none; transition: color .2s; }
body .article-title a:hover { color: var(--primary); }
body .article-excerpt { color: #475569; }

/* 标签：全站统一为浅绿胶囊 */
body .tag, body .tag-cloud .tag, body .article-card .tag {
    display: inline-block; background: #ecfdf5; color: var(--text-light);
    padding: 3px 11px; border-radius: 20px; font-size: .75rem;
    text-decoration: none; border: 1px solid var(--border);
    transition: all .2s ease;
}
body .tag-cloud .tag { margin: 0; }
body .tag:hover, body .tag-cloud .tag:hover, body .article-card .tag:hover {
    background: var(--primary); color: #fff; border-color: var(--primary);
    transform: translateY(-1px);
}

/* 分页：统一绿色主题 */
body .pagination a:not(.ellipsis),
body .pagination .page-num, body .pagination .page-btn,
body .pagination span.current {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border-radius: 9px; text-decoration: none;
    color: var(--text-light); background: var(--card);
    border: 1px solid var(--border); font-size: .84rem;
    font-weight: 500; transition: all .2s ease;
}
body .pagination a:not(.ellipsis):hover,
body .pagination .page-num:hover, body .pagination .page-btn:hover {
    background: #ecfdf5; border-color: var(--primary); color: var(--primary);
}
body .pagination .current, body .pagination a.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(21,128,61,.25);
}
body .pagination .ellipsis { color: var(--text-light); opacity: .7; }

/* 空状态 */
body .empty-state {
    text-align: center; padding: 56px 20px; background: var(--card);
    border: 1px dashed var(--border); border-radius: var(--radius);
    color: var(--text-light);
}
body .empty-state .empty-icon { font-size: 2.4rem; margin-bottom: 10px; opacity: .85; }
body .empty-state h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 6px; }
body .empty-state p { font-size: .88rem; margin-bottom: 18px; }
body .empty-state a {
    display: inline-block; padding: 8px 20px; border-radius: 20px;
    background: var(--primary); color: #fff; text-decoration: none;
    font-size: .85rem; font-weight: 600; transition: background .2s;
}
body .empty-state a:hover { background: var(--primary-dark); }

/* 侧栏 */
body .widget { transition: box-shadow .25s, transform .25s; }
body .widget:hover { box-shadow: var(--shadow-hover); }
body .ranking-list .rank-title:hover { color: var(--primary); }
body .subscribe-btn:hover { box-shadow: 0 3px 10px rgba(21,128,61,.22); }

/* 文章详情 */
body .article-body { color: #2f5d43; }
body .article-body h2, body .article-body h3 { border-bottom-color: var(--border); }
body .article-body code { background: #ecfdf5; color: #0f766e; }
body .article-body pre { box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
body .article-body blockquote { background: linear-gradient(90deg,#f0fdf4,#fff); }
body .article-body th { background: #f0fdf4; }
body .post-nav a:hover { box-shadow: var(--shadow-hover); }

/* 关于 / 资源 */
body .skill-tag { box-shadow: 0 3px 10px rgba(21,128,61,.22); }
body .cat-title { border-bottom-color: var(--border); }
body .resource-item { transition: background .2s, transform .2s; }
body .resource-item:hover { background: #f0fdf4; transform: translateX(3px); }

/* 搜索页 */
body .no-results {
    background: var(--card); border: 1px dashed var(--border);
}
body .article-card .cover { background: linear-gradient(135deg,#d1fae5,#a7f3d0); }
body .article-card .category { background: #ecfdf5; }
body .article-card .tag:hover { color: #fff; }

/* 后台：与前台统一绿色主题 */
body .admin-header h2 { color: var(--text); }
body .btn { border-radius: 8px; font-weight: 600; }
body .btn-primary { background: var(--primary); color: #fff; }
body .btn-primary:hover { background: var(--primary-dark); }
body .btn-secondary { background: #e2e8f0; color: var(--text); }
body .btn-secondary:hover { background: #cbd5e1; }
body .btn-danger { background: #dc2626; color: #fff; }
body .table-wrap { overflow-x: auto; border-radius: var(--radius); }
body .article-table { min-width: 720px; border: 1px solid var(--border); box-shadow: var(--shadow); }
body .article-table th { background: linear-gradient(135deg,#064e3b,#047857); }
body .article-table td { border-bottom: 1px solid var(--border); }
body .article-table tbody tr:hover { background: #f0fdf4; }
body .article-table a { color: var(--primary); }
body .badge-published { background: #dcfce7; color: #166534; }
body .badge-draft { background: #fef3c7; color: #92400e; }
body .stat-card, body .panel {
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
body .stat-card { border-left: 4px solid var(--primary); }
body .stat-card.green { border-left-color: #0d9488; }
body .stat-card.orange { border-left-color: #d97706; }
body .stat-card.purple { border-left-color: #7c3aed; }
body .stat-card .label, body .stat-card .value small { color: var(--text-light); }
body .stat-card .value, body .panel h3, body .sys-info b { color: var(--text); }
body .bar-track { background: #ecfdf5; }
body .bar-fill { background: linear-gradient(90deg,#15803d,#22c55e); }
body .sys-info div { background: #f0fdf4; }
body .back-link { color: var(--primary); }
body input:focus, body select:focus, body textarea:focus { border-color: var(--primary); }

/* 返回顶部 */
#backToTop {
    position: fixed; right: 24px; bottom: 24px; z-index: 99;
    width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.35);
    background: linear-gradient(135deg,#064e3b,#15803d); color: #fff;
    box-shadow: 0 6px 18px rgba(6,78,59,.28); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity .25s, transform .25s, visibility .25s;
}
#backToTop.show { opacity: 1; visibility: visible; transform: none; }
#backToTop:hover { transform: translateY(-3px); }

@media(max-width:768px){
    body .admin-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    body .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    body .form-row { flex-direction: column; gap: 0; }
}
@media(max-width:600px){
    body .section-title { font-size: 1.15rem; margin-bottom: 18px; }
    body .article-card { padding: 18px 16px; border-radius: var(--radius); }
    body .pagination { margin-top: 24px; gap: 5px; }
    body .pagination a:not(.ellipsis), body .pagination .page-num,
    body .pagination .page-btn, body .pagination span.current { padding: 6px 11px; font-size: .8rem; }
    #backToTop { right: 14px; bottom: 14px; width: 38px; height: 38px; }
    body .bar-row .bar-label { width: 68px; }
    body .bar-row .bar-val { width: 92px; font-size: .78rem; }
    body .empty-state { padding: 40px 16px; }
}
@media(prefers-reduced-motion:reduce){
    body, body * { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
