/* ============================================================
   1. 共通・ページ共通レイアウト
============================================================ */
.km-detail-page, .km-person-index {
    padding: calc(var(--header-height) + 20px) 0 80px;
    background-color: #fcfcfc;
}

.container_md {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 区切り線 */
.km-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 60px 0;
}

/* ============================================================
   2. 人物一覧ページ (Figures) 固有スタイル
============================================================ */
.km-hero-section {
    padding: 40px 0 60px;
    text-align: center;
}

.km-page-title {
    font-family: 'Lato', sans-serif;
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    margin-bottom: 30px;
    color: #1a1a1a;
}

.km-lead-text {
    font-size: 1.15rem;
    line-height: 2;
    color: #444;
    max-width: 800px;
    margin: 0 auto;
}

.km-text-columns {
    column-count: 2;
    column-gap: 50px;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #555;
    margin-bottom: 40px;
}

/* 人物カードグリッド */
.km-person-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin: 50px 0;
}

.km-person-card {
    display: block;
    text-decoration: none;
    border-top: 1px solid #eee;
    padding: 30px 10px;
    transition: all 0.3s ease;
    color: inherit;
}

.km-person-card:hover {
    background-color: #fafafa;
    border-top: 1px solid #333;
    transform: translateY(-5px);
}

.km-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

/* --- 史料引用グリッド：2列を維持 --- */
.km-archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(calc(50% - 25px), 1fr));
    column-gap: 40px;
    row-gap: 50px;
    margin: 60px 0 40px;
}

