/**
 * メールテンプレート編集画面のスタイル
 * 
 * 提供設定メールのテンプレート編集機能のスタイル定義
 * 運用種別、提供タイプの選択、都道府県・市区町村の選択機能を含む
 * 地震データ・防災情報データとの連携機能も提供
 */

/* ========================================
   ツールバー
   テンプレート数の表示と操作ボタン
   ======================================== */

.email-template-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 15px;
    margin-bottom: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.email-template-status {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    line-height: 1.4;
}

.email-template-buttons {
    display: flex;
    gap: 10px;
}

.email-template-buttons .btn {
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s ease;
    min-width: 80px;
}

/* ========================================
   メインコンテナ
   ======================================== */

.email-template-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    min-height: 100vh;
    max-height: none;
}

/* ========================================
   テンプレート選択エリア（上段）
   テンプレート一覧を表示するサイドバー
   ======================================== */

.template-sidebar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    order: 1;
    max-height: none;
    overflow-y: visible;
    height: auto;
}

.template-sidebar-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.template-sidebar-header h3 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 1.1rem;
}

.template-sidebar-header p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ========================================
   テンプレート一覧
   選択可能なテンプレートのリスト表示
   ======================================== */

.template-list {
    display: block;
    gap: 10px;
}

.template-list-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-list-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.template-list-item.selected {
    border-color: #007bff;
    background: #e3f2fd;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.template-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.template-item-header h4 {
    margin: 0;
    color: #495057;
    font-size: 1rem;
}

.template-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: #28a745;
    color: white;
}

.template-list-item:not(.selected) .template-status {
    background: #6c757d;
}

.template-item-info {
    color: #6c757d;
    font-size: 0.85rem;
}

