/* ==========================================================================
   曾桐紀念圖書館・數位典藏穿透中樞 (極簡純粹三層架構)
   視覺哲學：雅緻象牙白・典藏暖雪金・Apple 頂級純淨淺色美學・全設備絲滑 RWD
   ========================================================================== */

:root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.88);
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: #ffffff;
    
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-accent: rgba(184, 134, 11, 0.35);
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #8e9bb0;
    
    --gold-primary: #b8860b;
    --gold-deep: #926707;
    --gold-light: #fff8e6;
    --gold-glow: rgba(184, 134, 11, 0.18);
    
    --emerald-primary: #059669;
    --emerald-glow: rgba(5, 150, 105, 0.15);
    
    --font-serif: 'Noto Serif TC', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Outfit', 'SF Pro Text', 'PingFang TC', 'Helvetica Neue', sans-serif;
    --font-display: 'Cinzel', serif;

    --transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --radius-ios-sm: 8px;
    --radius-ios-md: 14px;
    --radius-ios-lg: 20px;
    --radius-ios-pill: 100px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    user-select: text;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* 氛圍背景微光 (Apple 溫潤明亮微暈) */
.ambient-glow {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(140px);
    z-index: 0;
}
.glow-top {
    top: -120px;
    left: 20%;
    width: 600px;
    height: 420px;
    background: radial-gradient(circle, rgba(184, 134, 11, 0.08) 0%, transparent 70%);
}
.glow-bottom {
    bottom: -120px;
    right: 15%;
    width: 650px;
    height: 450px;
    background: radial-gradient(circle, rgba(5, 150, 105, 0.05) 0%, transparent 70%);
}

#app-viewport {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   三層視圖切換 (Strict Layer State Machine)
   ========================================================================== */
.layer-view {
    display: none;
    opacity: 0;
    transform: scale(0.99) translateY(10px);
    transition: opacity 0.35s var(--transition-smooth), transform 0.35s var(--transition-smooth);
    min-height: 100vh;
    width: 100%;
}

.layer-view.active {
    display: flex;
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* ==========================================================================
   【第 1 層：思維大廳】(Layer 1 - The Vault)
   ========================================================================== */
#layer-search {
    justify-content: center;
    align-items: center;
    padding: 40px 24px;
}

.vault-container {
    width: 100%;
    max-width: 820px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.vault-header .crest-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 18px;
    box-shadow: none;
}

.firdi-crest-logo {
    width: 128px;
    height: 128px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.06));
    transition: transform 0.3s ease;
}

.firdi-crest-logo:hover {
    transform: scale(1.03);
}

.firdi-institute-tag {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--gold-deep);
    letter-spacing: 0.18em;
    margin-bottom: 6px;
    font-family: var(--font-serif);
}

.library-title {
    font-family: var(--font-serif);
    font-size: clamp(2.3rem, 5vw, 3.2rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #0f172a;
    margin-bottom: 8px;
    line-height: 1.2;
}

.library-subtitle {
    font-family: 'Cinzel', var(--font-serif), var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    color: #64748b;
}

/* 核心搜尋框 (Apple 頂級純淨白玉圓角) */
.search-hero-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid rgba(0, 0, 0, 0.09);
    border-radius: var(--radius-ios-pill);
    padding: 8px 10px 8px 22px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.28s var(--transition-smooth);
}

.search-input-wrapper:focus-within {
    border-color: var(--gold-primary);
    box-shadow: 0 20px 45px rgba(184, 134, 11, 0.15), 0 0 0 3px rgba(184, 134, 11, 0.1);
    transform: translateY(-1px);
}

.search-lens-icon {
    color: #94a3b8;
    display: flex;
    align-items: center;
    margin-right: 12px;
    transition: color 0.2s;
}

.search-input-wrapper:focus-within .search-lens-icon {
    color: var(--gold-primary);
}

#vault-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-family: var(--font-sans);
    font-size: 1.12rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    min-width: 0;
}

#vault-search-input::placeholder {
    color: #94a3b8;
    font-size: 0.98rem;
    font-weight: 400;
}

/* 典雅燙金主按鈕 */
.btn-vault-enter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #c59316, var(--gold-primary));
    color: #ffffff;
    font-weight: 700;
    font-size: 0.96rem;
    border: none;
    border-radius: var(--radius-ios-pill);
    padding: 12px 26px;
    cursor: pointer;
    transition: all 0.22s var(--transition-smooth);
    box-shadow: 0 6px 18px rgba(184, 134, 11, 0.3);
    flex-shrink: 0;
}

