/* =========================================
   1. 全域色彩與變數系統 (調色盤)
   ========================================= */
:root {
    /* 1-1. 背景色系 */
    --bg-main: #fdfbf7;        /* 全域底色 (米白) */
    --bg-card: #ffffff;        /* 卡片底色 (純白) */
    --bg-alt: #e5e9f0;         /* 替代底色 (梯腳、展間、表格頭的莫蘭迪灰藍) */
    --bg-tag: #f0ecf4;         /* 標籤/輕微懸停底色 (極淡紫) */

    /* 1-2. 文字色系 */
    --text-main: #4a4e69;      /* 主要內文 (深灰藍) */
    --text-muted: #888888;     /* 次要資訊、日期、摘要 (中灰) */

    /* 1-3. 主題色系 (莫蘭迪紫) */
    --primary: #74658a;        /* 標題、主要按鈕、活動狀態 */
    --primary-hover: #5a4f6d;  /* 按鈕懸停色 */
    
    /* 1-4. 輔助色系 (強調色) */
    --accent-red: #a8202b;     /* 書店價格、按鈕 (酒紅) */
    --accent-red-hover: #8a1922;
    --accent-green: #529977;   /* 友站連結 (莫蘭迪綠) */

    /* 1-5. 邊框與陰影 */
    --border-light: rgba(0, 0, 0, 0.04);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 20px rgba(0,0,0,0.1);
}

/* 深色模式變數 (自動對應替換) */
[data-theme="dark"] {
    --bg-main: #1e1e2e;
    --bg-card: #313244;
    --bg-alt: #313244;
    --bg-tag: rgba(203, 166, 247, 0.1);

    --text-main: #cdd6f4;
    --text-muted: #a6adc8;

    --primary: #cba6f7;
    --primary-hover: #b48eed;

    --accent-red: #ff6b6b;
    --accent-red-hover: #ff8787;
    --accent-green: #8bd5af;

    --border-light: rgba(255, 255, 255, 0.02);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 20px rgba(0,0,0,0.4);
}

/* =========================================
   2. 全域重置與基礎排版
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* 防止螢幕產生左右卷軸 */
}

a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary); }

main {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding-top: 1rem; 
}

/* =========================================
   3. 全域固定導覽列 (Header)
   ========================================= */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    padding: 0.8rem 5%; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    font-style: italic;
    font-weight: bold;
}

.header-left { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a { margin-left: 1.5rem; }
.nav-group { display: inline-flex; align-items: center; margin-left: 1.5rem; gap: 0.4rem; }
.nav-group a { margin-left: 0; }

/* 導覽列主頁圖示按鈕 (kR Logo Card) */
.home-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border-radius: 10px;
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.home-icon-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-md); background-color: var(--bg-tag); }
.home-logo-inner { font-family: serif; font-size: 1.8rem; line-height: 1; font-style: normal; color: var(--text-main); }
.logo-k { font-style: italic; font-weight: normal; }
.logo-r { font-style: italic; font-weight: bold; }

/* 視圖切換按鈕 ≡ */
.view-toggle-btn { font-size: 1.2rem; font-style: normal; color: var(--text-muted); padding: 0 4px; border-radius: 4px; }
.view-toggle-btn:hover { background-color: var(--bg-tag); color: var(--primary); }

/* =========================================
   UI 視覺層次優化 (導覽列專屬)
   ========================================= */

/* 1. 淺色模式：加深功能欄背景 (燕麥灰)，使其與網頁底色分離 */
[data-theme="light"] header {
    background-color: #f2efeb ; 
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03); /* 加上極微弱的實體陰影，增加漂浮感 */
}

