/* ========================================
   个人图书馆系统 - 全局响应式样式
   中复古 · 棕色木质调
   ======================================== */

/* --- 基础重置与变量 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* 棕色木质复古色板 */
    --color-bg: #e8dcc8;              /* 麻布米色背景 */
    --color-surface: #f5ede0;          /* 羊皮纸表面 */
    --color-surface-alt: #ede0cc;     /* 略深表面 */
    --color-text: #3e2723;            /* 深咖啡文字 */
    --color-text-light: #6d4c41;      /* 中棕文字 */
    --color-text-lighter: #a1887f;   /* 浅棕灰 */
    --color-primary: #8b5a2b;         /* 木纹棕主色 */
    --color-primary-hover: #6d4c41;  /* 深木棕 hover */
    --color-primary-light: #d7ccc8;  /* 浅木色 */
    --color-accent: #a0522d;          /* 赤陶强调色 */
    --color-danger: #b71c1c;          /* 暗红 */
    --color-danger-hover: #8c1414;
    --color-success: #5d4037;        /* 复古棕绿 */
    --color-warning: #e65100;
    --color-border: #cbb89a;          /* 木纹边框 */
    --color-admin: #6d4c41;           /* 管理员棕 */
    --shadow-sm: 0 1px 3px rgba(62,39,35,.08);
    --shadow-md: 0 4px 8px rgba(62,39,35,.12), 0 2px 4px rgba(62,39,35,.08);
    --shadow-lg: 0 8px 16px rgba(62,39,35,.15), 0 4px 8px rgba(62,39,35,.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --max-width: 1280px;
    --header-height: 60px;

    /* 阅读器主题变量 — 默认羊皮纸 */
    --reader-bg: #f5ede0;
    --reader-text: #3e2723;
    --reader-font-size: 100%;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Georgia', 'Songti SC', 'STSong', 'SimSun', 'PingFang SC',
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, serif;
    background: var(--color-bg);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(139,90,43,.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(160,82,45,.03) 0%, transparent 60%);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }

/* --- 头部导航 --- */
.site-header {
    background: linear-gradient(135deg, #5d4037 0%, #4e342e 100%);
    border-bottom: 2px solid #3e2723;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    box-shadow: 0 2px 8px rgba(62,39,35,.2);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f5ede0;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: #d7ccc8;
    transition: all .2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(245,237,224,.12);
    color: #f5ede0;
}

.nav-register {
    background: var(--color-accent);
    color: #fff !important;
}

.nav-register:hover {
    background: #7c3d1e;
}

.nav-logout {
    color: #e0b89a !important;
}

.nav-logout:hover {
    color: #f5ede0;
    background: rgba(183,28,28,.25);
}

.badge-admin {
    background: rgba(245,237,224,.15);
    color: #f5ede0;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(245,237,224,.25);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #f5ede0;
    border-radius: 2px;
    transition: all .2s;
}

/* --- 主体区域 --- */
.site-main {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
}

/* --- 底部 --- */
.site-footer {
    background: #4e342e;
    border-top: 2px solid #3e2723;
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: #bca994;
}

.site-footer a {
    color: #d7ccc8;
}

/* --- 搜索区域（首页） --- */
.hero-search {
    text-align: center;
    padding: 60px 20px 40px;
}

.hero-search h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-text);
    letter-spacing: 1px;
}

.hero-search p {
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-size: 1.05rem;
}

.search-box {
    display: flex;
    max-width: 640px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: 50px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: var(--shadow-md);
}

.search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(139,90,43,.12);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 24px;
    font-size: 1.05rem;
    background: transparent;
    color: var(--color-text);
}

.search-box input::placeholder {
    color: var(--color-text-lighter);
}

.search-box button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 600;
    transition: background .2s;
    white-space: nowrap;
}

.search-box button:hover {
    background: var(--color-primary-hover);
}

.search-results-info {
    text-align: center;
    color: var(--color-text-light);
    margin: 20px 0;
    font-size: 0.9rem;
}

/* --- 书籍卡片网格 --- */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    padding: 10px 0;
}

.book-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .25s, box-shadow .25s;
    cursor: pointer;
    border: 1px solid var(--color-border);
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

