/* --- 基本設定 --- */
:root {
    --header-bg-color: #3b5c7f;
    --header-border-color: #304e6c; 
    --warning-color: #ffcc00;
    --input-bg-color: #eaf1f7;
    --result-bg-color: #f0f3f6;
    --sidebar-width: 300px; /* サイドバーの幅 */
}

body { 
    font-family: 'メイリオ', Meiryo, sans-serif; 
    margin: 0; 
    background-color: #f7f9fb; 
    color: #333;
    min-width: 720px;
    font-size: 1.2em;
}

/* ヘッダー */
.site-header {
    background-color: #fff;
    border-bottom: 3px solid var(--header-bg-color);
    padding: 15px 0;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.site-header h1 {
    text-align: center;
    margin: 0;
    font-size: 1.5rem;
    color: var(--header-bg-color);
}

/* --- レイアウト構造 (PC/タブレット用: 2カラム) --- */
.layout-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    gap: 20px;
    align-items: flex-start; /* 上揃え */
    position: relative;
}

.main-content {
    flex: 1; /* 残りの幅をすべて使う */
    min-width: 0; /* Flexアイテムの縮小制御 */
}

/* --- サイドバー (共通パネルスタイル) --- */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    z-index: 100;
}

.sidebar-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.sidebar-panel h3 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: var(--header-bg-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

/* PC時のスクロール追従 (Sticky) */
@media (min-width: 1171px) {
    /* 1. 親コンテナの設定 */
    .layout-container {
        display: flex;
        gap: 20px;
        align-items: flex-start; /* 重要：子要素を上揃えにし、勝手に引き伸ばさない */
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 15px;
    }

    /* 2. メインコンテンツ */
    .main-content {
        flex: 1;
        min-width: 0;
    }

    /* 3. サイドバーの枠 */
    .sidebar {
        width: var(--sidebar-width);
        flex: 0 0 var(--sidebar-width);
        /* 重要：親がFlexboxの場合、デフォルトで高さが100%になろうとします。
           align-selfを上揃えにすることで、サイドバーの「枠」を最小限にします。
        */
        align-self: flex-start; 
        position: sticky; /* 枠そのものをstickyにするのが確実です */
        top: 20px;       /* 画面上端から20pxで固定 */
        z-index: 10;
    }

    /* 4. サイドバーの中身（もし中身が画面より長い場合への対策） */
    .sticky-content {
        max-height: calc(100vh - 40px);
        overflow-y: auto; /* サイドバー内が長すぎる場合は、サイドバー単体でスクロール可能に */
    }

    /* モバイル専用要素を隠す */
    #mobile-menu-btn, #sidebar-overlay, .sidebar-header-mobile {
        display: none;
    }

    .lang-switcher-mobile {
        display: none;
    }
}

/* 装備選択用のスタイル */
.equipment-selectors select {
    margin-bottom: 8px;
    background-color: #fff;
    border: 1px solid #ccc;
}

#fcs-display {
    font-size: 0.95em;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

/* --- スマホ/タブレット用レスポンシブ (1170px以下) --- */
@media (max-width: 1170px) {
    body { 
        font-size: 1.7rem;
    }

    th, td { 
        padding: 1px !important;

    }
    .layout-container {
        display: block; /* 縦並び */
    }

    .add-tab-button {
        padding: 10px 18px !important;
        font-size: 1.2em !important;
        margin-left: 25px !important;
    }

    .copy-tab-button{
        margin-left: 25px !important;
        padding: 10px 14px !important;
        font-size: 1.2em !important;
    }

    .delete-tab-button {
        padding: 10px 22px !important;
        margin-left: 25px !important;
        font-size: 1.2em !important;
    }

    /* サイドバー: オフキャンバスメニュー化 */
    .sidebar {
        position: fixed;
        top: 0;
        right: -100%; /* 画面外へ隠す */
        width: 80%;
        max-width: 600px;
        height: 100%;
        background-color: #fff;
        box-shadow: -2px 0 10px rgba(0,0,0,0.2);
        transition: right 0.3s ease-in-out; /* スライドアニメーション */
        overflow-y: auto;
        padding: 20px;
        box-sizing: border-box;
        font-size: 1.7rem;
    }

    .sidebar.open {
        right: 0; /* 表示 */
    }

    /* モバイル用ヘッダー（閉じるボタンなど） */
    .sidebar-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        border-bottom: 2px solid var(--header-bg-color);
        padding-bottom: 10px;
    }
    .close-sidebar-btn {
        background: none;
        border: none;
        font-size: 2rem;
        cursor: pointer;
        line-height: 1;
    }

    /* 背景暗転オーバーレイ */
    #sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        display: none;
    }
    #sidebar-overlay.open {
        display: block;
    }

    /* メニュー開閉ボタン (Floating Action Button) */
    #mobile-menu-btn {
        position: fixed;
        top: 5px;
        right: 20px;
        background-color: var(--header-bg-color);
        color: white;
        border: none;
        border-radius: 30px;
        padding: 12px 40px;
        font-weight: bold;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        z-index: 101;
        cursor: pointer;
        font-size: 1.4rem;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    #mobile-menu-btn:hover {
        background-color: #2c4a69;
    }

    .lang-switcher.pc-only{
        display: none !important; /* PC用の配置を隠す */
    }

    .sidebar-header-mobile {
        display: flex;
        justify-content: space-between; /* 言語ボタンと×ボタンを両端に配置 */
        align-items: center;
        padding: 10px 0;
        margin-bottom: 20px;
        border-bottom: 2px solid var(--header-bg-color);
    }

    .lang-switcher-mobile {
        display: flex;
        gap: 10px;
    }

    .lang-switcher-mobile .lang-btn {
        padding: 10px 20px; /* スマホで押しやすいサイズ */
        font-size: 1.2rem;
    }
}

