/*
 * 小说湾前台公共样式：设计变量、基础元素、页面框架与通用组件。
 *
 * @author zhenhua
 * @since 2026-08-02
 */
:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-alt: #fafaf8;
    --ink: #252525;
    --ink-2: #4c4c48;
    --ink-3: #8b8b85;
    --ink-4: #b3b3ac;
    --line: rgba(37, 37, 37, .09);
    --line-2: rgba(37, 37, 37, .16);
    --accent: #a85c4a;
    --accent-hover: #8e4a3a;
    --accent-soft: rgba(168, 92, 74, .09);
    --accent-2: #55756b;
    --accent-3: #536a86;
    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --shadow: 0 1px 2px rgba(30, 30, 28, .04);
    --shadow-lg: 0 12px 32px rgba(30, 30, 28, .10);
    --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    --serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
    --header-h: 68px;
    --maxw: 1180px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent);
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 600;
    line-height: 1.35;
}

p {
    margin: 0;
}

ul, ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

img {
    border: 0;
    max-width: 100%;
    vertical-align: middle;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

i {
    font-style: normal;
}

.muted {
    color: var(--ink-3);
}

.strong {
    color: var(--ink);
    font-weight: 600;
}

.accent {
    color: var(--accent);
}

.ellip {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ellip-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ellip-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hide {
    display: none !important;
}

.i {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
    vertical-align: -0.14em;
}

/* 版式 */
.page-title {
    font-size: 30px;
    letter-spacing: .5px;
}

.lead {
    color: var(--ink-3);
    font-size: 15px;
}

/* 布局 */
/* width 必须显式写 100%：body 是纵向 flex 容器（把页脚顶到底部），
   而 flex 项的横向 margin 为 auto 时不会触发 stretch，宽度会缩成内容宽度，
   导致窄内容页面在 PC 上只有一列手机宽度。 */
.wrap,
.wrap-wide {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
}

.wrap-wide {
    max-width: 1360px;
}

.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--ink-3);
}

.crumbs a {
    color: var(--ink-3);
}

.crumbs a:hover {
    color: var(--accent);
}

.layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 28px;
    align-items: start;
    padding-top: 28px;
    padding-bottom: 40px;
}

.stack > * + * {
    margin-top: 22px;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-5 {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

/* 顶部导航 */
.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    background: rgba(247, 247, 245, .92);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header-in {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 26px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: .5px;
    color: var(--ink);
    flex: none;
}

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

.logo-en {
    display: block;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 1.6px;
    color: var(--ink-4);
    text-transform: uppercase;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
}

.nav > a {
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 15px;
}

.nav > a:hover {
    background: var(--surface);
    color: var(--ink);
}

.nav > a.on {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 38px 0 14px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background: var(--surface);
    outline: none;
    transition: border-color .15s;
}

.search input:focus {
    border-color: var(--accent);
}

.search button {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--ink-3);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.search button:hover {
    color: var(--accent);
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-2);
    cursor: pointer;
    font-size: 17px;
}

.icon-btn:hover {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-weight: 600;
    overflow: hidden;
    flex: none;
}

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

/* 顶部账号按钮：昵称/账号是手机号、邮箱等长字符串时限宽并省略，否则会把头部撑出横向滚动条 */
.user-box__name {
    max-width: 132px;
}

/* 移动端抽屉 */
.nav-toggle {
    display: none;
}

.nav-drawer {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
}

.nav-drawer[data-open="1"] {
    display: block;
}

.nav-drawer-mask {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 18, .35);
}

.nav-drawer-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 78%;
    max-width: 320px;
    background: var(--surface);
    padding: 20px;
    overflow-y: auto;
}

.nav-drawer-panel a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 6px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 40px;
    padding: 0 20px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}

.btn:hover {
    border-color: var(--ink-4);
    color: var(--ink);
}

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

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

.btn-ghost {
    background: none;
    border-color: transparent;
    color: var(--ink-2);
    padding: 0 12px;
}

.btn-ghost:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: transparent;
}

