* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1e5bd7;
    --primary-dark: #1548a8;
    --primary-light: #eef3ff;
    --accent: #ff7a00;
    --bg: #f5f7fb;
    --card: #ffffff;
    --border: #e3e7ee;
    --text: #1c2332;
    --text-mute: #6b7690;
    --shadow-sm: 0 1px 2px rgba(28, 35, 50, 0.06);
    --shadow-md: 0 4px 14px rgba(28, 35, 50, 0.08);
    --shadow-lg: 0 10px 30px rgba(30, 91, 215, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
}

html, body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
                 "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

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

.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

/* ================= 顶部导航 ================= */
.top-bar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(8px);
    background-color: rgba(255, 255, 255, 0.95);
}
.top-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-logo {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), #4aa3ff);
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text);
}
.brand-tag {
    font-size: 12px;
    color: var(--text-mute);
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-weight: 500;
}

.lang-switcher {
    display: inline-flex;
    padding: 3px;
    background: #f1f3f8;
    border-radius: 999px;
    border: 1px solid var(--border);
}
.lang-btn {
    padding: 6px 14px;
    border: 0;
    background: transparent;
    color: var(--text-mute);
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
}
.lang-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.lang-btn:hover:not(.active) { color: var(--text); }

/* ================= Hero 搜索区 ================= */
.hero-section {
    background:
      radial-gradient(ellipse at 20% 0%, rgba(30, 91, 215, 0.12), transparent 50%),
      radial-gradient(ellipse at 100% 100%, rgba(255, 122, 0, 0.08), transparent 50%),
      linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
    border-bottom: 1px solid var(--border);
}
.hero-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 56px 24px 48px;
    text-align: center;
}
.hero-title {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.8px;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--text);
}
.hero-title span {
    background: linear-gradient(135deg, var(--primary), #4aa3ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-desc {
    font-size: 17px;
    color: var(--text-mute);
    max-width: 720px;
    margin: 0 auto 30px;
}
.search-wrap {
    display: flex;
    max-width: 680px;
    margin: 0 auto 28px;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 6px;
    box-shadow: var(--shadow-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 91, 215, 0.12);
}
.search-input {
    flex: 1;
    border: 0;
    outline: 0;
    padding: 10px 18px;
    font-size: 16px;
    background: transparent;
    color: var(--text);
}
.search-btn {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 10px 26px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.search-btn:hover { background: var(--primary-dark); }
.search-btn:active { transform: scale(0.98); }

.hero-stats {
    display: flex;
    gap: 36px;
    justify-content: center;
    flex-wrap: wrap;
}
.stat-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.stat-item strong {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary);
}
.stat-item span {
    font-size: 13px;
    color: var(--text-mute);
    font-weight: 500;
}

/* ================= 主布局：侧边栏 + 卡片区 ================= */
.main-layout {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 36px 24px;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    flex: 1;
}

/* ---- 侧边栏：国家筛选 ---- */
.country-sidebar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 86px;
    box-shadow: var(--shadow-sm);
}
.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    padding-bottom: 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.sidebar-list { display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto; }
.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-thumb { background: #d5dae4; border-radius: 3px; }
.country-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border: 0;
    background: transparent;
    text-align: left;
    width: 100%;
}
.country-chip:hover { background: var(--primary-light); color: var(--primary-dark); }
.country-chip.active {
    background: linear-gradient(135deg, var(--primary), #3a76ea);
    color: #fff;
    box-shadow: 0 3px 8px rgba(30, 91, 215, 0.25);
}
.country-chip .chip-flag { font-size: 18px; }
.country-chip .chip-count {
    margin-left: auto;
    background: rgba(30, 91, 215, 0.08);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.country-chip.active .chip-count { background: rgba(255,255,255,0.25); color: #fff; }
.loading-tiny { padding: 14px; text-align: center; color: var(--text-mute); font-size: 13px; }

/* ---- 模板卡片主区域 ---- */
.template-area { min-width: 0; }
.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.area-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.area-subtitle {
    font-size: 13px;
    color: var(--text-mute);
    font-weight: 500;
}
.sort-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-mute);
    font-weight: 500;
}
.sort-field select {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    outline: none;
}
.sort-field select:focus { border-color: var(--primary); }

.grid-loading {
    padding: 80px 20px;
    text-align: center;
    color: var(--text-mute);
    font-size: 15px;
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ---- 卡片网格 ---- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.tpl-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(.2,.8,.2,1),
                box-shadow 0.25s,
                border-color 0.2s;
}
.tpl-card:hover {
    transform: translateY(-4px);
    border-color: rgba(30, 91, 215, 0.35);
    box-shadow: var(--shadow-lg);
}
.tpl-thumb {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #f0f3fa 0%, #e6ecf7 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tpl-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.tpl-card:hover .tpl-thumb img { transform: scale(1.05); }
.tpl-thumb .no-image {
    text-align: center;
    color: var(--text-mute);
    padding: 20px;
}
.tpl-thumb .no-image .flag-lg {
    font-size: 72px;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12));
}
.tpl-thumb .badge {
    position: absolute;
    top: 12px; left: 12px;
    background: rgba(30, 91, 215, 0.95);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    backdrop-filter: blur(4px);
    letter-spacing: 0.3px;
}
.tpl-thumb .badge-new { background: rgba(255, 122, 0, 0.95); }