.template-item-info p {
    margin: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   テンプレート編集エリア（中段）
   選択されたテンプレートの編集フォーム
   ======================================== */

.template-editor {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    order: 2;
    overflow-y: visible;
    min-height: 600px;
}

.template-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.template-editor-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ========================================
   フォーム
   テンプレート編集用の入力フォーム
   ======================================== */

.template-form {
    display: flex;
    flex-direction: column;
    gap: 0px;
    /* 隙間を完全に削除 */
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0px;
    /* 隙間を完全に削除 */
}

.form-group:last-child {
    margin-bottom: 0;
    /* 最後の項目の下マージンを削除 */
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    line-height: 1.3;
    display: block;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-control::placeholder {
    color: #6c757d;
    opacity: 0.8;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.5;
}





/* ========================================
   ボタンスタイル
   各種操作ボタンの共通スタイルとバリエーション
   ======================================== */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #1e7e34;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

/* ========================================
   レスポンシブ対応
   タブレット・スマートフォン向けのレイアウト調整
   ======================================== */

/* 大型デスクトップ（1200px以上） */
@media (max-width: 1200px) {
    .email-template-container {
        gap: 15px;
    }
}

@media (max-width: 992px) {
    .email-template-container {
        gap: 15px;
    }

    .template-sidebar {
        max-height: 400px;
    }

    .template-editor {
        max-height: none;
        min-height: 500px;
    }
}

/* iPhone12以降対応 - 縦並びレイアウトを強制（iPhone14 Pro MAXまで対応） */
@media (max-width: 932px) {
    .email-template-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
        padding: 10px;
        margin-top: 60px;
        padding-top: 0;
    }

    .template-sidebar,
    .template-editor {
        width: 100% !important;
        max-width: none !important;
        padding: 15px;
        max-height: none;
        min-height: 300px;
    }

    .template-editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-control {
        font-size: 16px;
        /* iOS zoom prevention */
    }

    /* フォーム要素の最適化 */
    .template-form .form-group {
        margin-bottom: 10px;
    }

    .template-form textarea.form-control {
        min-height: 80px;
    }

    .template-form input[type="text"].form-control {
        min-height: 36px;
    }
}

@media (max-width: 768px) {
    .email-template-container {
        gap: 15px;
        margin-top: 60px;
        padding-top: 0;
    }

    .template-sidebar,
    .template-editor {
        padding: 15px;
        max-height: none;
        min-height: 400px;
    }

    .template-editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-control {
        font-size: 16px;
        /* iOS zoom prevention */
    }

    /* スマホでの戻るボタン配置調整 */
    .email-template-back-button {
        position: absolute;
        top: 15px;
        right: 35px;
        z-index: 100;
    }

    .email-template-back-button .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: 60px;
        max-width: 65px;
        border-radius: 4px;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {

    .template-sidebar,
    .template-editor {
        background: #2c3e50;
        border-color: #495057;
    }



    .template-list-item {
        background: #495057;
        border-color: #6c757d;
        color: #e9ecef;
    }

    .template-list-item.selected {
        background: #007bff;
        border-color: #0056b3;
    }

    .form-control {
        background: #495057;
        border-color: #6c757d;
        color: #e9ecef;
    }

    .form-control:focus {
        border-color: #007bff;
        background: #495057;
    }


}

/* 小さいスマホ画面対応 */
@media (max-width: 480px) {
    .email-template-back-button {
        position: absolute;
        top: 12px;
        right: 20px;
        z-index: 100;
    }

    .email-template-back-button .btn {
        padding: 5px 10px;
        font-size: 0.8rem;
        min-width: 60px;
        max-width: 65px;
        border-radius: 4px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    }

    .email-template-container {
        padding: 10px;
        gap: 10px;
        margin-top: 10px;
    }

    .template-sidebar,
    .template-editor {
        padding: 10px;
        max-height: none;
        min-height: 300px;
    }
}

/*
 戻るボタンのホバー・アクティブ効果 */
.email-template-back-button .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.email-template-back-button .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* タッチデバイス対応 */
@media (hover: none) and (pointer: coarse) {
    .email-template-back-button .btn:hover {
        transform: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .email-template-back-button .btn:active {
        background: #5a6268;
        transform: scale(0.98);
    }
}

/*
 戻るボタンのレスポンシブ対応 - 統一スタイル */

/* 大型デスクトップ（1200px以上） */
@media (min-width: 1200px) {
    .email-template-back-button {
        top: 25px;
        right: 60px;
    }

    .email-template-back-button .btn {
        padding: 8px 18px;
        font-size: 0.9rem;
        min-width: 70px;
        max-width: 80px;
    }
}

/* デスクトップ（992px - 1199px） */
@media (min-width: 992px) and (max-width: 1199px) {
    .email-template-back-button {
        top: 22px;
        right: 50px;
    }

    .email-template-back-button .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-width: 70px;
        max-width: 75px;
    }
}

/* タブレット（768px - 991px） */
@media (min-width: 768px) and (max-width: 991px) {
    .email-template-back-button {
        top: 18px;
        right: 45px;
    }

    .email-template-back-button .btn {
        padding: 7px 14px;
        font-size: 0.85rem;
        min-width: 65px;
        max-width: 70px;
    }
}

/* スマホ（481px - 767px） */
@media (min-width: 481px) and (max-width: 767px) {
    .email-template-back-button {
        top: 15px;
        right: 35px;
    }

    .email-template-back-button .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: 60px;
        max-width: 65px;
        border-radius: 4px;
    }
}

/* 小型スマホ（480px以下） */
@media (max-width: 480px) {
    .email-template-back-button {
        top: 12px;
        right: 30px;
    }

    .email-template-back-button .btn {
        padding: 5px 10px;
        font-size: 0.75rem;
        min-width: 55px;
        max-width: 60px;
        border-radius: 4px;
    }
}

/* インタラクション効果 - 統一スタイル */
@media (hover: hover) and (pointer: fine) {
    .email-template-back-button .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
        background: #545b62;
    }

    .email-template-back-button .btn:active {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

@media (hover: none) and (pointer: coarse) {
    .email-template-back-button .btn:active {
        background: #545b62;
        transform: scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
}

.email-template-back-button .btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* ツールバーのレスポンシブ対応 */
@media (max-width: 768px) {
    .email-template-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding: 15px;
    }

    .email-template-status {
        text-align: center;
        font-size: 0.85rem;
    }

    .email-template-buttons {
        justify-content: center;
    }

    .email-template-buttons .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .email-template-toolbar {
        padding: 12px;
        gap: 12px;
    }

    .email-template-status {
        font-size: 0.8rem;
    }

    .email-template-buttons .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
        min-width: 80px;
    }
}

/* ラジオボタンモード用のスタイル */
.template-radio-container {
    padding: 15px 0;
}

.template-radio-container h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.template-radio-item {
    margin-bottom: 12px;
}

/* チェックボックス用スタイル */
.template-checkbox-item {
    margin-bottom: 12px;
}

.template-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.template-checkbox-label:hover {
    background-color: #f1f3f4;
}

.template-checkbox {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.template-checkbox-text {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

.template-checkbox:checked+.template-checkbox-text {
    color: #007cba;
    font-weight: 600;
}

.template-checkbox-label:has(.template-checkbox:checked) {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
}

.template-radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.template-radio-label:hover {
    background-color: #f1f3f4;
}

.template-radio {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.template-radio-text {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

/* ラジオボタンがチェックされた時のスタイル */
.template-radio:checked+.template-radio-text {
    color: #007cba;
    font-weight: 600;
}

.template-radio-label:has(.template-radio:checked) {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .template-radio-container {
        padding: 10px 0;
    }

    .template-radio-label {
        padding: 8px 10px;
    }

    .template-radio-text {
        font-size: 0.9rem;
    }
}

/* ========================================
   2軸選択システム
   運用種別、提供タイプの選択UI
   ======================================== */

.template-radio-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.template-radio-container h4 {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
}

.template-selection-section {
    margin-bottom: 25px;
}

.template-selection-section:last-child {
    margin-bottom: 0;
}

.template-selection-section h5 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-radio-item {
    margin-bottom: 8px;
}

.template-radio-label {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.template-radio-label:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.template-radio-label input[type="radio"] {
    margin: 0 10px 0 0;
    transform: scale(1.2);
    accent-color: #007bff;
}

.template-radio-label input[type="radio"]:checked+.template-radio-text {
    color: #007bff;
    font-weight: 600;
}

.template-radio-label:has(input[type="radio"]:checked) {
    border-color: #007bff;
    background: #e7f3ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.template-radio-text {
    flex: 1;
    color: #495057;
    transition: color 0.3s ease;
}

/* メールテンプレート編集エリア */
.email-template-content {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    height: auto;
    min-height: 400px;
}

/* テンプレート選択エリアを上部に配置 */
.template-selection-area {
    grid-row: 1;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 500px;
    max-height: 600px;
    overflow-y: auto;
}



.template-edit-area {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}



.template-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.template-edit-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
}

.template-actions {
    display: flex;
    gap: 10px;
}

.template-actions .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.template-edit-form .form-group {
    margin-bottom: 0px;
    /* 隙間を完全に削除 */
}

.template-edit-form .form-group:last-child {
    margin-bottom: 0;
    /* 最後の項目の下マージンを削除 */
}

.template-edit-form label {
    display: block;
    margin-bottom: 0px;
    /* 隙間を完全に削除 */
    font-weight: 600;
    color: #495057;
    font-size: 0.8rem;
    /* フォントサイズを小さく */
    line-height: 1.2;
    /* 行間を詰める */
}

.template-edit-form .form-control {
    width: 100%;
    padding: 8px 12px;
    /* 10px 15px から 8px 12px に縮小 */
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.template-edit-form .form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.template-edit-form textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
}



/* レスポンシブ対応 */
@media (max-width: 992px) {
    .template-selection-area {
        max-height: 450px;
    }

    .template-edit-area {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .email-template-container {
        padding: 10px;
    }

    .template-radio-container {
        padding: 15px;
    }

    .template-actions {
        flex-direction: column;
        gap: 8px;
    }

    .template-actions .btn {
        width: 100%;
    }
}

/* ========================================
   地震データ関連ボタンの非表示
   地震データ連携ボタンを強制的に非表示
   ======================================== */

#generateWithEarthquakeBtn,
#showEarthquakeDataBtn,
button[onclick*="generateTemplateWithEarthquakeData"],
button[onclick*="showLatestEarthquakeData"] {
    display: none !important;
}

/* 地震データ関連の要素を非表示 */
.content-section#emailTemplateEditor #generateWithEarthquakeBtn,
.content-section#emailTemplateEditor #showEarthquakeDataBtn {
    display: none !important;
}

/* 地震データ関連ボタンを強制的に非表示 */
#generateWithEarthquakeBtn,
#showEarthquakeDataBtn,
button[onclick*="generateTemplateWithEarthquakeData"],
button[onclick*="showLatestEarthquakeData"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* テンプレートアクション内の地震データ関連ボタンを非表示 */
.template-actions #generateWithEarthquakeBtn,
.template-actions #showEarthquakeDataBtn,
.template-actions button[onclick*="generateTemplateWithEarthquakeData"],
.template-actions button[onclick*="showLatestEarthquakeData"] {
    display: none !important;
}

/* 地震データ関連の要素を非表示 */
.content-section#emailTemplateEditor #generateWithEarthquakeBtn,
.content-section#emailTemplateEditor #showEarthquakeDataBtn,
.content-section#emailTemplateEditor button[onclick*="generateTemplateWithEarthquakeData"],
.content-section#emailTemplateEditor button[onclick*="showLatestEarthquakeData"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* チェックボックス用のスタイル */
.template-checkbox-item {
    margin-bottom: 8px;
}

.template-checkbox-label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.template-checkbox-label:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.template-checkbox-label input[type="checkbox"] {
    margin: 0 10px 0 0;
    transform: scale(1.1);
    accent-color: #007bff;
}

.template-checkbox-label input[type="checkbox"]:checked+.template-checkbox-text {
    color: #007bff;
    font-weight: 600;
}

.template-checkbox-label:has(input[type="checkbox"]:checked) {
    border-color: #007bff;
    background: #e7f3ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.template-checkbox-text {
    flex: 1;
    color: #495057;
    transition: color 0.3s ease;
}

/* 市区町村選択セクションのスタイル調整（旧スタイル - 無効化） */
/* 新しいスタイルに置き換えられました */

.template-selection-section:has(input[name="municipality"]) h5 {
    position: sticky;
    top: 0;
    background: #fafafa;
    margin: -15px -15px 15px -15px;
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
}

/* ========================================
   市区町村選択機能
   都道府県選択と市区町村の検索・選択UI
   ======================================== */

.municipality-search-container {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.municipality-search {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 10px;
    transition: border-color 0.3s ease;
}

.municipality-search:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.municipality-controls {
    display: flex;
    gap: 8px;
}

.municipality-controls .btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* 地域別グループのスタイル */
.municipality-region-group {
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

.municipality-region-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f1f3f4;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    color: #495057;
}

.region-name {
    font-size: 0.95rem;
}

.region-toggle {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 3px;
    border: 1px solid #6c757d;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
}

.region-toggle:hover {
    background: #6c757d;
    color: white;
}

.municipality-region-content {
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

/* 市区町村選択セクションの高さ調整 */
.template-selection-section:has(input[name="municipality"]) {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    background: #fafafa;
}

.template-selection-section:has(input[name="municipality"]) h5 {
    position: sticky;
    top: 0;
    background: #fafafa;
    margin: -15px -15px 15px -15px;
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    z-index: 10;
}

/* チェックボックスアイテムのコンパクト表示 */
.municipality-region-content .template-checkbox-item {
    margin-bottom: 4px;
}

.municipality-region-content .template-checkbox-label {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* スクロールバーのスタイリング */
.municipality-region-content::-webkit-scrollbar,
.template-selection-section:has(input[name="municipality"])::-webkit-scrollbar {
    width: 6px;
}

.municipality-region-content::-webkit-scrollbar-track,
.template-selection-section:has(input[name="municipality"])::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.municipality-region-content::-webkit-scrollbar-thumb,
.template-selection-section:has(input[name="municipality"])::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.municipality-region-content::-webkit-scrollbar-thumb:hover,
.template-selection-section:has(input[name="municipality"])::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .municipality-region-content {
        max-height: 150px;
    }

    .template-selection-section:has(input[name="municipality"]) {
        max-height: 400px;
    }

    .municipality-controls {
        flex-direction: column;
    }

    .municipality-controls .btn {
        width: 100%;
    }
}

/* 都道府県選択メニューの幅制限 */
.prefecture-selection-section {
    margin-bottom: 20px;
}

.prefecture-selection-section .form-select,
.prefecture-selection-section select {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background-color: #ffffff;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.prefecture-selection-section .form-select:focus,
.prefecture-selection-section select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 市区町村選択セクションの幅制限 */
.municipality-selection-section {
    margin-bottom: 20px;
}

.municipality-list {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
}

/* 選択済み市区町村セクションの幅制限 */
.selected-municipalities-section {
    margin-bottom: 20px;
}

.selected-municipalities {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
}

/* 2段階選択全体のコンテナ */
.selection-step {
    margin-bottom: 15px;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.selection-step h6 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {

    .prefecture-selection-section .form-select,
    .prefecture-selection-section select {
        max-width: 100%;
        font-size: 16px;
        /* iOS zoom prevention */
    }

    .selection-step {
        padding: 12px;
    }
}

@media (max-width: 480px) {

    .prefecture-selection-section .form-select,
    .prefecture-selection-section select {
        padding: 10px;
        font-size: 16px;
        /* iOS zoom prevention */
    }

    .selection-step {
        padding: 10px;
    }

    .selection-step h6 {
        font-size: 0.9rem;
    }
}

/* テンプレート選択エリア内での幅制限 */
.template-selection-area .prefecture-selection-section .form-select,
.template-selection-area .prefecture-selection-section select {
    max-width: 280px;
}

@media (max-width: 992px) {

    .template-selection-area .prefecture-selection-section .form-select,
    .template-selection-area .prefecture-selection-section select {
        max-width: 100%;
    }
}

/* 小さい画面でのレスポンシブ対応 */
@media (max-width: 768px) {
    .email-template-content {
        gap: 15px;
        height: auto;
        min-height: auto;
    }

    .template-selection-area {
        max-height: 400px;
        padding: 15px;
    }



    .template-edit-area {
        padding: 15px;
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .email-template-content {
        gap: 10px;
    }

    .template-selection-area {
        max-height: 350px;
        padding: 10px;
    }

    .template-edit-area {
        padding: 10px;
        min-height: 250px;
    }
}

/* テンプレート選択エリアのヘッダー */
.template-selection-area h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
}

/* テンプレート選択エリア内のスクロール改善 */
.template-selection-area::-webkit-scrollbar {
    width: 8px;
}

.template-selection-area::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.template-selection-area::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.template-selection-area::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* メールテンプレート選択項目の強制表示 */
.template-radio-container,
.template-selection-section,
.template-radio-item,
.template-radio-label {
    display: block !important;
    visibility: visible !important;
}

.template-radio-container {
    min-height: 50px !important;
}

.template-selection-section {
    margin-bottom: 20px !important;
}

.template-radio-item {
    margin-bottom: 10px !important;
}

.template-radio-label {
    display: flex !important;
    padding: 8px 12px !important;
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
}

.template-radio-label:hover {
    background: #f8f9fa !important;
    border-color: #007bff !important;
}

.template-radio-text {
    margin-left: 8px !important;
    color: #495057 !important;
}

/* 都道府県・市区町村選択エリア */
.prefecture-selection-section,
.municipality-selection-section,
.selected-municipalities-section {
    display: block !important;
    visibility: visible !important;
    margin-bottom: 15px !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
}

.selection-step h6 {
    margin: 0 0 10px 0 !important;
    color: #495057 !important;
    font-weight: 600 !important;
}

#prefectureSelect {
    width: 100% !important;
    max-width: 300px !important;
    padding: 8px 12px !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
}

/* 🔥 超強力な強制表示CSS 🔥 */
#templateListSecondary {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 300px !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    border: 2px solid #007bff !important;
    padding: 20px !important;
    margin: 10px 0 !important;
}

#templateListSecondary * {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.template-radio-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    padding: 20px !important;
    margin: 10px 0 !important;
    min-height: 200px !important;
}

.template-radio-container h4 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 0 20px 0 !important;
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: #495057 !important;
    border-bottom: 2px solid #007bff !important;
    padding-bottom: 8px !important;
}

.template-selection-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 25px !important;
    padding: 15px !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
}

.template-selection-section h5 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 0 15px 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #6c757d !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.template-radio-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 10px !important;
}

.template-radio-label {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    padding: 10px 15px !important;
    background: #ffffff !important;
    border: 2px solid #e9ecef !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
}

.template-radio-label:hover {
    border-color: #007bff !important;
    background: #f8f9ff !important;
}

.template-radio-label input[type="radio"] {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 10px 0 0 !important;
    transform: scale(1.2) !important;
    accent-color: #007bff !important;
}

.template-radio-text {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1 !important;
    color: #495057 !important;
    font-size: 0.95rem !important;
}

/* 都道府県・市区町村選択エリア */
.prefecture-selection-section,
.municipality-selection-section,
.selected-municipalities-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 15px !important;
    padding: 15px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
}

.selection-step {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 15px !important;
    padding: 15px !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
}

.selection-step h6 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 0 10px 0 !important;
    color: #495057 !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
}

#prefectureSelect {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    max-width: 300px !important;
    padding: 8px 12px !important;
    border: 2px solid #ced4da !important;
    border-radius: 4px !important;
    background-color: #ffffff !important;
    font-size: 0.9rem !important;
}

/* 🚀 最終的な強制表示CSS - 最高優先度 🚀 */
.email-template-container,
.email-template-content,
.template-selection-area,
#templateListSecondary,
.template-radio-container,
.template-selection-section,
.template-radio-item,
.template-radio-label,
.template-radio-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    width: auto !important;
    position: relative !important;
}

