:root {
    --ink: #1c1915;
    --ink-soft: #5e584e;
    --muted: #8a8175;
    --paper: #f4f0e6;
    --paper-2: #fbf8f2;
    --line: #e3d9c8;
    --accent: #8f2d1f;
    --accent-soft: #f3e4dc;
    --warn: #9a6700;
    --danger: #9f1239;
    --nav-height: 64px;
    --shell: 1120px;
    --serif: "Palatino Linotype", Palatino, "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
    --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; }
.hidden { display: none !important; }

.shell,
.container,
.nav-content {
    max-width: var(--shell);
    margin: 0 auto;
    padding-left: 32px;
    padding-right: 32px;
}
.page-container { padding-top: 36px; padding-bottom: 80px; }

/* ===== 登录 ===== */
#login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    background: var(--paper);
}
.login-aside {
    background: var(--ink);
    color: var(--paper);
    padding: 72px 64px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100vh;
}
.login-kicker {
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #c8bba8;
    margin-bottom: 18px;
}
.login-aside h1 {
    font-family: var(--serif);
    font-size: 72px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    margin-bottom: 20px;
}
.login-aside p { max-width: 420px; font-size: 17px; line-height: 1.8; color: #e7dfd2; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 48px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-family: var(--serif); font-size: 32px; font-weight: 600; margin-bottom: 8px; }
.login-subtitle { color: var(--ink-soft); margin-bottom: 28px; font-size: 15px; }
.input-group { display: flex; flex-direction: column; gap: 12px; }
.input-group input {
    width: 100%;
    padding: 14px 0;
    border: none;
    border-bottom: 1px solid var(--ink);
    background: transparent;
    font-size: 16px;
    color: var(--ink);
    outline: none;
    border-radius: 0;
}
.input-group input:focus { border-bottom-width: 2px; }
.btn-primary {
    padding: 12px 18px;
    background: var(--ink);
    color: var(--paper);
    border: none;
    border-radius: 0;
    font-size: 15px;
    letter-spacing: 0.08em;
    cursor: pointer;
}
.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.input-group input:disabled { opacity: 0.5; cursor: not-allowed; }

.error-text { color: var(--danger); font-size: 14px; margin-top: 14px; min-height: 20px; }
.error-text.error-warn { color: var(--warn); }
.error-text.error-critical { color: var(--danger); font-weight: 600; }
.error-text.error-lockout { color: #6d28d9; }

.session-expired-overlay {
    position: fixed; inset: 0; background: rgba(28, 25, 21, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.session-expired-card {
    background: var(--paper-2);
    padding: 40px 36px;
    text-align: left;
    max-width: 420px;
    width: calc(100% - 40px);
    border-top: 3px solid var(--accent);
}
.expired-icon { display: none; }
.session-expired-card h2 { font-family: var(--serif); font-size: 28px; margin-bottom: 10px; }
.session-expired-card p { font-size: 15px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 16px; }
.expired-timer { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.expired-timer span { font-family: var(--serif); font-size: 22px; color: var(--accent); }

/* ===== 顶栏 ===== */
.navbar {
    position: sticky;
    top: 0;
    background: rgba(244, 240, 230, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    z-index: 100;
}
.nav-content {
    height: var(--nav-height);
    display: flex;
    align-items: center;
    gap: 28px;
}
.nav-brand {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink);
}
.nav-links { display: flex; gap: 20px; }
.nav-links a { font-size: 15px; color: var(--ink-soft); }
.nav-links a:hover { color: var(--accent); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.nav-search {
    display: flex;
    align-items: center;
    width: 220px;
    border-bottom: 1px solid var(--line);
}
.nav-search input {
    border: none;
    background: none;
    outline: none;
    padding: 8px 0;
    font-size: 14px;
    width: 100%;
    color: var(--ink);
}
.btn-search, .btn-logout, .nav-menu-btn, .btn-icon {
    background: none;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 14px;
    padding: 6px 0;
    white-space: nowrap;
}
.btn-search:hover, .btn-logout:hover, .nav-menu-btn:hover, .btn-icon:hover { color: var(--accent); }
.nav-menu-btn { display: none; margin-left: auto; }

.mobile-menu {
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
}
.mobile-menu a { display: block; padding: 14px 32px; border-top: 1px solid var(--line); color: var(--ink); }
.mobile-search { padding: 14px 32px 4px; }
.mobile-search input {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-bottom: 1px solid var(--ink);
    background: transparent;
    font-size: 15px;
    outline: none;
}

/* ===== 首页刊头 ===== */
.masthead { padding: 48px 0 8px; }
.kicker { font-size: 12px; letter-spacing: 0.22em; color: var(--accent); margin-bottom: 10px; }
.masthead h1 {
    font-family: var(--serif);
    font-size: 64px;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1;
}
.masthead-line { margin-top: 14px; color: var(--ink-soft); font-size: 16px; }
.masthead-stats {
    display: flex;
    gap: 22px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--ink);
    font-size: 13px;
    color: var(--ink-soft);
    letter-spacing: 0.04em;
}
.masthead-stats b { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); margin-right: 4px; }

.home-layout, .browse-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}
.home-layout { padding-top: 36px; padding-bottom: 72px; }
.home-side { position: sticky; top: calc(var(--nav-height) + 20px); }
.section { margin-bottom: 48px; }
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--ink);
    padding-bottom: 8px;
}
.section-header h2, .page-header-top h1, .story-detail-header h1, .chapter-list-header h2 {
    font-family: var(--serif);
    font-weight: 600;
}
.section-header h2 { font-size: 22px; }
.view-all { font-size: 13px; color: var(--accent); letter-spacing: 0.04em; }
.view-all:hover { text-decoration: underline; }

/* ===== 分类 ===== */
.category-board { display: flex; flex-direction: column; }
.cat-link, .cat-entry {
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 11px 0;
    text-align: left;
    cursor: pointer;
    color: var(--ink);
    font: inherit;
}
.cat-link { padding: 16px 0; }
.cat-link:hover .cat-name, .cat-entry:hover h3, .cat-link.is-current .cat-name { color: var(--accent); }
.cat-link.is-current { border-bottom-color: var(--accent); }
.cat-name { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.25; }
.cat-count { font-family: var(--serif); color: var(--muted); font-size: 14px; flex-shrink: 0; }
.category-index {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 56px;
}
.cat-entry { align-items: flex-start; padding: 20px 0; }
.cat-entry h3 { font-family: var(--serif); font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.cat-entry p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; }

/* ===== 故事列表 ===== */
.story-list { display: flex; flex-direction: column; }
.story-row {
    display: block;
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.story-row:hover h3 { color: var(--accent); }
.story-row h3 {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
}
.story-row.is-featured { display: block; padding: 8px 0 26px; }
.story-row.is-featured h3 { font-size: 40px; line-height: 1.25; margin-bottom: 10px; }
.story-row.is-featured .story-summary { font-size: 17px; max-width: 40rem; -webkit-line-clamp: 3; }
.story-row.is-featured .story-meta { margin-top: 14px; }
.story-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 2px 8px 3px;
    border: 1px solid var(--line);
    background: var(--paper-2);
    font-size: 13px;
    color: var(--ink);
    line-height: 1.4;
}
.tag em { font-style: normal; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; }
.story-detail-header .story-tags { margin: 4px 0 16px; }
.story-summary {
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.story-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px 16px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}
.story-list.compact .story-row { grid-template-columns: 1fr; gap: 2px; padding: 12px 0; }
.story-list.compact h3 { font-size: 16px; }
.story-list.compact .story-summary { display: none; }
.story-list.compact .story-meta { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }

.page-header { margin-bottom: 8px; }
.page-header-top { display: flex; align-items: baseline; gap: 18px; margin-bottom: 18px; }
.page-header-top h1 { font-size: 36px; }
.stories-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
}
.type-tabs, .sort-bar { display: flex; gap: 18px; background: none; border: none; padding: 0; }
.type-tab, .sort-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 0;
    font-size: 14px;
    color: var(--ink-soft);
    cursor: pointer;
}
.type-tab.active, .sort-btn.active { color: var(--ink); border-bottom-color: var(--accent); }
.type-tab:hover, .sort-btn:hover { color: var(--ink); }

