:root {
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a1a;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;
    --border-color: #dee2e6;
    --accent-color: #5b21b6;
    --accent-hover: #4c1d95;
    --code-bg: #f1f3f5;
    --code-border: #e9ecef;
    --sidebar-bg: #f8f9fa;
    --header-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

body.dark-mode {
    /* Dark Mode Colors - Obsidian inspired */
    --bg-primary: #1e1e1e;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --text-primary: #dcddde;
    --text-secondary: #b9bbbe;
    --text-tertiary: #72767d;
    --border-color: #3a3a3a;
    --accent-color: #6d28d9;
    --accent-hover: #7c3aed;
    --code-bg: #1a1a1a;
    --code-border: #2d2d2d;
    --sidebar-bg: #202020;
    --header-bg: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Logo Styles */
.logo {
    font-family: 'Orbitron', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    transition: opacity 0.3s ease;
}

.logo:hover {
    opacity: 0.8;
}

.logo-main {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

.logo-text {
    color: var(--text-primary);
}

.logo-suffix {
    color: #ff20ca;
}

.logo-subtitle {
    font-size: 0.7rem;
    font-weight: 400;
    font-family: 'Noto Sans JP', sans-serif;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #5b21b6 0%, #ff20ca 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding-left: 0.1rem;
}

body.dark-mode .logo-text {
    color: #ffffff;
}

body.dark-mode .logo-subtitle {
    background: linear-gradient(135deg, #7c3aed 0%, #ff20ca 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 1;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.header-title:hover {
    transform: scale(1.05);
}

.header-title:hover i {
    transform: rotate(10deg);
    color: var(--accent-hover);
}

.header-title .title-main {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--accent-color);
    transition: all 0.3s ease;
}

body.dark-mode .header-title .title-main {
    color: var(--accent-color);
}

.header-title i {
    color: var(--accent-color);
    transition: all 0.3s ease;
}

/* Buttons */
.btn-icon, .btn-icon-small {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    font-size: 18px;
    width: 40px;
    height: 40px;
}

.btn-icon-small {
    font-size: 14px;
    width: 32px;
    height: 32px;
}

.btn-icon:hover, .btn-icon-small:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Toggle sidebar button - only active in toc-mode */
#toggleSidebar {
    transition: opacity 0.3s ease;
}

#toggleSidebar:not(.active) {
    opacity: 0.3;
    cursor: default;
}

#toggleSidebar.active:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Back button in header center */
.btn-back-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 6px;
}

.btn-back-header.show {
    display: flex;
}

.btn-back-header:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

/* Container */
.container {
    display: flex;
    margin-top: 60px;
    height: calc(100vh - 60px);
    position: relative;
}



/* Sidebar */
.sidebar {
    width: auto;
    min-width: 280px;
    max-width: 400px;  /* 600px -> 400px に変更 */
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    overflow: hidden;
}

.sidebar.collapsed .toc-title-text {
    display: none;
}

.sidebar.collapsed .toc {
    display: none;
}

.sidebar.file-list-mode {
    width: fit-content;
}

.sidebar.toc-mode {
    width: 280px;
    min-width: 280px;
}

/* Sidebar content animations */
.sidebar-content-wrapper {
    animation: slideInFromLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-content-wrapper.slide-out {
    animation: slideOutToLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: var(--sidebar-bg);
    z-index: 10;
}

/* Sidebar List Title - for file list mode */
.sidebar-list-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 6px 16px;
}

.sidebar-list-title i {
    font-size: 16px;
    color: var(--text-secondary);
}

/* TOC Toggle Title - acts as toggle button */
.toc-toggle-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    padding: 6px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

.toc-toggle-title:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

.toc-toggle-title i {
    font-size: 18px;
}

.sidebar.collapsed .toc-toggle-title {
    padding: 8px;
    gap: 0;
}

