/*
Theme Name: My File Theme
*/

:root {
    /* Light Mode (Default) */
    --base-bg: #f6f8fa; /* アプリケーションライクな淡いグレー */
    --surface-bg: #ffffff;
    --tab-active-bg: #FFFFFF;
    --tab-inactive-bg: #f6f8fa;
    --border-color: #d0d7de; /* 目立ちすぎない境界線 */
    --text-main: #24292f; /* 純黒ではない読みやすいダークグレー */
    --text-sub: #57606a; /* コントラストを確保したサブテキスト */
    --accent-color: #0969da; /* 信頼感のあるブルー */
    --content-text: #24292f;
    --guide-line-color: #d8dee4;
    --hover-bg: #f3f4f6;
    --active-bg: #f1f8ff; /* 非常に淡いブルーの背景 */
    
    /* Scrollbar Colors (Light) */
    --scrollbar-thumb: #d0d7de;
    --scrollbar-thumb-hover: #afb8c1;

    --radius: 6px;
    /* 指定: パネル表現（影・ハイライト） */
    --shadow-panel: 0 1px 3px rgba(31, 35, 40, 0.12), 0 8px 24px rgba(66, 74, 83, 0.12);
    --highlight-inner: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    
    --btn-gradient: linear-gradient(to bottom, #f6f8fa, #ebecf0);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Roboto Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* Dark Mode Override */
body.dark-mode {
    --base-bg: #0d1117; /* 深いグレー（純黒回避） */
    --surface-bg: #161b22; /* ベースよりわずかに明るい */
    --tab-active-bg: #161B22;
    --border-color: #30363d; /* コントラストを抑えた境界線 */
    --text-main: #c9d1d9; /* オフホワイト */
    --text-sub: #8b949e; /* 落ち着いたグレー */
    --accent-color: #58a6ff; /* 視認性の高い明るいブルー */
    --content-text: #c9d1d9;
    --guide-line-color: #21262d;
    --hover-bg: rgba(110, 118, 129, 0.1);
    --active-bg: rgba(56, 139, 253, 0.1); /* 透明度を使った馴染む選択色 */
    
    /* Scrollbar Colors (Dark) */
    --scrollbar-thumb: #484f58;
    --scrollbar-thumb-hover: #6e7681;

    --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.5);
    --highlight-inner: inset 0 1px 0 rgba(255, 255, 255, 0.03);

    --btn-gradient: linear-gradient(to bottom, #21262d, #161b22);
}

/* Custom Scrollbar for Technical Feel */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 0;
}
/* Show scrollbar on hover over the scrollable element */
.tree-nav:hover::-webkit-scrollbar-thumb,
.pane-content:hover::-webkit-scrollbar-thumb,
.explorer-path-bar:hover::-webkit-scrollbar-thumb,
.pane-tabs:hover::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
}

body {
    background-color: var(--base-bg);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    height: 100vh; /* Fixed height for app-like feel */
    overflow: hidden; /* Prevent body scroll */
    display: flex;
    flex-direction: column;
    font-size: 13px; /* Revert to safe default, specific elements will override */
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

.site-container {
    display: flex;
    flex-grow: 1;
    height: 100%;
    overflow: hidden;
}

/* --- Sidebar --- */
.file-system-sidebar {
    width: 300px;
    min-width: 280px;
    background-color: var(--surface-bg);
    border-right: 1px solid var(--border-color); /* 外枠 */
    box-shadow: var(--shadow-panel), var(--highlight-inner); /* 内側ハイライト＋影 */
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    user-select: none; /* テキスト選択を防ぐ */
    z-index: 2; /* Ensure shadow sits above content if needed */
}

.sidebar-header {
    padding: 12px 20px;
    font-size: var(--fs-meta);
    letter-spacing: 1.5px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out title and toggle switch */
    font-family: var(--font-mono);
}

.sidebar-header-link {
    color: inherit;
    text-decoration: none;
    display: block;
    width: 100%;
}
.sidebar-header-link:hover {
    color: var(--accent-color);
}

/* --- Capsule Toggle Switch --- */
.theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--base-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: border-color 0.3s ease;
    overflow: hidden;
}