.template-radio-label {
    display: flex !important;
    align-items: center !important;
    padding: 8px 12px !important;
    margin: 5px 0 !important;
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
}

.template-radio-label input[type="radio"] {
    display: inline-block !important;
    margin-right: 8px !important;
}

.template-radio-text {
    display: inline !important;
    color: #495057 !important;
}

.template-selection-section h5 {
    display: block !important;
    margin: 0 0 10px 0 !important;
    font-weight: 600 !important;
    color: #6c757d !important;
}

.template-radio-container h4 {
    display: block !important;
    margin: 0 0 15px 0 !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: #495057 !important;
    border-bottom: 2px solid #007bff !important;
    padding-bottom: 8px !important;
}

/* 都道府県・市区町村選択 */
.prefecture-selection-section,
.municipality-selection-section,
.selected-municipalities-section,
.selection-step {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 10px 0 !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
}

.selection-step h6 {
    display: block !important;
    margin: 0 0 8px 0 !important;
    font-weight: 600 !important;
    color: #495057 !important;
}

#prefectureSelect {
    display: block !important;
    width: 100% !important;
    max-width: 300px !important;
    padding: 8px 12px !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    background: #ffffff !important;
}

/* ラジオボタン形式のテンプレート選択 */
.template-radio-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-radio-item {
    margin: 0;
}

.template-radio-label {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.template-radio-label:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.template-radio-label input[type="radio"] {
    margin: 0 12px 0 0;
    transform: scale(1.2);
    accent-color: #007bff;
}

.template-radio-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.template-name {
    color: #495057;
    font-size: 0.95rem;
}

.template-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.template-status.status-configured {
    background: #d4edda;
    color: #155724;
}

.template-status.status-unconfigured {
    background: #f8d7da;
    color: #721c24;
}

/* 選択されたラジオボタンのスタイル */
.template-radio-label:has(input[type="radio"]:checked) {
    border-color: #007bff;
    background: #e7f3ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.template-radio-label:has(input[type="radio"]:checked) .template-name {
    color: #007bff;
    font-weight: 600;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .template-radio-label {
        padding: 10px 12px;
    }

    .template-radio-text {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .template-status {
        align-self: flex-end;
    }
}

/* 2軸選択システムのスタイル */
.template-selection-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.template-selection-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
}

.template-selection-section h5 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.template-selection-section .template-radio-item {
    margin-bottom: 8px;
}

.template-selection-section .template-radio-item:last-child {
    margin-bottom: 0;
}

.template-selection-section .template-radio-label {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* 運用種別用の簡潔なスタイル */
.template-selection-section .template-radio-text {
    display: block;
    width: auto;
}

/* iPhone12以降対応 - 縦向きも横向きも同じレイアウト（iPhone14 Pro MAXまで対応） */
@media (max-width: 932px) {
    .template-selection-area {
        max-height: 300px;
        padding: 10px;
        overflow-y: auto;
    }

    .template-selection-container {
        gap: 10px;
    }

    .template-selection-section {
        padding: 10px;
        margin-bottom: 10px;
    }

    .template-selection-section h5 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .template-radio-item {
        margin-bottom: 6px;
    }

    .template-radio-label {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* 提供設定の上段を縦並びに - より強力な指定 */
    .template-top-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }

    .email-template-container .template-top-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .template-top-row .template-selection-section {
        width: 100% !important;
        padding: 8px !important;
        margin-bottom: 0 !important;
        grid-column: unset !important;
        flex: none !important;
    }

    .template-top-row .template-selection-section:nth-child(1),
    .template-top-row .template-selection-section:nth-child(2),
    .template-top-row .template-selection-section:nth-child(3) {
        grid-column: unset !important;
        width: 100% !important;
    }

    .template-top-row .template-selection-section h5 {
        font-size: 0.85rem !important;
        margin-bottom: 6px !important;
    }

    .template-top-row .template-radio-item {
        margin-bottom: 4px !important;
    }

    .template-top-row .template-radio-label {
        padding: 4px 8px !important;
        font-size: 0.8rem !important;
    }

    /* 日時入力フィールドの最適化 */
    .datetime-input-container {
        margin-top: 5px;
    }

    .datetime-input {
        padding: 6px 10px;
        font-size: 14px;
        min-height: 32px;
    }

    /* フォーム要素の間隔調整 */
    .template-form .form-group {
        margin-bottom: 8px !important;
    }

    .template-form .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
    }

    /* グリッドレイアウトを完全に無効化 */
    .email-template-container .template-top-row,
    #emailTemplateEditor .template-top-row,
    .content-section .template-top-row {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid: none !important;
    }

    /* 日時入力エリアも縦並びに（844px以下） */
    .template-bottom-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid: none !important;
        padding: 10px !important;
    }

    .email-template-container .template-bottom-row,
    #emailTemplateEditor .template-bottom-row,
    .content-section .template-bottom-row {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid: none !important;
    }

    .template-bottom-row .template-selection-section {
        width: 100% !important;
        padding: 8px !important;
        margin-bottom: 0 !important;
        grid-column: unset !important;
        flex: none !important;
    }

    .template-bottom-row .template-selection-section h5 {
        font-size: 0.85rem !important;
        margin-bottom: 6px !important;
    }

    /* 各セクションを確実に縦並びに */
    .template-top-row > .template-selection-section {
        display: block !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }
}

/* iPhone12専用設定 - 390px幅対応 */
@media (max-width: 390px) {
    .template-top-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid: none !important;
    }

    .template-top-row .template-selection-section {
        width: 100% !important;
        padding: 6px !important;
        margin-bottom: 0 !important;
        grid-column: unset !important;
        flex: none !important;
    }

    .template-top-row .template-selection-section h5 {
        font-size: 0.8rem !important;
        margin-bottom: 4px !important;
    }

    .template-top-row .template-radio-item {
        margin-bottom: 3px !important;
    }

    .template-top-row .template-radio-label {
        padding: 3px 6px !important;
        font-size: 0.75rem !important;
    }

    /* 日時入力エリアも縦並びに */
    .template-bottom-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid: none !important;
        padding: 8px !important;
    }

    .template-bottom-row .template-selection-section {
        width: 100% !important;
        padding: 6px !important;
        margin-bottom: 0 !important;
    }

    .template-bottom-row .template-selection-section h5 {
        font-size: 0.8rem !important;
        margin-bottom: 4px !important;
    }

    .datetime-input-container {
        margin-top: 3px !important;
    }

    .datetime-input {
        padding: 4px 8px !important;
        font-size: 0.75rem !important;
        min-height: 28px !important;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .template-selection-container {
        gap: 15px;
    }

    .template-selection-section {
        padding: 12px;
    }

    .template-selection-section h5 {
        font-size: 0.9rem;
    }
}

/* 2軸選択システムのスタイル - 横並びレイアウト */
.template-selection-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.template-selection-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    min-height: 0;
}

.template-selection-section h5 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 6px;
    text-align: center;
}

.template-selection-section .template-radio-item {
    margin-bottom: 6px;
}

.template-selection-section .template-radio-item:last-child {
    margin-bottom: 0;
}

.template-selection-section .template-radio-label {
    padding: 6px 10px;
    font-size: 0.85rem;
    justify-content: flex-start;
}

.template-selection-section .template-radio-label input[type="radio"] {
    margin: 0 8px 0 0;
    transform: scale(1.1);
}

/* 運用種別用の簡潔なスタイル */
.template-selection-section .template-radio-text {
    display: block;
    width: auto;
}

/* 提供タイプのステータス表示調整 */
.template-selection-section .template-radio-text .template-status {
    font-size: 0.7rem;
    padding: 1px 6px;
    margin-left: 6px;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .template-selection-container {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* 提供タイプを2列目に配置 */
    .template-selection-section:nth-child(3) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .template-selection-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .template-selection-section {
        padding: 12px;
    }

    .template-selection-section h5 {
        font-size: 0.85rem;
        text-align: left;
    }

    .template-selection-section .template-radio-label {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .template-selection-section .template-radio-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .template-selection-section .template-radio-label input[type="radio"] {
        margin: 0 0 4px 0;
    }
}

/* 🔥 2軸選択システム - 横並び強制レイアウト 🔥 */
.template-selection-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 15px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.template-selection-container .template-selection-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
    padding: 12px !important;
    margin: 0 !important;
    min-height: 120px !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    width: auto !important;
}

.template-selection-container .template-selection-section h5 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 0 10px 0 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #6c757d !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    border-bottom: 1px solid #e9ecef !important;
    padding-bottom: 6px !important;
    text-align: center !important;
}

.template-selection-container .template-radio-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 6px !important;
}

.template-selection-container .template-radio-item:last-child {
    margin-bottom: 0 !important;
}