/* Back Button - Sidebar */
.btn-back-sidebar,
.btn-close-sidebar {
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-back-sidebar:hover,
.btn-close-sidebar:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

.btn-back-sidebar span,
.btn-close-sidebar span {
    font-size: 13px;
}

/* Collapse Button - Sidebar */
.btn-collapse-sidebar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-collapse-sidebar:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

/* Back Button - iframe header */
.btn-back {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-back:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

/* Table of Contents */
.toc {
    padding: 12px 0;
}

.toc-empty {
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    text-align: center;
}

.toc-item {
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    font-size: 13px;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    cursor: pointer;
    margin-bottom: 4px;
}

.toc-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border-left-color: var(--text-tertiary);
}

.toc-item.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

.toc-item.level-1 { 
    padding-left: 16px; 
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
}
.toc-item.level-2 { 
    padding-left: 32px; 
    font-size: 13px; 
}
.toc-item.level-3 { 
    padding-left: 48px; 
    font-size: 12px; 
}
.toc-item.level-4 { 
    padding-left: 64px; 
    font-size: 12px; 
    color: var(--text-tertiary);
}
.toc-item.level-5 { 
    padding-left: 80px; 
    font-size: 11px; 
    color: var(--text-tertiary);
}
.toc-item.level-6 { 
    padding-left: 96px; 
    font-size: 11px; 
    color: var(--text-tertiary);
}

.toc-item.collapsed {
    display: none;
}

.toc-toggle {
    display: inline-block;
    width: 16px;
    margin-right: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 0;  /* Remove default padding for subheader */
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    min-height: 0;  /* Important for flex scrolling */
}

/* Content Subheader */
.content-subheader {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-back-subheader {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-back-subheader:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.content-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.file-date {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-date::before {
    content: '•';
    color: var(--text-tertiary);
}

/* HTML iframe wrapper */
.html-iframe-wrapper {
    flex: 1;
    display: none;
    width: 100%;
    height: 100%;  /* 明示的に高さを指定 */
    min-height: 0;  /* Important for flex scrolling */
    overflow: hidden;
    background-color: transparent;  /* 透明背景 */
}

.html-content-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;  /* 透明背景を明示 */
    display: block;  /* ブロック要素として表示 */
}

/* Main content area with padding */
.main-content > .welcome-screen,
.main-content > .markdown-body {
    padding: 40px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;  /* Important for flex scrolling */
}

/* Welcome Screen */
.welcome-screen {
    max-width: 600px;
    margin: 80px auto;
    text-align: center;
}

.welcome-icon {
    font-size: 80px;
    color: var(--accent-color);
    margin-bottom: 30px;
}

.welcome-screen h2 {
    font-size: 32px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.welcome-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
    color: var(--accent-color);
}

body.dark-mode .welcome-title {
    color: var(--accent-color);
}

.welcome-subtitle {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.welcome-screen > p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Markdown Body Styles */
.markdown-body {
    width: 100%;
    font-size: 16px;
    line-height: 1.8;
    padding: 20px;
}

/* Reading mode optimizations */
.markdown-body > * {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 48px;
    margin-bottom: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    scroll-margin-top: 80px;
    position: relative;
    letter-spacing: -0.02em;
}

/* Heading hover effect */
.markdown-body h1:hover::before,
.markdown-body h2:hover::before,
.markdown-body h3:hover::before {
    content: '#';
    position: absolute;
    left: -24px;
    color: var(--accent-color);
    opacity: 0.5;
    font-weight: 400;
}

.markdown-body h1 {
    font-size: 2.5em;
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 16px;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 32px;
    color: var(--text-primary);
}
}

.markdown-body h2 {
    font-size: 2em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
    font-weight: 700;
    margin-bottom: 24px;
}

.markdown-body h3 { 
    font-size: 1.5em;
    font-weight: 700;
}

.markdown-body h4 { 
    font-size: 1.25em;
    font-weight: 600;
}

.markdown-body h5 { 
    font-size: 1.1em;
    font-weight: 600;
}

.markdown-body h6 { 
    font-size: 1em;
    color: var(--text-secondary);
    font-weight: 600;
}

.markdown-body p {
    margin-bottom: 20px;
    text-align: justify;
    text-justify: inter-character;
}

/* Optional: Drop cap for first paragraph after h1 */
.markdown-body h1 + p::first-letter {
    font-size: 3.5em;
    font-weight: 700;
    line-height: 0.8;
    float: left;
    margin: 0.1em 0.1em 0 0;
    color: var(--accent-color);
    font-family: 'Playfair Display', Georgia, serif;
}

.markdown-body a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.markdown-body a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.markdown-body a:hover::after {
    width: 100%;
}

.markdown-body a:hover {
    color: var(--accent-hover);
}

/* Obsidian-style internal links */
.markdown-body a.internal-link {
    color: var(--accent-color);
    font-weight: 500;
}

.markdown-body strong {
    font-weight: 700;
    color: var(--text-primary);
}

.markdown-body em {
    font-style: italic;
}

.markdown-body mark,
.markdown-body .highlight {
    background: rgba(124, 58, 237, 0.12);
    padding: 3px 6px;
    border-radius: 4px;
    border-bottom: 2px solid rgba(124, 58, 237, 0.25);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.05);
}

body.dark-mode .markdown-body mark,
body.dark-mode .markdown-body .highlight {
    background: rgba(124, 58, 237, 0.18);
    border-bottom-color: rgba(124, 58, 237, 0.35);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin-bottom: 20px;
    padding-left: 32px;
    line-height: 1.8;
}

.markdown-body li {
    margin-bottom: 12px;
    position: relative;
}

.markdown-body ul > li {
    padding-left: 8px;
}

.markdown-body ul > li::marker {
    color: var(--accent-color);
    font-weight: bold;
}

.markdown-body ol > li::marker {
    color: var(--accent-color);
    font-weight: 600;
}

.markdown-body li > p {
    margin-bottom: 8px;
}

.markdown-body ul ul,
.markdown-body ol ol,
.markdown-body ul ol,
.markdown-body ol ul {
    margin-top: 12px;
    margin-bottom: 12px;
}

/* Task Lists (Obsidian style) */
.markdown-body .task-list-item {
    list-style: none;
    margin-left: -32px;
    padding-left: 32px;
    transition: opacity 0.2s ease;
}

.markdown-body .task-list-item input[type="checkbox"] {
    margin-right: 12px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

.markdown-body .task-list-item input[type="checkbox"]:checked + * {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Blockquotes */
.markdown-body blockquote {
    margin: 24px 0;
    padding: 16px 24px;
    border-left: 4px solid var(--accent-color);
    background: rgba(124, 58, 237, 0.05);
    color: var(--text-primary);
    border-radius: 8px;
    font-style: normal;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
}

body.dark-mode .markdown-body blockquote {
    background: rgba(179, 153, 240, 0.08);
    border-left-color: #b399f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body blockquote code {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(74, 127, 184, 0.4);
}

body.dark-mode .markdown-body blockquote code {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Code */
.markdown-body code {
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    background-color: #2d2d2d;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(74, 127, 184, 0.3);
    color: #e4e9f0;
}

body.dark-mode .markdown-body code {
    background-color: rgba(0, 0, 0, 0.6);
    border-color: rgba(90, 159, 216, 0.4);
}

.markdown-body pre {
    position: relative;
    margin: 20px 0;
    background-color: #1a1a1a !important;  /* Dark gray for light mode */
    border: 1px solid #4d5a6b;  /* Lighter border */
    border-radius: 8px;
    overflow: hidden;
}

body.dark-mode .markdown-body pre {
    background-color: #000000 !important;  /* Pure black in dark mode */
    border: 1px solid #5a6a7a;  /* Even lighter border in dark mode */
}

.markdown-body pre code {
    display: block;
    padding: 40px 20px 16px 20px; /* Top padding for copy button */
    overflow-x: auto;
    background: transparent !important;
    border: none;
    font-size: 14px;
    line-height: 1.6;
}

/* Code Block Copy Button */
.code-block-wrapper {
    position: relative;
    margin: 20px 0;
}

.code-block-wrapper pre {
    margin: 0;
    background-color: #1a1a1a !important;  /* Dark gray for light mode */
    border: 1px solid #4d5a6b !important;  /* Lighter border */
}

body.dark-mode .code-block-wrapper pre {
    background-color: #000000 !important;  /* Pure black for dark mode */
    border: 1px solid #5a6a7a !important;  /* Even lighter in dark mode */
}

.code-block-wrapper pre code.hljs {
    background-color: transparent !important;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.code-block-wrapper:hover .copy-btn {
    opacity: 1;
}

/* Always show copy button on mobile/touch devices */
@media (hover: none) {
    .copy-btn {
        opacity: 0.9;
    }
}

.copy-btn:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.copy-btn.copied {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 24px 0;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.dark-mode .markdown-body table {
    border-color: var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.markdown-body table th,
.markdown-body table td {
    padding: 14px 18px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

body.dark-mode .markdown-body table th,
body.dark-mode .markdown-body table td {
    border-right-color: var(--border-color);
    border-bottom-color: var(--border-color);
}

.markdown-body table th:last-child,
.markdown-body table td:last-child {
    border-right: none;
}

.markdown-body table tr:last-child td {
    border-bottom: none;
}

.markdown-body table th {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    font-weight: 700;
    font-size: 15px;
    text-transform: none;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--accent-color);
}

body.dark-mode .markdown-body table th {
    background: linear-gradient(135deg, #7c3aed, #9d7dea);
    color: white;
    border-bottom-color: #9d7dea;
}

.markdown-body table tbody tr {
    background-color: transparent;
    transition: all 0.2s ease;
}

.markdown-body table tbody tr:nth-child(even) {
    background-color: var(--bg-secondary);
}

body.dark-mode .markdown-body table tbody tr:nth-child(even) {
    background-color: var(--bg-secondary);
}

.markdown-body table tbody tr:hover {
    background-color: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.1);
}

body.dark-mode .markdown-body table tbody tr:hover {
    background-color: var(--bg-tertiary);
    box-shadow: 0 2px 4px rgba(179, 153, 240, 0.2);
}

/* First column styling (for path/key columns) */
.markdown-body table td:first-child {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-weight: 500;
    color: #5a9fd8;
}

body.dark-mode .markdown-body table td:first-child {
    color: #7ab8f5;
}

/* Horizontal Rule */
.markdown-body hr {
    border: none;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 48px 0;
    border-radius: 2px;
    opacity: 0.5;
}

.markdown-body hr::after {
    content: '✦';
    display: block;
    text-align: center;
    color: var(--accent-color);
    font-size: 20px;
    margin-top: -14px;
    background: var(--bg-primary);
    width: 30px;
    margin-left: auto;
    margin-right: auto;
}

/* Images */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 24px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.markdown-body img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.2);
}

body.dark-mode .markdown-body img {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-mode .markdown-body img:hover {
    box-shadow: 0 8px 24px rgba(179, 153, 240, 0.3);
}

/* Obsidian Callouts */
.markdown-body .callout {
    margin: 24px 0;
    padding: 20px 24px;
    border-left: 4px solid;
    border-radius: 10px;
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.markdown-body .callout:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.markdown-body .callout-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.markdown-body .callout-title::before {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 18px;
}

/* Note - Blue */
.markdown-body .callout-note { 
    border-color: #3b82f6;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.03));
}

.markdown-body .callout-note .callout-title {
    color: #3b82f6;
}

.markdown-body .callout-note .callout-title::before {
    content: '\f05a';
}

body.dark-mode .markdown-body .callout-note {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.05));
}

body.dark-mode .markdown-body .callout-note .callout-title {
    color: #60a5fa;
}

/* Tip/Success - Green */
.markdown-body .callout-tip { 
    border-color: #10b981;
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.03));
}

.markdown-body .callout-tip .callout-title {
    color: #10b981;
}

.markdown-body .callout-tip .callout-title::before {
    content: '\f0eb';
}

body.dark-mode .markdown-body .callout-tip {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.05));
}

body.dark-mode .markdown-body .callout-tip .callout-title {
    color: #34d399;
}

/* Warning - Yellow/Orange */
.markdown-body .callout-warning { 
    border-color: #f59e0b;
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.03));
}