.btn-lg {
    height: 46px;
    font-size: 16px;
    padding: 0 28px;
}

.btn-sm {
    height: 32px;
    padding: 0 13px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn[disabled] {
    opacity: .55;
    pointer-events: none;
}

/* 卡片与区块 */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.card-head h2, .card-head h3 {
    font-size: 17px;
}

.card-body {
    padding: 20px;
}

.card-list > li + li {
    border-top: 1px solid var(--line);
}

/* 卡片列表里的两列行（标题 + 右侧时间/统计）：标题可收缩省略，右侧不压缩 */
.card-list > li > a.row-between,
.card-list > li > div.row-between {
    display: flex;
    align-items: center;
}

.card-list .ellip {
    flex: 1 1 auto;
    min-width: 0;
}

.card-list .row-between > .muted,
.card-list .row-between > time {
    flex: 0 0 auto;
}

.card-list > li > a, .card-list > li > div {
    display: block;
    padding: 13px 20px;
}

.section {
    margin-bottom: 34px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.section-head h2 {
    font-size: 21px;
    position: relative;
    padding-left: 12px;
}

.section-head h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .28em;
    bottom: .28em;
    width: 3px;
    border-radius: 2px;
    background: var(--accent);
}

.section-head .sub {
    color: var(--ink-3);
    font-size: 13px;
}

.more {
    color: var(--ink-3);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.more:hover {
    color: var(--accent);
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 19px;
    background: rgba(83, 106, 134, .10);
    color: var(--accent-3);
}

.tag-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

.tag-green {
    background: rgba(85, 117, 107, .12);
    color: var(--accent-2);
}

.tag-solid {
    background: var(--accent);
    color: #fff;
}

.meta {
    color: var(--ink-3);
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}

.meta-sep {
    color: var(--ink-4);
}

.score {
    color: var(--accent);
    font-weight: 600;
}

/* 书籍卡片 */
.book-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .18s, border-color .18s, box-shadow .18s;
}

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

.cover {
    position: relative;
    aspect-ratio: 3 / 4;
    background: var(--surface-alt);
    overflow: hidden;
}

.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cover-fallback {
    display: grid;
    place-items: center;
    padding: 10px;
    text-align: center;
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.5;
    color: #fff;
    background: linear-gradient(155deg, #7d8f86, #4e6660);
}

.cover-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(28, 28, 26, .62);
    color: #fff;
}

.book-card-body {
    padding: 11px 13px 13px;
}

.book-card-body .title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.book-card-body .sub {
    color: var(--ink-3);
    font-size: 12.5px;
}

/* 列表行 */
.book-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.book-row:last-child {
    border-bottom: 0;
}

.cover-sm {
    width: 88px;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-alt);
    flex: none;
}

.cover-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-row h3 {
    font-size: 17px;
    margin-bottom: 5px;
}

.book-row .desc {
    margin-top: 8px;
    color: var(--ink-2);
    font-size: 13.5px;
    line-height: 1.75;
}

.chapter-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--ink-3);
    margin-top: 9px;
}

.chapter-line a {
    color: var(--ink-2);
    max-width: 62%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-line a:hover {
    color: var(--accent);
}

/* 排行榜 */
.rank-list > li {
    display: grid;
    grid-template-columns: 30px 52px 1fr;
    gap: 11px;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.rank-list > li:last-child {
    border-bottom: 0;
}

.rank-no {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink-4);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.rank-list > li:nth-child(1) .rank-no {
    color: var(--accent);
}

.rank-list > li:nth-child(2) .rank-no {
    color: #b98a5e;
}

.rank-list > li:nth-child(3) .rank-no {
    color: #a8907f;
}

.rank-cover {
    width: 52px;
    aspect-ratio: 3 / 4;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-alt);
}

.rank-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rank-body .title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 3px;
}

.rank-body .sub {
    font-size: 12.5px;
    color: var(--ink-3);
}

/* 榜单大卡（前 3 名） */
.rank-top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.rank-top-item {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.rank-top-item .no {
    font-family: var(--serif);
    font-size: 26px;
    color: var(--accent);
    line-height: 1;
}

/* 筛选与分页 */
.filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 6px;
    padding: 12px 0;
}