/* 3. 深色模式：調淺功能欄背景 (淺夜灰)，與深色底色形成對比 */
[data-theme="dark"] header {
    background-color: #2d2d3d ; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* =========================================
   UI 視覺層次優化 (導航卡片排除空殼版)
   ========================================= */

/* 淺色模式：加深文章底部的切換按鈕，但「排除」空卡片 (.empty-card) */
[data-theme="light"] .nav-card:not(.empty-card) {
    background-color: #f7f6f3 !important; 
    border-color: rgba(116, 101, 138, 0.15) !important; 
}

[data-theme="dark"] .nav-card:not(.empty-card) {
    background-color: #2d2d3d !important; 
    border-color: rgba(116, 101, 138, 0.15) !important; 
}

/* 確保空卡片絕對隱形，不受任何外力干擾 */
.nav-card.empty-card {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    pointer-events: none; /* 確保滑鼠點不到它 */
}

[data-theme="dark"] .logo-card {
    color: #cba6f7 !important; /* 強制把「Y」變成較深的莫蘭迪紫，讓它在白底上很清晰 */
}
[data-theme="dark"] .logo-card {
    background-color: #313244 !important; /* 強制把「Y」變成較深的莫蘭迪紫，讓它在白底上很清晰 */
}

/* =========================================
   4. 明暗切換按鈕 (懸浮固定版)
   ========================================= */
.theme-toggle-btn {
    position: fixed !important;
    bottom: 30px !important; right: 30px !important;
    z-index: 9999 !important;
    background-color: var(--bg-card) !important;
    color: var(--primary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    cursor: pointer;
    width: 48px !important; height: 48px !important;
    border-radius: 50%;
    display: inline-block; overflow: hidden;
    padding: 0 !important; margin: 0;
    transition: all 0.3s ease !important;
}
.theme-toggle-btn:hover {
    transform: translateY(-3px) !important;
    box-shadow: var(--shadow-lg) !important;
    background-color: var(--bg-tag) !important;
}

/* SVG 圖示動畫控制 */
.theme-toggle-btn svg {
    position: absolute !important; 
    top: 50% !important; left: 50% !important;
    width: 24px !important; height: 24px !important;
    margin: 0 !important; padding: 0 !important;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.5s ease;
}
.icon-sun { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) !important; }
.icon-moon { opacity: 0; transform: translate(-50%, -50%) rotate(-90deg) !important; }

[data-theme="dark"] .icon-sun { opacity: 0; transform: translate(-50%, -50%) rotate(90deg) !important; }
[data-theme="dark"] .icon-moon { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) !important; }

/* =========================================
   5. 莫蘭迪色帶梯腳 (Footer)
   ========================================= */
.footer-color-band {
    background-color: var(--bg-alt) !important; 
    width: 100vw !important;
    position: relative !important;
    left: 50% !important; right: 50% !important;
    margin-left: -50vw !important; margin-right: -50vw !important;
    padding: 0.3rem 0 !important; 
    margin-top: 5rem !important;
    border-top: 1px solid var(--border-color) !important;
    z-index: 10; 
}
.site-footer-content { max-width: 1200px; margin: 0 auto; text-align: center; }
.copyright { font-weight: bold; color: var(--primary); margin-bottom: 0.5rem; }
.footer-desc { font-size: 0.85rem; color: var(--text-muted); letter-spacing: 1px; }

/* =========================================
   6. 單篇文章閱讀版面 (Post)
   ========================================= */
.post-layout-container {
    display: flex; width: 100%; max-width: 1200px;
    margin: 0 auto; padding: 2rem 5%; 
    gap: 2rem; /* 把原本的 3rem 縮小一點，讓左右靠緊 */
    align-items: flex-start;
    justify-content: center; /* 新增這行：讓側邊欄跟文章在畫面中完美置中 */
    min-height: calc(100vh - 150px); 
}

/* 左側邊欄 */
.post-sidebar {
    position: sticky; top: 80px; 
    max-height: calc(100vh - 100px); overflow-y: auto; 
    width: 200px;       /* 把原本的 240px 改成 200px，視覺比例會更精緻 */
    flex-shrink: 0; 
}

