:root {
    --c-bg: #F7F5F2;
    --c-surface: #FCFBF9;
    --c-text: #4C463D;
    --c-text-muted: #8A8176;
    --c-accent: #005F73;
    --c-accent-darker: #004B5A;
    --c-accent-light: rgba(0, 95, 115, 0.1);
    --c-border: #E5E0DA;
    --c-row-hover: #F1EDE9;
    --c-panel-bg: rgba(250, 249, 247, 0.85);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --gradient-start: #F7F5F2;
    --gradient-end: #EFEAE4;
}

[data-theme="dark"] {
    --c-bg: #211F1D;
    --c-surface: #2A2724;
    --c-text: #EFEAE4;
    --c-text-muted: #9A9187;
    --c-accent: #E59572;
    --c-accent-darker: #D48C6E;
    --c-accent-light: rgba(229, 149, 114, 0.15);
    --c-border: #3c3833;
    --c-row-hover: #34302c;
    --c-panel-bg: rgba(42, 39, 36, 0.85);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.3);
    --gradient-start: #2A2724;
    --gradient-end: #211F1D;
}

@keyframes gradient-animation {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    background-size: 200% 200%;
    animation: gradient-animation 15s ease infinite;
    color: var(--c-text);
    line-height: 1.7;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: auto;
    padding: 30px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.header-title {
    display: flex;
    align-items: baseline;
    gap: 1em;
    flex-wrap: wrap;
}

.header-title h1 {
    margin: 0;
    font-size: 1.3rem;
    font-family: 'Hepta Slab', 'Source Serif Pro', 'Noto Serif JP', serif;
    font-weight: 400;
    letter-spacing: 0.03em;
}

.header-title h1 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.header-title h1 a:hover {
    color: var(--c-accent);
}

.tagline {
    margin: 0;
    padding-left: 1em;
    border-left: 1px solid var(--c-border);
    font-size: 0.85rem;
    color: var(--c-text-muted);
    font-weight: 400;
    white-space: nowrap;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.social-links {
    display: flex;
    gap: 20px;
}

.social-links a {
    color: var(--c-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    text-decoration: none;
}


.social-links a:hover {
    color: var(--c-accent);
}

.social-links svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.theme-switch {
    background: none;
    border: 1px solid var(--c-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-muted);
    transition: all 0.3s ease;
}

.theme-switch:hover {
    color: var(--c-accent);
    border-color: var(--c-accent);
    transform: rotate(15deg);
}

.theme-switch svg {
    width: 20px;
    height: 20px;
}

.theme-switch .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-switch .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-switch .icon-moon {
    display: none;
}

.modal-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.modal-panel.visible {
    opacity: 1;
    visibility: visible;
}

.panel-content {
    background-color: var(--c-panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 30px 40px;
    width: min(90vw, 700px);
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-panel.visible .panel-content {
    transform: scale(1) translateY(0);
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--c-text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
}

.close-button:hover {
    color: var(--c-text);
    transform: rotate(90deg);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.profile-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--c-accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-icon svg {
    width: 40px;
    height: 40px;
    fill: var(--c-accent);
}

.profile-title h2 {
    margin: 0 0 5px 0;
    border-left: none;
    padding-left: 0;
    font-size: 1.8rem;
}

.profile-title p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--c-text-muted);
}

.profile-section {
    margin-bottom: 25px;
}

.profile-section h3 {
    font-size: 1.1rem;
    color: var(--c-text);
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.profile-section p {
    font-size: 0.95rem;
    margin: 0;
}

.skills-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.skills-list li {
    background-color: var(--c-row-hover);
    color: var(--c-text);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    border: 1px solid var(--c-border);
}

.links-header {
    text-align: center;
    margin-bottom: 25px;
}

.links-header h2 {
    margin: 0 0 5px 0;
    border-left: none;
    padding-left: 0;
    font-size: 1.8rem;
}

.links-header p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--c-text-muted);
}

.links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.links-list li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    text-decoration: none;
    background-color: var(--c-surface);
    border-radius: 8px;
    border: 1px solid var(--c-border);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.links-list li a:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--c-accent);
}

.links-list .link-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.links-list .link-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--c-text-muted);
    transition: fill 0.2s;
}

.links-list li a:hover .link-icon svg {
    fill: var(--c-accent);
}

.links-list .link-text {
    display: flex;
    flex-direction: column;
}

.links-list .link-text strong {
    color: var(--c-text);
    font-size: 1rem;
    transition: color 0.2s;
}

.links-list li a:hover .link-text strong {
    color: var(--c-accent);
}

.links-list .link-text span {
    color: var(--c-text-muted);
    font-size: 0.85rem;
}

.article-container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: var(--c-surface);
    padding: 50px 60px;
    border-radius: 3px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--c-border);
}

.article-header {
    border-bottom: 3px solid var(--c-border);
    margin-bottom: 25px;
    padding-bottom: 18px;
}

.article-header h1 {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.8rem;
    line-height: 1.4;
    margin: 0 0 15px 0;
    color: var(--c-text);
}

.article-meta {
    font-size: 0.85rem;
    color: var(--c-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.article-meta span {
    display: inline-flex;
    align-items: center;
}

.article-meta .tag {
    display: inline-block;
    background-color: var(--c-accent-light);
    color: var(--c-accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 5px;
}

.article-body {
    font-size: 16px;
    line-height: 1.8;
    font-family: 'Noto Serif JP', serif;
    text-align: justify;
}

.article-body h2 {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.4rem;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 8px;
    margin-top: 40px;
    margin-bottom: 20px;
    font-weight: bold;
}

.article-body h3 {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.2rem;
    border-left: 2px solid var(--c-accent);
    padding-left: 12px;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: normal;
}

.article-body p {
    margin: 0 0 0.6em 0;
}

.article-body a {
    color: var(--c-accent);
    text-decoration: underline;
    transition: color 0.2s;
}

.article-body a:hover {
    color: var(--c-accent-darker);
}

.article-body ul,
.article-body ol {
    padding-left: 2em;
}

.article-body img {
    max-width: 100%;
    height: auto;
    max-height: 450px; /* ← お好みの高さに調整してください */
    display: block;
    margin: 2em auto;
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    cursor: pointer; /* この行を追加 */
    transition: opacity 0.2s;
}
.article-body img:hover {
    opacity: 0.85; /* ホバー時に少し透明にする効果 */
}


.article-body blockquote {
    margin: 1.5em 0;
    padding: 10px 20px;
    border-left: 4px solid var(--c-border);
    background-color: var(--c-row-hover);
    color: var(--c-text-muted);
}

.article-body blockquote p {
    margin-bottom: 0;
}

.article-body pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 1.2em 1.5em;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 1.5em;
}

.article-body code {
    font-family: 'Roboto Mono', monospace;
}

.article-body p>code {
    background-color: var(--c-row-hover);
    color: var(--c-accent);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
}

.footer {
    text-align: center;
    padding: 10px 0 10px 0;
    margin-top: 40px;
    font-size: 0.75rem;
    color: var(--c-text-muted);
}

.article-meta a,
.article-meta a:visited {
    color: var(--c-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.article-meta a:hover {
    color: var(--c-accent);
}

.article-meta .tag-link {
    text-decoration: none;
}

.article-body ul {
    list-style: none;
    padding-left: 1em;
}

.article-body ul li {
    position: relative;
    padding-left: 1.5em;
    margin-bottom: 0.1em;
}

/* 箇条書きマーカーの基本スタイル（全階層共通） */
.article-body ul li::before {
    content: '-'; /* en dash記号に統一 */
    position: absolute;
    left: 0;
    color: var(--c-accent); /* 1階層目の色 */
    font-weight: bold;
    /* ダッシュ記号のバランスを調整 */
    font-size: 1.2em;
    line-height: 1.5;
}

/* ネストされたulの余白調整 */
.article-body ul ul {
    padding-left: 1.8em;
    margin-top: 0em;
}

/* 2階層目以降のマーカーの色を上書き */
.article-body ul ul li::before {
    color: var(--c-text-muted);
}

/* ===== 目次 (Table of Contents) - ここから ===== */
.toc-container {
    background-color: var(--c-surface);
    border: 2px solid var(--c-border);
    border-radius: 8px;
    margin-bottom: 30px;
    padding: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.toc-container[open] {
    padding-bottom: 0; /* paddingはnav側で管理するため不要 */
}

/* 目次のタイトル部分（<summary>タグ想定） */
.toc-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    color: var(--c-text);
    padding: 15px 20px;
    list-style: none; /* デフォルトのマーカーを非表示 */
    transition: background-color 0.2s;
    position: relative;
}

.toc-title:hover {
    background-color: var(--c-row-hover);
}

.toc-title::-webkit-details-marker {
    display: none; /* Chrome/Safariのデフォルト矢印を非表示 */
}

/* 開閉アイコン（矢印）を追加 */
.toc-title::before {
    content: '▶';
    font-size: 0.7em;
    margin-right: 12px;
    color: var(--c-accent);
    transition: transform 0.3s ease;
    display: inline-block;
}

/* detailsが開いた状態のアイコンを回転 */
.toc-container[open] > .toc-title::before {
    transform: rotate(90deg);
}

/* 目次のリスト部分 */
.toc-container nav {
    padding: 0px 20px 10px 20px;
    margin-top: 0;
    border-top: 1px solid var(--c-border);
}

/* detailsが開いた時にnavをアニメーション表示 */
.toc-container[open] nav {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* リスト全体のスタイル */
.toc-container ul {
    list-style-type: none;
    padding-left: 15px;
    border-left: 3px solid var(--c-border);
    position: relative;
}

.toc-container ul:first-child {
    margin-top: 15px; /* タイトル下の罫線との間に余白を追加 */
}


.toc-container li {
    margin-bottom: 8px;
}
.toc-container li:last-child {
    margin-bottom: 0;
}

/* リンクのスタイル */
.toc-container a {
    color: var(--c-text-muted);
    text-decoration: none;
    font-size: 1rem;
    display: block;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.toc-container a:hover {
    color: var(--c-accent);
    background-color: var(--c-accent-light);
    text-decoration: none;
}

/* ネストされたリストのスタイル */
.toc-container ul ul {
    margin-top: 8px;
    padding-left: 20px; /* インデントをさらに追加 */
}
/* ===== 目次 (Table of Contents) - ここまで ===== */

/* ===== Table Styles ===== */

/* テーブルを囲むラッパー（レスポンシブ対応のため） */
.article-body .table-wrapper {
    overflow-x: auto; /* テーブルが画面幅を超える場合に横スクロールを有効にする */
    margin: 2em 0;
    border: 1px solid var(--c-border);
    border-radius: 8px; /* 角を丸める */
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch; /* スマートフォンでのスクロールを滑らかに */
}

.article-body table {
    width: 100%;
    border-collapse: collapse; /* セルの境界線を一本化 */
    font-size: 0.95rem; /* 本文より少しだけ文字を小さくする */
    min-width: 600px; /* この幅より狭い画面で横スクロールが発生 */
}

.article-body th,
.article-body td {
    padding: 12px 15px; /* セル内の余白を確保 */
    text-align: left; /* 文字を左揃えに */
    border-bottom: 1px solid var(--c-border); /* 行の区切り線 */
}

/* テーブルヘッダーのスタイル */
.article-body thead th {
    background-color: var(--c-row-hover); /* ヘッダーの背景色 */
    font-weight: 600; /* やや太字に */
    color: var(--c-text);
    font-size: 0.9rem;
    font-family: 'Noto Sans JP', sans-serif; /* ヘッダーはゴシック体で統一 */
}

/* テーブルボディの行にマウスカーソルを乗せた時の効果 */
.article-body tbody tr:hover {
    background-color: var(--c-row-hover);
}

/* テーブルの最終行の下線を消し、スッキリ見せる */
.article-body tbody tr:last-child th,
.article-body tbody tr:last-child td {
    border-bottom: none;
}

/* 画像ライトボックスの背景オーバーレイ */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(33, 31, 29, 0.9); /* ダークテーマに合わせた半透明の黒 */
    backdrop-filter: blur(5px); /* 背景をぼかす効果 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    cursor: pointer;
}

.lightbox-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* 表示される画像本体 */
.lightbox-content {
    max-width: 90vw; /* 画面幅の90%を最大幅に */
    max-height: 90vh; /* 画面高さの90%を最大高に */
    display: block;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
    transition: transform 0.3s ease;
    transform: scale(0.95);
    cursor: default; /* 画像上ではカーソルを標準に戻す */
}

.lightbox-overlay.visible .lightbox-content {
    transform: scale(1);
}

/* 閉じるボタン */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 3rem;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.lightbox-close:hover {
    color: var(--c-text-muted);
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    /* ===== 全体レイアウト ===== */
    .container {
        padding: 20px 15px; /* 全体の余白を調整 */
    }

    /* ===== ヘッダー ===== */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .tagline {
        padding-left: 0;
        border-left: none;
    }

    /* ===== 記事コンテナ ===== */
    .article-container {
        padding: 30px 20px; /* 記事エリアの余白を調整 */
    }

    /* ===== 記事ヘッダー ===== */
    .article-header h1 {
        font-size: 1.6rem; /* スマートフォン向けにタイトルを少し小さく */
        line-height: 1.5;
    }

    .article-meta {
        gap: 8px 15px; /* メタ情報（日付など）の行間を少し詰める */
    }

    /* ===== 記事本文 ===== */
    .article-body {
        font-size: 15px; /* 本文のフォントサイズを調整 */
        line-height: 1.8;
    }

    .article-body h2 {
        font-size: 1.3rem; /* h2見出しのサイズを調整 */
        margin-top: 35px;
    }

    .article-body h3 {
        font-size: 1.15rem; /* h3見出しのサイズを調整 */
        margin-top: 25px;
    }
    
    .article-body img {
         margin: 1.5em auto; /* 画像の上下マージンを少し詰める */
    }

    /* ===== 目次 ===== */
    .toc-title {
        padding: 12px 15px;
    }

    .toc-container nav {
        padding: 5px 15px 10px 15px;
    }

    /* ===== プロフィール等のモーダルパネル ===== */
    .panel-content {
        width: 95vw; /* 画面幅いっぱいに広がるように調整 */
        padding: 25px 20px;
    }

    /* ===== ライトボックスの閉じるボタン ===== */
    .lightbox-close {
        top: 15px;
        right: 20px;
        font-size: 2.5rem;
    }
}