:root {
    /* Brand Colors */
    --nix-blue: #5277C3;
    --nix-dark: #24292E;
    --nix-light: #7EBAE4;
    
    /* Backgrounds & Text */
    --bg-white: #FAFAFA;
    --bg-section: #F4F6F8;
    --text-main: #333333;
    --text-muted: #666666;
    
    /* Code & Accents */
    --code-bg: #1E1E1E; /* Dark theme for Terminal */
    --code-text: #D4D4D4;
    --doc-code-bg: #f6f8fa; /* Light theme for Articles */
    --border-color: #E1E4E8;
    
    /* Shadows */
    --card-shadow: 0 4px 6px rgba(0,0,0,0.02);
    --card-hover-shadow: 0 12px 24px rgba(0,0,0,0.08);
}

/* --- 1. Base Reset & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background-color: var(--bg-white);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- 2. Header & Navigation --- */
header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.2rem 5%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-link {
    text-decoration: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--nix-blue);
}

.logo img {
    height: 2rem;
    width: auto;
}

.logo span { color: var(--nix-dark); }

nav ul { display: flex; align-items: center; list-style: none; gap: 2rem; }
nav ul li a { 
    text-decoration: none; 
    color: var(--nix-dark); 
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}
nav ul li a:hover { color: var(--nix-blue); }