.btn-vault-enter:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(184, 134, 11, 0.45);
    background: linear-gradient(135deg, #d4a024, #b8860b);
}

.btn-vault-enter:active {
    transform: scale(0.97);
}

/* 思維微標籤 (iOS 淺灰膠囊) */
.search-inspiration {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
}

.inspiration-label {
    color: #64748b;
    font-size: 0.84rem;
    font-weight: 500;
}

.inspiration-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.chip-tag {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #334155;
    padding: 6px 15px;
    border-radius: var(--radius-ios-pill);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.chip-tag:hover {
    background: var(--gold-light);
    border-color: rgba(184, 134, 11, 0.4);
    color: var(--gold-deep);
    transform: translateY(-1px);
}

.chip-tag:active {
    transform: scale(0.95);
}

.vault-footer {
    margin-top: 10px;
}

.vault-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #64748b;
    padding: 6px 18px;
    background: #ffffff;
    border-radius: var(--radius-ios-pill);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--emerald-primary);
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.4);
    animation: pulseGlow 2.2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* ==========================================================================
   【第 2 層：專屬展台】(Layer 2 - Exhibition)
   ========================================================================== */
#layer-results {
    flex-direction: column;
    padding: 32px 36px;
    background-color: #f8fafc;
}

.exhibition-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.exhibition-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    gap: 16px;
}

.btn-nav-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #334155;
    padding: 9px 18px;
    border-radius: var(--radius-ios-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
}

.btn-nav-action:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.15);
    transform: translateX(-2px);
}

.search-verdict {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.verdict-query-label {
    font-size: 0.92rem;
    color: #475569;
}

.verdict-query-label strong {
    color: var(--gold-deep);
    font-weight: 700;
}

.verdict-count-badge {
    background: rgba(5, 150, 105, 0.08);
    color: var(--emerald-primary);
    border: 1px solid rgba(5, 150, 105, 0.25);
    padding: 4px 12px;
    border-radius: var(--radius-ios-pill);
    font-size: 0.82rem;
    font-weight: 700;
}

/* B 方案精準卡片 (左封面 + 右段落高亮) */
.results-stream-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.book-card-b {
    display: grid;
    grid-template-columns: 240px 1fr;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-ios-md);
    overflow: hidden;
    transition: all 0.28s var(--transition-smooth);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.book-card-b:hover {
    border-color: rgba(184, 134, 11, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08), 0 0 16px rgba(184, 134, 11, 0.08);
}

.book-cover-stage {
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc, #edf2f7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

/* 官方真實 PDF 精裝立體書封 (100% 原始封面長寬比例約 1:1.42) */
.book-3d-cover {
    width: 172px;
    height: 245px;
    border-radius: 3px 8px 8px 3px;
    background: #ffffff;
    box-shadow: 
        -5px 8px 20px rgba(0, 0, 0, 0.16),
        5px 12px 28px rgba(0, 0, 0, 0.08),
        inset 4px 0 6px rgba(0, 0, 0, 0.04);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 5px solid #0f172a;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.book-card-b:hover .book-3d-cover {
    transform: perspective(600px) rotateY(-7deg) scale(1.02);
}

/* 真實 PDF 封面影像 (極致輕量化載入) */
.real-pdf-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0 6px 6px 0;
}

/* 官方擬真 PDF 封面 (0 KB 傳輸、極速秒開) */
.book-cover-simulated {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.simulated-pdf-tag {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gold-deep);
    letter-spacing: 0.12em;
    border-bottom: 1.5px solid var(--gold-primary);
    padding-bottom: 4px;
    font-family: var(--font-sans);
}

.simulated-pdf-title {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1.4;
    color: #0f172a;
    margin: 8px 0;
}

.simulated-pdf-meta {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
}

.simulated-pdf-footer {
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: right;
    border-top: 1px dashed #e2e8f0;
    padding-top: 4px;
}

/* 右側：內文命中與 TAIDE 摘要 */
.book-details-stage {
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    background: #ffffff;
}

.book-headline-title {
    font-family: var(--font-serif);
    font-size: 1.48rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.book-tags-line {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.badge-pill {
    font-size: 0.74rem;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
}

.badge-pill.gold {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.highlights-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.highlight-snippet-card {
    background: #f8fafc;
    border-left: 3.5px solid var(--gold-primary);
    border-radius: 0 6px 6px 0;
    padding: 12px 18px;
    font-size: 0.94rem;
    line-height: 1.6;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
    border-right: 1px solid rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.highlight-snippet-card:hover {
    background: #fffdf5;
    color: #0f172a;
    border-color: var(--gold-primary);
    transform: translateX(3px);
}

.snippet-page-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gold-deep);
    margin-bottom: 3px;
}

.highlight-snippet-card mark {
    background: #fef08a;
    color: #854d0e;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 700;
}

.card-actions-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.btn-book-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 22px;
    border-radius: var(--radius-ios-sm);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: linear-gradient(135deg, #c59316, var(--gold-primary));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.25);
}

.btn-book-action:hover {
    background: linear-gradient(135deg, #d4a024, #b8860b);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(184, 134, 11, 0.4);
}

/* ==========================================================================
   【第 3 層：沉浸殿堂】(Layer 3 - Sanctuary)
   ========================================================================== */
#layer-reader {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: #f1f5f9;
}

.sanctuary-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.sanctuary-header {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    gap: 12px;
}

.nav-retreat-group {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-sanctuary-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #334155;
    padding: 7px 12px;
    border-radius: var(--radius-ios-sm);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sanctuary-tool:hover {
    background: #edf2f7;
    color: #0f172a;
}

.sanctuary-book-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

#sanctuary-book-title {
    font-family: var(--font-serif);
    font-size: 1.08rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.sanctuary-page-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: var(--radius-ios-pill);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    flex-shrink: 0;
}

.btn-stepper {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 1px 5px;
    transition: color 0.2s;
}

.btn-stepper:hover {
    color: var(--gold-deep);
}

.sanctuary-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Apple 淺色藥丸切換器 */
.mode-pill-toggle {
    display: flex;
    background: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-ios-sm);
    padding: 2px;
}

.mode-pill {
    background: transparent;
    border: none;
    color: #64748b;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.mode-pill.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.mobile-only-pill {
    display: none;
}

.btn-sanctuary-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-ios-sm);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    color: #334155;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.btn-sanctuary-action:hover {
    background: #f8fafc;
    color: #0f172a;
}

