:root {
    --bg-base: #f4f6f9;
    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --accent-blue: #0071e3;
    --accent-green: #34c759;
    --accent-danger: #ff3b30;
    --surface-color: rgba(255, 255, 255, 0.85);
    --glass-blur: blur(20px);
    --luxury-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    --card-shadow: 0 4px 16px rgba(0,0,0,0.04);
    --reader-line-height: 1.85;
    --reader-font-size: 19px; /* 新增全局字号控制 */
}

@keyframes spin { 100% { transform: rotate(360deg); } }
::-webkit-scrollbar { display: none; }

html, body { 
    margin: 0; padding: 0; width: 100%; height: 100%; 
    background: var(--bg-base); color: var(--text-main); 
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; 
    overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}

.app-shell { 
    width: 100%; max-width: 1200px; height: 100vh; margin: 0 auto;
    background: #ffffff; display: flex; flex-direction: column; position: relative; overflow: hidden; 
}
@media (min-width: 768px) { 
    .app-shell { height: 94vh; margin: 3vh auto; border-radius: 24px; box-shadow: var(--luxury-shadow); border: 1px solid rgba(0,0,0,0.05); } 
}

.nav-bar { 
    padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; 
    background: var(--surface-color); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid rgba(0,0,0,0.05); z-index: 100; 
}
.nav-bar .nav-title { font-size: 20px; font-weight: 800; color: #1d1d1f; letter-spacing: -0.5px; }
.nav-btn { background: #f5f5f7; border: none; color: #1d1d1f; padding: 8px 16px; border-radius: 100px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.nav-btn:active { transform: scale(0.96); background: #e8e8ed; }

.content-body { flex: 1; overflow-y: auto; padding: 24px; box-sizing: border-box; display: flex; flex-direction: column; padding-bottom: 50px;}
@media (max-width: 768px) { .content-body { padding: 16px; } }

.history-quick-portal { background: linear-gradient(135deg, #0071e3 0%, #4facfe 100%); padding: 16px 20px; border-radius: 20px; margin: 0 auto 30px auto; width: 100%; max-width: 800px; box-sizing: border-box; display: none; justify-content: space-between; align-items: center; cursor: pointer; box-shadow: 0 10px 25px rgba(0, 113, 227, 0.3); color: white; }
.hq-left-content { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.hq-icon { font-size: 26px; flex-shrink: 0; }
.hq-text-info { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 4px; }
.hq-subtitle { font-size: 12px; opacity: 0.8; font-weight: 600; text-transform: uppercase; }
.hq-main-title { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.hq-action-btn { background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 100px; font-size: 13px; font-weight: 800; flex-shrink: 0; margin-left: 15px; }

.shelf-title-box { font-size: 22px; font-weight: 800; color: #1d1d1f; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.bookshelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 20px; }
@media (min-width: 768px) { .bookshelf-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 30px; } }
.book-wrapper { display: flex; flex-direction: column; align-items: flex-start; cursor: pointer; text-decoration: none; }
.book-3d-cover { width: 100%; aspect-ratio: 3 / 4; position: relative; border-radius: 6px 12px 12px 6px; box-shadow: -2px 0 5px rgba(0,0,0,0.05), 5px 8px 20px rgba(0,0,0,0.15); display: flex; align-items: center; justify-content: center; box-sizing: border-box; background-size: cover; background-position: center; transition: all 0.3s; }
.book-3d-cover::before { content: ''; position: absolute; top: 0; left: 4px; width: 2px; height: 100%; background: linear-gradient(to right, rgba(255,255,255,0.4), rgba(0,0,0,0.05)); z-index: 10; }
.book-no-cover-inner { border: 1px solid rgba(255,255,255,0.3); width: 88%; height: 90%; border-radius: 4px; display: flex; align-items: center; justify-content: center; padding: 10px; box-sizing: border-box; background: rgba(255,255,255,0.1); }
.book-no-cover-inner .b-title { font-family: "STKaiti", serif; font-size: 15px; font-weight: bold; color: #fff; text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,0.3); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.book-label-text { font-size: 14px; font-weight: 700; margin-top: 12px; color: #1d1d1f; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-update-status { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* 🌟 核心突破：锁定 FIXED，彻底根除 Safari 底部导航栏遮挡问题 */
#luxury-reader-view { display: none; position: fixed; inset: 0; z-index: 1000; flex-direction: column; box-sizing: border-box; background: #fbf6ec; color: #3e2c1c; }
.reader-nav { position: absolute; top: 0; left: 0; width: 100%; display: flex; flex-direction: column; background: var(--surface-color); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); box-shadow: 0 4px 20px rgba(0,0,0,0.05); z-index: 1500; transform: translateY(-100%); transition: transform 0.3s cubic-bezier(0.2, 0.5, 0.5, 1); padding-top: env(safe-area-inset-top); }
.nav-top-row { display: flex; flex-wrap: nowrap; overflow-x: auto; padding: 12px 16px; gap: 10px; align-items: center; -webkit-overflow-scrolling: touch; }
.nav-top-row::-webkit-scrollbar { display: none; }
.reader-nav button { flex-shrink: 0; display: flex; align-items: center; gap: 6px; background: #ffffff; border: none; border-radius: 100px; padding: 10px 18px; cursor: pointer; font-weight: 700; font-size: 14px; color: #1d1d1f; box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: transform 0.1s; white-space: nowrap; }

.nav-color-row { display: flex; align-items: center; justify-content: flex-start; padding: 12px 16px 16px 16px; border-top: 1px solid rgba(0,0,0,0.05); flex-wrap: nowrap; overflow-x: auto; gap: 12px; -webkit-overflow-scrolling: touch; }
.nav-color-row::-webkit-scrollbar { display: none; }
.color-dot-pool { display: flex; gap: 12px; flex-shrink: 0; align-items: center; }
.color-dot { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.05); box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); cursor: pointer; flex-shrink: 0;}

.reader-footer { position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; font-size: 13px; font-weight: 700; color: #86868b; background: linear-gradient(to top, var(--surface-color), rgba(255,255,255,0)); backdrop-filter: blur(5px); z-index: 1500; transform: translateY(100%); transition: transform 0.3s; padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); }
.show-menu { transform: translateY(0); }

/* 🌟 流水级多列排版：无惧图片长短，文字水样环绕 */
.reader-body { flex: 1; width: 100%; position: relative; overflow: hidden; touch-action: none; }
#stage-wrapper { position: absolute; top: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); left: 20px; right: 20px; overflow: hidden; }
@media (min-width: 768px) { #stage-wrapper { width: 700px; left: 50%; right: auto; margin-left: -350px; } }

#novel-stage { 
    height: 100%; width: auto; 
    column-width: calc(100vw - 40px); column-gap: 40px; column-fill: auto;
    transition: transform 0.3s cubic-bezier(0.2, 0.5, 0.5, 1), opacity 0.2s; 
}
@media (min-width: 768px) { #novel-stage { column-width: 700px; column-gap: 80px; } }

/* 约束图片：决不容许图片撑爆一页造成空白 */
.ch-illus-box { text-align: center; width: 100%; margin: 15px auto; break-inside: avoid-column; }
.ch-illus-box img { max-width: 100%; max-height: 40vh; border-radius: 12px; box-shadow: 0 8px 20px rgba(0,0,0,0.1); object-fit: contain; }

#novel-stage p, #novel-stage > div:not(.ch-illus-box) { 
    margin: 0 0 1.2em 0; text-indent: 2em; line-height: var(--reader-line-height); 
    font-size: var(--reader-font-size); word-wrap: break-word; white-space: pre-wrap; 
    transition: background 0.2s; 
}
#novel-stage h3 { font-size: 1.4em; font-weight: 900; margin-bottom: 1.5em; text-align: center; line-height: 1.4; break-inside: avoid-column; }

.tts-reading-active { background: rgba(52, 199, 89, 0.15) !important; color: #248a3d !important; border-radius: 8px; box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.15); }

/* 后台与登录 */
.lock-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 30px; box-sizing: border-box;}
.lock-card { background: #ffffff; padding: 40px; border-radius: 24px; box-shadow: var(--luxury-shadow); width: 100%; max-width: 380px; text-align: center; border: 1px solid rgba(0,0,0,0.05); }
.lock-card input { width: 100%; padding: 16px; border-radius: 12px; border: 2px solid #e5e5ea; background: #f5f5f7; color: #1d1d1f; text-align: center; font-size: 18px; font-weight: bold; outline: none; margin-bottom: 25px; box-sizing: border-box; transition: border-color 0.2s; }

.admin-wrapper { max-width: 800px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.admin-wrapper.wide { max-width: 1200px; flex-direction: row; align-items: stretch; }

.create-book-form, .author-card, .stat-box { background: #ffffff; padding: 24px; border-radius: 20px; box-shadow: var(--card-shadow); border: 1px solid rgba(0,0,0,0.04); }
.create-book-form input[type="text"], .create-book-form textarea { width: 100%; padding: 16px; border: 1px solid #e5e5ea; border-radius: 12px; margin-bottom: 16px; box-sizing: border-box; font-size: 15px; outline: none; background: #f5f5f7; transition: all 0.2s; }
.create-book-form input:focus, .create-book-form textarea:focus { background: #ffffff; border-color: var(--accent-blue); }

.premium-btn { background: var(--accent-blue); color: white; border: none; padding: 14px 24px; border-radius: 100px; font-weight: 700; font-size: 15px; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(0, 113, 227, 0.2); width: 100%; box-sizing: border-box; white-space: nowrap; }
.premium-btn:active { transform: scale(0.96); }
.danger-btn { background: #ffeeed; color: var(--accent-danger); border: none; padding: 10px 20px; border-radius: 100px; font-weight: 700; cursor: pointer; font-size: 14px; }

input[type="file"] { width: 100%; padding: 12px; background: #f5f5f7; border-radius: 12px; box-sizing: border-box; font-size: 14px; color: var(--text-muted); cursor: pointer; outline: none; }
input[type="file"]::file-selector-button { padding: 8px 16px; border-radius: 100px; background: #ffffff; border: 1px solid rgba(0,0,0,0.1); color: #1d1d1f; font-weight: 700; cursor: pointer; transition: background 0.2s; margin-right: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }

.dashboard-header-stats { display: flex; gap: 15px; }
.stat-box { flex: 1; text-align: center; padding: 20px; }
.stat-num { font-size: 32px; font-weight: 900; color: var(--accent-blue); margin-bottom: 4px; }

.tabs-nav { display: flex; background: rgba(0,0,0,0.04); padding: 5px; border-radius: 14px; margin-bottom: 5px; gap: 5px; overflow-x: auto; }
.tab-lnk { flex: 1; text-align: center; font-size: 14px; font-weight: 700; color: var(--text-muted); cursor: pointer; padding: 12px 16px; border-radius: 10px; transition: all 0.2s; white-space: nowrap; }
.tab-lnk.active-tab { color: #1d1d1f; background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.write-stage { background: #ffffff; padding: 24px; border-radius: 20px; box-shadow: var(--card-shadow); border: 1px solid rgba(0,0,0,0.04); }

.rt-editor-wrapper { border: 1px solid #e5e5ea; border-radius: 16px; overflow: hidden; background: #ffffff; margin-bottom: 20px; display: flex; flex-direction: column; transition: border-color 0.2s; }
.rt-editor-wrapper:focus-within { border-color: var(--accent-blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.1); }
.rt-toolbar { background: #f5f5f7; border-bottom: 1px solid #e5e5ea; padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rt-toolbar button, .rt-toolbar input[type="color"] { background: #ffffff; border: 1px solid #d1d1d6; border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer; color: #1d1d1f; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.02); display: flex; align-items: center; justify-content: center; height: 34px; box-sizing: border-box; }
.rt-toolbar input[type="color"] { padding: 0 4px; width: 40px; }
.rt-toolbar button:hover { background: #e8e8ed; }
.rt-editor { flex: 1; min-height: 500px; padding: 24px; outline: none; font-size: 16px; line-height: 1.8; overflow-y: auto; cursor: text; }
.rt-editor p, .rt-editor div { margin: 0 0 1em 0; text-indent: 2em; }
.rt-editor img { max-width: 100%; border-radius: 8px; margin: 10px auto; display: block; }

#reader-drawer { position: absolute; top: 0; left: 0; width: 340px; max-width: 85%; height: 100%; background: rgba(255,255,255,0.95); backdrop-filter: blur(20px); z-index: 2000; box-shadow: 20px 0 50px rgba(0,0,0,0.1); transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.2, 0.5, 0.5, 1); display: flex; flex-direction: column; }
.drawer-search-box { padding: 20px; background: #f9f9f9; border-bottom: 1px solid rgba(0,0,0,0.05); }
.drawer-search-box input { width: 100%; padding: 12px 16px; border-radius: 100px; border: none; background: #e8e8ed; box-sizing: border-box; outline: none; font-size: 15px; font-weight: 500; }
.drawer-list { flex: 1; overflow-y: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.drawer-item { padding: 16px 24px; font-size: 15px; border-bottom: 1px solid rgba(0,0,0,0.03); cursor: pointer; font-weight: 500; color: #1d1d1f; }
.drawer-item.active-ch { background: #f4f9ff; color: var(--accent-blue); font-weight: 800; }
#drawer-mask { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1999; backdrop-filter: blur(2px); }
.toast { position: fixed; top: 50px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); color: #fff; padding: 14px 28px; border-radius: 100px; font-size: 15px; font-weight: 600; z-index: 99999; opacity: 0; transition: opacity 0.3s; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }