:root {
    --primary: #2f6fed;
    --primary-hover: #1f5ad0;
    --primary-soft: #e8f0fe;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #1f2329;
    --text-secondary: #6b7280;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 兜底：不允许出现页面级横向滚动条。
   窄屏（或字体加载过程中）一旦产生哪怕几十 px 的瞬时横向溢出，
   浏览器会保留横向滚动位置，页面看起来就是「内容左端被裁掉、右侧留白」。
   这里直接在根元素上禁止横向滚动，杜绝该现象。（不影响纵向滚动与 sticky 顶栏） */
html {
    overflow-x: hidden;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

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

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.brand .brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #5b8def);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.main-nav {
    display: flex;
    gap: 4px;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.main-nav a:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.main-nav a.active {
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

/* 语言切换：与导航链接同尺寸，用描边弱化，避免与主功能抢注意力。
   首页的语言链接也复用此类名（见 index.html / en/index.html），保证两处外观一致。 */
.main-nav .lang-switch {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.2;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    white-space: nowrap; /* 防止「中文」在窄屏被挤压后折成两行 */
    cursor: pointer;
    transition: all 0.15s ease;
}

.main-nav .lang-switch:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* ============ 主内容 ============ */
main {
    flex: 1;
    padding: 36px 0 60px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 28px;
}

/* ============ 通用组件 ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-outline {
    background: var(--surface);
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-soft);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text);
    border-color: #c9cdd3;
}

.empty-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.15rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.92rem;
    margin-bottom: 20px;
}

/* ============ 底部 ============ */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    background: var(--surface);
}
.site-footer .footer-link {
    color: var(--text-secondary);
    text-decoration: underline;
}
.site-footer .footer-link:hover {
    color: var(--primary);
}

@media (max-width: 640px) {
    main {
        padding: 24px 0 40px;
    }

    /* 顶栏：窄屏下品牌名可收缩并用省略号，
       避免把「导入 / 书库 / 语言」挤出屏幕造成横向溢出 */
    .header-inner {
        gap: 10px;
    }

    .brand {
        font-size: 1rem;
        min-width: 0;
    }

    .brand > span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-nav {
        flex: 0 0 auto;
    }

    .main-nav a {
        padding: 6px 10px;
        font-size: 0.88rem;
    }

    /* 语言控件与导航链接保持同一尺寸与节奏 */
    .main-nav .lang-switch {
        padding: 6px 10px;
        font-size: 0.88rem;
    }
}