/* ===== 详情与正文 ===== */
.story-back-bar { margin-bottom: 18px; }
.btn-back {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 14px;
    color: var(--accent);
    cursor: pointer;
}
.btn-back:hover { text-decoration: underline; }
.story-detail-header { margin-bottom: 28px; max-width: 44rem; }
.story-detail-header h1 { font-size: 42px; line-height: 1.25; margin-bottom: 14px; }
.story-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--ink-soft);
    font-size: 14px;
    margin-bottom: 18px;
}
.story-status { color: var(--accent); }
.story-detail-summary {
    font-size: 16px;
    color: var(--ink-soft);
    line-height: 1.8;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.short-story-divider { height: 1px; background: var(--line); margin: 8px 0 28px; max-width: 40rem; }
.short-story-content, .reader-body {
    max-width: 40rem;
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.95;
    color: var(--ink);
}
.short-story-content { margin: 0 0 48px; }
.short-story-content p, .reader-body p { text-indent: 2em; margin-bottom: 0.9em; }

.chapter-list-header { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 0; max-width: 44rem; border-bottom: 1px solid var(--ink); padding-bottom: 8px; }
.chapter-list-header h2 { font-size: 22px; }
.chapter-list { max-width: 44rem; }
.chapter-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 12px;
    align-items: baseline;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.chapter-item:hover .ch-title { color: var(--accent); }
.ch-number, .ch-words { font-size: 13px; color: var(--muted); }
.ch-title { font-family: var(--serif); font-size: 18px; }

/* ===== 阅读器 ===== */
.reader-header {
    position: sticky;
    top: var(--nav-height);
    background: rgba(244, 240, 230, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    gap: 16px;
}
.reader-chapter-title {
    font-family: var(--serif);
    font-size: 16px;
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reader-settings {
    display: flex;
    justify-content: center;
    gap: 36px;
    padding: 14px 32px;
    border-bottom: 1px solid var(--line);
    background: var(--paper-2);
}
.settings-item { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.font-size-ctrl { display: flex; align-items: center; gap: 8px; }
.font-size-ctrl button {
    width: 32px; height: 32px;
    border: 1px solid var(--line);
    background: transparent;
    cursor: pointer;
    color: var(--ink);
}
.font-size-ctrl button:hover { border-color: var(--ink); }
.theme-btns { display: flex; gap: 8px; }
.theme-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; }
.theme-btn.active { outline: 1px solid var(--accent); outline-offset: 2px; }
.theme-btn.light { background: #fbf8f2; }
.theme-btn.sepia { background: #f3e6cf; }
.theme-btn.dark { background: #1c1915; }
.reader-body { margin: 0 auto; padding: 48px 32px 24px; }
.reader-nav {
    max-width: 40rem;
    margin: 0 auto;
    padding: 12px 32px 72px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.reader-nav button {
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    padding: 8px 0;
    cursor: pointer;
    color: var(--ink);
    font-size: 14px;
}
.reader-nav button:hover:not(:disabled) { color: var(--accent); border-bottom-color: var(--accent); }
.reader-nav button:disabled { color: var(--muted); cursor: not-allowed; }
.reader-nav .btn-catalog { color: var(--accent); }

.reader-theme-sepia, .reader-theme-sepia .reader-header, .reader-theme-sepia .reader-settings { background: #f6efe2; }
.reader-theme-sepia .reader-body { color: #4a3b2a; }
.reader-theme-dark, .reader-theme-dark .reader-header, .reader-theme-dark .reader-settings { background: #161410; color: #e6e0d6; border-color: #2c2823; }
.reader-theme-dark .reader-body { color: #e6e0d6; }
.reader-theme-dark .reader-nav button { color: #e6e0d6; }
.reader-theme-dark .btn-back, .reader-theme-dark .btn-icon { color: #e7c7b4; }

/* ===== 分页、空态、页脚 ===== */
.pagination { display: flex; gap: 6px; margin-top: 28px; }
.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 14px;
}
.page-btn.active { color: var(--paper); background: var(--ink); }
.page-btn:hover:not(:disabled):not(.active) { color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.empty-state { padding: 48px 0; color: var(--muted); }
.footer { border-top: 1px solid var(--line); padding: 28px 32px 40px; color: var(--muted); font-size: 13px; letter-spacing: 0.12em; }

.loading { position: fixed; inset: 0; background: rgba(244,240,230,0.72); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #d5cbbd; }

/* ===== 平板与手机：保留可用，不再把桌面做成放大的手机页 ===== */
@media (max-width: 900px) {
    .shell, .container, .nav-content { padding-left: 20px; padding-right: 20px; }
    .nav-links, .nav-right { display: none; }
    .nav-menu-btn { display: block; }
    #login-page { grid-template-columns: 1fr; }
    .login-aside { min-height: auto; padding: 48px 28px 36px; }
    .login-aside h1 { font-size: 48px; }
    .login-panel { padding: 36px 28px 64px; }
    .masthead h1 { font-size: 44px; }
    .home-layout, .browse-layout { grid-template-columns: 1fr; gap: 28px; }
    .home-side { position: static; }
    .cat-name { font-size: 20px; }
    .story-row, .story-row.is-featured { display: block; }
    .story-row.is-featured h3 { font-size: 30px; }
    .story-meta { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 8px 14px; margin-top: 8px; align-items: center; }
    .category-index { grid-template-columns: 1fr; }
    .page-header-top h1, .story-detail-header h1 { font-size: 28px; }
    .reader-header, .reader-body, .reader-nav { padding-left: 20px; padding-right: 20px; }
    .page-header-top, .story-back-bar {
        position: sticky;
        top: var(--nav-height);
        background: rgba(244, 240, 230, 0.96);
        z-index: 50;
        margin-left: -20px;
        margin-right: -20px;
        padding: 10px 20px;
        border-bottom: 1px solid var(--line);
    }
    .stories-controls { flex-direction: column; align-items: flex-start; }
    .short-story-content, .reader-body { font-size: 17px; }
}

@media (max-width: 480px) {
    :root { --nav-height: 54px; }
    .masthead { padding-top: 28px; }
    .masthead h1 { font-size: 36px; }
    .masthead-stats { flex-wrap: wrap; gap: 10px 16px; }
    .chapter-item { grid-template-columns: 56px 1fr; }
    .ch-words { grid-column: 2; }
}