.book-card .card-cover {
    aspect-ratio: 3/4;
    background: var(--color-surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.book-card .card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6d4c41 0%, #5d4037 100%);
    color: #f5ede0;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 16px;
    text-align: center;
    word-break: break-word;
}

.book-card .card-info {
    padding: 14px;
}

.book-card .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text);
}

.book-card .card-author {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- 表单样式 --- */
.form-container {
    max-width: 440px;
    margin: 40px auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.form-container h2 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.form-container .form-subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
    background: var(--color-surface);
    color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139,90,43,.12);
}

.form-group input:disabled {
    background: var(--color-surface-alt);
    color: var(--color-text-lighter);
    cursor: not-allowed;
}

.form-group input[type="file"] {
    padding: 10px;
    border: 2px dashed var(--color-border);
    background: var(--color-surface-alt);
}

.form-group input[type="file"]:hover {
    border-color: var(--color-primary);
}

.form-group .help-text {
    font-size: 0.8rem;
    color: var(--color-text-lighter);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: all .2s;
    cursor: pointer;
}

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

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

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

.btn-danger:hover {
    background: var(--color-danger-hover);
}

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 4px;
}

.form-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.form-footer a {
    color: var(--color-primary);
    font-weight: 600;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* --- 消息提示 --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-error {
    background: #f0d5d5;
    color: var(--color-danger);
    border: 1px solid #d4a9a9;
}

.alert-success {
    background: #d7ccc8;
    color: var(--color-success);
    border: 1px solid #bca994;
}

.alert-info {
    background: #ede0cc;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

/* --- 后台管理表格 --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-header h2 {
    font-size: 1.5rem;
}

.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-surface-alt);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-text-light);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--color-surface-alt);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-active {
    background: #d7ccc8;
    color: var(--color-success);
}

.status-inactive {
    background: #f0d5d5;
    color: var(--color-danger);
}

.action-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

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

/* --- 阅读器页面 --- */
.reader-container {
    display: flex;
    height: calc(100vh - var(--header-height) - 20px);
    background: var(--reader-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin: -10px -20px;
    max-width: none;
    border: 1px solid var(--color-border);
}

.reader-sidebar {
    width: 260px;
    background: var(--reader-bg);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 20px;
    flex-shrink: 0;
    transition: background .3s;
}

.reader-sidebar h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--reader-text);
}

.toc-list {
    list-style: none;
}

.toc-list li {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--reader-text);
    opacity: 0.75;
    transition: all .15s;
}

.toc-list li:hover,
.toc-list li.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
    opacity: 1;
}

.reader-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--reader-bg);
    gap: 12px;
    flex-wrap: wrap;
    transition: background .3s;
}

.reader-toolbar .book-title-small {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--reader-text);
}

.reader-toolbar .reader-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.reader-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: var(--reader-bg);
    display: flex;
    flex-direction: column;
    transition: background .3s;
}

#viewer {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
}

#viewer p,
#viewer div,
#viewer span,
#viewer li {
    font-size: var(--reader-font-size) !important;
    color: var(--reader-text) !important;
    line-height: 1.8 !important;
}

#prev, #next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: all .2s;
    color: var(--color-text);
}

#prev { left: 20px; }
#next { right: 20px; }

#prev:hover, #next:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.reader-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: var(--color-text-lighter);
}

.reader-placeholder h3 {
    margin-bottom: 8px;
    color: var(--color-text-light);
}

/* --- 阅读器主题控制 --- */
.reader-settings {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--reader-bg);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    transition: background .3s;
}

.reader-settings-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}

.reader-settings-label {
    font-size: 0.8rem;
    color: var(--reader-text);
    opacity: 0.6;
    white-space: nowrap;
}

.theme-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    cursor: pointer;
    transition: all .2s;
    padding: 0;
    box-shadow: var(--shadow-sm);
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(139,90,43,.25);
    transform: scale(1.1);
}