.post-sidebar::-webkit-scrollbar { display: none; }
.sidebar-title { font-size: 1.3rem; font-weight: bold; margin-bottom: 2rem; }
.sidebar-year { font-size: 1.5rem; font-weight: bold; margin: 1.5rem 0 1rem 0; }
.sidebar-post-list { list-style: none; padding: 0; }
.sidebar-post-list li { margin-bottom: 1rem; }
.sidebar-post-list a { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; display: block; }
.sidebar-post-list a:hover { color: var(--text-main); }
.sidebar-post-list a.active { color: var(--primary); font-weight: bold; }

/* 分隔線與右側內容 */
.vertical-divider { width: 6px; background-color: var(--border-color); border-radius: 3px; align-self: stretch; margin-top: 1rem; }
.post-content-area {
    /* 刪除原本的 flex-grow: 1; 改用 width: 100% */
    width: 100%; 
    max-width: 800px; min-width: 0; 
    background-color: var(--bg-card);
    padding: 2.5rem 3.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.post-title { font-size: 2.2rem; font-weight: bold; color: var(--primary); margin-bottom: 1rem; line-height: 1.3; }
.post-meta { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 3rem; }
.post-body { line-height: 1.8; font-size: 1.05rem; color: var(--text-main); }
.post-body p { margin-bottom: 1.5rem; }
.post-body ul { margin-left: 1.5rem; margin-bottom: 1.5rem; }
.post-body li { margin-bottom: 0.8rem; }

/* =========================================
   文章內文超連結設計 (高對比強化版)
   ========================================= */
.post-body a {
    color: var(--primary-hover);       /* 使用較深的莫蘭迪紫，增加與內文的色彩對比 */
    font-weight: 600;                  /* 稍微加粗，讓文字在視覺上更突出 */
    text-decoration: underline;        /* 加上底線，確保讀者一眼看出是連結 */
    text-decoration-color: var(--border-color); /* 預設底線顏色使用淡淡的邊框色，避免畫面太亂 */
    text-underline-offset: 4px;        /* 讓底線往下沉一點，留出呼吸空間，排版更具現代感 */
    text-decoration-thickness: 1.5px;  /* 微調底線粗細 */
    transition: all 0.3s ease;         /* 設定平滑的漸變動畫 */
}

.post-body a:hover {
    color: var(--accent-red);          /* 懸停時切換成酒紅色，營造強烈的互動回饋 */
    text-decoration-color: var(--accent-red); /* 底線一起變成酒紅色 */
}

/* 導航卡片 */
.post-navigation {
    display: flex; justify-content: space-between; gap: 1.5rem; 
    margin-top: 4rem; padding-top: 3rem;
    border-top: 1px solid var(--border-color);
}
.nav-card {
    flex: 1; display: flex; flex-direction: column; padding: 1.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px; transition: all 0.3s ease;
}
.nav-card.empty-card { background-color: transparent; border-color: transparent; }
.nav-card:hover:not(.empty-card) { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.nav-older { text-align: right; }
.nav-label { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }
.nav-title { font-size: 1.1rem; font-weight: bold; color: var(--primary); line-height: 1.4; }

.post-content a {
  color: #007bff;
}

@media (max-width: 850px) {
    .post-layout-container { flex-direction: column; }
    .post-sidebar { width: 100%; position: relative; top: 0; max-height: none; margin-bottom: 2rem; }
    .vertical-divider { display: none; }
    .post-content-area { padding: 1.5rem 1.5rem; }
    .post-navigation { flex-direction: column; gap: 1rem; }
    .nav-older { text-align: left; }
}

/* =========================================
   7. Code 專屬清單排版 (Code)
   ========================================= */
.code-page-container { max-width: 800px; margin: 0 auto; padding: 40px 20px; }
.code-header { margin-bottom: 40px; border-bottom: 2px solid var(--border-color); padding-bottom: 20px; }
.code-header h1 { font-size: 2.5rem; color: var(--text-main); margin: 0 0 10px 0; white-space: nowrap; }
.code-header p { font-size: 1.1rem; color: var(--text-muted); margin: 0; line-height: 1.6; }

.code-list-item {
    display: flex; flex-direction: column; padding: 24px; margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px; box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}
@media (min-width: 600px) { .code-list-item { flex-direction: row; justify-content: space-between; align-items: center; } }
.code-list-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-left: 6px solid var(--primary); }

.code-item-content { flex: 1; margin-right: 20px; }
.code-item-title { font-size: 1.4rem; color: var(--primary); margin: 0 0 10px 0; font-weight: bold; }
.code-item-desc { color: var(--text-muted); font-size: 1rem; margin: 0 0 16px 0; line-height: 1.5; }

.code-item-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
@media (min-width: 600px) { .code-item-tags { margin-bottom: 0; } }
.code-tag { background: var(--bg-tag); color: var(--primary); padding: 4px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: bold; }

.code-item-action { flex-shrink: 0; }
.code-btn {
    display: inline-block; padding: 10px 20px;
    background: var(--primary); color: #ffffff !important;
    text-decoration: none !important; border-radius: 8px; font-weight: bold; transition: background 0.2s;
}
.code-btn:hover { background: var(--primary-hover); }

/* =========================================
   8. Book 網路書店版面 (Book)
   ========================================= */
.bookstore-container { max-width: 1000px; margin: 0 auto; padding: 2rem 5%; flex-grow: 1; }
.book-card { display: flex; gap: 2rem; padding: 2rem 0; align-items: flex-start; }
.book-cover { flex-shrink: 0; width: 150px; }
.book-cover img { width: 100%; height: auto; box-shadow: var(--shadow-md); border-radius: 4px; }
.book-info { flex-grow: 1; }
.book-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
.book-title a { color: var(--text-main); text-decoration: none; transition: color 0.2s; }
.book-title a:hover { color: var(--primary); }
.book-meta { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.book-author { color: var(--text-muted); }
.book-summary {
    font-size: 0.95rem; line-height: 1.6; color: var(--text-main);
    display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.book-action { flex-shrink: 0; width: 160px; display: flex; flex-direction: column; align-items: flex-end; gap: 0.8rem; }
.book-price-box { margin-bottom: 0.5rem; }
.book-discount { color: var(--accent-red); font-weight: bold; font-size: 1.1rem; margin-right: 0.3rem; }
.book-price { color: var(--accent-red); font-weight: bold; font-size: 1.3rem; }

.book-btn-read {
    display: block; width: 100%; text-align: center;
    background-color: var(--accent-red); color: white !important;
    padding: 0.6rem 0; border-radius: 4px; text-decoration: none; font-weight: bold; transition: background-color 0.2s;
}
.book-btn-read:hover { background-color: var(--accent-red-hover); }
.book-btn-fav {
    width: 100%; background-color: transparent; cursor: pointer;
    color: var(--accent-red); border: 1px solid var(--accent-red);
    padding: 0.4rem 0; border-radius: 4px; font-size: 0.9rem; transition: all 0.2s;
}
.book-btn-fav:hover { background-color: var(--bg-tag); }
.book-divider { border: none; border-top: 1px dashed var(--border-color); margin: 0; }

/* =========================================
   標題備註文字 (Subtitle Note)
   ========================================= */
.archive-title .title-note {
    font-size: 0.55em;         /* 字體縮小 (大約是主標題的 55% 大小，剛好小兩號) */
    font-weight: normal;       /* 拿掉粗體，看起來更像輕輕的備註 */
    color: var(--text-muted);  /* 使用較淡的文字顏色 (莫蘭迪灰) */
    vertical-align: middle;    /* 讓它跟前面的大字垂直置中對齊 */
}

@media (max-width: 768px) {
    .book-card { flex-direction: column; }
    .book-action { width: 100%; align-items: flex-start; }
    .book-cover { width: 120px; }
}

/* =========================================
   9. Photo 攝影日記 (Photo)
   ========================================= */
.photo-gallery-container { max-width: 1200px; margin: 0 auto; padding: 2rem 5%; flex-grow: 1; }
.masonry-gallery { column-count: 3; column-gap: 1.5rem; padding: 2rem 0; }
@media (max-width: 900px) { .masonry-gallery { column-count: 2; } }
@media (max-width: 600px) { .masonry-gallery { column-count: 1; } }

.masonry-item { break-inside: avoid; margin-bottom: 1.5rem; position: relative; overflow: hidden; border-radius: 8px; background-color: var(--border-color); }
.masonry-img { width: 100%; height: auto; display: block; transition: transform 0.5s ease; }
.masonry-item:hover .masonry-img { transform: scale(1.08); }

.masonry-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    color: white; opacity: 0; transition: opacity 0.3s ease; font-size: 0.9rem; pointer-events: none;
}
.masonry-item:hover .masonry-overlay { opacity: 1; }

.photo-single-container { max-width: 1000px; margin: 0 auto; padding: 2rem 5%; flex-grow: 1; }
.back-to-gallery { display: inline-block; margin-bottom: 2rem; color: var(--text-muted); transition: color 0.2s; }
.back-to-gallery:hover { color: var(--primary); }

.photo-showcase {
    text-align: center; margin-bottom: 3rem;
    background-color: var(--bg-alt);
    padding: 3rem 1rem; border-radius: 12px; border: 1px solid var(--border-color);
}
.showcase-img {
    max-width: 100%; max-height: 80vh; object-fit: contain;
    box-shadow: var(--shadow-lg); border-radius: 4px;
}
.photo-details { max-width: 700px; margin: 0 auto; text-align: center; }
.photo-single-title { font-size: 2rem; margin-bottom: 0.5rem; font-family: serif; color: var(--primary); }
.photo-single-meta { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 2rem; letter-spacing: 1px; }
.photo-single-story { font-size: 1.1rem; line-height: 1.8; color: var(--text-main); margin-bottom: 2.5rem; text-align: justify; }

.photo-single-exif {
    font-family: monospace; background: var(--bg-tag);
    padding: 1.2rem; border-radius: 8px; display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap;
    color: var(--text-muted); font-size: 0.95rem;
}

/* =========================================
   10. Other 專屬表格排版 (Blogroll)
   ========================================= */
.blogroll-wrapper { overflow-x: auto; margin-bottom: 2rem; }
.blogroll-table { width: 100%; border-collapse: collapse; background-color: var(--bg-card); font-size: 1rem; }
.blogroll-table th, .blogroll-table td {
    border: 1px solid var(--border-color);
    padding: 14px 18px; text-align: left; vertical-align: top;
}
.blogroll-table th { background-color: var(--bg-alt); font-weight: bold; color: var(--text-main); }
.blogroll-table .col-name { width: 15%; white-space: nowrap; }
.blogroll-table .col-desc { width: 85%; color: var(--text-muted); line-height: 1.6; }

.blogroll-table .col-name a { color: var(--accent-green); text-decoration: none; font-weight: bold; transition: color 0.2s ease; }
.blogroll-table .col-name a:hover { text-decoration: underline; }

/* =========================================
   11. XP 風格 About 頁面 (獨立色系保留原汁原味)
   ========================================= */
.about-container { width: 100%; display: flex; justify-content: center; padding: 2rem; }
.xp-window {
    width: 100%; max-width: 600px;
    background: #ece9d8; border: 3px solid #0055ea;
    border-top-left-radius: 8px; border-top-right-radius: 8px;
    box-shadow: var(--shadow-lg); font-family: Tahoma, "Segoe UI", sans-serif;
}
.xp-titlebar {
    background: linear-gradient(to bottom, #0058e6 0%, #3a93ff 8%, #288eff 40%, #127dff 88%, #036bfe 100%);
    color: white; padding: 4px 8px; font-weight: bold; display: flex; justify-content: space-between; align-items: center;
    border-top-left-radius: 5px; border-top-right-radius: 5px; text-shadow: 1px 1px #0f1089; letter-spacing: 1px;
}
.xp-controls { display: flex; gap: 2px; }
.xp-btn {
    width: 22px; height: 22px; color: white; font-weight: bold; font-size: 12px;
    border: 1px solid white; border-radius: 3px; display: flex; justify-content: center; align-items: center;
    cursor: pointer; box-shadow: inset -1px -1px 2px rgba(0,0,0,0.3);
}
.xp-btn.minimize, .xp-btn.maximize { background: #288eff; }
.xp-btn.close { background: #e36443; }
.xp-content {
    padding: 2rem; background-color: var(--bg-card); color: var(--text-main);
    border: 2px solid #ece9d8; min-height: 250px; line-height: 1.8;
}

[data-theme="dark"] .xp-window { border-color: #4a4a4a; background: #2b2b2b; }
[data-theme="dark"] .xp-titlebar { background: linear-gradient(to bottom, #5a5a5a 0%, #7a7a7a 8%, #6a6a6a 40%, #4a4a4a 88%, #3a3a3a 100%); text-shadow: 1px 1px #000; }
[data-theme="dark"] .xp-content { border-color: #2b2b2b; }

.xp-separator { margin: 1.5rem 0; border: none; border-top: 2px solid #ece9d8; border-bottom: 2px solid #ffffff; }
[data-theme="dark"] .xp-separator { border-top-color: #2b2b2b; border-bottom-color: #4a4a4a; }

/* 讓 About 頁面 XP 視窗內的段落，也能自動產生空行 */
.xp-content p {
    margin-bottom: 1rem; 
}

.xp-cards-section { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
@media (max-width: 600px) { .xp-cards-section { flex-direction: column; } }
.xp-card-card {
    flex: 1; background: var(--bg-card); border: 1px solid #7f9db9;
    border-radius: 12px; box-shadow: var(--shadow-sm); font-family: Tahoma, "Segoe UI", sans-serif;
}
[data-theme="dark"] .xp-card-card { border-color: #4a4a4a; }
.xp-card-pane { padding: 1rem; }
.xp-card-header {
    display: flex; align-items: center; gap: 0.5rem; padding-bottom: 0.5rem; margin-bottom: 0.5rem;
    border-bottom: 2px dashed #ece9d8; color: #0055ea; font-weight: bold; font-size: 1.1rem;
}
[data-theme="dark"] .xp-card-header { color: var(--text-main); border-bottom-color: #2b2b2b; }
.xp-card-icon { font-size: 1.5rem; }
.xp-card-content-pane { font-size: 0.95rem; line-height: 1.6; color: var(--text-main); }
.xp-long-pane { background: var(--bg-card); border: 1px solid #7f9db9; border-radius: 12px; padding: 1.5rem; box-shadow: var(--shadow-sm); }
[data-theme="dark"] .xp-long-pane { border-color: #4a4a4a; }

/* =========================================
   12. 全域響應式強化 (Mobile RWD)
   ========================================= */
@media (max-width: 768px) {
    /* --- 1. 導覽列 (Header) 優化 --- */
    /* 讓 Logo 與選單區塊並排，選單內斷行並置中形成倒三角平衡 */
    header {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        padding: 1rem 5%;
        gap: 1rem;
    }
    
    .header-left {
        width: auto;
        flex-shrink: 0; /* 防止 Logo 空間被壓縮變形 */
    }
    
    .nav-group {
        width: auto;
        flex: 1; /* 佔據 Logo 右側的所有剩餘空間 */
        margin-left: 0;
        padding-bottom: 0;
        display: flex;
        justify-content: center; /* 讓整個選單區塊置中對齊 */
    }
    
    .nav-group::-webkit-scrollbar { 
        display: none; /* 隱藏醜醜的滾動條，保持莫蘭迪極簡感 */
    }
    
    /* 選單容器：允許內部項目換行，並向中央靠攏 */
    .nav-links {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap; /* 允許選單空間不足時自動換行成雙排 */
        justify-content: center; /* 上下排皆向中央靠攏，形成穩定倒三角 */
        align-items: center;
        gap: 8px 25px; /* 上下間距 8px，左右間距 25px */
        max-width: 400px; /* 限制最大寬度，讓倒三角收斂得更集中 */
    }
    
    .nav-links a {
        white-space: nowrap; /* 確保單一選單文字不會斷行 */
    }

    /* --- 2. 字體與間距 (Typography & Spacing) --- */
    /* 縮小手機版的大標題，避免一個字佔據太多空間 */
    .post-title { font-size: 1.7rem; }
    .code-header h1 { font-size: 1.8rem; }
    
    /* 縮減手機版的左右留白，把空間還給文字 */
    .post-layout-container, 
    .code-page-container, 
    .bookstore-container, 
    .photo-gallery-container {
        padding: 1.5rem 5%;
    }
    
    /* 文章內容區塊在手機版取消多餘的內距 */
    .post-content-area {
        padding: 1.5rem 1rem;
    }

    /* --- 3. 懸浮按鈕微調 --- */
    /* 手機螢幕寸土寸金，讓日月按鈕稍微縮小，並更貼近角落 */
    .theme-toggle-btn {
        width: 40px !important;
        height: 40px !important;
        bottom: 20px !important;
        right: 20px !important;
    }
    .theme-toggle-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* --- 4. 梯腳微調 --- */
    /* 手機版色帶高度縮減 */
    .footer-color-band {
        padding: 2rem 0 !important;
        margin-top: 3rem !important;
    }
}

/* =========================================
   手機版側邊欄抽屜 (Off-canvas Sidebar)
   ========================================= */

/* 1. 電腦版預設隱藏開關與遮罩 */
.sidebar-toggle-btn { display: none; }
.sidebar-overlay { display: none; }

/* 2. 手機版 (小於 850px) 的專屬變形 */
@media (max-width: 850px) {
    /* 顯示開關按鈕，並給它精緻的卡片外觀 */
    .sidebar-toggle-btn {
        display: inline-flex;
        align-items: center;
        background-color: var(--bg-card);
        color: var(--primary);
        border: 1px solid var(--border-color);
        padding: 10px 18px;
        border-radius: 8px;
        font-size: 1.05rem;
        font-weight: bold;
        cursor: pointer;
        margin-bottom: 1.5rem;
        box-shadow: var(--shadow-sm);
        transition: all 0.2s ease;
        align-self: flex-start; /* 讓按鈕靠左，不會撐滿整行 */
    }
    .sidebar-toggle-btn:active {
        transform: scale(0.96); /* 點擊時微縮的物理回饋 */
    }

    /* 將側邊欄改造成「左側滑出抽屜」 */
    .post-sidebar {
        position: fixed;
        top: 0;
        left: -320px; /* 初始狀態：藏在螢幕左側 320px 的外面 */
        width: 300px;
        height: 100vh;
        background-color: var(--bg-main); /* 使用主底色 */
        z-index: 2000; /* 確保在最上層，蓋過導覽列 */
        padding: 2rem;
        margin: 0;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* 絲滑的進場動畫 */
    }

    /* 抽屜打開時的狀態 */
    .post-sidebar.active {
        left: 0;
    }

    /* 黑色半透明遮罩 */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0; left: 0;
        width: 100vw; height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1999; /* 墊在側邊欄下面，其他東西上面 */
        opacity: 0;
        pointer-events: none; /* 隱藏時不可點擊 */
        transition: opacity 0.3s ease;
    }

    /* 遮罩出現時的狀態 */
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto; /* 出現時可以點擊 */
    }
}