.template-selection-container .template-radio-label {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    padding: 6px 8px !important;
    font-size: 0.8rem !important;
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.template-selection-container .template-radio-label:hover {
    border-color: #007bff !important;
    background: #f8f9ff !important;
}

.template-selection-container .template-radio-label input[type="radio"] {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 6px 0 0 !important;
    transform: scale(1.0) !important;
    accent-color: #007bff !important;
}

.template-selection-container .template-radio-text {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    color: #495057 !important;
}

.template-selection-container .template-name {
    display: inline !important;
    color: #495057 !important;
    font-size: 0.8rem !important;
}

.template-selection-container .template-status {
    display: inline-block !important;
    font-size: 0.65rem !important;
    padding: 1px 4px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    margin-left: 4px !important;
}

/* 選択されたラジオボタンのスタイル */
.template-selection-container .template-radio-label:has(input[type="radio"]:checked) {
    border-color: #007bff !important;
    background: #e7f3ff !important;
    box-shadow: 0 1px 4px rgba(0, 123, 255, 0.15) !important;
}

.template-selection-container .template-radio-label:has(input[type="radio"]:checked) .template-name {
    color: #007bff !important;
    font-weight: 600 !important;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .template-selection-container {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    /* 提供タイプを2列目に配置 */
    .template-selection-container .template-selection-section:nth-child(3) {
        grid-column: 1 / -1 !important;
    }
}

@media (max-width: 768px) {
    .template-selection-container {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .template-selection-container .template-selection-section {
        padding: 10px !important;
        min-height: 100px !important;
    }

    .template-selection-container .template-selection-section h5 {
        font-size: 0.8rem !important;
        text-align: left !important;
    }

    .template-selection-container .template-radio-label {
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
    }
}

/* 市区町村選択セクションのスタイル */
.municipality-selection-section {
    max-height: 500px !important;
    overflow-y: auto !important;
}

.municipality-selection-section h5 {
    position: sticky !important;
    top: 0 !important;
    background: #ffffff !important;
    z-index: 10 !important;
    margin: -15px -15px 15px -15px !important;
    padding: 15px !important;
    border-bottom: 1px solid #e9ecef !important;
}

/* 選択ステップのスタイル */
.selection-step {
    margin-bottom: 15px !important;
    padding: 15px !important;
    background: #f8f9fa !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
}

.selection-step h6 {
    margin: 0 0 10px 0 !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #495057 !important;
}

/* 都道府県選択 */
.prefecture-selection-section .form-select,
.prefecture-selection-section select {
    width: 100% !important;
    max-width: 300px !important;
    padding: 8px 12px !important;
    border: 2px solid #e9ecef !important;
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    background-color: #ffffff !important;
    transition: border-color 0.3s ease !important;
}

.prefecture-selection-section .form-select:focus,
.prefecture-selection-section select:focus {
    outline: none !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
}

/* 市区町村検索 */
.municipality-search-container {
    margin-bottom: 15px !important;
    padding: 15px !important;
    background: #f8f9fa !important;
    border-radius: 6px !important;
    border: 1px solid #e9ecef !important;
}

.municipality-search {
    width: 100% !important;
    padding: 8px 12px !important;
    border: 2px solid #e9ecef !important;
    border-radius: 4px !important;
    font-size: 0.9rem !important;
    margin-bottom: 10px !important;
    transition: border-color 0.3s ease !important;
}

.municipality-search:focus {
    outline: none !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
}

.municipality-controls {
    display: flex !important;
    gap: 8px !important;
}

.municipality-controls .btn {
    padding: 4px 12px !important;
    font-size: 0.8rem !important;
    border-radius: 4px !important;
}

/* 市区町村リスト */
.municipality-list {
    max-height: 300px !important;
    overflow-y: auto !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
    padding: 10px !important;
    background: #ffffff !important;
}

/* チェックボックススタイル */
.template-checkbox-item {
    margin-bottom: 6px !important;
}

.template-checkbox-label {
    display: flex !important;
    align-items: center !important;
    padding: 6px 10px !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
}

.template-checkbox-label:hover {
    border-color: #007bff !important;
    background: #f8f9ff !important;
}

.template-checkbox-label input[type="checkbox"] {
    margin: 0 8px 0 0 !important;
    transform: scale(1.1) !important;
    accent-color: #007bff !important;
}

.template-checkbox-label input[type="checkbox"]:checked+.template-checkbox-text {
    color: #007bff !important;
    font-weight: 600 !important;
}

.template-checkbox-label:has(input[type="checkbox"]:checked) {
    border-color: #007bff !important;
    background: #e7f3ff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15) !important;
}

.template-checkbox-text {
    flex: 1 !important;
    color: #495057 !important;
    transition: color 0.3s ease !important;
}

/* 選択済み市区町村表示 */
.selected-municipalities {
    min-height: 40px !important;
    padding: 10px !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 6px !important;
    max-height: 200px !important;
    overflow-y: auto !important;
}

.selected-municipality-tag {
    display: inline-block !important;
    background: #007bff !important;
    color: white !important;
    padding: 2px 8px !important;
    margin: 2px 4px 2px 0 !important;
    border-radius: 12px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
}

/* スクロールバーのスタイリング */
.municipality-list::-webkit-scrollbar,
.selected-municipalities::-webkit-scrollbar,
.municipality-selection-section::-webkit-scrollbar {
    width: 6px !important;
}

.municipality-list::-webkit-scrollbar-track,
.selected-municipalities::-webkit-scrollbar-track,
.municipality-selection-section::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 3px !important;
}

.municipality-list::-webkit-scrollbar-thumb,
.selected-municipalities::-webkit-scrollbar-thumb,
.municipality-selection-section::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 3px !important;
}

.municipality-list::-webkit-scrollbar-thumb:hover,
.selected-municipalities::-webkit-scrollbar-thumb:hover,
.municipality-selection-section::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8 !important;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .municipality-selection-section {
        max-height: 400px !important;
    }

    .municipality-list {
        max-height: 200px !important;
    }

    .selected-municipalities {
        max-height: 150px !important;
    }

    .municipality-controls {
        flex-direction: column !important;
    }

    .municipality-controls .btn {
        width: 100% !important;
    }

    .prefecture-selection-section .form-select,
    .prefecture-selection-section select {
        max-width: 100% !important;
        font-size: 16px !important;
        /* iOS zoom prevention */
    }

    .municipality-search {
        font-size: 16px !important;
        /* iOS zoom prevention */
    }
}

@media (max-width: 480px) {
    .selection-step {
        padding: 10px !important;
    }

    .selection-step h6 {
        font-size: 0.9rem !important;
    }

    .municipality-search-container {
        padding: 10px !important;
    }

    .municipality-list {
        max-height: 150px !important;
    }

    .selected-municipalities {
        max-height: 100px !important;
    }
}

/* 新しいレイアウト：上段3列、下段全幅 */
.template-selection-container {
    display: block !important;
    width: 100% !important;
}

/* 上段のセクション（運用種別、提供タイプ）を横並びに配置 */
.template-top-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin-bottom: 25px !important;
    width: 100% !important;
}

/* 市区町村選択セクションを下段全幅に配置 */
.template-selection-container .municipality-selection-section {
    width: 100% !important;
    grid-column: unset !important;
    margin-top: 10px !important;
}

@media (max-width: 992px) {
    .template-top-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
    }

    .template-top-row .template-selection-section:nth-child(3) {
        grid-column: 1 / -1 !important;
        /* 提供タイプを下段に */
    }
}

@media (max-width: 768px) {
    .template-top-row {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
    }

    .template-top-row .template-selection-section {
        padding: 12px !important;
    }

    .template-top-row .template-selection-section h5 {
        font-size: 0.9rem !important;
    }

    .template-selection-container .municipality-selection-section {
        padding: 15px !important;
    }
}

/* 重複削除 - 上記で定義済み */

/* 上段セクションのスタイル調整 */
.template-top-row .template-selection-section {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    transition: border-color 0.3s ease;
}

.template-top-row .template-selection-section:hover {
    border-color: #007bff;
}

.template-top-row .template-selection-section h5 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bff;
}

/* 提供対象市区町村セクションを下段に配置 */
.municipality-selection-section {
    grid-column: 1 / -1;
    /* 全幅を使用 */
    margin-top: 10px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}

.municipality-selection-section h5 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #28a745;
}

/* 480px以下の追加対応 */
@media (max-width: 480px) {
    .template-top-row {
        gap: 10px !important;
        margin-bottom: 15px !important;
    }

    .template-top-row .template-selection-section {
        padding: 10px !important;
    }

    .template-top-row .template-selection-section h5 {
        font-size: 0.85rem !important;
        margin-bottom: 8px !important;
    }

    .template-selection-container .municipality-selection-section {
        padding: 12px !important;
    }
}

/* ラジオボタンのコンパクト表示（上段用） */
.template-top-row .template-radio-item {
    margin-bottom: 6px;
}

.template-top-row .template-radio-label {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.template-top-row .template-radio-text {
    font-size: 0.85rem;
}

/* 設定済み/未設定ステータスの調整 */
.template-status {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 5px;
    display: inline-block;
}

.status-configured {
    background: #28a745;
    color: white;
}

.status-unconfigured {
    background: #6c757d;
    color: white;
}

/* 提供タイプセクションでのステータス表示改善 */
.template-top-row .template-radio-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.template-name {
    flex: 1;
}

/*
 市区町村選択セクションの2列レイアウト */
.municipality-layout-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin-top: 15px !important;
}

/* 左側カラム：都道府県選択と市区町村選択 */
.municipality-left-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 右側カラム：選択済み市区町村 */
.municipality-right-column {
    display: flex;
    flex-direction: column;
}

/* 選択済み市区町村セクションの高さ調整 */
.municipality-right-column .selected-municipalities-section {
    height: 100%;
    min-height: 400px;
}

.municipality-right-column .selected-municipalities {
    flex: 1;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    background: #ffffff;
}

/* 選択済み市区町村のタグスタイル */
.selected-municipality-tag {
    display: inline-block;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 6px 12px;
    margin: 3px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    cursor: default;
    line-height: 1.2;
}

.selected-municipality-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

/* 市区町村リストの高さ調整 */
.municipality-left-column .municipality-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    background: #ffffff;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .municipality-layout-container {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .municipality-right-column .selected-municipalities-section {
        min-height: 300px;
    }

    .municipality-right-column .selected-municipalities {
        max-height: 250px;
    }
}

@media (max-width: 768px) {
    .municipality-layout-container {
        gap: 12px !important;
    }

    .municipality-left-column {
        gap: 12px;
    }

    .municipality-left-column .municipality-list {
        max-height: 150px;
    }

    .municipality-right-column .selected-municipalities-section {
        min-height: 250px;
    }

    .municipality-right-column .selected-municipalities {
        max-height: 200px;
    }
}

@media (max-width: 480px) {
    .municipality-layout-container {
        gap: 10px !important;
        margin-top: 10px !important;
    }

    .municipality-left-column {
        gap: 10px;
    }

    .municipality-left-column .municipality-list {
        max-height: 120px;
    }

    .municipality-right-column .selected-municipalities-section {
        min-height: 200px;
    }

    .municipality-right-column .selected-municipalities {
        max-height: 150px;
    }

    .selected-municipality-tag {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
}

/* スクロールバーのスタイリング */
.municipality-left-column .municipality-list::-webkit-scrollbar,
.municipality-right-column .selected-municipalities::-webkit-scrollbar {
    width: 6px;
}

.municipality-left-column .municipality-list::-webkit-scrollbar-track,
.municipality-right-column .selected-municipalities::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.municipality-left-column .municipality-list::-webkit-scrollbar-thumb,
.municipality-right-column .selected-municipalities::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.municipality-left-column .municipality-list::-webkit-scrollbar-thumb:hover,
.municipality-right-column .selected-municipalities::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* メールテンプレート枠の見栄え改善 */
/* メインコンテナの改善 */
.template-selection-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 12px !important;
    padding: 25px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    margin-bottom: 20px !important;
}