.markdown-body .callout-warning .callout-title {
    color: #d97706;
}

.markdown-body .callout-warning .callout-title::before {
    content: '\f071';
}

body.dark-mode .markdown-body .callout-warning {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.05));
}

body.dark-mode .markdown-body .callout-warning .callout-title {
    color: #fbbf24;
}

/* Danger - Red */
.markdown-body .callout-danger { 
    border-color: #ef4444;
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.03));
}

.markdown-body .callout-danger .callout-title {
    color: #dc2626;
}

.markdown-body .callout-danger .callout-title::before {
    content: '\f06a';
}

body.dark-mode .markdown-body .callout-danger {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.05));
}

body.dark-mode .markdown-body .callout-danger .callout-title {
    color: #f87171;
}

/* Info - Cyan */
.markdown-body .callout-info { 
    border-color: #06b6d4;
    background: linear-gradient(180deg, rgba(6, 182, 212, 0.08), rgba(6, 182, 212, 0.03));
}

.markdown-body .callout-info .callout-title {
    color: #0891b2;
}

.markdown-body .callout-info .callout-title::before {
    content: '\f05a';
}

body.dark-mode .markdown-body .callout-info {
    background: linear-gradient(180deg, rgba(6, 182, 212, 0.18), rgba(6, 182, 212, 0.08));
}

