/* ===== AI Visual Guide - Common Stylesheet ===== */

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

:root {
    --color-bg: #fafafa;
    --color-bg-card: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #6b7280;
    --color-accent: #3b82f6;
    --color-accent-light: #dbeafe;
    --color-highlight-bg: #fef3c7;
    --color-code-bg: #f3f4f6;
    --color-border: #e5e7eb;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --max-width: 880px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.05);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
        'Hiragino Sans', 'Yu Gothic Medium', 'Meiryo', sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
header.site-header {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    padding: 4rem 2rem;
    text-align: center;
}

header.site-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

header.site-header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* ナビゲーション */
nav.top-nav {
    background: white;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav.top-nav .nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

nav.top-nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

nav.top-nav a:hover {
    color: var(--color-accent);
}

nav.top-nav .home-link {
    font-weight: 700;
}

nav.top-nav a.active {
    color: var(--color-accent);
    font-weight: 700;
    position: relative;
}

nav.top-nav a.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -8px;
    height: 3px;
    background: var(--color-accent);
    border-radius: 2px;
}

/* サブナビ（章内のセクションリンク） */
nav.sub-nav {
    background: linear-gradient(180deg, #fafafa 0%, #f3f4f6 100%);
    border-bottom: 1px solid var(--color-border);
    padding: 0.65rem 2rem;
    position: sticky;
    top: 56px; /* top-nav の高さ分下げる */
    z-index: 99;
    font-size: 0.85rem;
}

nav.sub-nav .nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

nav.sub-nav .sub-nav-label {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

nav.sub-nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
}

nav.sub-nav a:hover {
    color: var(--color-accent);
}

@media (max-width: 640px) {
    nav.top-nav {
        padding: 0.75rem 1rem;
    }
    nav.top-nav .nav-inner {
        gap: 0.85rem;
    }
    nav.top-nav a {
        font-size: 0.8rem;
    }
    nav.sub-nav {
        padding: 0.5rem 1rem;
        top: 48px;
    }
    nav.sub-nav .sub-nav-label {
        display: none;
    }
}

/* メインコンテンツ */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
}

main h1 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

main h2 {
    font-size: 1.6rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-accent);
    letter-spacing: -0.01em;
}

main h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

main p {
    margin-bottom: 1.2rem;
}

main ul, main ol {
    margin-left: 2rem;
    margin-bottom: 1.2rem;
}

main li {
    margin-bottom: 0.5rem;
}

main a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

main strong {
    color: var(--color-text);
    font-weight: 700;
}

/* コードブロック */
code {
    background: var(--color-code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.9em;
}

pre {
    background: #1e293b;
    color: #f1f5f9;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.85em;
    line-height: 1.6;
}

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

/* カード */
.card {
    background: var(--color-bg-card);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-card);
}

.card.highlight {
    border-left: 4px solid var(--color-warning);
    background: var(--color-highlight-bg);
}

/* インタラクティブセクション */
.interactive {
    background: var(--color-bg-card);
    border: 2px solid var(--color-accent);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: var(--shadow-card);
}

.interactive .label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.interactive .title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* スライダー */
.slider-row {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.slider-row .slider-label {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.slider-row .slider-value {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.95rem;
    text-align: right;
    color: var(--color-accent);
    font-weight: 700;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* 出力表示 */
.output-display {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 1rem;
    line-height: 1.6;
}

.output-display .formula {
    color: var(--color-text-muted);
    font-size: 0.9em;
    margin-bottom: 0.5rem;
}

.output-display .result {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent);
}

/* 活性化関数選択 */
.activation-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.activation-tabs button {
    background: var(--color-code-bg);
    border: 2px solid transparent;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--color-text);
}

.activation-tabs button:hover {
    background: var(--color-accent-light);
}

.activation-tabs button.active {
    background: var(--color-accent);
    color: white;
}

/* ニューロンSVG */
.neuron-diagram {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 2rem auto;
}

.neuron-diagram .input-circle {
    fill: var(--color-accent-light);
    stroke: var(--color-accent);
    stroke-width: 2;
}

.neuron-diagram .neuron-circle {
    fill: var(--color-warning);
    stroke: #b45309;
    stroke-width: 2;
}

.neuron-diagram .output-circle {
    fill: #d1fae5;
    stroke: var(--color-success);
    stroke-width: 2;
}

.neuron-diagram .connection {
    stroke: #9ca3af;
    stroke-width: 1.5;
    fill: none;
}

.neuron-diagram .connection-active {
    stroke: var(--color-accent);
    stroke-width: 2.5;
}

.neuron-diagram .node-label {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 14px;
    font-weight: 600;
    text-anchor: middle;
    fill: var(--color-text);
}

.neuron-diagram .weight-label {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 11px;
    fill: var(--color-text-muted);
    text-anchor: middle;
}

/* グラフキャンバス */
.graph-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid var(--color-border);
}

.graph-container canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* テーブル：横幅が足りないときは横スクロール（sidebar.js が .table-scroll で包む） */
.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
}