/* 上段3つのセクションの改善 */
.template-top-row {
    margin-bottom: 30px !important;
}

.template-top-row .template-selection-section {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%) !important;
    border: 2px solid #e3f2fd !important;
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.1) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
}

.template-top-row .template-selection-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 12px 12px 0 0;
}

.template-top-row .template-selection-section:hover {
    border-color: #007bff !important;
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.2) !important;
    transform: translateY(-2px) !important;
}

.template-top-row .template-selection-section h5 {
    margin: 0 0 15px 0 !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #495057 !important;
    text-align: center !important;
    padding-bottom: 10px !important;
    border-bottom: 2px solid #e9ecef !important;
    position: relative !important;
}

.template-top-row .template-selection-section h5::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 2px;
    background: #007bff;
    border-radius: 1px;
}

/* ラジオボタンの改善 */
.template-top-row .template-radio-label {
    background: #ffffff !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    padding: 12px 15px !important;
    margin-bottom: 8px !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
}

.template-top-row .template-radio-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 123, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.template-top-row .template-radio-label:hover {
    border-color: #007bff !important;
    background: #f8f9ff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1) !important;
}

.template-top-row .template-radio-label:hover::before {
    left: 100%;
}

.template-top-row .template-radio-label:has(input[type="radio"]:checked) {
    border-color: #007bff !important;
    background: linear-gradient(135deg, #e7f3ff 0%, #cce7ff 100%) !important;
    box-shadow: 0 3px 12px rgba(0, 123, 255, 0.2) !important;
}

.template-top-row .template-radio {
    width: 18px !important;
    height: 18px !important;
    margin-right: 12px !important;
    accent-color: #007bff !important;
}

.template-top-row .template-radio-text {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    color: #495057 !important;
    transition: color 0.3s ease !important;
}

.template-top-row .template-radio-label:has(input[type="radio"]:checked) .template-radio-text {
    color: #007bff !important;
    font-weight: 600 !important;
}

/* 設定済み/未設定ステータスの改善 */
.template-status {
    font-size: 0.7rem !important;
    padding: 3px 8px !important;
    border-radius: 12px !important;
    margin-left: 8px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

.status-configured {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
}

.status-unconfigured {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    color: white !important;
}

/* 市区町村選択セクションの改善 */
.municipality-selection-section {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%) !important;
    border: 2px solid #d4edda !important;
    border-radius: 12px !important;
    padding: 25px !important;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.1) !important;
    position: relative !important;
    overflow: hidden !important;
}

.municipality-selection-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 12px 12px 0 0;
}

.municipality-selection-section h5 {
    margin: 0 0 20px 0 !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #495057 !important;
    text-align: center !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid #e9ecef !important;
    position: relative !important;
}

.municipality-selection-section h5::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: #28a745;
    border-radius: 1px;
}

/* 市区町村レイアウトコンテナの改善 */
.municipality-layout-container {
    background: rgba(255, 255, 255, 0.7) !important;
    border-radius: 8px !important;
    padding: 15px !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* 左右カラムの改善 */
.municipality-left-column .selection-step,
.municipality-right-column .selection-step {
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: 8px !important;
    padding: 15px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    transition: box-shadow 0.3s ease !important;
}

.municipality-left-column .selection-step:hover,
.municipality-right-column .selection-step:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.municipality-left-column .selection-step h6,
.municipality-right-column .selection-step h6 {
    margin: 0 0 10px 0 !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #495057 !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #e9ecef !important;
}

/* フォーム要素の改善 */
.prefecture-selection-section .form-select,
.prefecture-selection-section select {
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    padding: 10px 15px !important;
    font-size: 0.9rem !important;
    transition: all 0.3s ease !important;
    background: #ffffff !important;
}

.prefecture-selection-section .form-select:focus,
.prefecture-selection-section select:focus {
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
    outline: none !important;
}

/* 検索ボックスの改善 */
.municipality-search {
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    padding: 10px 15px !important;
    transition: all 0.3s ease !important;
    background: #ffffff !important;
}

.municipality-search:focus {
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
    outline: none !important;
}

/* ボタンの改善 */
.municipality-controls .btn {
    border-radius: 6px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.municipality-controls .btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

/* アニメーション効果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-selection-container {
    animation: fadeInUp 0.6s ease-out !important;
}

.template-top-row .template-selection-section {
    animation: fadeInUp 0.6s ease-out !important;
}

.template-top-row .template-selection-section:nth-child(1) {
    animation-delay: 0.1s !important;
}

.template-top-row .template-selection-section:nth-child(2) {
    animation-delay: 0.2s !important;
}

.template-top-row .template-selection-section:nth-child(3) {
    animation-delay: 0.3s !important;
}

.municipality-selection-section {
    animation: fadeInUp 0.6s ease-out 0.4s both !important;
}

/* 
選択済み市区町村エリアの表示改善 */
.municipality-right-column .selected-municipalities {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 2px;
    line-height: 1.4;
}

.municipality-right-column .selected-municipalities .text-muted {
    width: 100%;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    margin: 20px 0;
}

/* 選択済み市区町村の件数表示の改善 */
#selectedMunicipalityCount {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 5px;
    box-shadow: 0 1px 3px rgba(40, 167, 69, 0.3);
}

/* 選択済み市区町村セクションのヘッダー改善 */
.municipality-right-column .selection-step h6 {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

/* スクロールバーの改善（選択済み市区町村用） */
.municipality-right-column .selected-municipalities::-webkit-scrollbar {
    width: 8px;
}

.municipality-right-column .selected-municipalities::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.municipality-right-column .selected-municipalities::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.municipality-right-column .selected-municipalities::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

/* 大量選択時の最適化 */
.municipality-right-column .selected-municipalities.many-items .selected-municipality-tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    margin: 2px;
}

/* 市区町村レイアウトコンテナのスタイル */
.municipality-layout-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin-top: 15px !important;
    align-items: stretch !important;
    /* start から stretch に変更して高さを揃える */
}

/* 左側カラム（都道府県・市区町村選択） */
.municipality-left-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 右側カラム（選択済み市区町村） */
.municipality-right-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* 左側と同じ高さに調整 */
}

/* 選択済み市区町村セクション */
.selected-municipalities-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* 固定の min-height を削除して、親の高さに合わせる */
}

.selected-municipalities-section h6 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
}

/* 選択済み市区町村表示エリア */
.selected-municipalities {
    flex: 1;
    min-height: 200px;
    /* 最小限の高さに調整 */
    max-height: none;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    word-wrap: break-word;
}

/* 選択済み市区町村タグのスタイル */
.selected-municipality-tag {
    display: inline-block;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 6px 12px;
    margin: 4px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
    transition: all 0.3s ease;
}

.selected-municipality-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

/* 選択済み市区町村が多い場合の自動調整 */
@media (min-width: 1200px) {
    .municipality-right-column .selected-municipalities {
        min-height: 250px;
        /* 大幅に縮小して左側と揃える */
    }
}

@media (max-width: 992px) {
    .municipality-layout-container {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        align-items: start !important;
        /* 縦並び時は start に戻す */
    }

    .selected-municipalities-section {
        height: auto;
        /* 縦並び時は自動調整 */
        min-height: 300px;
    }

    .selected-municipalities {
        min-height: 250px;
    }
}

@media (max-width: 768px) {
    .selected-municipalities-section {
        min-height: 250px;
    }

    .selected-municipalities {
        min-height: 200px;
    }
}

/* 大
量の市区町村選択時の追加対応 */
.selected-municipalities.overflow-content {
    min-height: 800px !important;
}

/* 選択済み市区町村が50件以上の場合の特別対応 */
.selected-municipalities[data-count="50+"] {
    min-height: 700px !important;
}

/* 選択済み市区町村が100件以上の場合の特別対応 */
.selected-municipalities[data-count="100+"] {
    min-height: 900px !important;
}

/* 選択済み市区町村エリアの自動拡張 */
.municipality-right-column {
    min-height: fit-content;
    height: auto;
}

.selected-municipalities-section {
    height: auto;
    flex-grow: 1;
}

/* 選択済み市区町村タグの密度調整 */
.selected-municipalities.compact-mode .selected-municipality-tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 15px;
}

/* スクロール位置の保持 */
.selected-municipalities {
    scroll-behavior: smooth;
}

/* 選択済み市区町村エリアの最大高さ制限を完全に解除 */
.municipality-right-column .selected-municipalities {
    max-height: none !important;
    height: auto !important;
    overflow-y: auto !important;
}

/* 市区
町村選択の各ステップセクション */
.selection-step {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.selection-step h6 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
}

/* 都道府県選択セクション */
.prefecture-selection-section {
    min-height: 80px;
}

/* 市区町村選択セクション */
.municipality-selection-section {
    min-height: 300px;
    max-height: 400px;
}

/* 市区町村リスト */
.municipality-list {
    max-height: 250px;
    overflow-y: auto;
}

/* 市区町村検索コンテナ */
.municipality-search-container {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

/* 左右の高さを揃えるための調整 */
.municipality-left-column .selection-step:last-child {
    flex: 1;
    /* 最後のセクション（市区町村選択）を拡張 */
}

/* 右側の選択済み市区町村セクションを左側と同じ高さに調整 */
.municipality-right-column .selection-step {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.municipality-right-column .selection-step .selected-municipalities {
    flex: 1;
    min-height: 200px;
}





/* テンプレート編集エリアの項目間隙間を極限まで狭める */
.template-edit-area .template-form {
    gap: 0px !important;
    /* 隙間を完全に削除 */
}

.template-edit-area .form-group {
    margin-bottom: 0px !important;
    /* 項目間の隙間を完全に削除 */
}

.template-edit-area .form-group label {
    margin-bottom: 0px !important;
    /* ラベルと入力フィールド間を完全に削除 */
}

/* 署名フィールドがある場合の調整 */
.template-edit-form .form-group:nth-child(4) {
    margin-top: 0px !important;
    /* 署名フィールドの上マージンも削除 */
}

/* テンプレート編集エリア全体のパディング調整 */
.template-edit-area {
    padding: 10px !important;
    /* パディングをさらに縮小 */
}

/* フォーム要素の極限コンパクト化 */
.template-edit-form .form-control {
    padding: 4px 8px !important;
    /* 極限までコンパクトに */
    font-size: 0.8rem !important;
    /* フォントサイズをさらに小さく */
    margin-bottom: 0px !important;
    /* 下マージンを削除 */
}

.template-edit-form textarea.form-control {
    min-height: 80px !important;
    /* テキストエリアの最小高さをさらに縮小 */
    padding: 4px 8px !important;
    line-height: 1.3 !important;
    /* 行間を詰める */
}

/* ラベルのスタイル調整 */
.template-edit-form label {
    font-size: 0.8rem !important;
    /* ラベルのフォントサイズを小さく */
    line-height: 1.2 !important;
    /* ラベルの行間を詰める */
    padding: 0 !important;
    margin: 0 !important;
}

/* 
タブ切り替え機能のスタイル */
.target-selection-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    background: #f8f9fa;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: #6c757d;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-button.active {
    background: #ffffff;
    color: #007bff;
    border-bottom-color: #007bff;
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #ffffff;
}

/* タブコンテンツのスタイル */
.target-selection-content {
    position: relative;
    min-height: 400px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* メッシュ選択のスタイル */
.mesh-selection-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    height: 400px;
}

.mesh-map-container {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mesh-map {
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    position: relative;
}

#meshMap,
#emailTemplateMeshMap {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    position: relative !important;
}

/* Leaflet地図の強制表示 */
#meshMap .leaflet-container,
#emailTemplateMeshMap .leaflet-container {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    background: #f8f9fa !important;
}