.theme-white { background: #ffffff; }
.theme-dark { background: #2c2c2c; }
.theme-green { background: #c7edcc; }
.theme-parchment { background: #f5ede0; }

.font-size-btn {
    width: 30px;
    height: 26px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.font-size-btn:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.font-size-display {
    font-size: 0.8rem;
    color: var(--reader-text);
    opacity: 0.7;
    min-width: 36px;
    text-align: center;
}

/* --- 上传页面 --- */
.upload-preview {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.upload-preview .cover-preview {
    width: 160px;
    aspect-ratio: 3/4;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-preview .cover-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview .meta-preview {
    flex: 1;
    min-width: 200px;
}

/* --- 分页 --- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    transition: all .15s;
    background: var(--color-surface);
}

.pagination a:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 600;
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    :root { --header-height: 54px; }

    .header-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: #4e342e;
        flex-direction: column;
        padding: 12px;
        border-bottom: 1px solid #3e2723;
        box-shadow: var(--shadow-md);
    }

    .header-nav.open { display: flex; }

    .mobile-menu-btn { display: flex; }

    .hero-search { padding: 40px 16px 24px; }
    .hero-search h1 { font-size: 1.5rem; }

    .search-box input { padding: 14px 18px; font-size: 1rem; }
    .search-box button { padding: 14px 20px; font-size: 0.9rem; }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }

    .form-container {
        margin: 20px 10px;
        padding: 28px 24px;
    }

    .reader-container { flex-direction: column; }
    .reader-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .reader-content { padding: 20px; }
    
    #prev { left: 8px; }
    #next { right: 8px; }

    .data-table { font-size: 0.82rem; }
    .data-table th, .data-table td { padding: 10px 12px; }

    .dashboard-header { flex-direction: column; align-items: flex-start; }

    .reader-settings { gap: 8px; padding: 0 12px; }
    .reader-settings-label { display: none; }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .book-card .card-info { padding: 10px; }
    .book-card .card-title { font-size: 0.82rem; }

    .search-box { border-radius: var(--radius-md); }
    .search-box button { padding: 14px 16px; }

    .btn { padding: 10px 18px; font-size: 0.9rem; }
}

/* --- 工具类 --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* --- 加载动画 --- */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* ========================================
   个人图书馆系统 - 全局响应式样式
   Z-Library 极简风格
   ======================================== */

/* --- 基础重置与变量 --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #f5f5f5;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-light: #666;
    --color-text-lighter: #999;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-success: #16a34a;
    --color-warning: #f59e0b;
    --color-border: #e5e7eb;
    --color-admin: #7c3aed;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --max-width: 1280px;
    --header-height: 60px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }

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

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -.5px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-light);
    transition: all .2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.nav-register {
    background: var(--color-primary);
    color: #fff !important;
}

.nav-register:hover {
    background: var(--color-primary-hover);
}

.nav-logout {
    color: var(--color-danger) !important;
}

.badge-admin {
    background: var(--color-admin);
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: all .2s;
}

/* --- 主体区域 --- */
.site-main {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
}

/* --- 底部 --- */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-lighter);
}

/* --- 搜索区域（首页） --- */
.hero-search {
    text-align: center;
    padding: 60px 20px 40px;
}

.hero-search h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-text);
}

.hero-search p {
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-size: 1.05rem;
}

.search-box {
    display: flex;
    max-width: 640px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: 50px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: var(--shadow-md);
}

.search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 24px;
    font-size: 1.05rem;
    background: transparent;
    color: var(--color-text);
}

.search-box input::placeholder {
    color: var(--color-text-lighter);
}

.search-box button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 600;
    transition: background .2s;
    white-space: nowrap;
}

.search-box button:hover {
    background: var(--color-primary-hover);
}

.search-results-info {
    text-align: center;
    color: var(--color-text-light);
    margin: 20px 0;
    font-size: 0.9rem;
}

/* --- 书籍卡片网格 --- */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    padding: 10px 0;
}

.book-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .25s, box-shadow .25s;
    cursor: pointer;
    border: 1px solid var(--color-border);
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.book-card .card-cover {
    aspect-ratio: 3/4;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.book-card .card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 16px;
    text-align: center;
    word-break: break-word;
}

.book-card .card-info {
    padding: 14px;
}

.book-card .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text);
}

.book-card .card-author {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- 表单样式 --- */
.form-container {
    max-width: 440px;
    margin: 40px auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.form-container h2 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.6rem;
}

.form-container .form-subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
    background: var(--color-surface);
    color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-group input:disabled {
    background: var(--color-bg);
    color: var(--color-text-lighter);
    cursor: not-allowed;
}

.form-group input[type="file"] {
    padding: 10px;
    border: 2px dashed var(--color-border);
    background: var(--color-bg);
}

.form-group input[type="file"]:hover {
    border-color: var(--color-primary);
}

.form-group .help-text {
    font-size: 0.8rem;
    color: var(--color-text-lighter);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: all .2s;
    cursor: pointer;
}

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

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

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

.btn-danger:hover {
    background: var(--color-danger-hover);
}

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 4px;
}

.form-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.form-footer a {
    color: var(--color-primary);
    font-weight: 600;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* --- 消息提示 --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-error {
    background: #fef2f2;
    color: var(--color-danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--color-success);
    border: 1px solid #bbf7d0;
}

.alert-info {
    background: #eff6ff;
    color: var(--color-primary);
    border: 1px solid #bfdbfe;
}

/* --- 后台管理表格 --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-header h2 {
    font-size: 1.5rem;
}

.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-bg);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-text-light);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-active {
    background: #f0fdf4;
    color: var(--color-success);
}

.status-inactive {
    background: #fef2f2;
    color: var(--color-danger);
}

.action-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

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

/* --- 阅读器页面 --- */
.reader-container {
    display: flex;
    height: calc(100vh - var(--header-height) - 20px);
    background: var(--reader-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin: -10px -20px;
    max-width: none;
    border: 1px solid var(--color-border);
}

.reader-sidebar {
    width: 260px;
    background: var(--reader-bg);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 20px;
    flex-shrink: 0;
    transition: background .3s;
}

.reader-sidebar h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--reader-text);
}

.toc-list {
    list-style: none;
}

.toc-list li {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--reader-text);
    opacity: 0.75;
    transition: all .15s;
}

.toc-list li:hover,
.toc-list li.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
    opacity: 1;
}

.reader-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--reader-bg);
    gap: 12px;
    transition: background .3s;
}

.reader-toolbar .book-title-small {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--reader-text);
}

.reader-toolbar .reader-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.reader-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: var(--reader-bg);
    display: flex;
    flex-direction: column;
    transition: background .3s;
}

#viewer {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
}

#prev, #next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: all .2s;
    color: var(--color-text);
}

#prev { left: 20px; }
#next { right: 20px; }

#prev:hover, #next:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.reader-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: var(--color-text-lighter);
}

.reader-placeholder h3 {
    margin-bottom: 8px;
    color: var(--color-text-light);
}

/* --- 上传页面 --- */
.upload-preview {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.upload-preview .cover-preview {
    width: 160px;
    aspect-ratio: 3/4;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-preview .cover-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview .meta-preview {
    flex: 1;
    min-width: 200px;
}

/* --- 分页 --- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    transition: all .15s;
}

.pagination a:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 600;
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    :root { --header-height: 54px; }

    .header-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--color-surface);
        flex-direction: column;
        padding: 12px;
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
    }

    .header-nav.open { display: flex; }

    .mobile-menu-btn { display: flex; }

    .hero-search { padding: 40px 16px 24px; }
    .hero-search h1 { font-size: 1.5rem; }

    .search-box input { padding: 14px 18px; font-size: 1rem; }
    .search-box button { padding: 14px 20px; font-size: 0.9rem; }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }

    .form-container {
        margin: 20px 10px;
        padding: 28px 24px;
    }

    .reader-container { flex-direction: column; }
    .reader-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .reader-content { padding: 20px; }
    
    #prev { left: 8px; }
    #next { right: 8px; }

    .data-table { font-size: 0.82rem; }
    .data-table th, .data-table td { padding: 10px 12px; }

    .dashboard-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .book-card .card-info { padding: 10px; }
    .book-card .card-title { font-size: 0.82rem; }

    .search-box { border-radius: var(--radius-md); }
    .search-box button { padding: 14px 16px; }

    .btn { padding: 10px 18px; font-size: 0.9rem; }
}

/* --- 工具类 --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* --- 加载动画 --- */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
