/* Base Layout */
body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    display: flex;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: #f7f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 20px 0;
    /* Changed padding */
    position: fixed;
    height: 100%;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar h1 {
    font-size: 1.4rem;
    margin: 0 0 20px 20px;
    color: #2c3e50;
    font-weight: 600;
    border: none;
    padding: 0;
}

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

/* Link Container */
.nav-item {
    position: relative;
}

/* Main Link Style */
.nav-item>a {
    text-decoration: none;
    color: #444;
    display: flex;
    align-items: center;
    padding: 8px 15px 8px 35px;
    /* Space for toggle */
    transition: background-color 0.2s, color 0.2s;
    font-size: 1rem;
    font-weight: 500;
}

.nav-item>a:hover {
    background-color: #e9ecef;
    color: #000;
}

.nav-item>a.active {
    background-color: #e3f2fd;
    color: #1976d2;
}

/* Toggle Arrow */
.toggle-btn {
    position: absolute;
    left: 10px;
    top: 10px;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 0.8rem;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s;
}

.toggle-btn:hover {
    color: #555;
}

.toggle-btn.expanded {
    transform: rotate(90deg);
}

/* Sub-menu */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    /* Hidden by default */
    background-color: #fcfcfc;
}

.submenu.open {
    display: block;
}

.submenu li a {
    text-decoration: none;
    color: #666;
    display: block;
    padding: 6px 20px 6px 50px;
    /* Indent */
    font-size: 0.9rem;
    transition: color 0.2s;
}

.submenu li a:hover {
    color: #1976d2;
    background-color: #f0f0f0;
}

/* Main Content */
.main-content {
    margin-left: 281px;
    /* Match sidebar width + border */
    padding: 40px 60px;
    max-width: 900px;
    flex-grow: 1;
}

.meta-info {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.meta-info p {
    margin: 4px 0;
}

/* Typography & Elements */
h1 {
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

h2 {
    font-size: 1.6rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #34495e;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

h3 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: #455a64;
}

p,
ul,
ol {
    margin-bottom: 1.2rem;
}

li {
    margin-bottom: 0.5rem;
}

code {
    font-family: Consolas, Monaco, "Courier New", "MS Gothic", monospace;
    background-color: #f1f1f1;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    color: #d63384;
}

pre {
    background-color: #282c34;
    color: #abb2bf;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

/* Syntax */
.keyword {
    color: #c678dd;
}

.type {
    color: #e5c07b;
}

.string {
    color: #98c379;
}

.comment {
    color: #5c6370;
    font-style: italic;
}

.number {
    color: #d19a66;
}

/* Language Switch */
.header-nav {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.lang-link {
    text-decoration: none;
    color: #1976d2;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 5px 12px;
    border: 1px solid #1976d2;
    border-radius: 20px;
    transition: all 0.2s;
}

.lang-link:hover {
    background-color: #1976d2;
    color: #fff;
}

/* Troubleshooting */
.trouble-box {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    background-color: #fff;
}

.trouble-box .error-case {
    background-color: #fffafa;
    padding: 20px;
    border-bottom: 1px dashed #ffcdd2;
}

.trouble-box .error-case p:first-child {
    margin-top: 0;
    color: #d32f2f;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.trouble-box .error-case p:first-child::before {
    content: "✕";
    margin-right: 10px;
    background-color: #d32f2f;
    color: #fff;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
}

.trouble-box .solution {
    background-color: #f8fff8;
    padding: 20px;
    position: relative;
}

.trouble-box .solution p:first-child {
    margin-top: 0;
    color: #2e7d32;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.trouble-box .solution p:first-child::before {
    content: "✓";
    margin-right: 10px;
    background-color: #2e7d32;
    color: #fff;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
}

.trouble-box pre {
    margin: 15px 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.trouble-box .solution p:last-child {
    margin-bottom: 0;
    font-size: 0.95rem;
    color: #555;
}

/* Note/Alert block */
.note {
    background-color: #e3f2fd;
    border-left: 4px solid #1976d2;
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 0 4px 4px 0;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}