.table-scroll > table {
    margin-bottom: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: var(--color-code-bg);
    font-weight: 700;
    font-size: 0.9em;
}

tr:last-child td {
    border-bottom: none;
}

/* フッター */
footer {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--color-border);
    background: white;
    margin-top: 4rem;
}

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

/* 章カード（トップページ用） */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.chapter-card {
    background: white;
    border-radius: 12px;
    padding: 1.75rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--color-border);
}

.chapter-card:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: var(--color-accent);
}

.chapter-card .chapter-num {
    display: inline-block;
    background: var(--color-accent);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}

.chapter-card h3 {
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

.chapter-card p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

.chapter-card.coming-soon {
    opacity: 0.6;
    pointer-events: none;
}

.chapter-card.coming-soon .chapter-num {
    background: var(--color-text-muted);
}

/* ===== YouTube動画埋め込み ===== */
.video-embed {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    border-radius: 10px;
    border-left: 4px solid #ef4444;
}

.video-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: 0.75rem !important;
    margin-top: 0 !important;
}

.video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 アスペクト比 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #000;
}

.video-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-caption {
    text-align: right;
    margin: 0.6rem 0 0 !important;
    font-size: 0.85rem;
}

.video-caption a {
    color: #ef4444;
    font-weight: 600;
    text-decoration: none;
}

.video-caption a:hover {
    text-decoration: underline;
}

/* ===== 直交2軸図（第2章） ===== */
.orthogonal-axes-card {
    background: white;
    border-radius: 14px;
    padding: 1rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

.orthogonal-axes-card svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* ===== イコライザ比較図 ===== */
.equalizer-comparison {
    background: white;
    border-radius: 14px;
    padding: 1rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

.equalizer-comparison svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* ===== KaTeX：長い数式は横スクロール（縦は切らない） ===== */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
}

/* ===== コラムカード（折りたたみ式・番外編枠） ===== */
details.column-card {
    background: white;
    border: 2px solid #f59e0b;
    border-radius: 14px;
    padding: 0;
    margin: 2rem 0;
    overflow: hidden;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
}

/* 左上に「番外編」マークを表示 */
details.column-card::before {
    content: '番外編';
    position: absolute;
    top: 0;
    left: 0;
    background: #f59e0b;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-bottom-right-radius: 8px;
    letter-spacing: 0.08em;
    z-index: 1;
}

details.column-card[open] {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.18);
    border-color: #d97706;
}

/* summary 部分（クリックエリア） */
details.column-card summary {
    cursor: pointer;
    font-size: 1.05rem;
    color: #78350f;
    list-style: none;
    user-select: none;
    padding: 1.1rem 3.75rem 1.1rem 5.5rem;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    display: block;
    line-height: 1.5;
    transition: background 0.2s ease;
    position: relative;
    min-height: 3rem;
}

/* 「（クリックで展開）」のヒント：控えめに表示 */
details.column-card summary .summary-hint {
    font-size: 0.85em;
    font-weight: 400;
    color: #b45309;
    margin-left: 0.4rem;
    white-space: nowrap;
}

details.column-card summary:hover {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

details.column-card[open] summary {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 1px solid #fbbf24;
}

details.column-card summary::-webkit-details-marker {
    display: none;
}

/* 開閉アイコン（右側） */
details.column-card summary::after {
    content: '＋';
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    font-weight: 700;
    color: #f59e0b;
    transition: transform 0.25s ease, color 0.2s;
    /* 縦横を固定し、文字が長くても潰れないようにする */
    width: 1.6rem;
    height: 1.6rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #f59e0b;
    border-radius: 50%;
    background: white;
    line-height: 1;
}

details.column-card[open] summary::after {
    content: '−';
    transform: translateY(-50%) rotate(180deg);
    background: #f59e0b;
    color: white;
}

details.column-card summary:hover::after {
    background: #f59e0b;
    color: white;
}

/* コンテンツ本体 */
details.column-card .column-card-body {
    padding: 1.5rem 1.5rem 1.25rem;
    background: white;
}

details.column-card .column-card-body > p:first-child,
details.column-card .column-card-body > h4:first-child {
    margin-top: 0;
}

details.column-card .column-card-body h4 {
    color: #92400e;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
    padding-left: 0.5rem;
    border-left: 3px solid #f59e0b;
}

details.column-card .column-card-body h5 {
    color: #b45309;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    details.column-card summary {
        padding: 2.4rem 3.25rem 1rem 1.1rem;
        font-size: 0.95rem;
    }
    /* モバイルではヒント文を省略してタイトルを読みやすく */
    details.column-card summary .summary-hint {
        display: none;
    }
    /* 番外編ラベル分だけ下にずらして、タイトル行に揃える */
    details.column-card summary::after {
        top: calc(50% + 0.7rem);
        right: 1rem;
    }
    /* 入れ子カードも同じ左余白に揃える（後続の通常ルールより詳細度を上げる） */
    details.column-card.column-card-nested summary {
        padding-left: 1.1rem;
    }
    details.column-card::before {
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
        right: 0;
        text-align: center;
    }
}

