[hidden] { display: none !important; }
:root {
    --desk: #e9e3d8;
    --paper: #fffdf8;
    --ink: #302d28;
    --muted: #81796c;
    --line: #ddd4c5;
    --accent: #9a5f38;
    --accent-dark: #714224;
    --shadow: rgba(68, 51, 34, .14);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--desk); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,.65), transparent 32%),
        radial-gradient(circle at 90% 85%, rgba(142,108,74,.09), transparent 34%),
        var(--desk);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(154,95,56,.3); outline-offset: 3px; }
.desk { width: min(100%, 980px); margin: 0 auto; padding: 24px 28px calc(24px + env(safe-area-inset-bottom)); }
.topbar { display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand { text-align: center; min-width: 0; }
.brand h1 { margin: 0; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(22px, 3vw, 31px); font-weight: 700; letter-spacing: .08em; overflow-wrap: anywhere; }
.brand p { margin: 7px 0 0; color: var(--muted); font-size: 13px; letter-spacing: .06em; }
.text-button { border: 0; background: transparent; color: var(--accent-dark); text-decoration: none; font-size: 14px; cursor: pointer; padding: 10px 4px; text-align: center; }
.admin-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; }
.storage-info { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.reader { perspective: 1400px; }
.paper {
    position: relative;
    min-height: min(68vh, 720px);
    padding: clamp(30px, 5vw, 62px) clamp(24px, 6vw, 72px) 42px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(113,66,36,.035), transparent 9%, transparent 93%, rgba(113,66,36,.025)),
        var(--paper);
    border: 1px solid rgba(121, 96, 66, .14);
    border-radius: 5px 13px 13px 5px;
    box-shadow: 0 22px 60px var(--shadow), 0 2px 5px rgba(68,51,34,.08);
    touch-action: pan-y;
}
.paper::before { content: ""; position: absolute; inset: 0 auto 0 20px; width: 1px; background: rgba(174,92,77,.13); }
.paper-edge { position: absolute; right: 7px; top: 7px; bottom: 7px; width: 3px; border-right: 1px solid rgba(121,96,66,.12); border-left: 1px solid rgba(121,96,66,.07); pointer-events: none; }
.paper.turning .page-content { animation: page-in .26s ease-out; }
@keyframes page-in { from { opacity: .25; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
.loading, .empty-state, .error-state { min-height: 45vh; display: grid; place-content: center; gap: 16px; text-align: center; color: var(--muted); }
.empty-state a { color: var(--accent-dark); }
.error-state button { justify-self: center; border: 1px solid var(--line); background: var(--paper); color: var(--accent-dark); border-radius: 8px; padding: 9px 18px; cursor: pointer; }
.page-content { max-width: 720px; margin: 0 auto; }
.page-kicker { margin: 0 0 14px; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.page-content h2 { margin: 0; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(27px, 4vw, 38px); line-height: 1.35; overflow-wrap: anywhere; }
.rule { width: 42px; height: 2px; margin: 22px 0 26px; background: var(--accent); opacity: .7; }
.page-text { font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-size: clamp(17px, 2.2vw, 19px); line-height: 2; letter-spacing: .025em; white-space: pre-wrap; overflow-wrap: anywhere; }
.page-text:empty { display: none; }
.image-list { display: grid; gap: 16px; margin-top: 28px; }
.image-list.multiple { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.image-card { margin: 0; }
.image-card img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; border-radius: 6px; background: #f4f0e8; box-shadow: 0 4px 18px rgba(68,51,34,.1); }
.attachment-section { margin-top: 32px; padding-top: 22px; border-top: 1px solid var(--line); }
.attachment-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 500; }
.attachment-list { display: grid; gap: 9px; }
.attachment-list a { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent-dark); background: rgba(248,244,236,.68); text-decoration: none; overflow-wrap: anywhere; }
.attachment-list a:hover { border-color: #bda78f; background: #f8f3e9; }
.attachment-icon { flex: 0 0 auto; font-size: 12px; border: 1px solid #cdbca8; border-radius: 4px; padding: 2px 5px; }
.copy-link { margin-top: 34px; padding: 7px 0; border: 0; border-bottom: 1px solid #c7b6a2; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; margin-top: 24px; }
.pager button { border: 1px solid rgba(121,96,66,.2); border-radius: 9px; padding: 12px 18px; color: var(--accent-dark); background: rgba(255,253,248,.65); cursor: pointer; box-shadow: 0 2px 5px rgba(68,51,34,.04); }
.pager button:last-child { justify-self: end; }
.pager button:first-child { justify-self: start; }
.pager button:disabled { opacity: .35; cursor: default; }
.pager .page-counter { min-width: 82px; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.gesture-hint { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.modal { position: fixed; inset: 0; z-index: 20; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(35,29,23,.38); backdrop-filter: blur(3px); }
.toc-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(88vw, 380px); padding: 26px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; background: var(--paper); box-shadow: 12px 0 40px rgba(35,29,23,.18); }
.toc-head { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 18px; border-bottom: 1px solid var(--line); }
.toc-head h2 { margin: 0; font-family: "Songti SC", "STSong", serif; }
.toc-head button { border: 0; background: transparent; color: var(--muted); font-size: 30px; cursor: pointer; }
.toc-list { display: grid; gap: 5px; padding-top: 14px; }
.toc-item { display: grid; grid-template-columns: 34px 1fr; gap: 8px; width: 100%; padding: 13px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.toc-item:hover, .toc-item.active { background: #f2ecdf; color: var(--accent-dark); }
.toc-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.toc-title { overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 40px); padding: 11px 18px; border-radius: 8px; background: rgba(45,40,34,.92); color: white; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
@media (max-width: 640px) {
    .desk { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
    .topbar { grid-template-columns: 54px 1fr auto; margin-bottom: 14px; gap: 5px; }
    .admin-actions { gap: 4px; }
    .storage-info { font-size: 10px; }
    .brand h1 { font-size: 22px; letter-spacing: .04em; }
    .brand p { font-size: 11px; margin-top: 4px; }
    .paper { min-height: 67vh; padding: 30px 24px 32px 30px; border-radius: 4px 9px 9px 4px; }
    .paper::before { left: 15px; }
    .page-content h2 { font-size: 28px; }
    .page-text { font-size: 17px; line-height: 1.9; }
    .image-list.multiple { grid-template-columns: 1fr; }
    .pager { margin-top: 15px; gap: 8px; }
    .pager button { padding: 11px 12px; font-size: 14px; }
    .pager .page-counter { min-width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