.theme-toggle-thumb {
    width: 18px;
    height: 18px;
    background-color: var(--text-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    color: var(--base-bg); /* Icon color (inverse of thumb) */
}

.theme-toggle .icon {
    width: 12px;
    height: 12px;
    margin: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Default (Light Mode) Icon State */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }

/* Dark Mode State */
body.dark-mode .theme-toggle-thumb {
    transform: translateX(20px);
    background-color: var(--accent-color);
    color: #fff;
}

body.dark-mode .theme-toggle .icon-sun { display: none; }
body.dark-mode .theme-toggle .icon-moon { display: block; }

.sidebar-section {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section-title {
    font-size: var(--fs-meta);
    font-weight: 700;
    color: var(--text-sub);
    font-family: var(--font-mono);
    margin-bottom: 5px;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-link {
    display: block;
    padding: 5px 0;
    color: var(--text-main);
    font-size: var(--fs-ui);
    font-family: var(--font-mono);
    text-decoration: none;
}

.sidebar-link:hover {
    color: var(--accent-color);
}

.tree-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* --- File Tree --- */
.file-tree-root,
.sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* アイテム共通スタイル */
.tree-item a,
.folder-label {
    display: flex;
    align-items: center;
    padding: 8px 12px; /* 行間を広めに調整 */
    margin: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    /* white-space: nowrap; Removed to allow flex layout adjustments if needed, but usually kept for tree */
    font-size: 13px;
    border-left: none; /* Remove old marker */
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* ホバー効果 */
.tree-item a:hover,
.folder-label:hover {
    background-color: var(--hover-bg);
    /* グラデーション削除：ホバーはシンプルに */
}

/* アクティブ（現在開いているページ） */
.tree-item.current-menu-item > a,
.tree-item.current-menu-ancestor > .folder-label {
    background-color: var(--active-bg);
    color: var(--text-main); /* テキスト色は維持しつつ背景で強調 */
    font-weight: 500;
    border: 1px solid transparent; /* ボーダーを目立たせず背景色で表現 */
}

/* 階層構造（インデントとガイドライン） */
.sub-menu {
    margin-left: 22px; /* インデント幅 */
    border-left: 1px solid var(--guide-line-color); /* 縦線 */
    display: none; /* Hide by default */
}

.folder-item.is-open > .sub-menu {
    display: block; /* Show when open */
}

/* アイコン */
.icon {
    margin-right: 6px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* 矢印（Chevron） */
.toggle-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-right: 2px;
    flex-shrink: 0;
    opacity: 0.8;
}

.toggle-arrow::before {
    content: '>';
    font-size: 10px;
    font-weight: bold;
    transition: transform 0.15s ease-in-out;
}

.folder-item.is-open > .folder-label .toggle-arrow::before {
    transform: rotate(90deg);
}

/* トップレベル（Type, Topicなど）の特別スタイル */
.file-tree-root > .tree-item > .folder-label {
    font-weight: 600;
    color: var(--text-sub);
    padding-top: 10px;
    padding-bottom: 10px;
}

/* フォルダ名のテキスト */
.folder-text {
    color: var(--text-main);
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}
.folder-text:hover {
    color: var(--accent-color);
}

/* --- Main Content --- */
.site-main {
    flex-grow: 1;
    /* padding is now handled by individual panes or content wrappers */
    /* scrolling is now handled by individual panes */
    display: flex; /* Enable flexbox for multi-pane layout */
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.entry-title {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.entry-content {
    line-height: 1.7;
}

/* --- Multi-Pane Layout --- */
.pane-container {
    display: flex;
    flex-grow: 1;
    height: 100%;
    overflow: hidden;
}

/* 単一ペインモードでは、ペインは常にコンテナ全体を占める */
.single-pane-mode .pane {
    width: 100%;
    height: 100%; /* コンテナ全体を専有 */
    min-height: 0;
    border: none; /* 境界線も不要 */
    box-shadow: none;
}

.mobile-tab-bar {
    display: none; /* Hide on desktop by default */
}

.pane {
    /* flex: 1; */ /* Gridで制御するため不要に */
    min-width: 360px; /* 最小可読幅 (CSS Gridのminmaxと合わせる) */
    display: flex;
    flex-direction: column;
    height: auto; /* 高さをコンテンツに合わせる */
    min-height: 600px; /* 折り返した際の最低限の高さを確保 */
    background-color: var(--surface-bg); /* Panes are white/surface */
    position: relative;
    border-left: 1px solid var(--border-color);
    overflow: hidden; /* Ensure elements don't overflow the pane */
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.pane {
    /* ... existing styles ... */
    transition: opacity 0.2s ease-in-out, outline-color 0.2s ease;
    will-change: opacity;
}

/* New Tab-like Header */
.pane-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: var(--surface-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 40px;
    box-sizing: border-box;
}

.pane-path {
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    white-space: nowrap;
    margin-right: auto; /* Push controls to the right, making them wrap first */
}

.pane-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-view-controls {
    background-color: transparent;
    /* ボタン自体に枠をつけるのでコンテナの枠は削除 */
    border: none;
    padding: 1px;
    display: flex;
    gap: 2px;
}

.pane-view-btn {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    opacity: 0.6;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
    background: none;
}
.pane-view-btn.active {
    background-image: var(--btn-gradient);
    border-color: var(--border-color);
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    color: var(--accent-color);
    opacity: 1;
}

.pane-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    padding: 0 4px;
    min-width: 20px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background-color 0.15s;
    border: 1px solid transparent; /* 枠のスペース確保 */
}

.pane-btn .icon {
    margin-right: 0; /* ボタン内のアイコンはマージン不要 */
    opacity: 0.7;
}

.pane-btn:hover {
    color: var(--text-main);
    background-image: var(--btn-gradient);
    border-color: var(--border-color);
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    /* filter: brightness(1.02); Removed to prevent harsh jumps */
}

.pane-btn.is-pinned {
    color: var(--accent-color) !important;
}

.pane-btn:hover .icon,
.pane-btn.is-pinned .icon {
    opacity: 1;
}

.pane-content {
    flex-grow: 1;
    height: 0; /* Force flex child to respect parent height */
    overflow-y: auto;
    position: relative; /* For skeleton loading overlay */
    scroll-behavior: smooth;
}

.pane-content.is-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pane-content.is-loading .explorer-view.is-skeleton {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.15s ease;
    width: 100%;
}

.skeleton-item .col-name span,
.skeleton-item .col-date span,
.skeleton-item .col-type span {
    background-color: var(--surface-bg);
    display: block;
    height: 1em;
    border-radius: 4px;
    width: 80%;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.6; }
    100% { opacity: 0.3; }
}

.pane-loading-indicator {
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    color: var(--text-sub);
    text-align: center;
    padding: 20px;
}

/* --- Placeholder for empty state --- */
.pane-placeholder {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    font-family: var(--font-mono);
    user-select: none;
    width: 100%;
}

.pane-placeholder p {
    margin-top: 20px;
    font-size: 14px;
}

/* --- Explorer View (Archive) --- */
.explorer-main {
    padding: 0;
    font-family: var(--font-main);
}

.explorer-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-bg); /* Remove blur for cleaner look */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
}
.explorer-path-bar {
    font-size: var(--fs-meta);
    color: var(--text-sub);
}

.path-label {
    color: var(--text-sub);
    margin-right: 10px;
    font-weight: bold;
}

.path-root {
    color: var(--text-sub);
    text-decoration: none;
}
.path-root:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.path-separator {
    color: var(--text-sub);
    margin: 0 5px;
}

/* View Toggle Buttons */
.view-controls {
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 8px;
    display: flex;
    gap: 0;
}

.view-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--text-main);
}

.view-btn.active {
    background-color: var(--base-bg);
    color: var(--accent-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-weight: bold;
}

.explorer-view {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    position: relative;
}
.explorer-row {
    display: grid;
    /* 列幅を固定してレイアウトの崩れを防ぐ */
    grid-template-columns: 40px minmax(0, 1fr) minmax(0, 140px) minmax(0, 80px); /* Icon, Name, Date, Type */
    align-items: center;
    padding: 10px 16px; /* 行間を広げてモダンに */
    color: var(--text-main);
    font-family: var(--font-main); /* Use UI font for list */
    font-size: 13px;
    border-bottom: 1px solid var(--guide-line-color); /* 薄い区切り線 */
    transition: background-color 0.1s ease;
}

.header-row {
    font-weight: bold;
    color: var(--text-sub);
    background-color: var(--base-bg);
    text-transform: uppercase;
    font-size: var(--fs-meta);
    letter-spacing: 1.5px;
    border-bottom: 1px solid var(--guide-line-color);
}

/* Hide header row in file view */
.pane[data-view-type="file"] .header-row {
    display: none;
}

.explorer-row:not(.header-row):hover {
    background-color: var(--hover-bg);
    cursor: pointer;
}

/* Recent Post Indicator (Green Dot) */
.recent-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #2ea043; /* GitHub Green */
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 4px #2ea043;
}
.col-name {
    display: flex;
    align-items: center;
}

.col-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}


