/* ==========================================================================
   📚 Yushan 2026 - 文章書本立體外觀、材質與翻頁舞台共用樣式 (articles_book.css)
   
   【檔案用途說明】
   本樣式檔為前台（書櫃 / 書目列表）與後台（書本外觀設定彈窗）前後台共用之核心視覺樣式。
   主要包含：
   1. 書本通用字體與材質噪點紋理變數 (--serif, --n-*)
   2. 6 種精裝材質紋理樣式 (.mat, .mat-*)
   3. 書本立體封面樣式 (.book, .book.full, 標籤、標記、緞帶)
   4. 書脊樣式 (.spine, 燙金文字、書檔與盆栽裝飾)
   5. 後台書本外觀設定彈窗與即時預覽 (.bsm-book, .bsm-spine, .bsm-pv, 單選按鈕)
   6. 3D 開書翻頁舞台與展開目錄 (.veil, .stage, .spread, .page, .cover, .toc)
   7. 響應式佈局支援 (行動裝置單頁排版與無障礙降級)
   ========================================================================== */

/* ==========================================================================
   1. 書本通用字體與材質噪點紋理變數 (Texture Noise Tokens)
   ========================================================================== */
:root {
    /* 書本專用襯線字體 */
    --serif: "Noto Serif TC", "Songti TC", serif;

    /* 細緻深色噪點紋理 (布面 cloth) */
    --n-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

    /* 粗粒皮革噪點紋理 (皮革 leather / 牛皮紙 kraft) */
    --n-coarse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.35' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

    /* 斑駁雜質噪點紋理 */
    --n-speck: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .12 0 0 0 0 .05 0 0 0 1.4 -.75'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

    /* 內頁紙張微光柔和噪點紋理 (翻頁舞台內頁 page) */
    --n-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   2. 6 種精裝材質紋理樣式 (Book Materials)
   ========================================================================== */

/* 基礎材質渲染層 */
.mat {
    background-color: var(--sp);
    background-image: var(--shade, none), var(--tex, none);
    background-size: 100%, var(--ts, 160px);
}

/* (1) 平滑霧面 (flat) */
.mat-flat {
    --tex: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12));
}

/* (2) 精裝布紋 (cloth - 預設) */
.mat-cloth {
    --tex: var(--n-dark);
}

/* (3) 亞麻細紋 (linen) */
.mat-linen {
    --tex: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 3px),
           repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px);
    --ts: auto;
}

/* (4) 復古皮革 (leather) */
.mat-leather {
    --tex: var(--n-coarse);
    --ts: 200px;
    filter: saturate(0.9);
}

/* (5) 牛皮紙質 (kraft) */
.mat-kraft {
    --tex: var(--n-coarse);
    --ts: 56px;
    filter: sepia(0.3) saturate(0.85);
}

/* (6) 絲絨典雅 (velvet) */
.mat-velvet {
    --tex: radial-gradient(120% 80% at 30% 20%, rgba(255, 255, 255, 0.18), transparent 55%),
           radial-gradient(90% 90% at 80% 100%, rgba(0, 0, 0, 0.35), transparent 60%);
    --ts: 100%;
}

/* ==========================================================================
   3. 書本立體封面樣式 (Book 3D Cover)
   ========================================================================== */

/* 書本立體封面容器 */
.book {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 2px 6px 6px 2px;
    --shade: linear-gradient(90deg, rgba(0,0,0,0.3) 0, rgba(0,0,0,0.05) 6%, rgba(255,255,255,0.08) 7.5%, transparent 12%);
    box-shadow: 2px 3px 0 #d8cdb9, 3px 4px 0 #bfb39d, 4px 6px 0 #a89c86, 8px 14px 22px rgba(0,0,0,0.5);
    overflow: hidden;
    color: var(--on);
}

/* 滿版圖片封面模式 */
.book.full {
    background-image: var(--shade), var(--logo);
    background-size: 100%, cover;
    background-position: center;
}

/* 封面置中 Logo 區塊 */
.book .lo {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20% 16% 20% 22%;
}

.book .lo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 1px 0 rgba(255,255,255,0.15)) drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

