/* ========== 重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

button {
    font-family: inherit;
    cursor: pointer;
}

/* ========== 容器 ========== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

main {
    flex: 1;
}

/* ========== Header ========== */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    align-items: center;
    height: 64px;
    gap: 40px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
    flex-shrink: 0;
}

.logo img {
    height: 32px;
    width: auto;
}

.logo:hover {
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 40px;
    flex: 1;
}

.nav a {
    color: #4b5563;
    font-size: 15px;
    transition: color 0.2s;
}

.nav a:hover {
    color: #2563eb;
    text-decoration: none;
}

.nav a.active {
    color: #2563eb;
    font-weight: 500;
}

.auth-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.4;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    text-decoration: none;
}

.btn-outline {
    background: #fff;
    color: #2563eb;
    border-color: #2563eb;
}

.btn-outline:hover {
    background: #eff6ff;
    text-decoration: none;
}

.btn-text {
    color: #4b5563;
    background: transparent;
}

.btn-text:hover {
    color: #2563eb;
    text-decoration: none;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    text-decoration: none;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

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

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #2563eb;
}

.form-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
}

.form-success {
    color: #10b981;
    font-size: 13px;
    margin-top: 6px;
}

/* ========== Footer ========== */
.site-footer {
    background: #1f2937;
    color: #9ca3af;
    padding: 24px 0;
    text-align: center;
    margin-top: 60px;
    font-size: 13px;
}

.site-footer a {
    color: #9ca3af;
}

.site-footer p + p {
    margin-top: 6px;
}

/* ========== 登录态控制 ========== */
.nav-auth {
    display: none !important;
}

.nav-guest {
    display: inline-block;
}

body.logged-in .nav-auth {
    display: inline-block !important;
}

body.logged-in .nav-guest {
    display: none !important;
}

/* ========== 通用工具 ========== */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mt-40 {
    margin-top: 40px;
}

.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    padding: 40px 0;
    color: #9ca3af;
}

.empty {
    text-align: center;
    padding: 60px 0;
    color: #9ca3af;
}

/* ========== 页面布局 ========== */
.page-main {
    padding-top: 32px;
    padding-bottom: 60px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    color: #111827;
}

.page-header-actions {
    display: flex;
    gap: 12px;
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

.toast-success {
    background: #10b981;
    color: #fff;
}

.toast-error {
    background: #ef4444;
    color: #fff;
}

.toast-info {
    background: #3b82f6;
    color: #fff;
}

/* ========== 弹窗 Modal ========== */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* ========== 弹窗关闭按钮 ========== */
.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
    color: #9ca3af;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.modal-close-btn:hover {
    color: #111827;
    background: #f3f4f6;
}
/* ========== 响应式 ========== */
@media (max-width: 768px) {
    /* 1. 取消固定高度，允许容器换行 */
    .site-header .container {
        flex-wrap: wrap; 
        height: auto;
        padding-top: 12px;
        padding-bottom: 12px;
        gap: 12px; /* 控制上下两行的间距 */
    }

    /* 2. 第一行：Logo 和 右侧按钮 */
    .logo {
        flex: 1; /* 占据剩余空间，把按钮挤到最右边 */
    }
    
    .auth-actions {
        gap: 8px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* 3. 第二行：导航菜单占据整行，并居中 */
    .nav {
        order: 3;                   /* 排到第一行下面 */
        flex: 0 0 100%;             /* 占据 100% 宽度 */
        justify-content: center;    /* 居中显示 */
        gap: 40px;                  /* 首页、API 之间的间距，可以自己调 */
        padding-top: 12px;
        border-top: 1px solid #f3f4f6; /* 加一条浅色分割线更好看，不需要可删掉 */
    }

    .nav a {
        font-size: 14px;
    }
}