.col-icon {
    width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.col-icon img.file-thumb-img {

    width: 24px;
    height: 24px;
    object-fit: cover;
} 

/* This class is now deprecated as we use JS for clicks */
.card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

.col-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    padding-right: 10px;
    padding-left: 10px; /* テキストの左側の余白を調整 */
}

.name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-count {
    color: var(--text-sub);
    font-size: var(--fs-meta);
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 1em;
    padding: 1px 6px;
    font-family: var(--font-mono);
    flex-shrink: 0; /* Prevent count from shrinking */
    margin-left: 8px;
}

.col-date, .col-type {
    font-family: var(--font-mono); /* Keep metadata mono */
    font-size: var(--fs-meta);
}

.col-name a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.col-date, .col-type {
    color: var(--text-sub);
    font-size: var(--fs-meta);
    display: block; /* Use block to allow ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-date span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Accordion Post Details (List View) --- */
.explorer-item {
    border-top: none; /* Remove border as requested */
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    position: relative; /* Required for absolute positioning of details */

}

/* Focused/Selected item style */
.explorer-item.is-focused {
    background-color: var(--active-bg); /* 淡い帯ハイライト */
    outline: none;
    position: relative;
    z-index: 10;
    border: 1px solid transparent; /* ボーダーではなく背景色で表現 */
}

/* Details container */
.post-details {
    /* Revert to max-height animation to display between items */
    background-color: rgba(0, 0, 0, 0.2); /* Slightly darker */
    border: 1px solid var(--guide-line-color);
    max-height: 0;
    overflow: hidden;

    transition: max-height 0.4s ease-in-out;
    box-sizing: border-box;
}

.explorer-item.is-open .post-details {
    border-top: none; /* Border handled by container */
}

.explorer-item.mode-full-content .post-details {
    max-height: unset;
    overflow: visible;
    border-top: none;
}

.details-content-wrapper {
    /* This wrapper controls the inner spacing, making height calculation more reliable */
    padding: 20px 0;
    margin-left: 60px;
    margin-right: 10%;
    box-sizing: border-box;

}

.detail-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
    font-size: var(--fs-ui);
}

