/* ========== リセット・基本設定 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'メイリオ', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #222;
    background-color: #fff;
}

/* ========== レイアウト ========== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== ヘッダー ========== */
.site-header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #f0f4f8;
    padding: 40px 0;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.site-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #f0f4f8;
}

.site-subtitle {
    font-size: 16px;
    opacity: 0.95;
    color: #f0f4f8;
}

/* ========== メインコンテンツ ========== */
main {
    padding: 60px 20px;
    min-height: calc(100vh - 200px);
}

.lesson {
    padding: 40px;
    background: white;
}

.lesson-header {
    margin-bottom: 40px;
    border-bottom: 3px solid #e5e7eb;
    padding-bottom: 20px;
}

.lesson-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1f2937;
}

.lead {
    font-size: 18px;
    color: #6b7280;
    font-style: italic;
}

.lesson-section {
    margin-top: 40px;
}

.lesson-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1f2937;
    border-left: 4px solid #2563eb;
    padding-left: 12px;
}

.lesson-section p {
    line-height: 1.8;
    color: #374151;
    margin-bottom: 12px;
}

.lesson-section ul {
    margin-left: 24px;
    margin-bottom: 16px;
}

.lesson-section li {
    margin-bottom: 8px;
}

/* ========== コードブロック ========== */
pre {
    background-color: #272822;
    border-left: 6px solid #2563eb;
    padding: 20px;
    overflow-x: auto;
    border-radius: 8px;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 15px;
    line-height: 1.6;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    color: #f8f8f2;
}

/* コードブロック内のコード */
pre code {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 15px;
    color: #f8f8f2;
    background-color: transparent;
}

/* 段落やリスト内のインラインコード */
p code, li code, td code, span code {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    color: #1e40af;
    background-color: #eff6ff;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #bfdbfe;
}

/* デフォルトフォールバック */
code {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
}
5px solid #06b6d4;
    padding: 16px 18px;
    margin-top: 12px;
    border-radius: 6px;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 14px;
    color: #0c4a6e;
    line-height: 1.6;
    box-shadow: 0 2px 6px rgba(6, 182, 212, 0.08)or: #f0f9ff;
    border-left: 4px solid #06b6d4;
    padding: 12px 16px;
    margin-top: 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #0c4a6e;
}

/* ========== スペシャルセクション ========== */
.point {
    background-color: #eef6ff;
    border-left: 5px solid #2563eb;
    border-radius: 6px;
    padding: 18px 20px;
    margin-top: 24px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.point h2 {
    color: #2563eb;
    border-left: none;
    padding-left: 0;
    margin-bottom: 12px;
    font-size: 19px;
}

.point ul {
    margin-left: 20px;
}

.warning {
    background-color: #fef3c7;
    border-left: 5px solid #f59e0b;
    border-radius: 6px;
    padding: 18px 20px;
    margin-top: 24px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.08);
}

.warning h2 {
    color: #d97706;
    border-left: none;
    padding-left: 0;
    margin-bottom: 12px;
    font-size: 19px;
}

/* ========== 詳細ボックス ========== */
details {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 4px;
    margin: 12px 0;
}

details summary {
    cursor: pointer;
    font-weight: 600;
    color: #2563eb;
    user-select: none;
}

details[open] {
    background-color: #f3f4f6;
}

details[open] summary {
    margin-bottom: 12px;
}

/* ========== 表 ========== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

th, td {
    border: 1px solid #d1d5db;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #1f2937;
}

tr:nth-child(even) {
    background-color: #f9fafb;
}

/* ========== ナビゲーション ========== */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 60px;
    padding-top: 20px;
    border-top: 2px solid #e5e7eb;
}

.nav-prev, .nav-next {
    display: inline-block;
    padding: 12px 20px;
    background-color: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.2s;
    flex: 1;
    text-align: center;
}

.nav-prev:hover, .nav-next:hover {
    background-color: #1e40af;
}

.nav-prev {
    order: -1;
}

/* ========== フッター ========== */
.site-footer {
    background-color: #1f2937;
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    font-size: 14px;
}

/* ========== メモリ図解 ========== */
.memory-diagram {
    margin: 24px 0;
    text-align: center;
}

.memory-diagram svg {
    max-width: 100%;
    height: auto;
    background-color: #f9fafb;
    border-radius: 6px;
    padding: 16px;
}

.memory-diagram figcaption {
    margin-top: 12px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* ========== レスポンシブ ========== */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }

    .lesson {
        padding: 20px;
    }

    .lesson-title {
        font-size: 22px;
    }

    .lesson-section h2 {
        font-size: 18px;
    }

    .lesson-nav {
        flex-direction: column;
    }

    .nav-prev, .nav-next {
        width: 100%;
        order: 0;
    }

    .nav-prev {
        order: -1;
        margin-bottom: 12px;
    }

    pre {
        font-size: 12px;
        padding: 12px;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .site-title {
        font-size: 24px;
    }

    .lesson-title {
        font-size: 18px;
    }

    .lesson-section h2 {
        font-size: 16px;
    }

    main {
        padding: 20px 12px;
    }

    .lesson {
        padding: 16px;
    }
}