body.dark-mode .markdown-body .callout-info .callout-title {
    color: #22d3ee;
}

.markdown-body .callout-content {
    color: var(--text-primary);
    line-height: 1.7;
}

.markdown-body .callout p {
    margin-bottom: 8px;
}

.markdown-body .callout p:last-child {
    margin-bottom: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.modal-body textarea {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.modal-body textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        height: calc(100vh - 60px);
        z-index: 999;
        box-shadow: 4px 0 12px var(--shadow-lg);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .main-content {
        padding: 20px;
    }
    
    .markdown-body {
        font-size: 15px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-body textarea {
        min-height: 300px;
    }
}

/* Print Styles */
@media print {
    .header,
    .sidebar,
    .copy-btn {
        display: none !important;
    }
    
    .main-content {
        margin-top: 0;
        padding: 0;
    }
    
    .markdown-body {
        max-width: 100%;
    }
}

/* Custom Syntax Highlighting Colors */
/* GitHub-style highlighting colors */

/* Comments - Dark Blue (not italic) */
.hljs-comment {
    color: #7a9fcc !important;  /* Light mode: lighter blue for readability */
    font-style: normal;
}

body.dark-mode .hljs-comment {
    color: #6b8ca8 !important;  /* Dark mode: medium blue */
}

/* Command options/parameters - Green */
.hljs-params {
    color: #3fb950 !important;  /* Light mode: brighter green */
    font-weight: 500;
}

body.dark-mode .hljs-params {
    color: #7ee787 !important;  /* Dark mode: light green */
}

/* Built-in commands - Yellow/Gold */
.hljs-built_in {
    color: #e5b567 !important;  /* Light mode: brighter gold/yellow */
    font-weight: 600;
}

body.dark-mode .hljs-built_in {
    color: #e3b341 !important;  /* Dark mode: bright yellow */
}

/* Keywords - Red */
.hljs-keyword {
    color: #f47067 !important;  /* Light mode: brighter red */
    font-weight: 600;
}

body.dark-mode .hljs-keyword {
    color: #ff7b72 !important;  /* Dark mode: GitHub light red */
}

/* Strings - Green */
.hljs-string {
    color: #3fb950 !important;  /* Light mode: bright green */
}

body.dark-mode .hljs-string {
    color: #7ee787 !important;  /* Dark mode: light green */
}

/* Variables - Blue */
.hljs-variable {
    color: #58a6ff !important;  /* Light mode: bright blue */
}

body.dark-mode .hljs-variable {
    color: #79c0ff !important;  /* Dark mode: light blue */
}

/* Numbers - Purple/Magenta */
.hljs-number {
    color: #bc8cff !important;  /* Light mode: bright purple */
}

body.dark-mode .hljs-number {
    color: #c084fc !important;  /* Dark mode: light purple */
}

/* Operators - White/Gray */
.hljs-operator {
    color: #d4dce8 !important;  /* Light mode: light gray */
}

body.dark-mode .hljs-operator {
    color: var(--text-primary);
}

/* Meta (shebang) - Keep distinct */
.hljs-meta {
    color: #7a9fcc !important;
    font-weight: 600;
}

/* File List Styles - Table Format */
.file-table-container {
    width: 100%;
    background-color: var(--sidebar-bg);
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}

.file-table thead {
    background-color: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.file-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
    font-size: 12px;
}

.file-table th.sortable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.file-table th.sortable:hover {
    background-color: var(--bg-secondary);
}

.file-table th i {
    margin-right: 4px;
    color: var(--accent-color);
    font-size: 11px;
}

.sort-icon {
    margin-left: 4px;
    font-size: 10px;
    color: var(--text-tertiary);
}

.file-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.file-table tbody tr:hover {
    background-color: var(--bg-tertiary);
    cursor: pointer;
    transform: translateX(4px);
    box-shadow: -4px 0 0 var(--accent-color), 0 2px 8px rgba(124, 58, 237, 0.15);
}

body.dark-mode .file-table tbody tr:hover {
    box-shadow: -4px 0 0 var(--accent-color), 0 2px 8px rgba(179, 153, 240, 0.25);
}

.file-table td {
    padding: 14px 16px;
    color: var(--text-primary);
    white-space: nowrap;
}

.col-type {
    width: 50px;
    text-align: center;
    color: var(--text-secondary);
    padding: 14px 12px;
}

.file-type-icon {
    font-size: 16px;
    display: block;
    margin-bottom: 2px;
}

.file-type-ext {
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.col-type .fa-globe {
    color: #3b82f6;
}

.col-type .fa-file-lines {
    color: var(--text-secondary);
}

.col-name {
    min-width: 180px;
    max-width: 250px;
}

.file-name-text {
    color: var(--text-primary);
    font-weight: 500;
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-desc-inline {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.col-size {
    width: 80px;
    text-align: right;
    font-family: 'Fira Code', monospace;
    color: var(--text-secondary);
    font-size: 11px;
}

.col-date {
    width: 95px;
    font-family: 'Fira Code', monospace;
    color: var(--text-secondary);
    font-size: 11px;
}

/* Home button animation */
#homeBtn {
    animation: fadeIn 0.3s ease;
}

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

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner p {
    font-size: 16px;
    font-weight: 500;
    color: white;
}

/* Responsive adjustments for file table */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        height: calc(100vh - 60px);
        z-index: 999;
        box-shadow: 4px 0 12px var(--shadow-lg);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .file-table-container {
        height: calc(100vh - 60px);
    }
    
    .file-table {
        font-size: 11px;
    }
    
    .file-table th,
    .file-table td {
        padding: 8px 10px;
    }
    
    .col-date {
        display: none;
    }
    
    .col-size {
        width: 60px;
        font-size: 10px;
    }
    
    .col-name {
        min-width: 120px;
        max-width: 140px;
    }
    
    .file-name-text {
        font-size: 12px;
    }
    
    .file-desc-inline {
        font-size: 10px;
    }
}

/* Iframe Container Styles */
#iframe-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Fullscreen Iframe Container */
#iframe-container-fullscreen {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 60px);
    background-color: var(--bg-primary);
    z-index: 1000;
    display: none;
}

#iframe-container-fullscreen iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Back Button - Fullscreen */
.btn-back-fullscreen {
    position: fixed;
    top: 36px;  /* 60px(header) / 2 - 48px(button) / 2 = 36px で中央に */
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0.7;
}

.btn-back-fullscreen:hover {
    background-color: var(--accent-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    opacity: 1;
}

.iframe-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 16px;
}

.iframe-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    flex: 1;
}

.iframe-header h3 i {
    color: var(--accent-color);
}

/* Responsive adjustments for file list */
@media (max-width: 768px) {
    .file-items {
        grid-template-columns: 1fr;
    }
    
    .file-list {
        margin-top: 24px;
    }
}