.detail-label {
    font-family: var(--font-mono);
    color: var(--text-sub);
    min-width: 80px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.detail-value {
    color: var(--text-main);
}

.detail-value .topic-label {
    display: inline-block;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 1em;
    padding: 3px 10px;
    margin-right: 8px;
    font-size: var(--fs-meta);
    text-decoration: none;
    color: var(--text-sub);
    transition: all 0.2s;
}

.detail-value .topic-label:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.read-button {
    display: block;
    width: 100%;
    text-align: center;
    padding: 6px;
    margin-top: 15px;
    border: 1px solid var(--text-sub);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-main);
    background-image: var(--btn-gradient);
    border: 1px solid var(--border-color);
    transition: background-color 0.15s, color 0.15s;
}

.read-button:hover {
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    color: var(--accent-color);
}

/* --- Prose Content Styles (for full-content and single posts) --- */
.prose-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--content-text);
    letter-spacing: 0.01em;
    max-width: 100%; /* Let parent handle width */
    margin: 0;
    padding: 0;
}

.prose-content p {
    margin-top: 0;
    margin-bottom: 1.5em;
}

.prose-content img {
    display: block;
    max-width: 100%;
    width: 100%;
    margin-left: 0;
    margin: 40px 0;
    height: auto;
    border-radius: var(--radius);
}

