/* === Global Styles & Variables === */
:root {
    --primary-color: #007bff; /* Bright Blue */
    --secondary-color: #6c757d; /* Muted Gray */
    --background-color: #f8f9fa; /* Light Gray */
    --surface-color: #ffffff; /* White */
    --text-color: #343a40; /* Dark Gray */
    --text-muted-color: #6c757d;
    --border-color: #dee2e6; /* Light Gray Border */
    --hover-color: #0056b3; /* Darker Blue */
    --code-bg-color: #282c34; /* Prism Tomorrow Background */
    --code-text-color: #abb2bf; /* Prism Tomorrow Text */
    --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-monospace: 'Source Code Pro', SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

body {
    font-family: var(--font-family-sans-serif);
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.page-container {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar Navigation === */
.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    padding: 20px;
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.sidebar ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 20px;
}

.sidebar li a {
    text-decoration: none;
    color: var(--text-color);
    display: block;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease, color 0.2s ease;
    font-weight: 500;
}

.sidebar li a:hover,
.sidebar li a.active {
    background-color: var(--primary-color);
    color: var(--surface-color);
}

.sidebar .creation-date {
    font-size: 0.9em;
    color: var(--text-muted-color);
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.sidebar ul li a.active { /* home.html のメインTOCで使っていた active スタイル */
    background-color: var(--primary-color);
    color: var(--surface-color);
}

/* rs-5.html のページ内目次用のアクティブスタイル (script.js が #id を使うため) */
.in-page-toc-sidebar ul li a.active-inpage {
    background-color: var(--primary-color); /* 通常の .active と同じスタイル */
    color: var(--surface-color);
    font-weight: bold;
}


.back-to-home-sidebar-link {
    display: block;
    padding: 10px 15px;
    margin-top: 15px;
    background-color: var(--secondary-color);
    color: var(--surface-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    text-align: center;
    transition: background-color 0.2s ease;
}

.back-to-home-sidebar-link:hover {
    background-color: #545b62; /* 少し暗いグレー */
}

.sidebar .back-to-main-site-link {
    display: block;
    padding: 10px 15px;
    margin-top: 20px;
    background-color: #415a77;
    color: var(--surface-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    text-align: center;
    transition: background-color 0.2s ease;
}

.sidebar .back-to-main-site-link:hover {
    background-color: #00c4f5; 
}

/* === Main Content Area === */
.content-area {
    flex-grow: 1;
    padding: 30px 40px;
    max-width: calc(100% - 280px); /* Adjust if sidebar width changes */
    overflow-y: auto;
}

.main-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.main-header h1 {
    font-size: 2.8em;
    color: var(--text-color);
    margin-bottom: 5px;
}

.main-header .subtitle {
    font-size: 1.2em;
    color: var(--text-muted-color);
}

/* === Research Sections & Items === */
.research-section {
    background-color: var(--surface-color);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 30px;
}

.research-section header h2 {
    font-size: 2em;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.toc-section {
    margin-bottom: 25px;
    background-color: #fdfdff; /* Slightly different background for TOC */
    padding: 15px;
    border-radius: calc(var(--border-radius) - 4px);
    border: 1px solid #e9ecef;
}

.toc-section h3 {
    margin-top: 0;
    color: var(--secondary-color);
    font-size: 1.3em;
    margin-bottom: 10px;
}

.toc-section ul {
    list-style-type: disc;
    padding-left: 20px;
}

.toc-section li {
    margin-bottom: 8px;
}

.toc-section a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.2s ease;
}

.toc-section a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

.research-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
}
.research-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.research-item h4 {
    font-size: 1.4em;
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 8px;
}

.research-item p a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.research-item p a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

hr.section-divider {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 40px 0;
}

/* === Code Snippets === */
.code-snippet-card {
    background-color: var(--code-bg-color);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    overflow: hidden; /* Ensures border-radius applies to pre/code */
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #3a4049; /* Slightly lighter than code-bg for contrast */
    border-bottom: 1px solid #4a5059;
}

.code-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: #d4d4d4;
}

.language-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.copy-button {
    background-color: var(--primary-color);
    color: var(--surface-color);
    border: none;
    padding: 8px 12px;
    border-radius: calc(var(--border-radius) - 4px);
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

.copy-button:hover {
    background-color: var(--hover-color);
}

.copy-button.copied {
    background-color: #28a745; /* Green for success */
}

pre[class*="language-"] {
    margin: 0 !important; /* Override Prism's default margin */
    padding: 15px !important; /* Override Prism's default padding */
    border-radius: 0 0 var(--border-radius) var(--border-radius) !important;
    font-size: 0.95em;
    line-height: 1.5;
}

/* === Footer & Profile Box === */
.main-footer {
    text-align: center;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.profile-box {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin: 0 auto 20px auto;
    max-width: 500px;
}

.profile-box h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
}

.profile-info {
    display: flex;
    align-items: center;
    text-align: left;
}

.profile-pic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    margin-right: 20px;
    object-fit: cover;
}

.profile-text {
    flex: 1;
}

.profile-text p {
    margin: 5px 0;
    font-size: 0.95em;
}

.profile-text a {
    color: var(--primary-color);
    text-decoration: none;
}
.profile-text a:hover {
    text-decoration: underline;
}

.copy-right {
    font-size: 0.9em;
    color: var(--text-muted-color);
}

/* === Responsive Design === */
@media (max-width: 992px) {
    .page-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    .content-area {
        max-width: 100%;
        padding: 20px;
    }
    .main-header h1 {
        font-size: 2.2em;
    }
    .research-section header h2 {
        font-size: 1.8em;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 15px; /* Slightly smaller base font for small devices */
    }
    .main-header h1 {
        font-size: 1.8em;
    }
    .main-header .subtitle {
        font-size: 1em;
    }
    .research-section header h2 {
        font-size: 1.5em;
    }
    .research-item h4 {
        font-size: 1.2em;
    }
    .code-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .code-header h3, .code-header .language-badge {
        margin-bottom: 8px;
    }
    .copy-button {
        align-self: flex-end;
    }
    .profile-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .profile-pic {
        margin-right: 0;
        margin-bottom: 15px;
    }
}

/* Line numbers for Prism.js (if using plugin) */
.line-numbers .line-numbers-rows > span:before {
    color: var(--text-muted-color) !important; /* Ensure visibility with custom BG */
    opacity: 0.6;
}