/* 封面精裝燙印標題籤 */
.book .label {
    position: absolute;
    left: 16%;
    right: 10%;
    top: 16%;
    border: 1px solid color-mix(in srgb, var(--on), transparent 45%);
    outline: 1px solid color-mix(in srgb, var(--on), transparent 75%);
    outline-offset: 3px;
    padding: 10px 8px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

/* 封面底部品牌燙金標記 */
.book .mark {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10%;
    text-align: center;
    opacity: 0.6;
    font-size: 9px;
    letter-spacing: 0.3em;
    font-family: var(--serif);
    pointer-events: none;
    white-space: nowrap;
}

/* 測驗/特別書籤緞帶 */
.ribbon {
    position: absolute;
    right: 14%;
    top: -4px;
    width: 11px;
    height: 0;
    background: #38bdf8;
    transition: height 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
    z-index: 2;
}

.ribbon::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 0;
    border: 5.5px solid #38bdf8;
    border-bottom-color: transparent;
}

/* ==========================================================================
   4. 立體書脊樣式 (Book Spine)
   ========================================================================== */

/* 書架上的直立書脊本體 */
.spine {
    flex: 0 0 auto;
    position: relative;
    width: var(--spine-w, 42px);
    height: var(--spine-h, 210px);
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: var(--serif);
    color: var(--on);
    --shade: linear-gradient(90deg, rgba(0,0,0,0.35), rgba(255,255,255,0.12) 18%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.25));
    border-radius: 2px 2px 0 0;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateX(-40px);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.35s, opacity 0.35s;
}

/* 書本被抽出時的視覺反饋 (由 JS 賦予 class，CSS 負責設計演出) */
.spine.is-pulled {
    transform: translateY(-30px) !important;
}

.show .spine {
    animation: slidein 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
    animation-delay: calc(var(--k) * 55ms);
}

@keyframes slidein {
    to { opacity: 1; transform: none; }
}

.spine.ready {
    animation: none;
    opacity: 1;
    transform: none;
}