.filter-label {
    color: var(--ink-3);
    font-size: 13px;
    min-width: 56px;
}

.chip {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13.5px;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line);
}

a.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

a.chip.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    overflow-x: auto;
}

.tabs a {
    padding: 10px 0 12px;
    font-size: 16px;
    color: var(--ink-3);
    position: relative;
    white-space: nowrap;
}

.tabs a.on {
    color: var(--ink);
    font-weight: 600;
}

.tabs a.on::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 26px 0 6px;
    font-size: 14px;
}

.pager a, .pager span {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-2);
}

.pager a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pager .on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pager .disabled {
    color: var(--ink-4);
    background: none;
}

.pager .total {
    border: 0;
    background: none;
    color: var(--ink-3);
}

/* 表单 */
.field {
    margin-bottom: 18px;
}

.field > label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    color: var(--ink-2);
}

.input, .textarea, .select {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    outline: none;
    transition: border-color .15s;
}

.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent);
}

.textarea {
    min-height: 108px;
    resize: vertical;
    line-height: 1.7;
}

.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.form-tip {
    color: var(--ink-3);
    font-size: 12.5px;
    margin-top: 7px;
}

/* 空状态 */
.empty {
    padding: 54px 20px;
    text-align: center;
    color: var(--ink-3);
}

.empty .i {
    font-size: 34px;
    color: var(--ink-4);
    margin-bottom: 10px;
}

.empty p {
    font-size: 14px;
}

/* 提示条 */
.notice {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-size: 13.5px;
}

/* 页脚 */
/* 短页面也要把页脚顶到视口底部（阅读页 body.reader 除外） */
body:not(.reader) {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body:not(.reader) > main,
body:not(.reader) > .wrap,
body:not(.reader) > .wrap-wide {
    flex: 1 0 auto;
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 34px 0 40px;
    color: var(--ink-3);
    font-size: 13.5px;
}

.site-footer .links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 14px;
}

.site-footer a:hover {
    color: var(--accent);
}

.site-footer .copyright {
    line-height: 1.9;
}

/* 移动端底部导航 */
.tabbar {
    display: none;
}

/* 轻提示 */
#fb-toast {
    position: fixed;
    left: 50%;
    top: 24px;
    transform: translateX(-50%) translateY(-18px);
    z-index: 200;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: rgba(37, 37, 35, .93);
    color: #fff;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    max-width: 80vw;
}

#fb-toast.on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#fb-toast.ok {
    background: rgba(60, 92, 78, .95);
}

/* 弹窗 */
.dialog-mask {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(24, 24, 22, .42);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dialog-mask[data-open="1"] {
    display: flex;
}

.dialog {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.dialog h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.dialog .dialog-body {
    color: var(--ink-2);
    font-size: 14.5px;
    line-height: 1.8;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* 响应式 */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* 中等宽度下顶部导航与账号区挤在一起：书架、在读在顶部导航里已有入口，先收起这两个重复按钮 */
@media (max-width: 1080px) {
    .user-box__nav {
        display: none;
    }
}

@media (max-width: 860px) {
    .nav, .search.search-inline {
        display: none;
    }

    /* 窄屏头部只留头像与菜单按钮，个人中心/退出登录在抽屉里 */
    .user-box__name, #userBox #logoutBtn {
        display: none;
    }

    .nav-toggle {
        display: grid;
    }

    .wrap {
        padding: 0 16px;
    }

    .page-title {
        font-size: 24px;
    }

    .rank-top {
        grid-template-columns: 1fr;
    }

    body {
        padding-bottom: 58px;
    }

    .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 70;
        height: 58px;
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--line);
    }

    .tabbar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 11px;
        color: var(--ink-3);
    }

    .tabbar a .i {
        font-size: 20px;
    }

    .tabbar a.on {
        color: var(--accent);
    }

    .site-footer {
        padding-bottom: 78px;
    }
}