/* --- パネル内コンテンツの微調整 --- */
.file-actions input[type="text"] {
    width: 100%;
    margin-bottom: 8px;
}
.button-group {
    display: flex;
    gap: 5px;
}
.btn-save, .btn-load {
    flex: 1;
    padding: 8px;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    border: none;
    color: white;
    display: block;
}
.btn-save { background-color: #28a745; }
.btn-load { background-color: #007bff; margin: 0; }


.summary-table {
    width: 100%;
    border-collapse: collapse;
}
.summary-table td {
    border: none;
    border-bottom: 1px solid #eee;
    padding: 8px 0;
    text-align: right;
    background: transparent;
}
.summary-table .label {
    text-align: left;
    color: #666;
    font-weight: normal;
}
.summary-table .summary-value {
    color: #0000cc;
    font-weight: bold;
    font-size: 1.1em;
}

/* 既存スタイルの調整 (marginなど) */
.section-title {
    margin-top: 20px; /* サイドバーがあるので上マージン削減 */
}

/* タブUI */
.copy-tab-button:hover {
    background-color: #ec971f !important;
}

.tab-header {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--header-bg-color);
    margin-bottom: 20px;
    align-items: center;
}

.tab-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.0;

    padding: 8px 15px;
    background-color: #e0e6ec;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    margin-right: 4px;
    font-weight: bold;
    color: #555;
    font-size: 0.9em;
}

.delete-tab-button:hover {
    background-color: #c9302c;
}

.tab-button.active {
    background-color: #51007a;
    color: white;
    border-color: var(--header-border-color);
}
.tab-button.excluded-from-summary {
    background-color: #d9534f;
    color: white;
    border-color: #d43f3a;
}
.tab-button.active.excluded-from-summary {
    background-color: #c9302c;
    color: white;
    border-color: #ac2925;
}

.tab-veteran-sub {
    font-size: 0.9em;
    font-weight: normal;
    opacity: 0.9;
    color: #068006;
}

.add-tab-button {
    padding: 6px 14px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    margin-left: 15px;
}

.copy-tab-button{
    background-color: #f0ad4e;
    margin-left: 15px;
    border: none;
    color: white;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
}

.delete-tab-button {
    padding: 6px 14px;
    background-color: #d9534f; /* 赤系 */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin-left: 15px;
    font-size: 1em;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0;
    margin-bottom: 25px; 
    background-color: #ffffff; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); 
    border-radius: 8px; 
    overflow: hidden; 
}
th, td { 
    background-color: var(--result-bg-color);
    font-weight: bold; 
    border: 1px solid #e0e6ec; 
    padding: 5px 15px; 
    text-align: center; 
    vertical-align: middle; 
}
th { 
    background-color: var(--header-bg-color);
    color: #ffffff;
    border-color: var(--header-border-color); 
    position: relative; 
}
.input-cell { color: #ffffff; }
.calculation-cell { 
    background-color: var(--result-bg-color); 
    text-align: right; 
    padding-right: 20px; 
    font-weight: bold; 
    font-size:1.1em;
}
input[type="number"], select, input[type="text"] { 
    width: 100%; 
    padding: 8px; 
    box-sizing: border-box; 
    border: 1px solid #aaa; 
    border-radius: 4px; 
    font-size: 1em;
}
hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(59, 92, 127, 0.75), rgba(0, 0, 0, 0));
    margin: 30px 0;
}
.sub-label-deficit {
    font-size: 0.8em; 
    color: var(--warning-color);
    font-weight: normal; 
    display: block; 
}
.sub-label {
    font-size: 0.85em;
    color: #00f;
    font-weight: normal;
    display: block; 
    text-align: right;
}
.crew-selection-table th, .settings-table th, .ability-table th {
    background-color: var(--header-bg-color);
    color: #ffffff;
    border-color: var(--header-border-color);
}

.summary-value .sub-weight {
    font-size: 0.85em; /* 少し小さく */
    font-weight: normal; /* 太字を解除 */
    color: #666; /* 少し薄い色に */
    margin-left: 4px;
}

.lang-btn {
    text-decoration: none;
    font-size: 1rem;
    padding: 5px 12px;
    border-radius: 4px;
    background-color: #f0f3f6;
    color: #3b5c7f;
    border: 1px solid #ccc;
    font-weight: bold;
    transition: all 0.2s;
    margin-right: 25px;
}

.lang-btn.active {
    background-color: var(--header-bg-color);
    color: #fff;
    border-color: var(--header-border-color);
}

/* PC版：ヘッダー内の配置 */
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pc-only {
    position: absolute;
    right: 20px;
    display: flex;
    gap: 5px;
}

.table-caption-info {
    font-size: 0.7em;
    color: #666;
    margin-bottom: 10px;
}

#container-seaman .table-caption-info{
    display: none;
}