.btn-sanctuary-action.primary {
    background: linear-gradient(135deg, #c59316, var(--gold-primary));
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
}

/* 雙欄主舞台 (明亮清爽) */
#sanctuary-stage {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
}

.stage-pane {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.pane-original {
    background: #cbd5e1;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.pane-refined {
    background: #ffffff;
}

.pane-header {
    height: 38px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 0.78rem;
}

.pane-badge {
    color: #475569;
    font-weight: 700;
}

.pane-badge.refined {
    color: var(--gold-deep);
}

.pane-zoom-hint, .pane-copy-hint {
    color: #94a3b8;
    font-size: 0.72rem;
}

/* 左側：真實原版 PDF 頁面視角 (150 DPI 高清全景) */
.original-paper-wrapper {
    flex: 1;
    overflow: auto;
    padding: 16px 12px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    cursor: grab;
    background: #eef2f6;
    user-select: none;
    position: relative;
    touch-action: pan-x;
}

.original-paper-wrapper:active {
    cursor: grabbing;
}

.pdf-stage-wrapper {
    position: relative;
    display: inline-block;
    width: 98%;
    max-width: 980px;
    margin: 0 auto;
}

.real-pdf-page-image {
    width: 100%;
    height: auto;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    background: #ffffff;
    transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1), opacity 0.22s ease;
}

/* 🌟 Paragraph Bounding Boxes Overlay Layer (物理段落文字框定) */
.pdf-bbox-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* 🌟 段落文字框定：預設完全透明純淨，零視覺污染，維持原始 PDF 的真實清晰閱覽感 */
.para-bbox-box {
    position: absolute;
    border: 1.5px solid transparent;
    background: transparent;
    border-radius: 4px;
    pointer-events: auto;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    box-sizing: border-box;
    z-index: 6;
}

/* 僅在滑鼠移動至段落時，呈現極簡極淡的親和輪廓 */
.para-bbox-box:hover {
    border: 1.5px solid rgba(37, 99, 235, 0.65);
    background: rgba(37, 99, 235, 0.03);
    z-index: 15;
}

/* 僅在目前單一對焦中的段落，呈現清晰優雅的高科技精準對焦框線 */
.para-bbox-box.active {
    border: 2px solid #2563eb;
    background: rgba(37, 99, 235, 0.04);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    z-index: 25;
}

/* 段落序號標籤：預設徹底隱藏，不遮擋圖表與文字 */
.para-bbox-tag {
    display: none;
    position: absolute;
    top: -12px;
    left: 4px;
    background: #2563eb;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    line-height: 1.2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    z-index: 30;
}