/* 書脊直書標題文字 */
.spine .tt {
    position: absolute;
    left: 50%;
    top: 30px;
    bottom: 30px;
    transform: translateX(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

/* 書脊上下燙金線條裝飾 */
.spine .bd {
    position: absolute;
    left: 3px;
    right: 3px;
    height: 5px;
    border-top: 1px solid var(--gold);
    border-bottom: 1px solid var(--gold);
}

.spine .bd.t { top: 12px; }
.spine .bd.b { bottom: 12px; }

/* 懸浮抽書動作 */
.spine:hover, .spine:focus-visible {
    transform: translateY(-14px);
    filter: brightness(1.12);
    outline: none;
}

/* 篩選未選中時之暗化狀態 */
.spine.dim {
    opacity: 0.2 !important;
    filter: saturate(0.2);
    transform: translateY(8px) !important;
    pointer-events: none;
}

/* 書本自然微傾斜效果 */
.spine.lean.ready {
    transform: rotate(-7deg);
    transform-origin: bottom left;
    margin-left: 16px;
}

.spine.lean.ready:hover {
    transform: rotate(-7deg) translateY(-10px);
}

/* 書架層板托底 */
.board {
    height: 10px;
    border-radius: 0 0 2px 2px;
    background: linear-gradient(180deg, rgba(186, 230, 253, 0.35), rgba(56, 189, 248, 0.12));
    border-top: 1px solid rgba(186, 230, 253, 0.6);
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
}

/* 玻璃透明書檔 */
.bookend {
    flex: 0 0 auto;
    width: 22px;
    height: 120px;
    margin-left: 6px;
    background: linear-gradient(90deg, rgba(186, 230, 253, 0.15), rgba(186, 230, 253, 0.35) 40%, rgba(186, 230, 253, 0.1));
    border: 1px solid rgba(186, 230, 253, 0.4);
    border-radius: 2px 10px 0 0;
}

/* 書架盆栽擺飾 */
.plant {
    flex: 0 0 auto;
    align-self: flex-end;
    margin: 0 10px 0 auto;
    width: 46px;
    height: 54px;
    position: relative;
}

.plant::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 6px;
    right: 6px;
    height: 26px;
    background: linear-gradient(#8b5a3c, #6b432c);
    border-radius: 2px 2px 8px 8px;
}

.plant::after {
    content: "";
    position: absolute;
    bottom: 22px;
    left: 50%;
    width: 34px;
    height: 34px;
    transform: translateX(-50%);
    border-radius: 50% 50% 40% 40%;
    background: radial-gradient(circle at 35% 35%, #5f8a5a, #2f5130);
    box-shadow: -10px 6px 0 -4px #3d6a3b, 10px 4px 0 -5px #4b7a48;
}

/* ==========================================================================
   5. 後台書本外觀設定彈窗與即時預覽 (Book Style Modal & Preview)
   ========================================================================== */

/* 即時預覽容器 (封面與書脊並列) */
.bsm-pv {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 22px;
    padding: 10px 0;
}

/* 彈窗中獨立呈現的書本封面預覽 */
.bsm-book {
    width: 145px;
    height: 195px;
    border-radius: 2px 6px 6px 2px;
    position: relative;
    --shade: linear-gradient(90deg, rgba(0, 0, 0, 0.3) 0, rgba(0, 0, 0, 0.05) 6%, rgba(255, 255, 255, 0.08) 7.5%, transparent 12%);
    box-shadow: 2px 3px 0 #d8cdb9, 4px 5px 0 #bfb39d, 6px 8px 0 #a89c86, 12px 18px 25px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    color: var(--on, #fff);
}

.bsm-book.full {
    background-image: var(--shade), var(--logo);
    background-size: 100%, cover;
    background-position: center;
}

.bsm-book .lo {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16% 12% 16% 18%;
}

.bsm-book .lo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.bsm-book .label {
    position: absolute;
    left: 18%;
    right: 12%;
    top: 18%;
    border: 1px solid color-mix(in srgb, var(--on, #fff), transparent 45%);
    outline: 1px solid color-mix(in srgb, var(--on, #fff), transparent 75%);
    outline-offset: 3px;
    padding: 10px 8px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--on, #fff);
    word-break: break-word;
}

.bsm-book .mark {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10%;
    text-align: center;
    opacity: 0.6;
    font-size: 9px;
    letter-spacing: 0.3em;
    font-family: var(--serif);
    color: var(--on, #fff);
    white-space: nowrap;
    pointer-events: none;
}

/* 彈窗中獨立呈現的書脊預覽 */
.bsm-spine {
    width: 38px;
    height: 195px;
    border-radius: 2px 4px 4px 2px;
    position: relative;
    box-shadow: 2px 2px 0 #cfc4b0, 4px 8px 20px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bsm-spine .tt {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #e2e8f0;
    max-height: 155px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    user-select: none;
}

.bsm-spine .bd {
    position: absolute;
    left: 4px;
    right: 4px;
    height: 1px;
    background: rgba(255, 255, 255, 0.35);
}

.bsm-spine .bd.t { top: 8px; }
.bsm-spine .bd.b { bottom: 8px; }

/* 選擇器卡片包裹容器 */
.bsm-picker-card {
    padding: 16px;
    margin-bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
}

/* Radio 單選與 filter-btn 整合樣式 */
.filter-buttons .bsm-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.filter-buttons .bsm-radio:checked + .filter-btn,
.filter-buttons .bsm-radio:checked + label.filter-btn {
    border-color: #00d9ff;
    box-shadow: 0 0 14px rgba(0, 217, 255, 0.3);
    color: #00d9ff;
    background: rgba(0, 217, 255, 0.1);
}

.filter-buttons .bsm-radio:disabled + .filter-btn,
.filter-buttons .bsm-radio:disabled + label.filter-btn {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   6. 開書 3D 翻頁舞台與對話框 (3D Book Opening Stage)
   ========================================================================== */

/* 舞台暗色毛玻璃遮罩 */
.veil {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 10, 0.72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
    z-index: 1040;
}

.veil.on {
    opacity: 1;
    pointer-events: auto;
}

/* 3D 舞台置中視圖 */
.stage {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1045;
    padding: 16px;
}

/* 雙頁展開書體 (Spread) */
.spread {
    position: relative;
    width: min(860px, 100%);
    aspect-ratio: 860/560;
    perspective: 1800px;
    opacity: 0;
    transform: translateY(30px) scale(0.92);
    transition: opacity 0.35s, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.stage.on .spread {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.stage.on:not(.open) .spread {
    transform: translateX(-25%);
}

/* 書本內頁底色與紋理 */
.page {
    background-color: #111a2b;
    background-image: var(--n-light), linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    background-size: 160px, 100%;
    color: #e2e8f0;
}

/* 左側內頁 (預設隱藏，由封面翻開之背面呈現) */
.page.l {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 50%;
    visibility: hidden;
}

/* 右側內頁 (固定展示書籍簡介、最新章節與進入按鈕) */
.page.r {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 50%;
    border-radius: 0 8px 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 0;
    box-shadow: inset 22px 0 30px -20px rgba(0, 0, 0, 0.7), 0 30px 60px rgba(0, 0, 0, 0.55);
    padding: 30px 30px 24px;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* 3D 翻轉封面主體 */
.cover {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 50%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.1s cubic-bezier(0.6, 0.05, 0.25, 1);
    z-index: 3;
}

.stage.open .cover {
    transform: rotateY(-180deg);
}

.cover .front, .cover .back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    filter: none !important;
}

.cover .front.book {
    aspect-ratio: auto;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.cover .front .label {
    font-size: 20px;
    padding: 16px 12px;
}

.cover .back {
    transform: rotateY(180deg);
    border-radius: 8px 0 0 8px;
}

.cover .back .inner {
    position: absolute;
    inset: 10px;
    border-radius: 4px 0 0 4px;
    padding: 26px 22px 20px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 0;
    box-shadow: inset -22px 0 30px -20px rgba(0, 0, 0, 0.7);
}

/* 內容淡入動畫 */
.page.r > *, .cover .back .inner > * {
    opacity: 0;
    transition: opacity 0.4s;
}

.stage.open .page.r > *, .stage.open .cover .back .inner > * {
    opacity: 1;
    transition-delay: 0.75s;
}

.page.r h2 {
    font-family: var(--serif);
    font-size: 26px;
    margin: 4px 0 10px;
    line-height: 1.35;
    color: #f8fafc;
}

.page.r p {
    font-size: 14px;
    line-height: 1.85;
    color: #a7b3c4;
    margin: 0 0 14px;
}

.latest.pl {
    margin: 6px 0 0;
    padding: 11px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13.5px;
}

.frow {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.frow .mrow {
    flex: 1 1 260px;
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.acts {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn.read {
    background: #38bdf8;
    color: #04121c;
    border: 1px solid #38bdf8;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s;
}

.btn.read:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
}

.xbtn {
    position: absolute;
    top: -38px;
    right: 0;
    background: none;
    border: 0;
    color: #cbd5e1;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    opacity: 0;
    transition: opacity 0.3s;
}

.stage.open .xbtn {
    opacity: 1;
    transition-delay: 0.9s;
}

/* ==========================================================================
   7. 翻頁目錄樣式 (TOC inside Book Spread)
   ========================================================================== */

.toc-h {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--hx, #38bdf8), transparent 40%);
}

.toc-h b {
    font-family: var(--serif);
    font-size: 22px;
    letter-spacing: 0.25em;
    color: #f8fafc;
}

.toc-h span {
    font-size: 10px;
    letter-spacing: 0.35em;
    color: #64748b;
}

.toc {
    list-style: none;
    margin: 0;
    padding: 4px 4px 18px 14px;
    overflow: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(#000 90%, transparent);
    mask-image: linear-gradient(#000 90%, transparent);
}

.toc > li {
    position: relative;
}

.toc a {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 8px 10px 4px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    position: relative;
    transition: background 0.25s;
}

.toc > li > a::after {
    content: "";
    position: absolute;
    left: 48px;
    right: 8px;
    bottom: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.07);
}

.toc .n {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 900;
    color: var(--hx, #38bdf8);
    line-height: 1;
    transition: transform 0.3s;
    opacity: 0.9;
}

.toc .s {
    font-family: var(--serif);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.45;
    min-width: 0;
    color: #e2e8f0;
}

.toc .s small {
    display: block;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #64748b;
    margin-top: 2px;
}

.toc .ar {
    opacity: 0;
    transform: translateX(-6px);
    transition: 0.25s;
    color: #38bdf8;
    font-size: 12px;
    font-family: system-ui, -apple-system, sans-serif;
    white-space: nowrap;
}

.toc a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toc a:hover .ar {
    opacity: 1;
    transform: none;
}

.toc a:hover .n {
    transform: translateX(3px);
}

.toc .sub {
    list-style: none;
    margin: 0 0 6px 48px;
    padding: 0;
}

.toc .sub a {
    grid-template-columns: 1fr auto;
    padding: 5px 8px;
}

.toc .sub .s {
    font-size: 13px;
    font-weight: 500;
    color: #a7b3c4;
}

.toc .sub .s::before {
    content: "—";
    color: #475569;
    margin-right: 8px;
}

.toc .nw {
    margin-left: 6px;
    vertical-align: 2px;
    font-family: system-ui, -apple-system, sans-serif;
}

.toc li.here > a {
    background: rgba(244, 114, 182, 0.08);
}

.toc li.here > a::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 0;
    width: 10px;
    height: 30px;
    background: #f472b6;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}

.toc .hl {
    color: #f472b6 !important;
    font-weight: 600;
}

.stage.open .toc > li {
    animation: tocIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(0.85s + var(--j) * 60ms);
}

@keyframes tocIn {
    from { opacity: 0; transform: translateX(-10px); }
}

.toc-m { display: none; }
.toc-wrap { display: none; }

/* ==========================================================================
   8. 響應式規範與無障礙支援 (Responsive & Accessibility)
   ========================================================================== */

@media (max-width: 900px) {
    .spread {
        width: min(560px, 100%);
        aspect-ratio: auto;
        perspective: none;
    }
    .stage.on:not(.open) .spread { transform: none; }
    .cover, .page.l { display: none; }
    .page.r {
        position: relative;
        width: 100%;
        height: min(86vh, 780px);
        overflow: hidden;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        padding: 52px 24px 18px;
        box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
    }
    .page.r > * { flex: none; opacity: 1 !important; }
    .page.r p {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 10px;
    }
    .page.r .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin-bottom: 0;
    }
    .page.r .chips > * { flex-shrink: 0; white-space: nowrap; }
    .page.r h2 { font-size: 22px; margin: 2px 0 6px; }
    .page.r .badges { margin-bottom: 4px; }
    .latest.pl { display: none; }
    .toc-wrap {
        display: flex;
        flex: 1 1 auto !important;
        min-height: 0;
        position: relative;
        flex-direction: column;
        margin-top: 12px;
    }
    .toc-wrap .toc-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 12px;
        color: #64748b;
        padding: 0 2px 6px 14px;
    }
    .toc-wrap .toc-bar b {
        color: #cbd5e1;
        font-family: var(--serif);
        letter-spacing: 0.2em;
        font-size: 13px;
    }
    .toc-m {
        display: block;
        flex: 1;
        min-height: 0;
        overflow: auto !important;
        overscroll-behavior: contain;
        -webkit-mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 24px), transparent) !important;
        mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 24px), transparent) !important;
        padding: 6px 4px 18px 14px !important;
        margin: 0;
    }
    .toc-m > li { animation: none !important; }
    .toc-m li.fold { display: none; }
    .toc-m li.gap {
        list-style: none;
        text-align: left;
        padding: 2px 0 2px 52px;
        color: #475569;
        font-size: 16px;
        letter-spacing: 0.3em;
    }
    .toc-more {
        flex: none;
        margin: 6px 0 0 14px;
        align-self: flex-start;
        background: none;
        border: 1px dashed rgba(255, 255, 255, 0.18);
        color: #94a3b8;
        border-radius: 10px;
        padding: 6px 12px;
        font-family: inherit;
        font-size: 12.5px;
        cursor: pointer;
    }
    .toc-more:hover { color: #38bdf8; border-color: #38bdf8; }
    .frow {
        flex: none !important;
        background: linear-gradient(transparent, #111a2b 30%);
        margin-top: 6px;
    }
    .xbtn {
        top: 12px;
        right: 16px;
        opacity: 1;
        z-index: 5;
        color: #cbd5e1;
        background: rgba(15, 23, 42, 0.92);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 10px;
        padding: 6px 12px;
    }
}

@media (max-width: 600px) {
    .stage {
        align-items: flex-end;
        padding: 0;
    }
    .spread { width: 100%; }
    .page.r {
        border-radius: 18px 18px 0 0;
        max-height: 88vh;
    }
    .acts { width: 100%; margin-left: 0; }
    .acts .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .spine { opacity: 1; transform: none; }
}