/* ===== コラム・イン・コラム（入れ子） ===== */
details.column-card-nested {
    border-color: #8b5cf6;
    margin: 1.5rem 0;
}

details.column-card-nested::before {
    content: 'さらに脱線';
    background: #8b5cf6;
}

details.column-card-nested[open] {
    border-color: #7c3aed;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.18);
}

details.column-card-nested summary {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    color: #5b21b6;
    padding-left: 6.5rem;
}

details.column-card-nested summary:hover {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

details.column-card-nested[open] summary {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    border-bottom-color: #c4b5fd;
}

details.column-card-nested summary::after {
    border-color: #8b5cf6;
    color: #8b5cf6;
}

details.column-card-nested[open] summary::after,
details.column-card-nested summary:hover::after {
    background: #8b5cf6;
    color: white;
}

details.column-card-nested .column-card-body h4 {
    color: #5b21b6;
    border-left-color: #8b5cf6;
}

details.column-card-nested .column-card-body h5 {
    color: #6d28d9;
}

/* ===== 損失関数の凸凹地形（学習の章用） ===== */
.loss-landscape-card {
    background: white;
    border-radius: 14px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

.loss-landscape {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.loss-landscape-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
}

.legend-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot-red {
    background: radial-gradient(circle at 35% 35%, #fca5a5, #dc2626);
    border: 2px solid white;
    box-shadow: 0 0 0 1px #dc2626;
}

.legend-dot-gray {
    background: #9ca3af;
    opacity: 0.8;
}

.legend-curve {
    display: inline-block;
    width: 30px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .loss-landscape-card {
        padding: 0.75rem;
    }
    .loss-landscape-legend {
        font-size: 0.8rem;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ===== 重み行列の可視化（全結合層） ===== */
.matrix-visual {
    background: white;
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    overflow-x: auto;
}

.matrix-visual-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.matrix-visual-axis-label-top {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.05em;
}

.matrix-visual-body {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.matrix-visual-axis-left {
    writing-mode: vertical-rl;
    font-size: 0.8rem;
    font-weight: 700;
    color: #f59e0b;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.matrix-visual-content {
    flex: 1;
}

.matrix-visual-cols {
    display: grid;
    grid-template-columns: 130px repeat(3, 65px) 1fr;
    text-align: center;
    font-family: 'SF Mono', Menlo, monospace;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.matrix-visual-cols span:first-child {
    grid-column: 2;
}

.matrix-visual-table {
    width: auto;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
}

.matrix-visual-table tr.matrix-row {
    background: transparent;
}

.matrix-visual-table tr.matrix-row td {
    border-bottom: none;
    padding: 0;
    text-align: center;
}

.matrix-row-label {
    width: 130px;
    text-align: right !important;
    padding-right: 0.75rem !important;
    font-weight: 700;
    color: var(--color-text);
    font-size: 0.88rem;
    white-space: nowrap;
}

.matrix-row-1 .matrix-row-label { color: #3b82f6; }
.matrix-row-2 .matrix-row-label { color: #8b5cf6; }
.matrix-row-3 .matrix-row-label { color: #ec4899; }
.matrix-row-4 .matrix-row-label { color: #f59e0b; }

.matrix-cell {
    width: 65px !important;
    height: 50px;
    font-family: 'SF Mono', Menlo, monospace;
    font-weight: 600;
    font-size: 0.95rem;
    background: #f3f4f6;
    border: 2px solid var(--color-border);
    margin: 0;
}

.matrix-row-1 .matrix-cell { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.3); color: #1e40af; }
.matrix-row-2 .matrix-cell { background: rgba(139, 92, 246, 0.08); border-color: rgba(139, 92, 246, 0.3); color: #6b21a8; }
.matrix-row-3 .matrix-cell { background: rgba(236, 72, 153, 0.08); border-color: rgba(236, 72, 153, 0.3); color: #9d174d; }
.matrix-row-4 .matrix-cell { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.3); color: #92400e; }

/* 行を一塊に見せるためのボーダー結合 */
.matrix-visual-table .matrix-cell:first-of-type {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}
.matrix-visual-table .matrix-cell:last-of-type {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    border-right-width: 2px;
}
.matrix-visual-table tr.matrix-row td.matrix-cell {
    border-right-width: 0;
}
.matrix-visual-table tr.matrix-row td.matrix-cell:last-of-type {
    border-right-width: 2px;
}

.matrix-row-desc {
    text-align: left !important;
    padding-left: 0.75rem !important;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.matrix-row-1 .matrix-row-desc { color: #3b82f6; }
.matrix-row-2 .matrix-row-desc { color: #8b5cf6; }
.matrix-row-3 .matrix-row-desc { color: #ec4899; }
.matrix-row-4 .matrix-row-desc { color: #f59e0b; }

.matrix-visual-shape {
    margin: 1rem 0 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    padding: 0.5rem;
    background: var(--color-code-bg);
    border-radius: 6px;
}

@media (max-width: 768px) {
    .matrix-visual-body {
        flex-direction: column;
        align-items: stretch;
    }
    .matrix-visual-axis-left {
        writing-mode: horizontal-tb;
        transform: none;
        text-align: center;
        margin-bottom: 0.5rem;
    }
    .matrix-row-label,
    .matrix-row-desc {
        font-size: 0.75rem;
    }
    .matrix-cell {
        width: 50px !important;
        height: 40px;
        font-size: 0.85rem;
    }
    .matrix-visual-cols {
        grid-template-columns: 100px repeat(3, 50px) 1fr;
    }
    .matrix-row-label {
        width: 100px;
    }
}

/* ===== 直交マトリックス表 ===== */
table.orthogonal-matrix {
    margin: 1.5rem 0;
}

table.orthogonal-matrix th:first-child,
table.orthogonal-matrix td:first-child {
    background: var(--color-code-bg);
    font-weight: 700;
    width: 130px;
    text-align: center;
}

table.orthogonal-matrix tbody tr:hover td:first-child {
    background: var(--color-accent-light);
}

/* 象限バッジ */
.quadrant-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}

.quadrant-badge.sup-dl {
    background: #dbeafe;
    color: #1e40af;
}

.quadrant-badge.unsup-dl {
    background: #ede9fe;
    color: #6b21a8;
}

.quadrant-badge.reinf-dl {
    background: #fef3c7;
    color: #92400e;
}

/* ===== 古典 vs DL の対比 ===== */
.approach-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: stretch;
    margin: 2rem 0;
}

.approach-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.approach-card.approach-classic {
    border-top: 4px solid #94a3b8;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.approach-card.approach-deep {
    border-top: 4px solid #f59e0b;
    background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.approach-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.approach-emoji {
    font-size: 1.6rem;
}

.approach-card h4 {
    margin: 0;
    font-size: 1.1rem;
}

.approach-card pre {
    background: #1e293b;
    margin: 0.75rem 0;
    flex-grow: 1;
}

.approach-summary {
    background: var(--color-code-bg);
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.approach-arrow {
    display: flex;
    align-items: center;
    font-size: 2rem;
    color: var(--color-accent);
    font-weight: 700;
}

@media (max-width: 768px) {
    .approach-comparison {
        grid-template-columns: 1fr;
    }
    .approach-arrow {
        justify-content: center;
        transform: rotate(90deg);
    }
}

/* ===== 3つの条件カード ===== */
.conditions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.condition-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border-top: 4px solid var(--color-accent);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.condition-card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.condition-card:nth-child(1) { border-top-color: #3b82f6; }
.condition-card:nth-child(2) { border-top-color: #10b981; }
.condition-card:nth-child(3) { border-top-color: #f59e0b; }

.condition-num {
    display: inline-block;
    background: var(--color-text);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.condition-card h3 {
    margin-top: 0;
    font-size: 1.15rem;
}

.condition-card p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

.condition-card p:last-child {
    margin-bottom: 0;
}

.condition-card ul {
    font-size: 0.9rem;
    margin: 0;
}

.condition-card ul li {
    margin-bottom: 0.3rem;
}

/* ===== 学習タイプの3カード ===== */
.learning-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.learning-type-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border-top: 4px solid var(--color-accent);
    transition: transform 0.2s, box-shadow 0.2s;
}

.learning-type-card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.learning-type-card.type-supervised { border-top-color: #3b82f6; }
.learning-type-card.type-unsupervised { border-top-color: #8b5cf6; }
.learning-type-card.type-reinforcement { border-top-color: #f59e0b; }

.type-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.type-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--color-text);
}

.type-en {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    font-family: 'SF Mono', Menlo, monospace;
}

.type-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.type-formula {
    background: var(--color-code-bg);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

.type-examples {
    font-size: 0.9rem;
    color: var(--color-text);
}

.type-examples ul {
    margin-top: 0.4rem;
    margin-left: 1.5rem;
    margin-bottom: 0;
}

.type-examples li {
    margin-bottom: 0.2rem;
}

/* ===== 機械学習手法テーブル ===== */
.ml-methods-table {
    font-size: 0.95rem;
}

.ml-methods-table small {
    color: var(--color-text-muted);
    font-size: 0.85em;
    font-weight: 400;
}

.ml-methods-table tr {
    transition: background 0.15s;
}

.ml-methods-table tbody tr:hover {
    background: #f9fafb;
}

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.type-badge.sup {
    background: #dbeafe;
    color: #1e40af;
}

.type-badge.unsup {
    background: #ede9fe;
    color: #6b21a8;
}

.type-badge.reinf {
    background: #fef3c7;
    color: #92400e;
}

/* ===== 各手法の解説カード ===== */
.method-card {
    background: white;
    border-left: 4px solid var(--color-accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.method-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08), 0 8px 20px rgba(0, 0, 0, 0.06);
    border-left-color: #8b5cf6;
}

.method-card h4 {
    font-size: 1.15rem;
    margin: 0 0 0.75rem 0;
    color: var(--color-text);
}

.method-card p {
    margin-bottom: 0.85rem;
    line-height: 1.7;
}

.method-card p:last-child {
    margin-bottom: 0;
}

.method-card ol, .method-card ul {
    margin-bottom: 0.85rem;
}

.method-formula {
    background: var(--color-code-bg);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    text-align: center;
    margin: 0.75rem 0;
    font-size: 1em;
}

.method-card pre {
    margin: 0.75rem 0;
    font-size: 0.85em;
}

/* ====================================================================
   トップページ専用デザイン
   ヒーロー、特徴、学習フロー、ペルソナ、最終CTA
   ==================================================================== */

/* ===== ヒーローセクション ===== */
.hero {
    position: relative;
    overflow: hidden;
    padding: 5rem 2rem 6rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #312e81 100%);
    color: white;
    text-align: center;
}

.hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    top: -150px;
    left: -100px;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
}

.orb-2 {
    width: 500px;
    height: 500px;
    top: 100px;
    right: -200px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    animation-delay: -7s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    bottom: -100px;
    left: 30%;
    background: radial-gradient(circle, #ec4899 0%, transparent 70%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, -30px) scale(1.05); }
    66% { transform: translate(-30px, 40px) scale(0.95); }
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 880px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.badge-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    color: white;
}

.hero-title .hero-gradient {
    display: block;
    background: linear-gradient(135deg, #60a5fa 0%, #c084fc 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.2rem;
}

.hero-subtitle {
    font-size: 1.15rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2.5rem;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.hero-subtitle strong {
    color: white;
    font-weight: 700;
}

/* CTAボタン */
.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 1.75rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(59, 130, 246, 0.5);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    color: white;
}

.btn-large {
    padding: 1.1rem 2.25rem;
    font-size: 1.1rem;
}

.btn-arrow {
    transition: transform 0.2s ease;
}

.btn:hover .btn-arrow {
    transform: translateX(4px);
}

/* ヒーロー統計 */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.4rem;
    font-weight: 500;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
}

/* ===== セクション共通 ===== */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 1rem;
}

.section-header h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: -0.02em;
}

.section-header .section-lead {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.7;
}

/* main 内のセクション */
main > section {
    padding: 4rem 0 2rem;
}

main > section:first-child {
    padding-top: 5rem;
}

/* ===== 特徴セクション（トップページ「このサイトの特徴」）===== */
.features {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    border-bottom: 1px solid #e2e8f0;
}

/* 章一覧セクションも淡い背景で交互に */
.chapters-section {
    background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
    border-top: 1px solid #e2e8f0;
}

/* ===== 特徴カード ===== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: white;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-top: 4px solid transparent;
    background-image: linear-gradient(white, white), linear-gradient(135deg, #3b82f6, #8b5cf6);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

.feature-card:hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
    line-height: 1;
}

.feature-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.feature-card p {
    color: var(--color-text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
    margin: 0;
}

/* ===== 学習の流れ ===== */
.learning-flow {
    background: linear-gradient(180deg, transparent 0%, #f8fafc 50%, transparent 100%);
}

.flow-steps {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.flow-step {
    width: 100%;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border-left: 6px solid;
    transition: transform 0.3s, box-shadow 0.3s;
}

.flow-step:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.flow-phase-1 { border-left-color: #3b82f6; }
.flow-phase-2 { border-left-color: #8b5cf6; }
.flow-phase-3 { border-left-color: #ec4899; }

.flow-phase-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    color: white;
}

.flow-phase-1 .flow-phase-tag { background: #3b82f6; }
.flow-phase-2 .flow-phase-tag { background: #8b5cf6; }
.flow-phase-3 .flow-phase-tag { background: #ec4899; }

.flow-step h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.flow-step p {
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.7;
}

.flow-arrow-down {
    font-size: 1.6rem;
    color: var(--color-accent);
    padding: 1rem 0;
    font-weight: 700;
    animation: bounce-down 2s ease-in-out infinite;
}

@keyframes bounce-down {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(6px); opacity: 1; }
}

/* ===== 章カード強化 ===== */
.chapters-section {
    padding-top: 4rem !important;
}

.chapter-card {
    position: relative;
    overflow: hidden;
}

.chapter-card-featured {
    position: relative;
}

.chapter-card-featured::before {
    content: '🎮 インタラクティブ';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.chapter-card-shogi {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
}

.chapter-card-shogi:hover {
    border-color: #f59e0b;
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--color-border);
}

.meta-tag {
    font-size: 0.7rem;
    background: rgba(59, 130, 246, 0.08);
    color: var(--color-accent);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-weight: 600;
}

/* ===== ペルソナ ===== */
.personas {
    background: linear-gradient(180deg, transparent, #f8fafc);
}

.personas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.persona-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.persona-card:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
}

.persona-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    line-height: 1;
}

.persona-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.persona-card p {
    color: var(--color-text-muted);
    line-height: 1.7;
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    flex-grow: 1;
}

.persona-link {
    display: inline-block;
    color: var(--color-accent);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}

.persona-link:hover {
    border-bottom-color: var(--color-accent);
}

/* ===== 最終CTA ===== */
.final-cta {
    background: linear-gradient(135deg, #0f172a 0%, #312e81 100%);
    color: white;
    text-align: center;
    border-radius: 24px;
    padding: 4rem 2rem !important;
    margin: 3rem 0 1rem;
    position: relative;
    overflow: hidden;
}

.final-cta::before,
.final-cta::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.final-cta::before {
    top: -100px;
    left: -100px;
    width: 300px;
    height: 300px;
    background: #3b82f6;
}

.final-cta::after {
    bottom: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: #ec4899;
}

.final-cta h2 {
    font-size: 2.2rem;
    color: white;
    border-bottom: none;
    margin: 0 0 1rem;
    position: relative;
    z-index: 1;
}

.final-cta p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.final-cta .hero-cta {
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

/* ===== overview-section ===== */
.overview-section {
    padding-top: 4rem !important;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .hero {
        padding: 3.5rem 1.5rem 4rem;
    }
    .hero-stats {
        gap: 1rem;
    }
    .stat-divider {
        display: none;
    }
    .section-header h2 {
        font-size: 1.7rem;
    }
    main > section {
        padding: 3rem 0 1rem;
    }
    .final-cta {
        padding: 3rem 1.5rem !important;
        border-radius: 16px;
    }
    .final-cta h2 {
        font-size: 1.6rem;
    }
}

/* ===== 全体像フロー (Overview Flow) ===== */
.overview-flow {
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.overview-step {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 1.5rem;
    background: white;
    border: 2px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-card);
}

.overview-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    font-size: 1.75rem;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.overview-step-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0; /* grid の 1fr が中身（SVG・数式）に引っ張られて広がるのを防ぐ */
}

.overview-step-content h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--color-text);
}

.overview-summary {
    margin: 0;
    color: var(--color-text);
    line-height: 1.7;
    font-size: 1rem;
}

.overview-mini-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.5rem 0;
}

.overview-mini-svg svg {
    max-width: 100%;
    height: auto;
}

.overview-formula {
    margin: 0;
    text-align: center;
    overflow-x: auto;
    background: var(--color-code-bg);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.95em;
    color: var(--color-text);
}

.overview-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-accent);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.5rem;
    letter-spacing: 0.05em;
}

@media (max-width: 640px) {
    .quadrant-badge {
        white-space: normal;
        line-height: 1.5;
    }

    .overview-step {
        grid-template-columns: 50px 1fr;
        gap: 1rem;
        padding: 1.25rem 1rem;
    }

    .overview-step-num {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    .overview-step-content h3 {
        font-size: 1.1rem;
    }
}

/* ===== サイドバー（デスクトップ用） — 2カラム構造 ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 440px;
    height: 100vh;
    background: white;
    border-right: 1px solid var(--color-border);
    overflow: hidden;
    z-index: 50;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
}

/* トップページ用：1カラムなのでサイドバーを狭く */
.sidebar.sidebar-narrow {
    width: 280px;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ロゴ：上部全幅 */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--color-border);
    transition: opacity 0.15s;
    flex-shrink: 0;
    background: white;
}

.sidebar-logo:hover {
    opacity: 0.7;
}

.sidebar-logo .logo-icon {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-logo .logo-text {
    line-height: 1.2;
}

/* 2カラムレイアウト */
.sidebar-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex-grow: 1;
    overflow: hidden;
    min-height: 0;
}

/* 1カラムレイアウト（トップページ用） */
.sidebar-columns.sidebar-columns-single {
    grid-template-columns: 1fr;
    flex-grow: 0;
}

/* 1カラム時：章リストの右に区切り線を出さない */
.sidebar-columns.sidebar-columns-single .sidebar-column-chapters {
    border-right: none;
}

/* 1カラム時：フッターを下端に押し出す */
.sidebar-inner:has(.sidebar-columns-single) .sidebar-footer {
    margin-top: auto;
}

.sidebar-column {
    overflow-y: auto;
    padding: 1rem 0.5rem 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-column-chapters {
    border-right: 1px solid var(--color-border);
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

.sidebar-column-toc {
    background: linear-gradient(180deg, #fffef9 0%, #ffffff 100%);
}

/* 各カラムのスクロールバーを細く */
.sidebar-column::-webkit-scrollbar {
    width: 6px;
}

.sidebar-column::-webkit-scrollbar-track {
    background: transparent;
}

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

.sidebar-column::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* セクション見出し */
.sidebar-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.06em;
    margin: 0 0 0.6rem;
    padding: 0 0.5rem;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
}

/* リスト */
.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-list li {
    margin: 0;
}

.sidebar-list a {
    display: block;
    padding: 0.5rem 0.6rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.82rem;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s, border-left-color 0.12s;
    border-left: 3px solid transparent;
    line-height: 1.4;
    margin: 1px 0;
}

.sidebar-list a:hover {
    background: #f3f4f6;
    color: var(--color-accent);
}

/* 大目次（左カラム）：現在の章 */
.sidebar-chapters li.active > a {
    background: var(--color-accent-light);
    color: var(--color-accent);
    font-weight: 700;
    border-left-color: var(--color-accent);
}

.sidebar-chapters .chapter-tag {
    display: inline-block;
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-accent);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-right: 0.3rem;
    flex-shrink: 0;
}

.sidebar-chapters li.active .chapter-tag {
    background: var(--color-accent);
    color: white;
}

.sidebar-chapters a {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.sidebar-chapters a > span:last-child {
    font-size: 0.78rem;
    line-height: 1.3;
}

/* 小目次（右カラム）：現在のセクション */
.sidebar-toc a {
    font-size: 0.82rem;
    padding: 0.4rem 0.6rem;
    color: var(--color-text-muted);
}

.sidebar-toc a:hover {
    color: var(--color-text);
    background: #fffbeb;
}

.sidebar-toc li.active > a {
    background: #fef3c7;
    color: #92400e;
    border-left-color: #f59e0b;
    font-weight: 600;
}

/* フッター：下部全幅 */
.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.7rem;
    color: var(--color-text-muted);
    background: white;
    text-align: center;
}

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

.sidebar-footer a:hover {
    text-decoration: underline;
}

/* デスクトップ：サイドバー表示、上部ナビ非表示 */
@media (min-width: 1024px) {
    body {
        padding-left: 440px;
    }

    /* トップページ：サイドバー(280px)の右側に余白を確保 */
    body.page-home {
        padding-left: 280px;
    }

    body:has(.sidebar.sidebar-narrow) {
        padding-left: 280px;
    }

    /* トップページ：main を画面いっぱいに広げ、各セクションの中身を中央寄せ */
    body.page-home main {
        max-width: none;
        padding-left: 0;
        padding-right: 0;
    }

    /* 各セクション内の主要コンテンツを max-width 880px で中央寄せ */
    body.page-home main > section > .section-header,
    body.page-home main > section > .features-grid,
    body.page-home main > section > .flow-steps,
    body.page-home main > section > .chapter-grid,
    body.page-home main > section > .personas-grid,
    body.page-home main > section > .diagram-wrapper,
    body.page-home main > section > .card,
    body.page-home main > section > p,
    body.page-home main > section > h2,
    body.page-home main > section > h3 {
        max-width: 880px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 2rem;
        padding-right: 2rem;
        box-sizing: border-box;
        width: 100%;
    }

    /* セクションの上下余白（左右はコンテンツ側で管理） */
    body.page-home main > section {
        padding-left: 0;
        padding-right: 0;
    }

    /* 最終CTAは独自の背景なので、内側にもう少し幅を確保 */
    body.page-home main > .final-cta {
        max-width: 880px;
        margin-left: auto;
        margin-right: auto;
    }

    nav.top-nav,
    nav.sub-nav {
        display: none;
    }

    header.site-header,
    main,
    footer {
        margin-left: 0;
    }
}

/* モバイル/タブレット：ドロワーメニュー */
@media (max-width: 1023px) {
    /* サイドバーをドロワーとして左に隠す */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 300px;
        z-index: 1001;
    }

    .sidebar.drawer-open {
        transform: translateX(0);
    }

    /* トップページ（sidebar-narrow）も含めてドロワー幅を揃える */
    .sidebar,
    .sidebar.sidebar-narrow {
        width: min(88vw, 360px);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    body {
        padding-left: 0;
    }

    /* ドロワー内は全体を1つのスクロール領域にする */
    .sidebar-inner {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ロゴ行はスクロールしても上部に固定 */
    .sidebar-logo {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 0.9rem 3rem 0.9rem 1rem;
        font-size: 1rem;
    }

    /* ドロワーを閉じるボタン（sidebar.js が生成） */
    .drawer-close {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        z-index: 3;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f3f4f6;
        border: none;
        border-radius: 50%;
        color: var(--color-text);
        font-size: 1.1rem;
        line-height: 1;
        cursor: pointer;
    }

    .drawer-close:hover {
        background: #e5e7eb;
    }

    /* 2カラム → 縦積み1カラム */
    .sidebar-columns,
    .sidebar-columns.sidebar-columns-single {
        display: flex;
        flex-direction: column;
        flex: 0 0 auto;
        min-height: auto;
        overflow: visible;
    }

    .sidebar-column {
        flex: 0 0 auto;
        min-height: auto;
        overflow: visible;
        padding: 1rem 0.75rem 1.1rem;
    }

    /* 「この章の目次」を上、「全章目次」を下に */
    .sidebar-column-toc {
        order: -1;
        border-bottom: 1px solid var(--color-border);
    }

    .sidebar-column-chapters {
        border-right: none;
        background: none;
    }

    .sidebar-heading {
        position: static;
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    /* リンクをタップしやすい大きさに */
    .sidebar-list a {
        font-size: 0.95rem;
        padding: 0.6rem 0.75rem;
        margin: 2px 0;
    }

    /* 章バッジと章名を1行に収める */
    .sidebar-chapters a {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .sidebar-chapters .chapter-tag {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
        margin-right: 0;
        white-space: nowrap;
    }

    .sidebar-chapters a > span:last-child {
        font-size: 0.92rem;
        line-height: 1.35;
    }

    .sidebar-toc a {
        font-size: 0.95rem;
        padding: 0.55rem 0.75rem;
    }

    .sidebar-footer {
        margin-top: auto;
        padding: 0.75rem 1rem;
    }

    /* 上部ナビを非表示にし、モバイルヘッダーに置き換え */
    nav.top-nav,
    nav.sub-nav {
        display: none;
    }

    /* モバイルヘッダー */
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        background: white;
        border-bottom: 1px solid var(--color-border);
        padding: 0.65rem 1rem;
        height: 48px;
    }

    .mobile-header-title {
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--color-text);
        text-decoration: none;
    }

    /* ハンバーガーアイコン */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
    }

    .menu-icon,
    .menu-icon::before,
    .menu-icon::after {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--color-text);
        border-radius: 2px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .menu-icon {
        position: relative;
    }

    .menu-icon::before,
    .menu-icon::after {
        content: '';
        position: absolute;
        left: 0;
    }

    .menu-icon::before {
        top: -6px;
    }

    .menu-icon::after {
        top: 6px;
    }

    /* ハンバーガー → ✕ アニメーション */
    .mobile-menu-btn.active .menu-icon {
        background: transparent;
    }

    .mobile-menu-btn.active .menu-icon::before {
        top: 0;
        transform: rotate(45deg);
    }

    .mobile-menu-btn.active .menu-icon::after {
        top: 0;
        transform: rotate(-45deg);
    }

    /* オーバーレイ */
    .drawer-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .drawer-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
}

/* デスクトップではモバイルヘッダーとオーバーレイを非表示 */
@media (min-width: 1024px) {
    .mobile-header,
    .drawer-overlay,
    .drawer-close {
        display: none;
    }
}

/* ===== 入れ子図 (Nested Diagram) ===== */
.diagram-wrapper {
    margin: 2.5rem 0;
}

.nested-diagram {
    position: relative;
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 16px;
    margin: 1.25rem auto;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.06);
}

.nested-diagram:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.1);
}

/* 各レイヤーの色 — 外側ほど淡く、内側ほど鮮やか */
.diagram-wrapper > .nested-diagram {
    /* AI層（最外層） */
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 2px solid #94a3b8;
}

.layer-ml {
    /* 機械学習層 */
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 2px solid #60a5fa;
}

.layer-nn {
    /* ニューラルネット層 */
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    border: 2px solid #a78bfa;
}

.layer-dl {
    /* ディープラーニング層 */
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    border: 2px solid #ec4899;
}

.layer-genai {
    /* 生成AI層（最内層） */
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    margin-bottom: 0;
}

/* レイヤーラベル（左上に貼り付くタグ風） */
.layer-label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    margin-bottom: 0.5rem;
}

.layer-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
}

.layer-year {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.8rem;
    color: white;
    background: var(--color-text);
    padding: 0.1rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
}

.layer-desc {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    margin-left: 0.5rem;
    line-height: 1.5;
}

/* 並列の統計学box */
.parallel-diagram {
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 16px;
    margin: 1.25rem auto;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 2px solid #10b981;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.parallel-diagram:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.1);
}

/* 区切り（並列を示す矢印） */
.diagram-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 2rem auto;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.divider-arrow {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    animation: bounce 2s ease-in-out infinite;
}

.divider-text {
    background: white;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(4px); opacity: 1; }
}

/* レスポンシブ */
@media (max-width: 640px) {
    .nested-diagram, .parallel-diagram {
        padding: 1.25rem 1rem;
    }
    .layer-label {
        flex-wrap: wrap;
        font-size: 0.95rem;
    }
    .layer-name {
        font-size: 0.95rem;
    }
}

/* ===== レスポンシブ全般 ===== */
@media (max-width: 640px) {
    header.site-header {
        padding: 2.5rem 1rem;
    }

    header.site-header h1 {
        font-size: 1.75rem;
    }

    main {
        padding: 2rem 1rem;
    }

    main h1 {
        font-size: 1.6rem;
    }

    main h2 {
        font-size: 1.3rem;
    }

    .interactive {
        padding: 1.25rem;
    }

    .slider-row {
        grid-template-columns: 60px 1fr 60px;
    }
}