/* 僅在懸停或單一對焦時優雅展現段落標記 */
.para-bbox-box:hover .para-bbox-tag {
    display: block;
    background: #3b82f6;
}

.para-bbox-box.active .para-bbox-tag {
    display: block;
    background: #1d4ed8;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

/* 🌟 搜尋關鍵字精準螢光筆圈選（僅在關鍵字命中位置劃下溫和螢光黃，不遮字不混濁） */
.keyword-highlight-box {
    position: absolute;
    background: rgba(254, 240, 138, 0.45);
    border-bottom: 2px solid #ca8a04;
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
    transition: all 0.2s ease;
}

.btn-locate-para {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
}

.btn-locate-para:hover {
    background: #b8860b;
    color: #ffffff;
    border-color: #b8860b;
    box-shadow: 0 2px 6px rgba(184, 134, 11, 0.25);
}

.pdf-fallback-container {
    width: 100%;
    max-width: 530px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 36px 32px;
    border: 1px solid #e2e8f0;
}

.paper-body {
    flex: 1;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 2.1;
    text-align: justify;
    color: #1e293b;
}

.paper-body p {
    text-indent: 2em;
    margin-bottom: 16px;
}

.paper-footer {
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.78rem;
    color: #94a3b8;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

/* 右側：清洗文字流 (護眼無雜訊) */
.paragraphs-stream-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #ffffff;
}

.sanctuary-page-stepper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 3px 8px;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn-stepper {
    background: transparent;
    border: none;
    color: #475569;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 999px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-stepper:hover {
    background: #f1f5f9;
    color: var(--gold-deep);
}

.page-indicator {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stepper-input {
    width: 48px;
    height: 24px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold-deep);
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stepper-input:focus {
    border-color: var(--gold-primary);
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.2);
}

.page-indicator strong,
.page-indicator span {
    font-family: var(--font-display);
}

.original-paper-wrapper {
    position: relative;
}

.pdf-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
    transition: opacity 0.25s ease;
}

.pdf-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--gold-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.pdf-loading-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.05em;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.refined-paragraph-card {
    background: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-ios-sm);
    padding: 20px 24px;
    transition: all 0.25s ease;
}

.refined-paragraph-card.target-focused {
    background: #fffdf5;
    border: 2px solid var(--gold-primary);
    box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.16), 0 12px 28px rgba(184, 134, 11, 0.15);
    animation: targetGlowPulse 2.2s ease-in-out infinite;
    position: relative;
}

@keyframes targetGlowPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.16), 0 12px 28px rgba(184, 134, 11, 0.15);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(184, 134, 11, 0.32), 0 16px 36px rgba(184, 134, 11, 0.25);
    }
}

.target-penetrated-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #b8860b, #d4af37);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 6px rgba(184, 134, 11, 0.3);
}

.para-text {
    font-family: var(--font-serif);
    font-size: 1.12rem;
    line-height: 1.95;
    color: #1e293b;
    letter-spacing: 0.01em;
}

.para-text mark {
    background: #fef08a;
    color: #854d0e;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 700;
}

/* 3D 翻頁模式視圖 */
.stage-3d-view {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e2e8f0;
}

.book-3d-viewport {
    display: flex;
    width: 860px;
    height: 570px;
    perspective: 1600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.book-spine {
    width: 14px;
    height: 100%;
    background: #cbd5e1;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.book-page-spread {
    flex: 1;
    background: #ffffff;
    color: #1e293b;
    padding: 36px;
    font-family: var(--font-serif);
    overflow-y: auto;
}

.book-page-spread.left {
    border-radius: 6px 0 0 6px;
}

.book-page-spread.right {
    border-radius: 0 6px 6px 0;
}

/* 提示通知 Toast (明亮簡潔) */
.toast-box {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: #0f172a;
    border: 1px solid #334155;
    color: #ffffff;
    padding: 10px 22px;
    border-radius: var(--radius-ios-pill);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: all 0.28s var(--transition-smooth);
    z-index: 1000;
}

.toast-box.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    color: #34d399;
    font-weight: 900;
}

/* ==========================================================================
   全設備完美 RWD 深度適配 (Desktop ➔ Tablet ➔ Mobile)
   ========================================================================== */

/* 1. 平板尺寸 (992px 以下) */
@media (max-width: 992px) {
    #layer-results {
        padding: 24px 20px;
    }
    .book-card-b {
        grid-template-columns: 180px 1fr;
    }
    .book-details-stage {
        padding: 20px;
    }
    .paragraphs-stream-wrapper {
        padding: 20px 24px;
    }
    .original-paper-wrapper {
        padding: 20px;
    }
}

/* 2. 手機直屏尺寸 (768px 以下) */
@media (max-width: 768px) {
    #layer-search {
        padding: 24px 16px;
    }
    .firdi-crest-logo {
        width: 92px;
        height: 92px;
    }
    .vault-container {
        gap: 20px;
    }
    .library-title {
        font-size: 2.1rem;
        letter-spacing: 0.05em;
    }
    .search-input-wrapper {
        padding: 6px 8px 6px 16px;
    }
    #vault-search-input {
        font-size: 1rem;
    }
    .btn-vault-enter {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    .inspiration-tags {
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 4px;
        width: 100%;
        scrollbar-width: none;
    }
    .inspiration-tags::-webkit-scrollbar {
        display: none;
    }
    .chip-tag {
        flex-shrink: 0;
    }

    #layer-results {
        padding: 16px 12px;
    }
    .exhibition-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .search-verdict {
        width: 100%;
        justify-content: space-between;
    }
    .book-card-b {
        grid-template-columns: 1fr;
    }
    .book-cover-stage {
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        padding: 20px;
    }
    .book-details-stage {
        padding: 18px 16px;
    }
    .book-headline-title {
        font-size: 1.25rem;
    }
    .card-actions-footer {
        justify-content: stretch;
    }
    .btn-book-action {
        width: 100%;
        justify-content: center;
    }

    .sanctuary-header {
        height: auto;
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 6px;
        background: rgba(255, 255, 255, 0.98);
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }
    .sanctuary-book-info {
        order: 1;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 4px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    }
    #sanctuary-book-title {
        max-width: 180px;
        font-size: 0.92rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav-retreat-group {
        order: 2;
        display: flex;
        gap: 4px;
    }
    .sanctuary-actions-group {
        order: 3;
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .btn-sanctuary-tool, .btn-sanctuary-action {
        padding: 5px 8px;
        font-size: 0.76rem;
    }
    .btn-text {
        display: none;
    }
    .mode-pill {
        padding: 4px 8px;
        font-size: 0.76rem;
    }

    /* 手機直向：單欄閱讀 + 頂部 Tab 切換 */
    #sanctuary-stage {
        grid-template-columns: 1fr;
    }
    .mobile-only-pill {
        display: inline-block;
    }
    .desktop-only-pill {
        display: none;
    }
    #btn-mode-dual {
        display: none;
    }
    .pane-original {
        display: none;
    }
    .pane-refined {
        display: flex;
    }
    body.mobile-view-original .pane-original {
        display: flex;
    }
    body.mobile-view-original .pane-refined {
        display: none;
    }

    .paper-canvas {
        padding: 28px 24px;
        min-height: auto;
    }
    .paper-body {
        font-size: 0.94rem;
        line-height: 1.9;
    }
    .paragraphs-stream-wrapper {
        padding: 16px;
    }
    .refined-paragraph-card {
        padding: 14px 16px;
    }
    .para-text {
        font-size: 1rem;
    }

    /* 📱 3D 仿真翻書在手機端極致精簡現代化 (拒絕按鈕山堆疊) */
    .st-flipbook-topbar {
        padding: 6px 8px !important;
        gap: 5px !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        background: rgba(253, 251, 247, 0.98) !important;
        height: 44px !important;
        min-height: 44px !important;
        border-bottom: 1px solid rgba(180, 160, 140, 0.25) !important;
    }

    /* 手機上隱藏笨重文字標籤，只保留乾淨圖標 */
    .st-flipbook-topbar .st-btn-label {
        display: none !important;
    }

    /* 手機上隱藏多餘手動文字翻頁按鈕（手機手勢直接滑動/點擊翻頁） */
    #st-btn-prev,
    #st-btn-next {
        display: none !important;
    }

    /* 自動翻頁按鈕簡化為純圖標 */
    #st-btn-autoflip {
        padding: 5px 8px !important;
        font-size: 0.8rem !important;
    }

    /* 頁碼控制膠囊微型化 */
    .st-ctrl-group {
        padding: 2px 6px !important;
        gap: 3px !important;
        background: rgba(0, 0, 0, 0.04) !important;
        border-radius: 12px !important;
    }
    .st-ctrl-label {
        display: none !important; /* 隱藏「跳到總張：」冗字 */
    }
    .st-page-input {
        width: 36px !important;
        height: 24px !important;
        padding: 1px 2px !important;
        font-size: 0.82rem !important;
    }
    .st-total-badge {
        font-size: 0.72rem !important;
    }
    .st-step-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 0.7rem !important;
    }

    /* 圖標功能按鈕精簡 */
    #st-btn-sound,
    #st-btn-theme,
    #st-btn-fullscreen {
        padding: 5px 8px !important;
        font-size: 0.82rem !important;
        min-width: 30px !important;
    }
    #st-btn-exit {
        padding: 5px 8px !important;
        font-size: 0.8rem !important;
        background: #f1f5f9 !important;
    }
    #st-btn-exit .st-btn-label {
        display: inline !important;
        font-size: 0.76rem !important;
    }

    /* 單頁滿版陰影優化 */
    body.st-portrait-mode .st-book-wrapper {
        filter: drop-shadow(0 12px 28px rgba(60, 45, 30, 0.22)) !important;
    }
    body.st-portrait-mode .st-pageflip-book {
        box-shadow: 0 8px 24px rgba(50, 40, 25, 0.18) !important;
    }
    body.st-portrait-mode .st-spine-shadow {
        display: none !important;
    }
}

/* ==========================================================================
   📱 方案 4：手機橫向旋轉 (Landscape Auto-Dual) 自動還原 1:1 左右雙欄對開比對
   ========================================================================== */
@media (orientation: landscape) and (max-height: 550px) {
    /* 1. 緊湊頂部導航列，將高度極限讓位給雙欄視窗 */
    .sanctuary-header {
        height: 42px !important;
        padding: 4px 12px !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
    }
    .sanctuary-book-info {
        order: 0 !important;
        width: auto !important;
    }
    #sanctuary-book-title {
        max-width: 240px !important;
        font-size: 0.86rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .btn-text {
        display: inline !important;
    }
    
    /* 2. 強制重啟 1:1 左右雙欄 Grid (排除 3D 翻書模式) */
    body:not(.mode-3d-active) #sanctuary-stage {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        height: calc(100vh - 42px) !important;
    }
    body.mode-3d-active #sanctuary-stage {
        display: none !important;
    }
    body.mode-3d-active .stage-3d-view {
        height: 100vh !important;
    }

    /* 橫向模式 3D 控制列自適應高度 */
    .st-flipbook-topbar {
        height: 40px !important;
        min-height: 40px !important;
        padding: 4px 12px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }
    .st-flipbook-topbar .st-btn-label {
        display: none !important;
    }
    #st-btn-exit .st-btn-label {
        display: inline !important;
    }
    #st-btn-prev,
    #st-btn-next {
        display: none !important;
    }

    /* 3. 雙欄兩側同步滿版顯示 */
    .pane-original,
    .pane-refined {
        display: flex !important;
        height: 100% !important;
        overflow-y: auto !important;
    }

    /* 4. 膠囊切換狀態：隱藏單欄切換 Tab，顯示雙欄與 3D 比對按鈕 */
    .mobile-only-pill {
        display: none !important;
    }
    .desktop-only-pill {
        display: inline-block !important;
    }
    #btn-mode-dual {
        display: inline-block !important;
    }

    /* 5. 兩側容器邊距自適應微調 */
    .original-paper-wrapper,
    .paragraphs-stream-wrapper {
        padding: 12px 14px !important;
    }
    .paper-canvas {
        padding: 16px 18px !important;
    }
    .refined-paragraph-card {
        padding: 10px 14px !important;
        margin-bottom: 10px !important;
    }
    .para-text {
        font-size: 0.94rem !important;
        line-height: 1.7 !important;
    }
}

/* ==========================================================================
   🏛️ 物理級 3D 擬真翻頁閱覽艙 (比照參考圖 StPageFlip 雙頁對開物理捲曲引擎)
   ========================================================================== */

.stage-3d-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - 56px);
    background: radial-gradient(circle at 50% 45%, #eee9e0 0%, #dfd8cc 60%, #cec6b6 100%);
    position: relative;
    overflow: hidden !important;
    user-select: none;
    box-sizing: border-box;
    transition: background 0.3s ease;
}

/* 桌面背景情境切換：胡桃原木 與 護眼茶綠 */
.stage-3d-view.desk-walnut {
    background: radial-gradient(circle at 50% 42%, #42362f 0%, #2e241e 65%, #1c1511 100%);
}
.stage-3d-view.desk-sage {
    background: radial-gradient(circle at 50% 45%, #d8ded5 0%, #c5cdc1 60%, #aeb8a9 100%);
}

/* 進入 3D 閱讀模式或瀏覽器全螢幕時，全面隱藏主閱讀艙標頭，將 100% 垂直高度完整讓位給 3D 舞台 */
body.mode-3d-active .sanctuary-header,
:fullscreen .sanctuary-header,
:-webkit-full-screen .sanctuary-header {
    display: none !important;
}

body.mode-3d-active .stage-3d-view,
:fullscreen .stage-3d-view,
:-webkit-full-screen .stage-3d-view {
    height: 100vh !important;
    max-height: 100vh !important;
}

/* 頂部清爽象牙微光控制列 */
.st-flipbook-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(253, 251, 247, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(180, 160, 140, 0.35);
    box-shadow: 0 2px 10px rgba(80, 60, 40, 0.05);
    z-index: 100;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stage-3d-view.desk-walnut .st-flipbook-topbar {
    background: rgba(38, 30, 24, 0.94);
    border-bottom: 1px solid rgba(217, 119, 6, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.st-ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.84rem;
    font-weight: 500;
    color: #334155;
    background: #ffffff;
    border: 1px solid rgba(180, 160, 140, 0.45);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stage-3d-view.desk-walnut .st-ctrl-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.st-ctrl-btn:hover {
    background: #f8fafc;
    border-color: #b45309;
    color: #b45309;
    box-shadow: 0 2px 8px rgba(180, 83, 9, 0.15);
    transform: translateY(-1px);
}

.stage-3d-view.desk-walnut .st-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fbbf24;
    color: #fbbf24;
}

.st-ctrl-btn.active {
    background: rgba(14, 165, 233, 0.12);
    border-color: #0284c7;
    color: #0284c7;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.2);
}

/* 3D 書本滿版視口：徹底消除捲動條，絕對滿版居中，極限利用螢幕空間 */
.st-viewport {
    width: 100%;
    max-width: 100%;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 20px;
    position: relative;
    overflow: hidden !important;
    box-sizing: border-box;
}

/* 全域隱藏 3D 舞台的所有 scrollbar，杜絕白條跑版 */
.stage-3d-view,
.st-viewport,
.st-book-wrapper,
.st-pageflip-book,
.stf__parent,
.stf__wrapper,
.stf__block {
    overflow: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.stage-3d-view::-webkit-scrollbar,
.st-viewport::-webkit-scrollbar,
.st-book-wrapper::-webkit-scrollbar,
.st-pageflip-book::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* 當身處 3D 閱讀模式時，強制 body 與主視口禁止溢出捲動 */
body.mode-3d-active,
body.mode-3d-active #app-viewport,
body.mode-3d-active #layer-reader,
body.mode-3d-active .sanctuary-container {
    overflow: hidden !important;
    height: 100vh !important;
}

.st-book-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
    filter: drop-shadow(0 20px 40px rgba(60, 45, 30, 0.28)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12));
}

/* StPageFlip 實體容器與頁面樣式 */
.st-pageflip-book {
    box-shadow: 0 12px 36px rgba(50, 40, 25, 0.22);
    border-radius: 4px;
    background: #ffffff;
}

/* 中縫立體書脊陰影 */
.st-spine-shadow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 100%;
    background: linear-gradient(to right, 
        rgba(0, 0, 0, 0) 0%, 
        rgba(0, 0, 0, 0.15) 35%, 
        rgba(0, 0, 0, 0.26) 50%, 
        rgba(0, 0, 0, 0.15) 65%, 
        rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
    z-index: 50;
    mix-blend-mode: multiply;
}

/* 自動向前翻頁強調膠囊按鈕 */
.st-ctrl-btn.st-btn-accent {
    background: #fef3c7;
    border-color: #d97706;
    color: #b45309;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(217, 119, 6, 0.18);
}

.st-ctrl-btn.st-btn-accent:hover {
    background: #d97706;
    color: #ffffff;
    border-color: #b45309;
}

.st-ctrl-btn.st-btn-accent.is-running {
    background: #d97706;
    color: #ffffff;
    border-color: #92400e;
    box-shadow: 0 0 12px rgba(217, 119, 6, 0.4);
}

/* 返回雙欄按鈕 */
.st-ctrl-btn.st-btn-exit {
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.35);
    color: #dc2626;
    margin-left: 6px;
}

.st-ctrl-btn.st-btn-exit:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #dc2626;
}

/* 跳到總張數字調節群組 */
.st-ctrl-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ffffff;
    border: 1px solid rgba(180, 160, 140, 0.45);
    padding: 3px 10px;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stage-3d-view.desk-walnut .st-ctrl-group {
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.2);
}

.st-ctrl-label {
    color: #475569;
    font-size: 0.82rem;
    font-family: var(--font-sans, sans-serif);
}

