:root {
    --bg: #f5f6f8;
    --fg: #1f2329;
    --muted: #8a8f99;
    --brand: #2f6fed;
    --line: #e3e6ea;
    --warn: #b06a00;
    --error: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: var(--fg);
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar.admin { background: #1f2329; }
.topbar.admin .brand, .topbar.admin .user, .topbar.admin .link { color: #fff; }

.brand { font-weight: 600; color: var(--brand); text-decoration: none; }
.topbar .user { color: var(--muted); margin-right: 12px; }
.inline { display: inline; margin: 0; }
.link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 14px; }

.container { max-width: 960px; margin: 0 auto; padding: 24px; }

.muted { color: var(--muted); }
.warn { color: var(--warn); }
.error { color: var(--error); margin: 8px 0; }

/* 登录页 */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
}
.auth-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 32px;
    width: 320px;
    box-shadow: 0 6px 24px rgba(0,0,0,.06);
}
.auth-card h1 { font-size: 20px; margin: 0 0 16px; }
.auth-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.auth-card input {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 14px;
}
.auth-card button {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    border: none;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}
.auth-card .hint { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* 后台 */
.admin-shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
    width: 200px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar a { color: var(--fg); text-decoration: none; }
.sidebar .muted { font-size: 14px; }

.cards { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; }
.card {
    flex: 1 1 220px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}
.card h3 { margin: 0 0 8px; font-size: 16px; }

/* 通用按钮/表格/表单 */
.btn {
    display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--brand);
    background: var(--brand); color: #fff; text-decoration: none; font-size: 14px; cursor: pointer;
}
.btn.ghost { background: #fff; color: var(--brand); }
.page-head { display: flex; align-items: center; justify-content: space-between; }
.page-head .actions { display: flex; gap: 8px; }
.ok, .ok-text { color: #1a7f37; }
.err-text { color: var(--error); }
.center { text-align: center; }
.danger { color: var(--error); }

.filter { display: flex; gap: 8px; margin: 16px 0; }
.filter input, .filter select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.filter button { padding: 8px 16px; border: none; border-radius: 6px; background: var(--brand); color: #fff; cursor: pointer; }

.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grid th, .grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid th { background: #fafbfc; color: var(--muted); font-weight: 600; }
.grid .ops { display: flex; gap: 10px; align-items: center; }

.pager { display: flex; gap: 12px; align-items: center; margin: 16px 0; }
.pager a { color: var(--brand); text-decoration: none; }

.form { max-width: 460px; display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form input, .form select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.form-actions button { padding: 9px 18px; border: none; border-radius: 6px; background: var(--brand); color: #fff; font-size: 14px; cursor: pointer; }

/* 前台导航 */
.mainnav { display: flex; align-items: center; gap: 18px; }
.mainnav a { color: var(--fg); text-decoration: none; }

/* 落地页 hero + 搜索 + 分类 chips */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: 28px; margin: 0 0 20px; }
.hero-search { display: flex; gap: 8px; justify-content: center; max-width: 560px; margin: 0 auto; }
.hero-search.compact { margin: 0 0 12px; }
.hero-search input { flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.hero-search button { padding: 11px 22px; border: none; border-radius: 8px; background: var(--brand); color: #fff; font-size: 15px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--fg); text-decoration: none; font-size: 13px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.block { margin: 28px 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.block-head h2 { font-size: 18px; margin: 0; }
.block-head a { color: var(--brand); text-decoration: none; font-size: 14px; }

/* 图书卡片 */
.bookgrid { display: flex; flex-wrap: wrap; gap: 16px; }
.bookgrid .bookcard { width: 140px; }
.bookcard { display: block; text-decoration: none; color: var(--fg); }
.bk-cover { position: relative; overflow: hidden; width: 100%; border-radius: 8px; background: #eef1f5; border: 1px solid var(--line); }
/* 占位标题:绝对铺满居中,在图片之后(有图则被图盖住) */
.bk-cover span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: var(--muted); font-size: 13px; }
/* 网格(首页热门/新书):固定高 + 填充裁切 */
.bookgrid .bk-cover { height: 190px; }
.bookgrid .bk-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
/* 瀑布流(/Books):按原图比例自然高度 → 高低错落 masonry */
.waterfall .bk-cover { min-height: 200px; }
.waterfall .bk-cover img { display: block; width: 100%; height: auto; background: #fff; position: relative; }
/* 详情大图:固定高填充 */
.detail-cover .bk-cover { height: 300px; }
.detail-cover .bk-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.bk-title { margin-top: 8px; font-size: 14px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bk-author { font-size: 12px; }

/* 瀑布流 */
.waterfall { column-count: 5; column-gap: 16px; }
.waterfall .bookcard { break-inside: avoid; margin-bottom: 16px; }
@media (max-width: 1100px) { .waterfall { column-count: 4; } }
@media (max-width: 800px) { .waterfall { column-count: 3; } }
@media (max-width: 560px) { .waterfall { column-count: 2; } }

/* 详情 */
.detail { display: flex; gap: 28px; margin-top: 16px; flex-wrap: wrap; }
.detail-cover { width: 220px; flex-shrink: 0; }
.detail-cover img, .detail-cover .bk-cover { width: 100%; border-radius: 10px; }
.detail-meta { flex: 1; min-width: 280px; }
.detail-meta h1 { font-size: 22px; margin: 0 0 16px; }
table.meta { border-collapse: collapse; margin-bottom: 16px; }
table.meta th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 16px 4px 0; vertical-align: top; }
table.meta td { padding: 4px 0; }
.summary { line-height: 1.7; color: #333; }

/* 阅读器 */
.reader-bar { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; }
.reader-bar a { color: var(--brand); text-decoration: none; }
.rd-title { font-weight: 600; }
.rd-nav { display: flex; align-items: center; gap: 8px; }
.rd-nav button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.rd-nav input { width: 64px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; text-align: center; }
.reader-view { text-align: center; background: #2b2f36; border-radius: 8px; padding: 16px; }
.reader-view img { max-width: 100%; max-height: 82vh; background: #fff; }

/* ============ 渐进式美化:交互反馈与层次(不改变既有布局尺寸) ============ */
a { transition: color .15s ease; }

/* 顶栏吸顶 + 导航悬浮/当前项高亮 */
.topbar { position: sticky; top: 0; z-index: 50; }
.brand { font-size: 17px; letter-spacing: .5px; }
.mainnav a { padding: 6px 2px; border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease; }
.mainnav a:hover { color: var(--brand); }
.mainnav a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* 落地页 hero 渐变 + 输入聚焦环 */
.hero { background: linear-gradient(135deg, #eef3ff 0%, #f7f9fc 60%, #fff 100%); border-radius: 14px; padding: 48px 24px 32px; margin-top: 8px; }
.hero h1 { font-size: 30px; letter-spacing: 1px; }
.hero-search input:focus, .form input:focus, .form textarea:focus, .filter input:focus, .filter select:focus, .auth-card input:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,237,.12);
}

/* 按钮交互 */
.btn { transition: transform .12s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { box-shadow: 0 4px 12px rgba(47,111,237,.25); }
.btn.ghost:hover { background: #f0f5ff; }
.hero-search button:hover, .filter button:hover, .form-actions button:hover { filter: brightness(1.06); }

/* 资源卡片悬浮:抬起 + 阴影 + 封面轻微放大 + 标题变色 */
.bookcard { transition: transform .15s ease; }
.bookcard:hover { transform: translateY(-4px); }
.bookcard:hover .bk-cover { box-shadow: 0 8px 20px rgba(0,0,0,.12); border-color: #cdd5e0; }
.bk-cover img { transition: transform .25s ease; }
.bookcard:hover .bk-cover img { transform: scale(1.05); }
.bookcard:hover .bk-title { color: var(--brand); }

/* 卡片(后台/首页)悬浮 */
.card { transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.07); }

/* 区块标题左侧强调条 */
.block-head h2 { position: relative; padding-left: 12px; }
.block-head h2::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; border-radius: 2px; background: var(--brand); }

/* 首页资源导航磁贴 */
.navtiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 8px 0 4px; }
@media (max-width: 720px) { .navtiles { grid-template-columns: repeat(2, 1fr); } }
.navtile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.navtile:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.08); border-color: #cdd5e0; }
.navtile .ico { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; color: #fff; }
.navtile .nt-name { font-size: 15px; font-weight: 600; }
.navtile .nt-desc { font-size: 12px; color: var(--muted); }

/* 页脚 */
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 16px; border-top: 1px solid var(--line); margin-top: 32px; }