/* --- 史料引用ブロック（親要素） --- */
.km-archive-quote {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 2px solid #ccc; /* 控えめなアクセント線に修正 */
    border-radius: 4px;
    position: relative; 
    padding: 30px 25px 20px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* --- 左上のタグ（一覧・個別共通で修正反映） --- */
.km-quote-label, .km-archive-tag {
    position: absolute;
    top: -12px;
    left: 15px;
    background: #aaa; /* 濃すぎないグレーに修正 */
    color: #fff !important;
    padding: 2px 12px; /* 高さを抑えたスリム設定 */
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    border-radius: 2px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
    z-index: 10;
    white-space: nowrap;
}

/* --- 本文エリア（游明朝） --- */
.km-archive-text-sm {
    font-family: "YuMincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
    margin: 0 0 12px 0;
    text-align: left;
    font-weight: 500;
}

/* --- 注釈エリア（斜体解除・統一） --- */
.km-quote-note, .km-archive-note {
    font-size: 0.72rem;
    color: #777;
    font-style: normal; /* 斜体解除：ご要望を反映 */
    margin: 0;
    border-top: 1px solid #f5f5f5;
    padding-top: 8px;
    line-height: 1.5;
    word-break: break-all; 
}

/* --- ホバー演出 --- */
.km-archive-quote:hover {
    border-color: #bbb;
    border-left-color: #999;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.km-archive-quote:hover .km-quote-label,
.km-archive-quote:hover .km-archive-tag {
    background: #888;
}

/* ============================================================
   3. 人物個別詳細ページ (Profile) 固有スタイル
============================================================ */
.km-entry {
    background: #fff;
    padding: 80px 60px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.02);
    border-radius: 2px;
    margin-bottom: 40px;
}

.km-name-large {
    font-size: 3rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: 10px;
}

.km-years {
    display: block;
    text-align: center;
    color: #aaa;
    font-family: 'Lato', sans-serif;
    margin-bottom: 15px;
}

.km-bio-section, .km-record-section, .km-activity-section {
    margin-bottom: 60px;
}

.km-section-head {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

/* ============================================================
   4. 家系図セクション (画像ベース)
============================================================ */
.km-lineage-section.km-bg-accent {
    background-color: #fafafa;
    padding: 80px 0;
    margin: 60px 0;
}

.km-section-head-center {
    text-align: center;
    margin-bottom: 50px;
}

.km-section-ttl {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

/* --- スライダー制御 --- */
.km-lineage-slider-container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.km-lineage-slider {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.km-lineage-slider::-webkit-scrollbar { display: none; }

.km-lineage-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    justify-content: center; /* 横方向中央 */
    align-items: center;     /* 縦方向中央 */
    padding: 20px 0;
}

.km-lineage-image-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

/* --- ぼやけ防止：重要 --- */
.km-lineage-img {
    width: auto;      /* 自動幅 */
    height: auto;     /* 自動高さ */
    max-width: 100%;  /* コンテナより大きい場合は縮小 */
    
    /* 1. 画像本来のサイズで表示（引き伸ばしを防止） */
    object-fit: none; 
    
    /* 2. ブラウザによる補間を制御してクッキリさせる */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;

    background: #fff;
    padding: 10px;
    border: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* ナビゲーションボタン */
.km-slider-prev, .km-slider-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
}

.km-slider-prev:hover, .km-slider-next:hover {
    background: #333;
    color: #fff;
}

.km-slider-prev { left: 10px; }
.km-slider-next { right: 10px; }

.km-slider-dots { text-align: center; margin-top: 20px; }
.dot { display: inline-block; width: 8px; height: 8px; margin: 0 5px; background: #ddd; border-radius: 50%; }
.dot.active { background: #888; }

/* --- レイアウト全体 --- */
.km-timeline-wrapper {
    background-color: #f4f1ea;
    padding: 80px 0 30px 0;
    overflow-x: auto;
}

.km-timeline-inner {
    width: 2500px;
    position: relative;
    margin: 0 60px;
    padding-top: 10px;
}

/* 垂直補助線 */
.km-time-axis {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
}
.km-tick {
    position: absolute; top: 0; width: 1px; height: 100%;
    background: rgba(0,0,0,0.05);
}
.km-tick.major { background: rgba(0,0,0,0.1); }
.km-tick.major span {
    position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
    font-size: 15px; font-weight: bold; color: #444;
}

/* --- 段（Row）の修正 --- */
.km-chart-row {
    position: relative;
    height: auto !important;
    padding: 10px 20px 15px 20px; 
    min-height: 50px;
    overflow: visible !important;
}

.km-life-bar-wrapper {
    position: absolute;
    top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible !important;
    z-index: 10;
}

.km-person-label-group {
    font-size: 11px;
    font-weight: 700;
    color: #555;
    margin-bottom: 2px;
    line-height: 1.1;
    white-space: nowrap;
}

/* 線の土台（ここを基準にドットを配置） */
.km-bar-body {
    position: relative;
    width: 100%;
    height: 8px;
    display: flex;
    align-items: center;
    overflow: visible !important;
}

/* ★フェード（マスク）を適用する専用の箱 */
.km-bar-content {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    /* ここに overflow: visible は書かない */
}

.km-life-line {
    position: absolute;
    width: 100%;
    height: 1px;
    background-color: #bbb;
    z-index: 1;
}

.km-active-bar {
    position: absolute;
    height: 3px;
    background: #555;
    border-radius: 4px;
    z-index: 5;
}

/* フェード効果：contentだけに適用することでドットを守る */
.fade-in .km-bar-content {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%);
    mask-image: linear-gradient(to right, transparent 0%, black 15%);
}
.fade-out .km-bar-content {
    -webkit-mask-image: linear-gradient(to left, transparent 0%, black 15%);
    mask-image: linear-gradient(to left, transparent 0%, black 15%);
}

/* 確定ポイントの丸印（ズレ修正版） */
.km-marker-dot {
    position: absolute;
    top: 50%; /* bodyの中央に確実に配置 */
    width: 8px;
    height: 8px;
    background: #fff;
    border: 2px solid #555;
    border-radius: 50%;
    transform: translate(-50%, -50%); 
    z-index: 20;
}

.km-active-dot {
    position: absolute;
    top: 50%;
    width: 3px;
    height: 3px;
    background: #555;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 8;
}

.km-year-label {
    position: absolute;
    top: 12px; /* 線の中央から下に配置 */
    font-size: 10px;
    color: #666;
    line-height: 1;
    white-space: nowrap;
}

/* 家系名の見出しスタイル */
.km-group-title {
    background: rgba(85, 85, 85, 0.1); /* 薄いグレーの背景 */
    color: #444;
    font-size: 14px;
    font-weight: bold;
    padding: 5px 15px;
    margin-top: 30px; /* 前の家系との間隔 */
    margin-bottom: 10px;
    border-left: 4px solid #555; /* 左側にアクセント線 */
    position: sticky; /* スクロールしても家系名が見えるように */
    left: 0;
    width: fit-content;
    z-index: 100;
}

/* 最初の家系名の上の余白を調整 */
.km-group-title:first-child {
    margin-top: 10px;
}
/* ============================================================
   6. アクティビティタイムライン (Timeline)
============================================================ */
.km-activity-section {
    padding: 20px 0 60px;
}

/* 垂直ラインのベース */
.km-v-timeline {
    position: relative;
    max-width: 800px;
    margin: 40px auto;
    padding: 0;
}

/* 中央を走る線 */
.km-v-timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px; /* モバイルデフォルト */
    width: 1px;
    height: 100%;
    background: #e0e0e0;
}

/* 各アイテムのコンテナ */
.km-timeline-item {
    position: relative;
    margin-bottom: 45px;
    padding-left: 60px; /* 線からの距離 */
}

/* タイムライン上のドット */
.km-timeline-item::before {
    content: '';
    position: absolute;
    left: 16px; /* ラインの中心に合わせる */
    top: 6px;
    width: 9px;
    height: 9px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    z-index: 2;
    transition: all 0.3s ease;
}

/* ホバー時にドットを強調 */
.km-timeline-item:hover::before {
    background: #333;
    transform: scale(1.3);
}

/* 年代・元号表示 */
.km-time {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-family: 'Lato', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.km-time span {
    font-size: 0.8rem;
    color: #999;
    font-weight: normal;
    font-family: "YuMincho", serif;
}

/* イベント内容のカード */
.km-event {
    background: #fff;
    padding: 20px 25px;
    border-radius: 2px;
    border: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.km-timeline-item:hover .km-event {
    transform: translateX(5px);
    border-color: #ccc;
}

.km-event-title {
    margin: 0 0 10px 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: #333;
    border-left: 3px solid #333;
    padding-left: 15px;
}

.km-event-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.8;
    color: #666;
    text-align: justify;
}

/* PCレイアウト：左右交互に配置 */
@media (min-width: 851px) {
    .km-v-timeline::before {
        left: 50%;
        transform: translateX(-50%);
    }

    .km-timeline-item {
        width: 50%;
        padding-left: 0;
        margin-bottom: 60px;
    }

    /* 奇数番目 (左側) */
    .km-timeline-item:nth-child(odd) {
        padding-right: 60px;
        text-align: right;
    }
    
    .km-timeline-item:nth-child(odd) .km-time {
        justify-content: flex-end;
    }

    .km-timeline-item:nth-child(odd) .km-event-title {
        border-left: none;
        border-right: 3px solid #333;
        padding-left: 0;
        padding-right: 15px;
    }

    .km-timeline-item:nth-child(odd)::before {
        left: auto;
        right: -6px; /* 中央線に合わせる */
    }

    /* 偶数番目 (右側) */
    .km-timeline-item:nth-child(even) {
        margin-left: auto;
        padding-left: 60px;
    }

    .km-timeline-item:nth-child(even)::before {
        left: -5px; /* 中央線に合わせる */
    }
}

/* スマホ用調整（既存のメディアクエリに含めてもOK） */
@media (max-width: 850px) {
    .km-v-timeline {
        margin-left: 10px;
    }
    .km-event-title {
        font-size: 0.95rem;
    }
}
/* ============================================================
   7. レスポンシブ
============================================================ */
@media (max-width: 850px) {
    .km-person-grid {
        grid-template-columns: 1fr;
    }
    .km-archive-grid {
        grid-template-columns: 1fr;
    }
    .km-text-columns {
        column-count: 1;
    }
    .km-entry {
        padding: 40px 20px;
    }
    .km-time-axis {
        padding-left: 100px;
    }
    .km-person-label {
        width: 100px;
    }
}