/* Header Search Button (Cmd+K) */
.cmd-k-btn {
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 0.35rem 0.8rem;
    font-family: inherit;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.cmd-k-btn:hover {
    background: #fff;
    border-color: var(--nix-blue);
    color: var(--nix-blue);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.cmd-k-badge {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    padding: 0px 6px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: #666;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* --- 3. Hero Section (Top Page) --- */
.hero {
    padding: 6rem 5%;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 4rem;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 80vh;
}

h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -1.5px;
    color: var(--nix-dark);
}

.highlight { color: var(--nix-blue); }

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 540px;
    line-height: 1.8;
}

.cta-group { display: flex; gap: 1rem; }

.btn-primary {
    background: var(--nix-blue);
    color: white;
    padding: 1rem 2.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid var(--nix-blue);
}
.btn-primary:hover { 
    background: #4060a0; 
    border-color: #4060a0;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--nix-blue);
    color: var(--nix-blue);
    padding: 1rem 2.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-secondary:hover { 
    background: rgba(82, 119, 195, 0.08); 
}

/* --- 4. Dynamic Terminal Window --- */
.terminal-window {
    min-height: 380px;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: var(--code-bg);
    border: 1px solid #333;
    overflow: hidden;
}

.code-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2d2d2d;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #1a1a1a;
}

.label-text {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
}

.terminal-controls {
    display: flex;
    gap: 8px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.control.close { background-color: #ff5f56; }
.control.minimize { background-color: #ffbd2e; }
.control.maximize { background-color: #27c93f; }

.terminal-window pre {
    flex-grow: 1;
    margin: 0;
    padding: 1.5rem;
    background: var(--code-bg);
    color: var(--code-text);
    overflow: hidden;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Typed.js Cursor */
.typed-cursor {
    color: var(--nix-blue);
    opacity: 1;
}

/* Syntax Highlighting for Terminal */
.code-comment { color: #6A9955; font-style: italic; }
.code-string { color: #CE9178; }

/* --- 5. Curriculum Section (12 Chapters) --- */
.curriculum {
    padding: 6rem 5%;
    background-color: var(--bg-section);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.section-header h2 {
    font-size: 2.5rem;
    color: var(--nix-dark);
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.chapter-card {
    background: #fff;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--nix-blue);
}

.chapter-meta {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--nix-blue);
    margin-bottom: 1rem;
    font-weight: 800;
    opacity: 0.8;
}

.chapter-card h3 {
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.chapter-card h3 a {
    text-decoration: none;
    color: var(--nix-dark);
    font-size: 1.25rem;
    font-weight: 700;
    display: block;
}

.chapter-card h3 span {
    display: block;
    font-size: 0.85rem;
    color: #999;
    font-weight: normal;
    margin-top: 0.4rem;
    font-family: sans-serif;
}

.topic-list {
    list-style: none;
    margin-top: auto;
}

.topic-list li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.5;
}

.topic-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--nix-blue);
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1.1;
}

/* New Chapter Badge (Optional) */
.new-chapter::after {
    /* content: "NEW"; */
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.6rem;
    background: var(--nix-blue);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* --- 6. Features Section --- */
.features {
    padding: 6rem 5%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    background: #fff;
    max-width: 1400px;
    margin: 0 auto;
}

.feature-card {
    padding: 2rem;
    border-top: 4px solid var(--nix-blue); 
    background: #fff;
}

.feature-card .icon {
    font-weight: 800;
    color: var(--nix-blue);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--nix-dark);
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* --- 7. Footer --- */
footer {
    text-align: center;
    padding: 4rem;
    font-size: 0.85rem;
    color: #999;
    border-top: 1px solid var(--border-color);
    background: #fff;
}

/* --- 8. Global Components for Articles & Docs --- */

/* Article Code Blocks (Light Theme) */
.doc-code-block {
    background: var(--doc-code-bg);
    border: 1px solid #d0d7de;
    border-radius: 6px;
    margin: 1.5rem 0;
    padding: 0;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    break-inside: avoid;
}

.doc-code-label {
    background: #eef2f6;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: #57606a;
    font-weight: bold;
    border-bottom: 1px solid #d0d7de;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.doc-code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    color: #24292f;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Copy Button */
.copy-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.75rem;
    color: #57606a;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.copy-btn:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--nix-blue);
}
.copy-btn.copied {
    color: #2da44e; /* GitHub Green */
    border-color: rgba(45, 164, 78, 0.3);
    background-color: rgba(45, 164, 78, 0.05);
}

/* Technical Note Box */
.technical-note {
    background-color: #fcfcfc;
    border-left: 4px solid #6e7681;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    color: #444;
    font-size: 0.95rem;
}
.technical-note h4 {
    margin-top: 0;
    color: #24292E;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* Math Formula Box */
.math-formula {
    font-family: 'Times New Roman', serif;
    font-style: italic;
    background: #fdfdfd;
    padding: 1rem;
    text-align: center;
    border: 1px solid #eee;
    margin: 1rem 0;
    font-size: 1.1rem;
}

/* Concept Diagram Container */
.concept-diagram {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 2rem;
    margin: 2rem 0;
    border-radius: 8px;
    text-align: center;
    break-inside: avoid;
}

/* --- 9. Command Palette Modal --- */
.cmd-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    animation: fadeIn 0.1s ease-out;
}
.cmd-palette-overlay.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.cmd-palette {
    width: 90%;
    max-width: 600px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cmd-header { padding: 1rem; border-bottom: 1px solid var(--border-color); }
.cmd-input {
    width: 100%; border: none; font-size: 1.2rem; font-family: inherit;
    color: var(--nix-dark); outline: none; background: transparent;
}
.cmd-input::placeholder { color: #ccc; }

.cmd-results {
    max-height: 400px; overflow-y: auto; padding: 0.5rem; list-style: none;
}
.cmd-item {
    padding: 0.8rem 1rem; border-radius: 4px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text-main); transition: background 0.1s; margin-bottom: 2px;
}
.cmd-item-title { font-weight: 600; font-size: 0.95rem; }
.cmd-item-subtitle { font-size: 0.8rem; color: #888; margin-left: 1rem; }

.cmd-item.selected, .cmd-item:hover {
    background-color: var(--nix-blue); color: white;
}
.cmd-item.selected .cmd-item-subtitle, .cmd-item:hover .cmd-item-subtitle {
    color: rgba(255,255,255,0.8);
}

.cmd-footer {
    padding: 0.5rem 1rem; background: #f9f9f9; border-top: 1px solid var(--border-color);
    font-size: 0.75rem; color: #999; display: flex; justify-content: space-between;
}
.cmd-key {
    background: #eee; padding: 2px 6px; border-radius: 3px;
    border: 1px solid #ddd; font-family: monospace; margin: 0 4px;
}

/* --- 10. Responsive Queries --- */
@media (max-width: 1024px) {
    h1 { font-size: 2.8rem; }
    .hero { 
        grid-template-columns: 1fr; 
        gap: 3rem;
        padding: 4rem 5%;
        text-align: center;
    }
    .hero-content { margin: 0 auto; }
    .subtitle { margin: 0 auto 2.5rem auto; }
    .cta-group { justify-content: center; }
    .terminal-window { order: 2; margin-top: 2rem; }
    
    .features { grid-template-columns: 1fr; gap: 2rem; }
}

@media (max-width: 768px) {
    nav { flex-direction: column; gap: 1rem; padding: 1rem; }
    nav ul { flex-wrap: wrap; justify-content: center; gap: 1rem; }
    
    .chapter-grid { grid-template-columns: 1fr; }
    
    .btn-primary, .btn-secondary {
        width: 100%; display: block; margin-bottom: 0.5rem; padding: 1rem;
    }
    .cta-group { flex-direction: column; width: 100%; }
}

@media (max-width: 600px) {
    .cmd-k-badge { display: none; }
}

/* --- Topic List Links --- */
.topic-list li a {
    text-decoration: none;
    color: inherit; /* 親の文字色(#555)を受け継ぐ */
    transition: color 0.2s;
    display: inline-block;
}

.topic-list li a:hover {
    color: var(--nix-blue); /* ホバー時のみNixブルーに */
    text-decoration: underline;
}

/* --- Back to Top Button --- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background-color: var(--nix-blue);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(52, 125, 219, 0.4);
    
    /* フレックスボックスでアイコンを中央寄せ */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* アニメーション設定 */
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none; /* 見えないときはクリック不可に */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 900;
}

/* 表示状態のクラス */
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ホバー時のエフェクト */
.back-to-top:hover {
    background-color: var(--nix-dark);
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* アイコンサイズ */
.back-to-top svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* スマホでの調整（少し小さく、端に寄せすぎない） */
@media (max-width: 768px) {
    .back-to-top {
        width: 3rem;
        height: 3rem;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    margin-bottom: 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace; /* コードっぽいフォントで統一 */
}

.breadcrumbs ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
}

/* 区切り文字 (/) */
.breadcrumbs li:not(:last-child)::after {
    content: "/";
    margin-left: 0.5rem;
    color: #ccc;
    font-weight: normal;
}

.breadcrumbs a {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: var(--nix-blue);
    text-decoration: underline;
}

/* 現在のページ */
.breadcrumbs li[aria-current="page"] {
    color: var(--nix-dark);
    font-weight: 700;
}

/* スマホ表示時の調整 */
@media (max-width: 768px) {
    .breadcrumbs {
        margin-bottom: 1.5rem;
        font-size: 0.75rem;
    }
}