/* ==========================================================================
   1. リセット CSS (必要最小限の初期化)
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body, h1, h2, h3, p, ul, ol, figure, blockquote, dl, dd {
    margin: 0;
    padding: 0;
}

ul, ol {
    list-style: none;
}

/* ==========================================================================
   2. 基本設計 (モバイルファースト・1カラム・折返し崩れ防止)
   ========================================================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
    line-height: 1.6;
    background-color: #f5f7fa;
    color: #2d3748;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* テキスト折り返しを徹底し、横スクロールを防止 */
    overflow-wrap: anywhere;
    word-break: break-all;
}

.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-container {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.site-logo {
    font-size: 20px;
    font-weight: 800;
    color: #1a202c;
    text-decoration: none;
}

.site-main {
    flex: 1;
    width: 100%;
    max-width: 480px; /* モバイルの画面幅に合わせたコンテナ設計 */
    margin: 0 auto;
    padding: 24px 16px;
}

.site-footer {
    background-color: #2d3748;
    color: #a0aec0;
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
}

.footer-container {
    max-width: 480px;
    margin: 0 auto;
}

/* ==========================================================================
   3. 共通コンポーネント (フォーム、ボタン、カード)
   ========================================================================== */
.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 24px;
    margin-bottom: 20px;
}

h1, h2, h3 {
    color: #1a202c;
    margin-bottom: 16px;
}

h1 { font-size: 24px; font-weight: 700; text-align: center; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }

/* タイトルとバッジのレイアウト設定 */
.title-container {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.title-container h1 {
    margin-bottom: 0;
}

/* 試験運用中バッジのスタイリング */
.badge-testing {
    display: inline-block;
    background-color: #e53e3e; /* 注意を促す赤〜アクセントカラー */
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
}

p {
    margin-bottom: 16px;
    font-size: 14px;
    color: #4a5568;
}

/* フォーム要素 (モバイルタップターゲット確保) */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 8px;
}

.input-text {
    width: 100%;
    height: 48px; /* タップしやすい高さ */
    padding: 12px;
    font-size: 16px; /* iOSのズーム防止のため16px以上 */
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background-color: #ffffff;
    transition: border-color 0.2s;
}

.input-text:focus {
    border-color: #3182ce;
    outline: none;
}

/* チェックボックス・グリッド (エリアや曜日の選択) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2カラム並び */
    gap: 12px;
    margin-bottom: 16px;
}

/* 地区選択用3行レイアウト */
.checkbox-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.checkbox-row {
    display: grid;
    gap: 6px;
}

.checkbox-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.checkbox-row.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.checkbox-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px; /* タップ領域確保 */
    padding: 6px 4px;
    background-color: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 4px;
    accent-color: #3182ce;
    flex-shrink: 0;
}

/* ボタン (モバイルファースト) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%; /* 基本は全幅 */
    height: 48px; /* タップしやすい高さ */
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn-primary {
    background-color: #3182ce;
    color: #ffffff;
}

.btn-primary:hover, .btn-primary:active {
    background-color: #2b6cb0;
}

.btn-secondary {
    background-color: #edf2f7;
    color: #4a5568;
    border: 1px solid #cbd5e0;
}

.btn-secondary:hover, .btn-secondary:active {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: #e53e3e;
    color: #ffffff;
}

.btn-danger:hover, .btn-danger:active {
    background-color: #c53030;
}

.btn-sm {
    height: 36px;
    padding: 6px 16px;
    font-size: 13px;
}

.btn-outline-secondary {
    background-color: transparent;
    color: #718096;
    border: 1px solid #cbd5e0;
}

.btn-outline-secondary:hover, .btn-outline-secondary:active {
    background-color: #edf2f7;
    color: #4a5568;
    border-color: #a0aec0;
}

/* 警告・通知メッセージ */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success { background-color: #f0fff4; color: #22543d; border: 1px solid #c6f6d5; }
.alert-danger { background-color: #fff5f5; color: #742a2a; border: 1px solid #fed7d7; }
.alert-warning { background-color: #fffaf0; color: #7b341e; border: 1px solid #feebc8; }

/* ==========================================================================
   4. メールプレビュー & レスポンスの微調整
   ========================================================================== */
.mail-preview-container {
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    margin-top: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    color: #2d3748;
    text-align: left;
}

.mail-preview-header {
    background-color: #f7fafc;
    border-bottom: 1px solid #cbd5e0;
    padding: 12px 16px;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    font-size: 13px;
    line-height: 1.5;
}

.mail-preview-header div {
    margin-bottom: 4px;
}

.mail-preview-header div:last-child {
    margin-bottom: 0;
}

.mail-preview-body {
    padding: 16px;
    line-height: 1.6;
}

.mail-preview-body hr {
    border: 0;
    border-top: 1px dashed #cbd5e0;
    margin: 16px 0;
}

.mail-preview-item {
    margin-bottom: 16px;
}

.mail-preview-item:last-of-type {
    margin-bottom: 0;
}

/* ローディングスピナー */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #3182ce;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 画面幅極小・モバイルデバイス向けのメディアクエリ */
@media (max-width: 400px) {
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
    .checkbox-row.cols-3,
    .checkbox-row.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .delivery-status-box {
        padding: 12px;
    }
    .status-toggle-label {
        white-space: normal;
        height: auto;
        min-height: 42px;
    }
}

/* ==========================================================================
   5. 配信ステータス グループボックス定義
   ========================================================================== */
.delivery-status-box {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 24px;
}

.delivery-status-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.delivery-status-title {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
}

.status-toggle-label {
    background-color: #ffffff;
    border: 1px solid #cbd5e0;
    font-weight: 600;
}

.delivery-status-content {
    padding-left: 4px;
    padding-right: 4px;
}