.wp-caption-text {
    font-size: var(--fs-meta);
    color: var(--text-sub);
    text-align: center;
    margin-top: -30px;
    margin-bottom: 40px;
    font-family: var(--font-mono);
}

/* --- Document View (in list) --- */
.document-item {
    display: grid;
    grid-template-columns: 60px 1fr; /* Gutter width reduced */
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--guide-line-color);
    margin-bottom: 20px;
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden; /* Keep rounded corners */
    box-shadow: 0 1px 3px rgba(0,0,0,0.03); /* 微細な影 */
}

.document-meta {
    /* Gutter style */
    border-right: 1px solid var(--border-color);
    background-color: var(--surface-bg);
    text-align: right;
    padding: 20px 10px 20px 0;
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    color: var(--text-sub);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* List View (Archives/Category) - Content Width & Alignment */
/* Ensure block is centered but text is left-aligned */
.view-list .document-body {
    max-width: 880px; /* Optimal reading width */
    margin-left: auto;
    margin-right: auto;
    width: 100%; /* Ensure it takes space to center within */
    text-align: left; /* Ensure text remains left-aligned */
}

.document-body {
    padding: 30px;
    max-width: 100%;
}

/* --- Single Post Specific Styles --- */
/* Scoped to .single-post-container to avoid breaking lists/galleries */

.single-post-container .document-body {
    max-width: 72ch;
    margin: 0 auto; /* Center the entire block */
    padding: 30px 24px; /* Consistent padding */
}

.single-post-container .document-title {
    font-size: 24px !important; /* Ensure 24px */
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 25px 0;
    padding: 0;
    line-height: 1.3;
    text-align: left;
}

.document-title a {
    color: inherit;
    text-decoration: none;
}

.document-title a:hover {
    color: var(--accent-color);
}

/* Status Bar */
.status-bar {
    margin-top: 40px;
    padding: 5px 10px;
    background-color: var(--surface-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-sub);
    font-size: var(--fs-meta);
    font-family: var(--font-mono);
    display: flex;
    gap: 20px;
    flex-wrap: wrap; /* Allow stacking on small screens */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-bar span {
    display: inline-block;
}


.single .entry-header {
    max-width: 720px;
    margin: 0 auto 40px auto;
}

.single .entry-title {
    font-size: 40px;
    line-height: 1.2;
    color: var(--text-main);
    padding: 0;
    margin: 0;
    border: none;
}

.single .entry-content {
    /* This becomes the prose container */
    margin: 0 auto;
}

/* --- Gallery View Styles --- */
body:not(.single) .view-gallery .explorer-row {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    border: 1px solid transparent; /* Start with transparent border */
    border-radius: 0;
    padding: 10px;
    background-color: var(--surface-bg);
    text-align: center; /* Center text */
    position: relative; /* For hover effect */
    min-height: 220px;
    pointer-events: auto; /* Ensure clickable */
    cursor: pointer;
}

body:not(.single) .view-gallery .explorer-row:hover {
    transform: none; /* 浮き上がりエフェクト削除（フラットに） */

    border-color: var(--border-color); /* Highlight border */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

body:not(.single) .view-gallery .explorer-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 18vw, 220px), 1fr));
    gap: 20px;
    padding: 20px;
}

/* Ensure items stretch to fill grid cells */
body:not(.single) .view-gallery .explorer-item {
    height: 100%;
}

body:not(.single) .view-gallery .header-row {
    display: none;
}