.tpl-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
.tpl-country {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tpl-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    min-height: 43px;
}
.tpl-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    font-size: 12px;
    color: var(--text-mute);
    padding: 10px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}
.tpl-meta div span { color: var(--text); font-weight: 600; }

.tpl-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
}
.tpl-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.tpl-btn-primary {
    background: var(--primary);
    color: #fff;
}
.tpl-btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 91, 215, 0.25);
}
.tpl-btn-ghost {
    background: #fff;
    border-color: var(--border);
    color: var(--text-mute);
}
.tpl-btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    background: var(--primary-light);
}

/* ---- 空状态 ---- */
.grid-empty {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
}
.empty-icon { font-size: 60px; margin-bottom: 12px; opacity: 0.6; }
.grid-empty p { color: var(--text-mute); font-size: 15px; }

/* ================= 底部 ================= */
.site-footer {
    margin-top: 40px;
    background: #fff;
    border-top: 1px solid var(--border);
    color: var(--text-mute);
}
.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 24px 24px;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 36px;
}
.footer-col h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}
.footer-col p { font-size: 13px; line-height: 1.7; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 8px; font-size: 13px; }
.footer-col ul li a { color: var(--text-mute); }
.footer-col ul li a:hover { color: var(--primary); }
.footer-lang { display: flex; flex-direction: column; gap: 6px; }
.flang-btn {
    background: #f4f6fb;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-mute);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.flang-btn:hover { border-color: var(--primary); color: var(--primary); }
.flang-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}
.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 18px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-mute);
}

/* ================= 响应式 ================= */
@media (max-width: 980px) {
    .main-layout { grid-template-columns: 1fr; padding: 24px 16px; }
    .country-sidebar { position: static; max-height: 320px; }
    .sidebar-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
    .country-chip { width: auto; }
    .hero-title { font-size: 28px; }
    .hero-desc { font-size: 15px; }
    .hero-inner { padding: 40px 18px 32px; }
    .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 560px) {
    .brand-tag { display: none; }
    .top-bar-inner { padding: 12px 16px; }
    .hero-title { font-size: 24px; }
    .search-wrap { flex-direction: column; padding: 10px; border-radius: 12px; }
    .search-btn { border-radius: 8px; }
    .hero-stats { gap: 18px; }
    .stat-item strong { font-size: 20px; }
    .template-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
    .tpl-title { font-size: 14px; min-height: auto; }
}

@media (min-width: 1400px) {
    .main-layout { max-width: 1360px; }
    .template-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