/* 地図読み込み中の表示改善 */
.mesh-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mesh-map-loading p {
    margin: 0;
    color: #495057;
    font-size: 0.9rem;
}

.mesh-map-placeholder {
    text-align: center;
    padding: 20px;
    width: 100%;
}

.mesh-map-placeholder h6 {
    margin: 0 0 10px 0;
    color: #495057;
    font-weight: 600;
}

.mesh-map-placeholder p {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 0.9rem;
}

.mesh-map-controls {
    margin-bottom: 15px;
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.mesh-map-controls .btn {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* メッシュグリッドデモ */
.mesh-grid-demo {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 200px;
    margin: 0 auto;
}

.mesh-cell {
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
    user-select: none;
}

.mesh-cell:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.mesh-cell.selected {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-color: #0056b3;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* メッシュ情報コンテナ */
.mesh-info-container {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.mesh-info-container h6 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    flex-shrink: 0;
}

.selected-mesh-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: block !important;
    visibility: visible !important;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    min-height: 0;
    max-height: 100%;
}

.selected-mesh-tag {
    display: inline-block;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(40, 167, 69, 0.3);
}

.selected-mesh-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.4);
}

/* メッシュ件数表示 */
#selectedMeshCount {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 5px;
    box-shadow: 0 1px 3px rgba(40, 167, 69, 0.3);
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .mesh-selection-container {
        grid-template-columns: 1fr;
        height: auto;
        gap: 15px;
    }

    .mesh-map-container,
    .mesh-info-container {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .tab-button {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    .mesh-grid-demo {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        max-width: 180px;
    }

    .mesh-cell {
        padding: 8px;
        font-size: 0.7rem;
    }
}

/* 
地図エラー表示とLeafletスタイル調整 */
.mesh-map-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    color: #dc3545;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.mesh-map-error p {
    margin: 5px 0;
    font-size: 0.9rem;
}

/* Leaflet地図のスタイル調整 */
.mesh-map .leaflet-container {
    height: 100%;
    width: 100%;
    border-radius: 4px;
}

/* メッシュラベルのスタイル */
.mesh-label {
    background: none !important;
    border: none !important;
}

.mesh-label div {
    background: rgba(255, 255, 255, 0.8) !important;
    border-radius: 3px !important;
    padding: 2px 4px !important;
    border: 1px solid rgba(33, 150, 243, 0.3) !important;
}

/* 地図コントロールのスタイル調整 */
.mesh-map .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.mesh-map .leaflet-control-zoom a {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    color: #495057 !important;
    font-weight: 600 !important;
}

.mesh-map .leaflet-control-zoom a:hover {
    background: #f8f9fa !important;
    border-color: #007bff !important;
    color: #007bff !important;
}

/* 地図の境界線調整 */
.mesh-map .leaflet-container {
    border: 1px solid #e9ecef;
}

/* 地図読み込み中の表示 */
.mesh-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.mesh-map-loading p {
    margin: 0;
    color: #495057;
    font-size: 0.9rem;
}

/*
 メッシュリスト強制表示 */
#selectedMeshList {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
}

#selectedMeshCount {
    display: inline !important;
    visibility: visible !important;
}

/* メッシュタグのスタイル強化 */
.selected-mesh-tag {
    display: inline-block !important;
    visibility: visible !important;
    margin: 2px !important;
    padding: 4px 8px !important;
    background: #28a745 !important;
    color: white !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 12px !important;
}

.selected-mesh-tag:hover {
    background: #218838 !important;
    transform: translateY(-1px) !important;
}

/* メッシュ選択コンテナのレイアウトは上記で定義済み */

.mesh-map-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.mesh-map-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
    z-index: 10000 !important;
    position: relative;
    background: white;
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mesh-map-controls .btn {
    z-index: 10001 !important;
    position: relative;
    pointer-events: auto !important;
}

.mesh-map {
    flex: 1;
    min-height: 0;
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

#emailTemplateMeshMap {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Leaflet地図のz-indexを制御 */
#emailTemplateMeshMap .leaflet-pane,
#meshMap .leaflet-pane {
    z-index: 1 !important;
}

#emailTemplateMeshMap .leaflet-tile-pane,
#meshMap .leaflet-tile-pane {
    z-index: 1 !important;
}

#emailTemplateMeshMap .leaflet-overlay-pane,
#meshMap .leaflet-overlay-pane {
    z-index: 2 !important;
}

#emailTemplateMeshMap .leaflet-control-container,
#meshMap .leaflet-control-container {
    z-index: 500 !important;
}

/* 地図コンテナ全体のz-indexを制限 */
.mesh-map {
    z-index: 1 !important;
}

#emailTemplateMeshMap,
#meshMap {
    z-index: 1 !important;
}

.mesh-info-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px;
}

.mesh-info-container h6 {
    margin: 0 0 5px 0;
    flex-shrink: 0;
}

.selected-mesh-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Leafletコントロールの調整 */
.leaflet-control-container {
    position: relative !important;
}

.leaflet-top {
    top: 10px !important;
}

.leaflet-right {
    right: 10px !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4) !important;
}

/* メッシュマップのボタンが画面外に出ないように調整 */
.mesh-map .leaflet-control {
    margin: 5px !important;
}

.mesh-map .leaflet-bar {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4) !important;
    border: none !important;
}

.mesh-map .leaflet-bar a {
    background-color: #fff !important;
    border-bottom: 1px solid #ccc !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    display: block !important;
    text-align: center !important;
    text-decoration: none !important;
    color: black !important;
}

.mesh-map .leaflet-bar a:hover {
    background-color: #f4f4f4 !important;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .mesh-selection-container {
        grid-template-columns: 1fr 250px;
    }
}

@media (max-width: 992px) {
    .mesh-selection-container {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
    }

    .mesh-map-container {
        height: 400px;
    }

    .mesh-info-container {
        height: 200px;
    }
}

/* iPhone12以降対応 - メッシュ地図も縦並び（iPhone14 Pro MAXまで対応） */
@media (max-width: 932px) {
    .mesh-selection-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
        height: auto !important;
        max-height: none !important;
    }

    .mesh-map-container {
        height: 300px;
        width: 100%;
        order: 1;
    }

    .mesh-info-container {
        width: 100%;
        min-height: 200px;
        order: 2;
    }

    .mesh-map-controls {
        flex-wrap: wrap;
        gap: 5px;
        position: relative;
        z-index: 10000 !important;
        flex-shrink: 0;
    }

    .mesh-map-controls .btn {
        font-size: 0.8rem;
        padding: 5px 10px;
        z-index: 10001 !important;
        position: relative;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .mesh-map {
        min-height: 250px;
        position: relative;
        z-index: 1 !important;
    }

    #emailTemplateMeshMap {
        min-height: 250px;
        position: relative !important;
        z-index: 1 !important;
    }
}

@media (max-width: 768px) {
    .mesh-selection-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
        height: auto !important;
        max-height: none !important;
    }

    .mesh-map-container {
        height: 350px;
        width: 100%;
        order: 1;
    }

    .mesh-info-container {
        width: 100%;
        min-height: 250px;
        order: 2;
    }

    .mesh-map-controls {
        flex-wrap: wrap;
        gap: 5px;
        position: relative;
        z-index: 10000 !important;
        flex-shrink: 0;
    }

    .mesh-map-controls .btn {
        font-size: 0.8rem;
        padding: 5px 10px;
        z-index: 10001 !important;
        position: relative;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .mesh-map {
        min-height: 300px;
        position: relative;
        z-index: 1 !important;
    }

    #emailTemplateMeshMap {
        min-height: 300px;
        position: relative !important;
        z-index: 1 !important;
    }
}

/* スマホ用の追加調整 */
@media (max-width: 480px) {
    .mesh-selection-container {
        gap: 10px;
        height: auto !important;
        min-height: 600px !important;
    }

    .mesh-map-container {
        height: 500px !important;
        min-height: 500px !important;
        position: relative;
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
    }

    .mesh-map-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        position: relative;
        z-index: 10000 !important;
        background: white;
        padding: 10px;
        margin-bottom: 10px;
        flex-shrink: 0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
        border-radius: 6px;
        flex-wrap: nowrap !important;
    }

    .mesh-map-controls .btn {
        width: 100% !important;
        font-size: 0.85rem !important;
        padding: 8px 12px !important;
        white-space: normal !important;
        line-height: 1.3 !important;
        min-height: 36px !important;
        z-index: 10001 !important;
        position: relative;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    .mesh-map {
        height: 450px !important;
        min-height: 450px !important;
        width: 100%;
        position: relative;
        z-index: 1 !important;
        flex: 1;
        flex-shrink: 0;
    }

    #emailTemplateMeshMap {
        height: 450px !important;
        min-height: 450px !important;
        width: 100% !important;
        position: relative !important;
        z-index: 1 !important;
        display: block !important;
    }

    #emailTemplateMeshMap .leaflet-container {
        height: 450px !important;
        min-height: 450px !important;
        width: 100% !important;
    }

    /* Leafletの全てのレイヤーをボタンより下に */
    #emailTemplateMeshMap .leaflet-pane,
    #emailTemplateMeshMap .leaflet-tile-pane,
    #emailTemplateMeshMap .leaflet-overlay-pane,
    #emailTemplateMeshMap .leaflet-shadow-pane,
    #emailTemplateMeshMap .leaflet-marker-pane,
    #emailTemplateMeshMap .leaflet-tooltip-pane,
    #emailTemplateMeshMap .leaflet-popup-pane {
        z-index: 1 !important;
    }

    .mesh-info-container {
        min-height: 200px;
    }

    .selected-mesh-list {
        max-height: 150px;
    }

    .mesh-item {
        padding: 8px;
        font-size: 0.85rem;
    }
}