body:not(.single) .view-gallery .col-icon {
    width: 100%;
    /* 16:9 Aspect Ratio for the image container */
    aspect-ratio: 16 / 10;
    margin-bottom: 15px;
    background-color: var(--base-bg);
    display: flex;

    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

body:not(.single) .view-gallery .col-icon img.file-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body:not(.single) .view-gallery .col-icon .icon {
    width: 48px; /* Larger icon for files without thumbnails */
    height: 48px;
    color: var(--text-sub);
}

body:not(.single) .view-gallery .col-name {

    width: 100%; /* Take full width */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal; /* Allow text to wrap */
    font-size: 13px;
    font-weight: bold;
    line-height: 1.4;
    margin-bottom: 5px; /* Space between title and potential excerpt */

}

body:not(.single) .view-gallery .file-excerpt .detail-value {
    white-space: normal;
}

body:not(.single) .view-gallery .col-date,
body:not(.single) .view-gallery .col-type {
    display: none; /* Hide date and type in gallery view */
}

/* For folder rows in gallery view */
body:not(.single) .view-gallery .folder-row .col-icon {
    background-color: transparent; /* No background for folder icon */
}
body:not(.single) .view-gallery .folder-row .col-icon .icon-folder {
    width: 64px; /* Larger folder icon */
    height: 64px;
    color: var(--accent-color);
}
body:not(.single) .view-gallery .folder-row .col-name {
    color: var(--text-main);
}

/* --- Document Item in Gallery View --- */
/* Force document items to look like cards in gallery view */
body:not(.single) .view-gallery .document-item {
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
    border-radius: 4px;    background-color: var(--surface-bg);
    padding: 15px;
    margin-bottom: 0;
    height: 100%;
    box-sizing: border-box;
    transition: transform 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

body:not(.single) .view-gallery .document-item:hover {
    transform: none;
    border-color: var(--border-color);
}

body:not(.single) .view-gallery .document-meta,
body:not(.single) .view-gallery .status-bar {
    display: none; /* Hide gutter and status bar in gallery */
}

body:not(.single) .view-gallery .document-body {
    padding: 0;
    max-width: 100%;
}

body:not(.single) .view-gallery .document-title {
    font-size: var(--fs-ui);
    font-weight: bold;
    margin: 0 0 10px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

body:not(.single) .view-gallery .prose-content {
    font-size: 13px;
    margin-top: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 8; /* Show only first few lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.collapse-branch-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    margin-right: 8px;
    line-height: 1;
    transition: color 0.2s ease-in-out;
    flex-shrink: 0;
}

.collapse-branch-btn:hover {
    color: var(--text-main);
}

/* --- Status Bar (Fixed Bottom) --- */
.status-bar-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 22px;
    background-color: var(--accent-color);
    color: #fff; /* Contrast text */
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    z-index: 1000;
    user-select: none;
    transition: background-color 0.2s;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Single Post/Page Layout (for independent scrolling) --- */
.pane[data-view-type="file"] .pane-content {
    overflow-y: auto; /* Enable scrolling for the pane content wrapper */
    display: block; /* Ensure block layout for vertical stacking */
}

.single-post-container {
    display: flex;
    flex-direction: column; /* Stack vertically */
    height: auto; /* Let content define height */
    width: 100%;
    min-height: 100%; /* Ensure it fills at least the pane height */
}

/* The main article content should scroll */
.single-post-container > .explorer-main {
    flex: none; /* Don't flex, just take natural height */
    width: 100%;
    overflow: visible; /* Allow content to flow */
}

/* The metadata sidebar should also scroll independently */
.single-post-container > .post-metadata-sidebar {
    width: 100%; /* Full width */
    max-width: none;
    flex-shrink: 0;
    height: auto;
    overflow: visible;
    border-left: none;
    border-top: 1px solid var(--guide-line-color); /* Separator line */
    box-sizing: border-box;
    background-color: transparent;
    padding-bottom: 80px; /* Extra padding at bottom */
}

/* Sticky is no longer needed as the whole sidebar scrolls now */
.single-post-container .metadata-sticky-wrapper {
    position: static;
    padding: 30px; /* Match document-body padding */
}

/* Hide INFO section for inactive panes or when collapsed */
.pane:not(.is-active) .post-metadata-sidebar {
    /* display: none;  - Removed to keep layout consistent even if inactive */
}

/* 2-Column Layout for Metadata Items */
.metadata-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 30px;
}
.metadata-content .metadata-item {
    margin-bottom: 0;
}

/* --- ADDED FOR TABLET BREAKPOINT --- */
/* タブレット幅でプロパティ表示が崩れるのを防ぐため、1カラムレイアウトに切り替え */
@media (min-width: 769px) and (max-width: 1024px) {
    .metadata-content {
        grid-template-columns: 1fr;
        gap: 8px 20px; /* ギャップを少し調整 */
    }
}
/* --- END ADDED --- */

/* System Properties Style Metadata */
.metadata-sticky-wrapper {
    font-family: var(--font-mono);
    font-size: var(--fs-meta);
    background-color: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
}
.metadata-header {
    color: var(--text-sub);
    margin-bottom: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--guide-line-color);
    padding-bottom: 8px;
    opacity: 0.8;
}
.metadata-footer {
    color: var(--text-sub);
    margin-top: 15px;
    opacity: 0.5;
}
.metadata-item {
    display: flex;
    margin-bottom: 8px;
    line-height: 1.4;
}
.metadata-label {
    color: var(--text-sub);
    width: 90px;
    flex-shrink: 0;
    white-space: pre;
}
.metadata-value {
    color: var(--text-main);
    flex-grow: 1;
    word-break: break-all;
}
.meta-action-link {
    color: inherit;
    text-decoration: none;
    margin-right: 10px;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}
.meta-action-link:hover {
    color: var(--accent-color);
}


/* --- Single Post/Page Layout Fix --- */
/* .document-item is used in archives and single views. Remove list-like styles for single views. */
.single .document-item,
.page .document-item {
    border-bottom: none;
    margin-bottom: 0;
}

/* --- Responsive & Mobile --- */

/* Hamburger Menu Button */
.hamburger-menu {
    display: none; /* Hidden on desktop */
    position: fixed;
    top: 10px;
    left: 15px;
    z-index: 1001;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.hamburger-menu:hover {
    background-color: var(--accent-color);
    color: white;
}
.hamburger-menu .icon-close { display: none; }
.hamburger-menu .icon-menu { display: block; }

body.sidebar-open .hamburger-menu .icon-close { display: block; }
body.sidebar-open .hamburger-menu .icon-menu { display: none; }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

body.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    /* --- 1. Navigation & Layout --- */

    .hamburger-menu {
        display: block;
    }

    .file-system-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.25s ease-in-out;
        border-right: 1px solid var(--border-color);
        width: 300px; /* Ensure width is set for drawer */
    }

    body.sidebar-open .file-system-sidebar {
        transform: translateX(0);
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }

    /* Dashboard specific mobile styles */
    .dashboard-container .pane {
        min-width: 0; /* Allow shrinking on mobile */
    }

    .mobile-tab-bar {
        display: flex;
        display: none; /* タブバー自体を非表示 */
    }

    .pane-container {
        display: flex; /* 単一ペインをflexで表示 */
        flex-grow: 1;
    }

    .pane {
        display: flex !important; /* 常に単一ペインを表示 */
        height: 100%; /* Fill remaining space */
    }
    
    /* モバイルでもコントロールバーは表示するが、パスは省略してもよい */
    .pane-path {
        display: none;
    }
    
    .pane-placeholder {
        padding: 0 20px;
        text-align: center;
    }
    .site-main {
        padding: 0; /* Remove default padding for mobile */
    }

    .explorer-header {
        position: sticky;
        top: 0;
        z-index: 100;
        display: none; /* Hide old header on mobile */
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding-left: 70px; /* Space for hamburger menu */
        background-color: rgba(29, 29, 31, 0.95); /* More opaque on mobile */
    }

    .explorer-path-bar {
        overflow-x: auto;
        white-space: nowrap;
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }
    .explorer-path-bar::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    /* --- 2. List View Optimization --- */

    .header-row {
        display: none; /* Hide header row on mobile */
    }

    .explorer-row {
        display: block;
        padding: 10px 20px;
        position: relative;
        min-height: 44px;
        pointer-events: auto;
        box-sizing: border-box;
    }
    .explorer-row:active {
        background-color: rgba(47, 129, 247, 0.2);
    }

    .explorer-row .col-icon {
        display: none;
    }
    .explorer-row .col-name {
        display: block;
        padding-left: 0;
        font-size: 14px;
    }
    .explorer-row .col-name .name-text {
        font-size: 15px;
    }

    .explorer-row .col-date,
    .explorer-row .col-type {
        display: inline-flex; /* Use inline-flex to align items horizontally */
        font-family: var(--font-mono);
        align-items: center;
        font-size: var(--fs-meta);
        color: var(--text-sub);
        margin-top: 4px;
    }

    /* --- 3. Gallery & Full Content --- */

    body:not(.single) .view-gallery .explorer-body {
        grid-template-columns: 1fr 1fr; /* Force 2 columns */
        gap: 12px;
        padding: 12px;
    }

    body:not(.single) .view-gallery .explorer-row {
        padding: 10px;
        background: none;
        border: none;
        min-height: auto;
    }

    body:not(.single) .view-gallery .explorer-row:hover {
        transform: none;
        background: none;
    }

    body:not(.single) .view-gallery .col-icon {
        aspect-ratio: 1 / 1; /* Square layout for photos */
        padding-top: 0;
        margin-bottom: 8px;
        border: none;
        border-radius: 12px;
        background-color: var(--surface-bg);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    body:not(.single) .view-gallery .col-icon img.file-thumb-img {
        border-radius: 12px;
    }

    body:not(.single) .view-gallery .col-icon .icon {
        width: 32px;
        height: 32px;
    }

    body:not(.single) .view-gallery .folder-row .col-icon .icon-folder {
        width: 40px;
        height: 40px;
    }

    body:not(.single) .view-gallery .col-name {
        font-size: var(--fs-meta);
        text-align: center;
        padding: 0 4px;
        font-weight: normal;
        color: var(--text-main);
    }
    
    /* Document items in mobile gallery */
    body:not(.single) .view-gallery .document-item {
        padding: 10px;
        aspect-ratio: 1 / 1;
        justify-content: center;
        align-items: center;
        text-align: center;
        background-color: var(--surface-bg);
        border-radius: 12px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    body:not(.single) .view-gallery .document-title {
        font-size: var(--fs-meta);
        margin: 0;
        white-space: normal;
        text-align: center;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    body:not(.single) .view-gallery .prose-content {
        display: none; /* Hide text preview on mobile for cleaner grid */
    }

    @media (max-width: 480px) {
        body:not(.single) .view-gallery .explorer-body {
            grid-template-columns: 1fr 1fr; /* Keep 2 columns even on small screens */
        }
    }

    .document-body {
        padding: 20px; /* Adjust padding for mobile */
    }

    .prose-content {
        font-size: 15px !important;
        line-height: 1.8 !important;
        padding: 0;
    }
    
    .prose-content img {
        max-width: 100%;
        height: auto;
    }

    .document-body {
        padding: 20px 0; /* Adjust padding for mobile */
        max-width: 100%;
    }

    .document-item {
        grid-template-columns: 40px 1fr; /* Reduce gutter width */
    }

    .document-meta {
        padding: 20px 5px 20px 0; /* Reduce padding */
        font-size: 10px;
    }

    .prose-content img {
        max-width: calc(100% + 40px);
        width: calc(100% + 40px);
        margin-left: -20px;
        border-radius: 0; /* Sharp edges for full width */
    }

    /* System Components Optimization */
    .status-bar {
        margin-top: 30px;
        font-size: 10px;
        padding: 8px 0;
        border-top: 1px solid var(--guide-line-color);
        background-color: transparent;
        gap: 15px;
    }
    
    /* --- 4. Single Post Page --- */
    .single-post-container {
        flex-direction: column;
        height: auto; /* Let content define height */
        gap: 0;
    }
    .single-post-container > .explorer-main,
    .single-post-container > .post-metadata-sidebar {
        overflow-y: visible; /* Disable independent scrolling */
        height: auto;
        border-left: none;
    }
    .post-metadata-sidebar {
        /* order: 3; Already at bottom in DOM */
        padding: 0;
        border-top: 1px solid var(--guide-line-color);
        margin-top: 0;
        width: 100%;
    }
    
    .metadata-sticky-wrapper {
        padding: 20px;
    }
    
    .metadata-content {
        grid-template-columns: 1fr; /* Single column for metadata on mobile */
        gap: 5px;
    }
    
    .metadata-label {
        width: 70px; /* Compact label width */
    }

}

/* --- Quick Look Image Viewer --- */
.quick-look-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.1s ease-out;
    cursor: zoom-out;
}

.quick-look-overlay.is-visible {
    opacity: 1;
}

.quick-look-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.tabs-overflow-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-panel);
    z-index: 102;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.tabs-overflow-dropdown .pane-tab {
    width: 100%;
    border-bottom: 1px solid var(--guide-line-color);
}
.tabs-overflow-dropdown .pane-tab:last-child {
    border-bottom: none;
}