.stage-3d-view.desk-walnut .st-ctrl-label {
    color: #cbd5e1;
}

.st-step-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s ease;
    padding: 0;
}

.stage-3d-view.desk-walnut .st-step-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

.st-step-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.st-page-input {
    width: 46px;
    background: transparent;
    border: none;
    color: #b45309;
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: bold;
    text-align: center;
    padding: 0 2px;
    outline: none;
    -moz-appearance: textfield;
}

.stage-3d-view.desk-walnut .st-page-input {
    color: #fbbf24;
}

.st-page-input::-webkit-outer-spin-button,
.st-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.st-total-badge {
    color: #64748b;
    font-size: 0.82rem;
    font-family: monospace;
    margin-right: 4px;
}

.stage-3d-view.desk-walnut .st-total-badge {
    color: #94a3b8;
}

/* 狀態提示條 */
.st-flipbook-status {
    position: absolute;
    top: 54px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(217, 119, 6, 0.5);
    color: #b45309;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: monospace;
    box-shadow: 0 4px 16px rgba(80, 60, 40, 0.12);
    z-index: 150;
    transition: opacity 0.3s ease;
    pointer-events: none;
}


.st-page {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.st-page-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    background: #ffffff;
}

/* 頁面載入中骨架 */
.st-page-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.88rem;
    font-family: monospace;
    gap: 12px;
}

.st-page-skeleton .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #d97706;
    border-radius: 50%;
    animation: st-spin 0.8s linear infinite;
}

@keyframes st-spin {
    to { transform: rotate(360deg); }
}

/* 中縫裝訂深色立體書脊陰影 */
.st-spine-shadow {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    pointer-events: none;
    z-index: 100;
    background: linear-gradient(to right, rgba(0,0,0,0.01) 0%, rgba(0,0,0,0.48) 50%, rgba(0,0,0,0.01) 100%);
}

/* 3D 物理翻頁高質感仿真紙本排版兜底層 */
.st-page-fallback-paper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 32px 28px 26px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #faf8f3;
    color: #2b2625;
    font-family: var(--font-serif, 'Noto Serif TC', 'Songti TC', serif);
    box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    z-index: 5;
}

.st-fallback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(138, 90, 43, 0.25);
    padding-bottom: 6px;
    font-size: 0.72rem;
    color: #8c7355;
    letter-spacing: 0.06em;
}

.st-fallback-book-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.st-fallback-lib {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

.st-fallback-body {
    flex: 1;
    overflow-y: auto;
    margin: 12px 0;
    line-height: 1.8;
    font-size: 0.92rem;
}

.st-fallback-p {
    margin-bottom: 10px;
    text-align: justify;
    text-indent: 2em;
}

.st-fallback-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid rgba(138, 90, 43, 0.2);
    padding-top: 6px;
    font-size: 0.75rem;
    color: #8c7355;
    letter-spacing: 0.05em;
}

.st-paper-mark {
    background-color: #fef08a !important;
    color: #854d0e !important;
    padding: 1px 3px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.35);
    font-weight: 600;
}

/* ==========================================================================
   🚀 浮動回到頂部輔助按鈕 (Back to Top)
   ========================================================================== */
.btn-back-to-top {
    position: fixed;
    bottom: 36px;
    right: 36px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(184, 134, 11, 0.35);
    border-radius: 30px;
    color: #1e293b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 1;
    transform: translateY(0);
}

.btn-back-to-top:hover {
    background: #b8860b;
    border-color: #b8860b;
    color: #ffffff;
    box-shadow: 0 6px 24px rgba(184, 134, 11, 0.4);
    transform: translateY(-2px);
}

.btn-back-to-top:active {
    transform: scale(0.96);
}

.btn-back-to-top.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px);
}

/* ==========================================================================
   🏛️ 學術級純文字無符號卡片資訊欄位 (Academic Metadata Strip)
   ========================================================================== */
.book-academic-meta {
    margin: 8px 0 12px 0;
    font-size: 0.84rem;
    line-height: 1.6;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 14px;
}

.academic-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.academic-meta-item {
    display: inline-flex;
    align-items: baseline;
}

.academic-meta-label {
    color: #64748b;
    font-weight: 500;
}

.academic-meta-value {
    color: #1e293b;
    font-weight: 600;
}

.academic-meta-divider {
    color: #cbd5e1;
    margin: 0 2px;
}

.academic-tags-row {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 6px;
}

.academic-tag-chip {
    display: inline-block;
    color: #0369a1;
    background: #e0f2fe;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}