/* 市区町村選択エリアのレイアウト調整 */
.municipality-layout-container {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin-top: 5px !important;
    height: 700px !important;
    max-height: 700px !important;
    min-height: 700px !important;
}

.municipality-left-column {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    overflow: hidden !important;
    height: 100% !important;
    min-height: 0 !important;
}

.municipality-right-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 選択済み市区町村セクションの高さ制限 */
.selected-municipalities-section {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
}

.selected-municipalities-section h6 {
    flex-shrink: 0 !important;
    margin-bottom: 5px !important;
}

.selected-municipalities {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
    max-height: 420px !important;
    height: 420px !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    word-wrap: break-word !important;
}

/* IDセレクターでより強力に指定 */
#selectedMunicipalities {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
    max-height: 550px !important;
    height: 550px !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    word-wrap: break-word !important;
    display: block !important;
}

/* 選択済み市区町村タグのスタイル */
.selected-municipality-tag {
    display: inline-block !important;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
    color: white !important;
    padding: 4px 8px !important;
    margin: 2px !important;
    border-radius: 12px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 1px 3px rgba(0, 123, 255, 0.3) !important;
    white-space: nowrap !important;
    max-width: 200px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.selected-municipality-tag:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.4) !important;
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%) !important;
}

/* 選択済み市区町村コンテナの追加スタイル */
.selected-municipalities {
    line-height: 1.4 !important;
}

.selected-municipalities .text-muted {
    text-align: center !important;
    padding: 20px !important;
    color: #6c757d !important;
}

/* 市区町村リストの高さ制限 */
.municipality-list {
    min-height: 350px !important;
    max-height: 600px !important;
    height: 550px !important;
    overflow-y: auto !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    padding: 5px !important;
    background: white !important;
}

/* IDセレクターでより強力に指定 */
#municipalityList {
    min-height: 350px !important;
    max-height: 600px !important;
    height: 550px !important;
    overflow-y: auto !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    padding: 5px !important;
    background: white !important;
    display: block !important;
}

/* 都道府県・市区町村選択セクションの調整 */
.prefecture-selection-section {
    flex-shrink: 0 !important;
    margin-bottom: 8px !important;
}

.municipality-selection-section {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

.prefecture-selection-section h6,
.municipality-selection-section h6 {
    margin-bottom: 8px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
}

/* 市区町村検索コンテナ */
.municipality-search-container {
    margin-bottom: 5px !important;
    flex-shrink: 0 !important;
}

.municipality-search {
    width: 100% !important;
    margin-bottom: 8px !important;
    padding: 6px 10px !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    font-size: 0.85rem !important;
}

.municipality-controls {
    display: flex !important;
    gap: 8px !important;
}

.municipality-controls .btn {
    font-size: 0.75rem !important;
    padding: 4px 8px !important;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    .municipality-layout-container {
        grid-template-columns: 1fr !important;
        height: auto !important;
        max-height: none !important;
    }

    .municipality-right-column {
        height: 200px !important;
    }

    .selected-municipalities {
        max-height: 150px !important;
    }
}

@media (max-width: 768px) {
    .municipality-layout-container {
        gap: 15px !important;
    }

    .municipality-list {
        max-height: 200px !important;
    }

    .selected-municipalities {
        max-height: 120px !important;
    }
}

/* テンプレート選択セクション全体の高さ調整 */
.template-selection-section {
    margin-bottom: 8px !important;
}

/* タブコンテンツの高さ調整 */
.target-selection-content {
    min-height: 800px !important;
}

.tab-content {
    min-height: 750px !important;
}

#municipality-tab,
#mesh-tab {
    min-height: 750px !important;
}

/* 
テンプレート編集エリアの高さ制限を解除 */
.template-editor {
    max-height: none !important;
    height: auto !important;
    min-height: 600px !important;
}

/* フォーム要素の間隔調整（上書き） */
.template-form .form-group {
    margin-bottom: 15px !important;
}

.template-form .form-group label {
    margin-bottom: 8px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
}

/* テンプレート編集エリア全体の高さを自動調整 */
.email-template-container {
    min-height: auto !important;
    max-height: none !important;
}

/* テンプレート編集フォームの高さ調整 */
.template-form {
    min-height: auto !important;
}

/* テキストエリアの高さ調整 */
.template-form textarea.form-control {
    min-height: 150px !important;
    resize: vertical !important;
}

.template-form textarea {
    min-height: 80px !important;
    resize: vertical !important;
}

.template-form input[type="text"] {
    height: auto !important;
    min-height: 38px !important;
}

/* 
右側カラムの高さを左側に合わせる */
.municipality-right-column {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100% !important;
}

/* 選択済み市区町村セクションの高さ調整 */
.selected-municipalities-section {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
}

.selected-municipalities-section h6 {
    flex-shrink: 0 !important;
    margin-bottom: 5px !important;
}

/* 選択済み市区町村エリアを左隣に合わせる */
.selected-municipalities {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
    max-height: 550px !important;
    height: 550px !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    word-wrap: break-word !important;
}

/* フ
ォームコントロールのフォーカススタイル */
.form-control:focus {
    border-color: #007bff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* テンプレート編集エリアのボタンスタイル */
.template-editor-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.template-editor-buttons .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* テンプレート編集フォームの間隔調整 */
.template-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-form .form-group {
    margin-bottom: 0;
}

/* テキストエリアの調整 */
.template-form textarea.form-control {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

/* インプットフィールドの調整 */
.template-form input[type="text"].form-control {
    height: auto;
    min-height: 38px;
}

/* ラベルのスタイル統一 */
.template-form label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: block;
}

/* メッシュ
ラベル（背景なし）のスタイル */
.mesh-label-no-bg {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.mesh-label-no-bg div {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 日
時入力フィールドのスタイル */
.datetime-input-container {
    margin-top: 10px;
}

.datetime-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background-color: #ffffff;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.datetime-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.datetime-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: background-color 0.3s ease;
}

.datetime-input::-webkit-calendar-picker-indicator:hover {
    background-color: #f8f9fa;
}

/* 下段レイアウトのスタイル */
.template-bottom-row {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.template-bottom-row .template-selection-section {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 0;
}

.template-bottom-row .template-selection-section h5 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .template-bottom-row {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 15px;
    }

    .datetime-input {
        font-size: 16px;
        /* iOS zoom prevention */
    }
}

@media (max-width: 480px) {
    .template-bottom-row {
        padding: 10px;
        gap: 10px !important;
    }

    .template-bottom-row .template-selection-section {
        padding: 10px;
    }
}

/* 市区町村選択モーダルのスタイル */
.municipality-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.municipality-modal-content {
    background: white;
    border-radius: 8px;
    width: 80% !important;
    max-width: 1400px !important;
    max-height: 90%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.municipality-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.municipality-modal .modal-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.2rem;
}

.municipality-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.municipality-modal .modal-close:hover {
    color: #495057;
}

.municipality-modal .modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.municipality-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.municipality-modal .municipality-layout-container {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 30px;
}

.municipality-modal .municipality-left-column,
.municipality-modal .municipality-right-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.municipality-modal .selection-step {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
}

.municipality-modal .municipality-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    background: white;
}

.municipality-modal .selected-municipalities {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    background: white;
}

/* 選択済み市区町村のタグスタイル */
.selected-municipality-tag {
    display: inline-block;
    margin: 2px;
    padding: 4px 8px;
    background: #28a745;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.selected-municipality-tag:hover {
    background: #dc3545;
}

/* 市区町村アイテムのスタイル */
.municipality-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.municipality-item:hover {
    background-color: #f8f9fa;
}

.municipality-item:last-child {
    border-bottom: none;
}

.municipality-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: 0;
    font-weight: normal;
}

.municipality-label input[type="checkbox"] {
    margin-right: 8px;
    margin-top: 0;
}

.municipality-name {
    flex: 1;
    font-size: 14px;
    color: #495057;
}

/* レスポンシブ対応 */

/* 大画面用：より広いレイアウト */
@media (min-width: 1400px) {
    .municipality-modal .municipality-layout-container {
        gap: 35px;
    }
    
    .municipality-modal .modal-body {
        padding: 30px;
    }
}

/* タブレット・スマートフォン用 */
@media (max-width: 768px) {
    .municipality-modal-content {
        width: 98%;
        max-width: none;
        max-height: 95%;
    }
    
    .municipality-modal .municipality-layout-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .municipality-modal .modal-header,
    .municipality-modal .modal-body,
    .municipality-modal .modal-footer {
        padding: 15px;
    }
    
    .municipality-modal .modal-footer {
        flex-direction: column;
    }
    
    .municipality-modal .modal-footer .btn {
        width: 100%;
    }
}
/* フ
ォームボタンのスタイル */
.form-buttons {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    text-align: left;
}

.form-buttons .btn {
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s ease;
    min-width: 80px;
    /* 戻るボタンと同じサイズに調整 */
}

.form-buttons .btn-success {
    background: #28a745;
    color: white;
    border: none;
}

.form-buttons .btn-success:hover {
    background: #1e7e34;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.form-buttons .btn-success:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(40, 167, 69, 0.3);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .form-buttons {
        text-align: center;
    }
    
    .form-buttons .btn {
        width: 100%;
        /*max-width: 200px;*/
    }
}
/* ラジオボタンの見た目を地味に変更 */
.template-radio-label {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    box-shadow: none !important;
}

.template-radio-label:hover {
    border-color: #adb5bd !important;
    background: #f8f9fa !important;
}

.template-radio-label input[type="radio"] {
    accent-color: #6c757d !important;
}

.template-radio-label input[type="radio"]:checked + .template-radio-text {
    color: #495057 !important;
    font-weight: 600 !important;
}

.template-radio-label:has(input[type="radio"]:checked) {
    border-color: #6c757d !important;
    background: #e9ecef !important;
    box-shadow: none !important;
}

/* 運用種別・提供タイプのラジオボタンを地味に */
.template-selection-container .template-radio-label {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    box-shadow: none !important;
}

.template-selection-container .template-radio-label:hover {
    border-color: #adb5bd !important;
    background: #f8f9fa !important;
}

.template-selection-container .template-radio-label input[type="radio"] {
    accent-color: #6c757d !important;
}

.template-selection-container .template-radio-label:has(input[type="radio"]:checked) {
    border-color: #6c757d !important;
    background: #e9ecef !important;
    box-shadow: none !important;
}

.template-selection-container .template-radio-label:has(input[type="radio"]:checked) .template-radio-text {
    color: #495057 !important;
    font-weight: 600 !important;
}

/* セクションヘッダーの青い下線も地味に */
.template-radio-container h4 {
    border-bottom: 2px solid #dee2e6 !important;
}

.template-selection-section h5 {
    color: #6c757d !important;
}

.template-selection-area h3 {
    border-bottom: 2px solid #dee2e6 !important;
}

/* ラジオボタンのアニメーションを無効化 */
.template-radio-label {
    transition: none !important;
}

.template-radio-label:hover {
    transition: none !important;
}

.template-radio-text {
    transition: none !important;
}

.template-selection-container .template-radio-label {
    transition: none !important;
}

.template-selection-container .template-radio-label:hover {
    transition: none !important;
}

.template-selection-container .template-radio-text {
    transition: none !important;
}

/* 運用種別・提供タイプのセクション全体のアニメーションを無効化 */
.template-selection-section {
    transition: none !important;
}

.template-radio-item {
    transition: none !important;
}

.template-top-row {
    transition: none !important;
}

.template-bottom-row {
    transition: none !important;
}

/* すべてのアニメーションとトランジションを完全に無効化 */
.template-radio-label,
.template-radio-label *,
.template-radio-text,
.template-selection-container .template-radio-label,
.template-selection-container .template-radio-label *,
.template-selection-container .template-radio-text,
.template-selection-section,
.template-selection-section *,
.template-radio-item,
.template-radio-item *,
.template-top-row,
.template-top-row *,
.template-bottom-row,
.template-bottom-row *,
.template-selection-container,
.template-selection-container *,
.template-radio-container,
.template-radio-container * {
    transition: none !important;
    animation: none !important;
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -o-animation: none !important;
}

/* フォーカス時のアニメーションも無効化 */
.template-radio-label:focus,
.template-radio-label:focus-within,
.template-radio-label input[type="radio"]:focus {
    transition: none !important;
    animation: none !important;
}

/* 提供設定ヘッダーのレイアウト */
.template-header-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.template-header-title h3 {
    margin: 0;
}

/* 提供／非提供トグルスイッチ */
.provision-toggle-group {
    display: flex;
    flex-direction: row;
    gap: 20px;
    flex-wrap: wrap;
}

.provision-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.provision-toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.provision-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.provision-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.provision-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.provision-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.provision-toggle-switch input:checked + .provision-toggle-slider {
    background-color: #28a745;
}

.provision-toggle-switch input:focus + .provision-toggle-slider {
    box-shadow: 0 0 1px #28a745;
}

.provision-toggle-switch input:checked + .provision-toggle-slider:before {
    transform: translateX(26px);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .template-header-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .provision-toggle-container {
        width: 100%;
        justify-content: space-between;
    }
}

/* 無効化されたラジオボタンのスタイル */
.template-radio-label.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

.template-radio-label.disabled:hover {
    border-color: #dee2e6 !important;
    background: #f8f9fa !important;
}

.template-radio-label.disabled input[type="radio"] {
    cursor: not-allowed !important;
}

.template-radio-label.disabled .template-radio-text {
    color: #6c757d !important;
}

/* 無効化されたチェックボックスのスタイル */
.template-checkbox-label.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

.template-checkbox-label.disabled:hover {
    border-color: #dee2e6 !important;
    background: #f8f9fa !important;
}

.template-checkbox-label.disabled input[type="checkbox"] {
    cursor: not-allowed !important;
}

.template-checkbox-label.disabled .template-checkbox-text {
    color: #6c757d !important;
}

/* 縦向きスマートフォン専用の調整 - 横向きと同じ自然な操作を可能に */
@media (max-width: 480px) and (orientation: portrait) {
    .mesh-selection-container {
        min-height: 650px !important;
    }

    .mesh-map-container {
        height: 550px !important;
        min-height: 550px !important;
        /* max-heightを削除して自然なリサイズを許可 */
        flex-shrink: 0 !important;
    }

    .mesh-map,
    #emailTemplateMeshMap {
        height: 500px !important;
        min-height: 500px !important;
        /* max-heightを削除して自然なリサイズを許可 */
        width: 100% !important;
        position: relative !important;
        flex-shrink: 0 !important;
    }

    #emailTemplateMeshMap .leaflet-container {
        height: 500px !important;
        min-height: 500px !important;
        /* max-heightを削除して自然なリサイズを許可 */
        width: 100% !important;
        position: relative !important;
    }

    /* 地図の初期化を確実にする */
    .mesh-map-loading {
        height: 500px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* タッチ操作の最適化（横向きと同じ） */
    #emailTemplateMeshMap .leaflet-container {
        touch-action: manipulation !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    /* ズーム操作の最適化 */
    #emailTemplateMeshMap .leaflet-zoom-animated {
        -webkit-transform-origin: center center !important;
        transform-origin: center center !important;
    }

    /* タッチイベントの最適化 */
    #emailTemplateMeshMap {
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -khtml-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
}

/* 地図コンテナの表示を強制 */
@media (max-width: 480px) {
    #emailTemplateMeshMap {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .mesh-map-container {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Leafletコンテナの強制表示 */
    #emailTemplateMeshMap .leaflet-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* スマートフォン縦向け専用 - 地図サイズ保護 */
@media (max-width: 480px) and (orientation: portrait) {
    /* メッシュ地図コンテナの完全固定 */
    #emailTemplateMeshMap {
        height: 300px !important;
        max-height: 300px !important;
        min-height: 300px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        position: relative !important;
    }
    
    /* Leafletコンテナの固定 */
    #emailTemplateMeshMap .leaflet-container {
        height: 300px !important;
        max-height: 300px !important;
        min-height: 300px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    
    /* メッシュ地図の親コンテナも固定 */
    .mesh-map-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    .mesh-map {
        height: 300px !important;
        max-height: 300px !important;
        min-height: 300px !important;
        overflow: hidden !important;
    }
    
    /* メッシュ選択セクション全体の高さ制限 */
    .mesh-selection-section {
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* 選択済みメッシュリストの表示確保 */
    .mesh-info-container {
        display: block !important;
        visibility: visible !important;
        margin-top: 15px !important;
        padding: 10px !important;
        background: #f8f9fa !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 4px !important;
    }
    
    .selected-mesh-list {
        display: block !important;
        visibility: visible !important;
        max-height: 150px !important;
        overflow-y: auto !important;
    }
    
    /* メッシュ選択タグのスタイル */
    .selected-mesh-tag {
        display: inline-block !important;
        margin: 2px !important;
        padding: 4px 8px !important;
        background: #28a745 !important;
        color: white !important;
        border-radius: 4px !important;
        cursor: pointer !important;
        font-size: 0.8rem !important;
    }
    
    /* 地図コントロールボタンの配置調整 */
    .mesh-map-controls {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
    }
    
    .mesh-map-controls .btn {
        flex: 1 !important;
        min-width: 0 !important;
        font-size: 0.75rem !important;
        padding: 6px 8px !important;
    }
}

/* 中間サイズ画面（PC版で横幅を狭めた時）でのボタン折り返し対応 */
@media (min-width: 769px) and (max-width: 1200px) {
    .mesh-map-controls {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: flex-start !important;
    }
    
    .mesh-map-controls .btn {
        flex: 0 0 auto !important;
        min-width: auto !important;
        white-space: nowrap !important;
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
    }
    
    .mesh-map-controls .btn-warning {
        min-width: auto !important;
        max-width: 250px !important;
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
    }
}

/* PC画面でのボタン表示調整 */
@media (min-width: 1201px) {
    .mesh-map-controls .btn {
        flex: 0 0 auto !important;
        min-width: auto !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: clip !important;
        font-size: 0.875rem !important;
        padding: 6px 12px !important;
    }
    
    .mesh-map-controls .btn-warning {
        /*min-width: 250px !important;*/
        width: auto !important;
        font-size: 0.875rem !important;
        padding: 6px 12px !important;
    }
}

/* 縦向きスマートフォンでのLeaflet特有の問題対策 */
@media (max-width: 480px) and (orientation: portrait) {
    /* Leafletのタイルレイヤーの固定 */
    #emailTemplateMeshMap .leaflet-tile-pane {
        width: 100% !important;
        height: 300px !important;
    }
    
    /* Leafletのオーバーレイペインの固定 */
    #emailTemplateMeshMap .leaflet-overlay-pane {
        width: 100% !important;
        height: 300px !important;
    }
    
    /* Leafletのマップペインの固定 */
    #emailTemplateMeshMap .leaflet-map-pane {
        width: 100% !important;
        height: 300px !important;
    }
    
    /* Leafletコントロールの調整 */
    #emailTemplateMeshMap .leaflet-control-container {
        position: relative !important;
    }
    
    /* ズームコントロールの位置調整 */
    #emailTemplateMeshMap .leaflet-control-zoom {
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        z-index: 1000 !important;
    }
}

/* 縦向きスマートフォンでのテンプレート選択エリア調整 */
@media (max-width: 480px) and (orientation: portrait) {
    /* 上段・下段レイアウトを縦並びに強制 */
    .template-top-row,
    .template-bottom-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        grid-template-columns: none !important;
    }
    
    /* 各選択セクションの幅を100%に */
    .template-selection-section {
        width: 100% !important;
        max-width: none !important;
        margin-bottom: 15px !important;
    }
    
    /* 日時入力フィールドの調整 */
    .datetime-input-container {
        width: 100% !important;
    }
    
    .datetime-input {
        width: 100% !important;
        font-size: 16px !important; /* iOS zoom prevention */
    }
}
/* 編集モード専用の地震データボタンのスタイル調整 */
.mesh-map-controls .btn-warning {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    min-width: 250px;
    width: auto;
    font-size: 0.875rem;
    padding: 6px 12px;
}

/* スマートフォンでの長いボタンテキスト対応 */
@media (max-width: 768px) {
    .mesh-map-controls .btn-warning {
        white-space: normal;
        max-width: none;
        line-height: 1.2;
        padding: 8px 10px;
    }
    
    .mesh-map-controls {
        gap: 8px !important;
    }
}

/* 極小画面での縦並び対応 */
@media (max-width: 480px) {
    .mesh-map-controls .btn-warning {
        font-size: 0.75rem !important;
        padding: 6px 8px !important;
    }
}
