/* =====================================================
   健康支援AIのぞみシステム 個別CSS
   ===================================================== */

/* ログイン画面 */
#login .wrapper {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(135deg, #ec4899 0%, #be185d 25%, #667eea 100%);
}

#login .left_logo {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 40px;
}

#login .nozomi_character {
    margin-bottom: 20px;
}

#login .character_img {
    width: clamp(260px, 28vw, 340px);
    height: clamp(260px, 28vw, 340px);
    border-radius: 50%;
    border: 6px solid rgba(255,255,255,0.35);
    box-shadow: 0 10px 36px rgba(0,0,0,0.28);
}

#login h1 {
    font-size: 32px;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#login p {
    font-size: 18px;
    opacity: 0.9;
}

#login .login_form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 40px;
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

/* フォーム幅とタイポグラフィ */
#login .login_form form { width: 100%; max-width: 440px; }
#login .login_form h3 { letter-spacing: .02em; }

/* 入力UI（よりモダンに） */
#login input[type="text"],
#login input[type="password"] {
    width: 100%;
    height: 54px;
    padding: 0 30px 0 10px; /* 右はアイコン分の余白 */
    border-radius: 12px;
    background: linear-gradient(#ffffff, #ffffff) padding-box,
                linear-gradient(135deg, #ec4899, #667eea) border-box;
    border: 2px solid transparent;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    font-size: 12px;
    color: #111827;
}

#login input[type="text"]::placeholder,
#login input[type="password"]::placeholder { color: #9ca3af; }

#login input[type="text"]:focus,
#login input[type="password"]:focus {
    outline: none;
    box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.12), 0 8px 22px rgba(79,70,229,0.18);
}

/* ラベル・行間 */
#login dt { color: #374151; font-size: 12px; font-weight: 700; }
#login dl { margin-bottom: 16px; }

/* パスワードの目アイコンを少し大きく */
#login .pw_input .fa { font-size: 12px; color: #6b7280; }

#login .login_form h3 {
    font-size: 24px;
    margin-bottom: 30px;
    color: #4f46e5;
    text-align: center;
}

#login dl {
    margin-bottom: 20px;
}

#login dt {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #495057;
}

#login dd {
    position: relative;
}

#login .pw_input {
    position: relative;
}

#login .pw_input input {
    padding-right: 40px;
}

#login .pw_input .fa {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #6c757d;
    transition: color 0.3s ease;
}

#login .pw_input .fa:hover {
    color: #ec4899;
}

#login .checkbox {
    margin-right: 8px;
}

#login .checkbox-p {
    font-size: 14px;
    color: #6c757d;
}

#login .login_btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #4338ca 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    box-shadow: 0 8px 18px rgba(79,70,229,0.35);
}

#login .login_btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(79,70,229,0.45);
}

#login .attention {
    text-align: center;
}

#login .attention a {
    color: #ec4899;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

#login .attention a:hover {
    color: #be185d;
    text-decoration: underline;
}

/* ホーム画面 */
#home .main_wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* AIメッセージセクション */
.ai_message_section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.character_background {
    display: flex;
    align-items: center;
    gap: 30px;
    position: relative;
    z-index: 2;
}

.character_container {
    flex-shrink: 0;
}

.main_character {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.3);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.message_window {
    flex: 0 0 auto;
    width: 600px;
    height: 450px;
    background-image: url('/img/msg_background/nozomi001.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255,255,255,0.25);
    position: relative;
    display: flex;
    align-items: flex-end;
}

.message_content {
    font-size: 18px;
    line-height: 1.7;
    color: #fff;
    background: rgba(0,0,0,0.45);
    padding: 10px 12px;
    border-radius: 7.5px;
    width: 100%;
}

/* AIメッセージ再生成ボタン（右上） */
.ai_message_refresh {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    z-index: 2;
}
.ai_message_refresh:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.85);
    transform: scale(1.05);
}
.ai_message_refresh:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}
.ai_message_refresh.loading i {
    animation: ai_refresh_spin 0.9s linear infinite;
}
@keyframes ai_refresh_spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.message_typing_indicator {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.message_typing_indicator span {
    width: 8px;
    height: 8px;
    background-color: rgba(255,255,255,0.7);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.message_typing_indicator span:nth-child(1) { animation-delay: -0.32s; }
.message_typing_indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ================================
   分析ページ
================================ */
.analysis_wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.analysis_card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 18px 40px -24px rgba(26, 32, 44, 0.35);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(79, 70, 229, 0.08);
}

.analysis_header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
}

.analysis_header h2 {
    font-size: 19px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 4px;
}

.analysis_description {
    margin: 0;
    color: #6b7280;
    font-size: 12px;
}

.analysis_period_range {
    background: rgba(79, 70, 229, 0.08);
    color: #312e81;
    border-radius: 12px;
    padding: 7.5px 12px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 3.5px;
}

.analysis_period_range .label {
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #4338ca;
}

.analysis_period_range .value {
    font-weight: 600;
    font-size: 12px;
}

.analysis_period_selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.period_button {
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: #f5f7ff;
    color: #4c51bf;
    border-radius: 999px;
    padding: 5.5px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period_button:hover {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(79, 70, 229, 0.45);
}

.period_button.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 10px 20px -12px rgba(79, 70, 229, 0.55);
}

.analysis_custom_range {
    background: rgba(248, 250, 255, 0.68);
    border: 1px dashed rgba(99, 102, 241, 0.35);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.analysis_custom_range .range_controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.analysis_custom_range label {
    font-size: 12px;
    font-weight: 600;
    color: #4338ca;
}

.analysis_custom_range input[type="date"] {
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-radius: 10px;
    padding: 7px 9px;
    font-size: 12px;
    color: #1f2937;
    background: #ffffff;
}

.analysis_custom_range input[type="date"]:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.analysis_custom_range .range_sep {
    font-size: 12px;
    font-weight: 600;
    color: #4c51bf;
    margin: 0 3px;
}

.analysis_custom_range .custom_apply {
    padding: 6.5px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #ffffff;
    border: none;
    box-shadow: 0 12px 25px -18px rgba(37, 99, 235, 0.6);
    font-size: 12px;
    font-weight: 600;
}

.analysis_custom_range .custom_apply:hover {
    transform: translateY(-1px);
}

.analysis_custom_range .custom_hint {
    margin: 0;
    font-size: 12px;
    color: #6366f1;
}

.manual_calories_toggle {
    margin-top: 8px;
}

.checkbox_label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    user-select: none;
}

.checkbox_label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4f46e5;
    cursor: pointer;
}

.analysis_alert {
    display: flex;
    align-items: center;
    gap: 7.5px;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.32);
    color: #b91c1c;
    padding: 7.5px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.analysis_alert .alert_icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f87171;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.analysis_chart_container {
    position: relative;
    width: 100%;
    min-height: 480px;
}

.analysis_summary_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 4px;
}

.summary_item {
    background: #f9fafb;
    border-radius: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    display: flex;
    flex-direction: column;
    gap: 4.5px;
}

.summary_label {
    color: #6b7280;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.summary_value {
    color: #111827;
    font-size: 13.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: baseline;
    gap: 3.5px;
}

.summary_value .unit {
    margin-left: 3.5px;
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
}

.summary_value small {
    display: block;
    font-size: 12px;
    margin-top: 3.5px;
    color: #6b7280;
}

@media (max-width: 768px) {
    .analysis_card {
        padding: 16px 14px 22px;
    }
    .analysis_period_range {
        width: 100%;
    }
    .analysis_custom_range {
        padding: 10px;
    }
    .analysis_custom_range .range_controls {
        flex-direction: column;
        align-items: stretch;
    }
    .analysis_custom_range .range_sep {
        margin: 0;
        text-align: center;
    }
    .analysis_custom_range .custom_apply {
        width: 100%;
        text-align: center;
    }
    .analysis_chart_container {
        min-height: 320px;
    }
}

/* カレンダーセクション */
.calendar_section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* 直近10日一覧 */
.ten_day_section {
    background: white;
    border-radius: 20px;
    padding: 20px 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-top: 20px;
}
.ten_day_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.ten_day_header h2 {
    font-size: 20px;
    color: #333;
    margin: 0;
    flex-shrink: 0;
}

.ten_day_activity_goals {
    display: flex;
    align-items: stretch;
    gap: 8.5px;
    margin-left: auto;
    flex-wrap: wrap;
}

.ten_day_goal_chip {
    display: flex;
    align-items: center;
    gap: 5.5px;
    padding: 5.5px 8.5px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8.5px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.ten_day_goal_chip_icon {
    font-size: 14.5px;
    line-height: 1;
}

.ten_day_goal_chip label,
.ten_day_goal_chip_label {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    margin: 0;
}

.ten_day_goal_chip_input {
    display: flex;
    align-items: center;
    gap: 3.5px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 5.5px;
    padding: 1.5px 4.5px 1.5px 2.5px;
}

.ten_day_goal_chip_input:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.ten_day_goal_chip_input input,
.ten_day_goal_chip_value {
    width: 38px;
    border: none;
    background: transparent;
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
    color: #111827;
    outline: none;
    padding: 2px 0;
    display: inline-block;
    line-height: 1.2;
}

.ten_day_goal_chip_unit {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.ten_day_goal_chip--aerobic .ten_day_goal_chip_input input,
.ten_day_goal_chip--aerobic .ten_day_goal_chip_value { color: #059669; }
.ten_day_goal_chip--mtraining .ten_day_goal_chip_input input,
.ten_day_goal_chip--mtraining .ten_day_goal_chip_value { color: #d97706; }
.ten_day_list {
    display: flex;
    flex-direction: column;
    gap: 7.5px;
}
.ten_day_row {
    display: grid;
    /* 日付 | 指標(可変) | メモ | 回数丸 | 履歴 | 追加+編集 */
    grid-template-columns: 3.5rem minmax(23rem, max-content) minmax(8rem, 1fr) auto minmax(12rem, 1.2fr) 9.5rem;
    align-items: center;
    gap: 7.5px;
    padding: 7.5px 10px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 7.5px;
}
.ten_day_row.today {
    border: 3px solid #ff6b35;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}
.ten_date {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.ten_date_main, .ten_date_sub { white-space: normal; }
.ten_date_main { font-size: 16px; font-weight: 700; color: #333; margin-right: 4px; }
.ten_date_sub { font-size: 12px; }
.ten_date_sub.weekday { color: #9ca3af; }
.ten_date_sub.saturday { color: #93c5fd; }
.ten_date_sub.sunday { color: #fbbf24; }
.ten_counts {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    min-width: 0;
    overflow: visible;
}
.ten_counts .pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: clamp(11px, 0.75rem, 12px);
    padding: 0.15rem 0.4rem;
    gap: 0.12rem;
    flex-shrink: 0;
    min-width: max-content;
}
.ten_counts .pill strong {
    display: inline-block;
    min-width: 4.2ch; /* 4桁の歩数・kcalでも単位が見切れない */
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
    flex-shrink: 0;
}
.ten_counts .pill_unit {
    flex-shrink: 0;
    letter-spacing: 0;
}
.ten_activities {
    color: #666;
    font-size: 13px;
    max-height: 76px;
    min-width: 0;
    overflow-y: auto;
}
.ten_memo { color: #6b7280; font-size: 12px; padding-left: 0px; }
.ten_memo .day_memo { font-size: 12px; height: 43px; width: 95%; border-radius: 5px; margin: 5px 0 0 0; }
.ten_action_count { display: flex; justify-content: flex-start; min-width: min-content; }
.ten_actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    min-height: 28.5px;
}
.btn_ten_edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28.5px;
    height: 28.5px;
    min-width: 28.5px;
    min-height: 28.5px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.35);
    transition: box-shadow 0.15s ease, filter 0.15s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    line-height: 1;
}
.btn_ten_edit:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.45);
}
.btn_ten_edit i {
    display: block;
    font-size: 13.5px;
    line-height: 1;
    margin: 0;
    pointer-events: none;
}
.ten_actions .btn_primary {
    flex: 1;
    min-width: 0;
    height: 28.5px;
    min-height: 28.5px;
    padding: 0 2.8px;
    font-size: 13.5px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    box-sizing: border-box;
}
.pill {
    display: inline-flex; align-items: center; gap: 2px;
    background: #eef2ff; color: #4f46e5; border: 1px solid #e0e7ff;
    padding: 2px 4px; border-radius: 4px; font-size: 12px;
    flex-shrink: 0; /* 縮小を防止 */
    min-width: 0; /* 内容に合わせて幅調整 */
}

/* 中間幅: ボタンが見切れるので「追加」をアイコンのみに縮小し列を詰める */
@media (max-width: 1180px) {
    .ten_day_row {
        /* counts は max-content 固定（中身より縮めると pill がはみ出すため） */
        grid-template-columns: 3.5rem max-content minmax(5rem, 1fr) auto minmax(6rem, 1fr) auto;
        gap: 6px;
    }
    .ten_actions .btn_primary .btn_label { display: none; }
    .ten_actions .btn_primary {
        flex: 0 0 auto;
        width: 28.5px;
        min-width: 28.5px;
        padding: 0;
        gap: 0;
    }
    .ten_actions .btn_primary i { margin: 0; }
}

@media (max-width: 900px) {
    .ten_day_row {
        grid-template-columns: 80px 1fr;
        row-gap: 5px;
        grid-template-areas:
            "date counts"
            "memo memo"
            "action_count activities"
            "actions actions";
    }
    .ten_date { grid-area: date; }
    .ten_counts {
        grid-area: counts;
        width: auto; /* モバイルでは幅制限を解除 */
        flex-wrap: wrap; /* モバイルでは折り返し可能 */
    }
    .ten_memo { grid-area: memo; }
    .ten_action_count { grid-area: action_count; justify-content: flex-start; }
    .ten_activities { grid-area: activities; }
    .ten_actions { grid-area: actions; text-align: left; justify-content: flex-start; }
    /* モバイルは横幅があるので「追加」ラベルを表示に戻す */
    .ten_actions .btn_primary .btn_label { display: inline; }
    .ten_actions .btn_primary {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        padding: 0 12px;
        gap: 4px;
    }
}

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

.calendar_header h2 {
    font-size: 24px;
    color: #333;
    margin: 0;
}

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

.nav_btn {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav_btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.current_period {
    font-size: 16px;
    font-weight: 500;
    color: #495057;
    min-width: 200px;
    text-align: center;
}

/* カレンダーグリッド */
.calendar_container {
    width: 100%;
    overflow: visible;
}

.calendar_grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calendar_week {
    display: grid;
    /* 横幅に合わせて折り返し、最大7列（1週=7項目なので7列が上限） */
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.calendar_week_header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.weekday_header {
    text-align: center;
    font-weight: 600;
    color: #6c757d;
    padding: 10px;
    font-size: 14px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.calendar_day:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.calendar_day {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    min-height: 200px; /* 折り返し対応のため固定高さをやめ内容に合わせる */
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.calendar_day.today {
    border: 3px solid #ff6b35; /* オレンジの枠線のみ */
    background: #f8f9fa; /* 薄いグレー */
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

.calendar_day.today::before {
    content: '今日';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff6b35;
    color: white;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    z-index: 20;
}

.calendar_day.current_period {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
}

.day_header {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.day_content {
    display: flex;
    flex-direction: column;
    gap: 5px; /* 間隔を狭くして、メモ欄と追加ボタンの配置を調整 */
    flex: 1;
}

.activity_summary {
    font-size: 12px;
    color: #6c757d;
}

.calories, .exercise_count {
    margin-bottom: 5px;
}

.calories_value, .exercise_count_value {
    font-weight: 600;
    color: #4CAF50;
}

/* カロリー表示 */
.calories {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.calories_value {
    font-weight: 600;
    color: #4CAF50;
}

/* 有酸素運動時間の数字部分を太字で着色 */
.aerobic_time {
    font-weight: 600;
    color: #4CAF50;
}

.day_memo {
    font-size: 12px;
    color: #495057;
    background: white;
    padding: 5px;
    border-radius: 2.5px;
    border: 1px solid #ddd;
    height: 60px; /* 固定高さ */
    max-height: 60px; /* 最大高さも固定 */
    word-break: break-word;
    overflow-y: auto; /* 縦スクロール */
    overflow-x: hidden; /* 横スクロールは非表示 */
    resize: none; /* リサイズ不可 */
    scrollbar-width: thin; /* Firefox用の細いスクロールバー */
    scrollbar-color: #c1c1c1 #f1f1f1; /* Firefox用のスクロールバー色 */
    margin-top: auto; /* 下部に固定 */
    margin-bottom: 5px; /* 追加ボタンとの間隔 */
    font-family: inherit;
    line-height: 1.4;
}

.day_memo:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Webkit系ブラウザ（Chrome、Safari）用のスクロールバースタイル */
.day_memo::-webkit-scrollbar {
    width: 6px;
}

.day_memo::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.day_memo::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.day_memo::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.add_activity_btn {
    background: #4f46e5; /* インディゴ */
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3.75px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    width: 100%;
    margin-top: 0; /* 固定間隔を確実にするため0に設定 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    line-height: 1;
}

.add_activity_btn:hover {
    background: #4338ca; /* インディゴ（ホバー時は少し濃い） */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.add_activity_btn:active {
    background: #3730a3; /* インディゴ（クリック時はさらに濃い） */
    transform: translateY(0);
}

.add_activity_btn .plus_icon,
.ten_actions .btn_primary .plus_icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

/* カレンダー日付ヘッダー */
.day_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px 5px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: bold;
}



.day_number { 
    font-size: 16px; 
    color: #333; 
    flex-shrink: 0; /* サイズを固定 */
    margin-right: 3px;
}

.exercise_count_circle {
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%; 
    font-size: 14px;
    font-weight: 700; 
    line-height: 1; 
    color: white;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.exercise_count_circle:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.add_activity_btn {
    flex-shrink: 0; /* サイズを固定 */
    margin-left: auto; /* 右端に配置 */
}

/* 昨日以前の状態 */
.exercise_count_circle.has_exercise {
    background: #218838; /* 少し薄い緑 */
    color: white;
}

.exercise_count_circle.no_exercise {
    background: #dc3545; /* 濃い赤 */
    color: white;
}

.exercise_count_circle.rest_day {
    background: #007bff; /* 青（今の色） */
    color: white;
}

/* 今日以降の状態 */
.exercise_count_circle.future {
    background: lightgray;
    color: white;
}

.exercise_count_circle.future.rest_day {
    background: #007bff; /* 休息日は青のまま */
    color: white;
}

/* 統計情報の表示 */
.summary_stats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 5px;
}

.stat_item {
    display: flex;
    align-items: center;
    gap: 2.5px;
    font-size: 12px;
    color: #6c757d;
    background: #ffffff;
    padding: 2.5px 5px;
    border-radius: 2.5px;
    border: 1px solid #e9ecef;
    flex: 1 1 calc(50% - 2.5px); /* 2つずつで改行、横幅いっぱいに広がる */
    min-width: calc(50% - 2.5px); /* 最小幅も50%に設定 */
    justify-content: center; /* 中央揃え */
}

.stat_item span {
    font-weight: 600;
    color: #4CAF50;
}

/* 活動詳細表示 */
.activity_details {
    margin-top: 5px;
    height: 60px;
    max-height: 60px; /* 最大高さを設定（フォント拡大で追加ボタンがはみ出さないよう10px短縮） */
    overflow-y: auto; /* 縦スクロール */
    overflow-x: hidden; /* 横スクロールは非表示 */
    scrollbar-width: thin; /* Firefox用の細いスクロールバー */
    scrollbar-color: #c1c1c1 #f1f1f1; /* Firefox用のスクロールバー色 */
}

.activity_item {
    font-size: 11px;
    color: #666;
    margin-bottom: 2.5px;
    padding: 2.5px 5px;
    background: #f8f9fa;
    border-radius: 2.5px;
    border-left: 3px solid #007bff;
}

.activity_item:last-child {
    margin-bottom: 0;
}

/* Webkit系ブラウザ（Chrome、Safari）用のスクロールバースタイル */
.activity_details::-webkit-scrollbar {
    width: 6px;
}

.activity_details::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.activity_details::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.activity_details::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .calendar_grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 8px;
    }
    
    .week_labels {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    
    .calendar_week_header {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    
    .calendar_day {
        min-height: 180px;
        padding: 12px;
    }
}

@media (max-width: 768px) {
    #login .wrapper {
        flex-direction: column;
    }
    
    #login .left_logo {
        padding: 20px;
    }
    
    #login .character_img {
        width: 120px;
        height: 120px;
    }
    
    #login h1 {
        font-size: 24px;
    }
    
    #login .login_form {
        padding: 20px;
    }
    
    .ai_message_section {
        padding: 20px;
    }
    
    .character_background {
        flex-direction: column;
        text-align: center;
        gap: 20px;
        width: 100%;
    }

    .home_hero_row {
        --home-message-window-height: 320px;
    }

    .home_hero_row .message_window {
        height: var(--home-message-window-height);
        max-height: var(--home-message-window-height);
    }

    .home_memo_panel,
    .home_memo_panel.settings_card--memo {
        height: var(--home-message-window-height);
        max-height: var(--home-message-window-height);
    }
    
    .main_character {
        width: 100px;
        height: 100px;
    }
    
    .message_content {
        font-size: 16px;
    }
    
    .calendar_section {
        padding: 20px;
    }
    
    .calendar_header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .calendar_navigation {
        justify-content: center;
    }
    
    .calendar_week_header {
        display: none; /* スマホでは曜日ヘッダ非表示（各カードに曜日あり） */
    }

    .calendar_day {
        padding: 10px; /* 列数は base の auto-fit（最大7列）が幅に応じて決定 */
    }

    .day_header {
        font-size: 16px;
    }
    
    /* 統計情報のレスポンシブ対応 */
    .stat_item {
        flex: 1 1 calc(50% - 2.5px);
        min-width: calc(50% - 2.5px);
    }
}

@media (max-width: 480px) {
    #login .left_logo {
        padding: 10px;
    }
    
    #login .login_form {
        padding: 10px;
    }
    
    .ai_message_section {
        padding: 15px;
    }
    
    .main_character {
        width: 80px;
        height: 80px;
    }
    
    .message_content {
        font-size: 14px;
    }
    
    .calendar_section {
        padding: 10px;
    }
    
    .calendar_week_header {
        display: none;
    }

    .calendar_day {
        padding: 10px;
    }

    .day_header {
        font-size: 14px;
    }
    
    .add_activity_btn {
        font-size: 13px;
        padding: 5px 10px;
    }
    
    /* 統計情報のレスポンシブ対応（小画面） */
    .stat_item {
        flex: 1 1 calc(50% - 2.5px);
        min-width: calc(50% - 2.5px);
        font-size: 12px; /* 小画面ではフォントサイズを少し小さく */
        padding: 2px 4px;
    }
}

/* 活動ログ管理 フィルター（旧スタイルは activity_filter_panel に統合） */

/* 共通テーブル */
.activity_list { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table thead tr { background: #f8f9fa; }
.table th, .table td {
    text-align: left;
    padding: 7.5px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
    font-size: 13px;
}
.table_empty { padding: 10px; text-align: center; color: #6c757d; }
.table_notes { max-width: 320px; }
.table_actions { display: flex; gap: 5px; }

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 25%, #f472b6 50%, #ec4899 75%, #be185d 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease-in-out infinite;
    color: white;
    padding: 10px 0;
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%, rgba(255, 255, 255, 0.1) 100%);
    pointer-events: none;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.header_inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.header h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header_nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header_nav a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.header_nav a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.user_info {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.logout_btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.logout_btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

/* 日付情報 */
.day_info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
}

.day_number { 
    font-size: 16px; 
    color: #333; 
    flex-shrink: 0; /* サイズを固定 */
    margin-right: 3px;
}

.day_weekday {
    font-size: 12px; /* 日付より小さく */
    font-weight: 500;
    line-height: 1;
}

/* 曜日の色分け */
.day_weekday.weekday {
    color: #9ca3af; /* 薄いグレー（平日） */
}

.day_weekday.saturday {
    color: #93c5fd; /* 薄いブルー（土曜日） */
}

.day_weekday.sunday {
    color: #fbbf24; /* 薄いピンク（日曜日） */
}

/* ==========================================
   設定カード関連のスタイル
   ========================================== */

/* AIメッセージ＆設定セクション全体 */
.ai_content_wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 0;
}

/* 上段：AI画像 ＋ 全体メモ */
.home_hero_row {
    display: flex;
    gap: 15px;
    align-items: stretch;
    --home-message-window-height: 450px;
}

.home_memo_panel {
    flex: 1 1 auto;
    min-width: 0;
    height: var(--home-message-window-height);
    max-height: var(--home-message-window-height);
    min-height: 0;
    color: #374151;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.home_hero_row .character_background {
    flex: 0 0 auto;
    align-self: stretch;
    display: flex;
    align-items: stretch;
}

.home_hero_row .message_window {
    width: min(600px, 42vw);
    height: var(--home-message-window-height);
    max-height: var(--home-message-window-height);
    box-sizing: border-box;
}

/* 下段：健康情報・目標ダッシュボード */
.home_dashboard {
    display: flex;
    flex-direction: column;
    gap: 12.5px;
    color: #374151;
}

.home_dashboard_panel {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 12.5px;
    padding: 12.5px 13.5px 13.5px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(8px);
}

.home_dashboard_heading {
    display: flex;
    align-items: center;
    gap: 8.5px;
    margin-bottom: 10px;
    padding-bottom: 8.5px;
    border-bottom: 1px solid #eef2f7;
}

.home_dashboard_heading--with_action .home_dashboard_title {
    flex: 1;
    min-width: 0;
}

.home_dashboard_action {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 4.5px 9.5px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.home_dashboard_action:hover,
.home_dashboard_action:focus {
    background: #e0e7ff;
    border-color: #a5b4fc;
    outline: none;
}

.home_dashboard_action:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.home_dashboard_icon {
    width: 30px;
    height: 30px;
    border-radius: 8.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14.5px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.home_dashboard_icon--health {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.home_dashboard_icon--goals {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}

.home_dashboard_title h3 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
}

.home_dashboard_title p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #6b7280;
}

/* 健康情報：目標達成度カード */
.home_progress_grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7.5px;
}

.home_progress_card {
    border-radius: 10px;
    padding: 10px 8.5px 9px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e5e7eb;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5.5px;
}

.home_progress_card_head {
    display: flex;
    align-items: center;
    gap: 4.5px;
}

.home_progress_icon {
    font-size: 14.5px;
    line-height: 1;
}

.home_progress_label {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
}

.home_progress_current {
    display: flex;
    align-items: baseline;
    gap: 2.5px;
    line-height: 1.1;
}

.home_progress_value {
    font-size: clamp(15.5px, 2.6vw, 20px);
    font-weight: 800;
    color: #111827;
}

.home_progress_unit {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.home_progress_goal {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 4.5px;
    font-size: 12px;
    line-height: 1.4;
}

.home_progress_goal_label {
    color: #6b7280;
    font-weight: 600;
}

.home_progress_goal_value {
    color: #6366f1;
    font-weight: 700;
}

.home_progress_bar {
    height: 5.5px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin-top: 1.5px;
}

.home_progress_bar_fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #818cf8 0%, #6366f1 100%);
    transition: width 0.35s ease;
}

.home_progress_bar_fill--achieved {
    background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
}

.home_progress_bar_fill--remaining {
    background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
}

.home_progress_meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
}

.home_progress_percent {
    color: #6366f1;
}

.home_progress_status {
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home_progress_status--achieved {
    color: #059669;
}

.home_progress_status--remaining {
    color: #d97706;
}

/* === 主要3指標（体重・平均歩数・平均消費）を強調 === */
.home_progress_card--primary {
    gap: 6.5px;
    background: linear-gradient(180deg, #ffffff 0%, #eef2ff 100%);
    border: 1.5px solid #c7d2fe;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.14);
}

.home_progress_card--primary .home_progress_icon {
    font-size: 18px;
}

.home_progress_card--primary .home_progress_label {
    font-size: 12.5px;
}

.home_progress_card--primary .home_progress_value {
    font-size: clamp(20px, 3.4vw, 27px);
}

.home_progress_card--primary .home_progress_unit {
    font-size: 12px;
}

.home_progress_card--primary .home_progress_goal,
.home_progress_card--primary .home_progress_goal_value {
    font-size: 12px;
}

.home_progress_card--primary .home_progress_meta {
    font-size: 12px;
}

.home_progress_card--primary .home_progress_percent {
    font-size: 12px;
}

.home_progress_card--primary .home_progress_status {
    font-size: 12px;
    font-weight: 800;
}

.home_progress_card--primary .home_progress_meta--decrease .home_progress_status--remaining {
    font-size: 13px;
    color: #c2410c;
}

/* === サブ指標（BMI・体脂肪率）は控えめに === */
.home_progress_card--muted {
    background: #fafafa;
    border: 1px solid #ececf0;
}

.home_progress_card--muted .home_progress_icon {
    font-size: 12.5px;
    opacity: 0.85;
}

.home_progress_card--muted .home_progress_label {
    font-size: 12px;
    color: #6b7280;
}

.home_progress_card--muted .home_progress_value {
    font-size: clamp(14px, 2.2vw, 17px);
}

.home_progress_card--muted .home_progress_unit {
    font-size: 12px;
}

.home_progress_card--muted .home_progress_goal,
.home_progress_card--muted .home_progress_goal_value {
    font-size: 12px;
}

.home_progress_card--muted .home_progress_meta {
    font-size: 12px;
}

.home_progress_card--muted .home_progress_meta--decrease .home_progress_status--remaining {
    color: #d97706;
    font-weight: 700;
}

.home_progress_bar--decrease,
.home_progress_bar--increase {
    margin-top: 1.5px;
}

.home_progress_card--primary .home_progress_bar {
    height: 6.5px;
}

.home_progress_gap_arrow {
    margin-right: 2px;
}

/* バーなしで差分だけ表示（体重など） */
.home_progress_status_solo {
    margin-top: auto;
    padding-top: 2px;
    font-size: 12px;
    font-weight: 700;
}

.home_progress_card--primary .home_progress_status_solo {
    font-size: 13.5px;
    font-weight: 800;
}

.home_progress_status_solo--remaining {
    color: #c2410c;
}

.home_progress_status_solo--achieved {
    color: #059669;
}

/* BMI・体脂肪率の合成カード */
.home_progress_card--composite {
    justify-content: center;
    gap: 4px;
    padding: 8.5px 10px;
}

.home_progress_subrow {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 7px;
    padding: 7px 0;
}

.home_progress_subrow + .home_progress_subrow {
    border-top: 1px solid #e5e7eb;
}

.home_progress_sub_icon {
    font-size: 16.5px;
    opacity: 0.9;
}

.home_progress_sub_main {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.home_progress_sub_label {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
}

.home_progress_sub_value {
    font-size: 20px;
    font-weight: 800;
    color: #111827;
}

.home_progress_sub_unit {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-left: 1.5px;
}

.home_progress_sub_goal {
    text-align: right;
    line-height: 1.3;
    white-space: nowrap;
}

.home_progress_sub_goal_label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
}

.home_progress_sub_goal_value {
    font-size: 12px;
    font-weight: 700;
    color: #6366f1;
}

.home_progress_subrow--bmi .home_progress_sub_value { color: #10b981; }
.home_progress_subrow--bodyfat .home_progress_sub_value { color: #f59e0b; }

.home_progress_note {
    margin: 2px 0 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.45;
}

.home_progress_card--weight .home_progress_value { color: #2563eb; }
.home_progress_card--bmi .home_progress_value { color: #10b981; }
.home_progress_card--bodyfat .home_progress_value { color: #f59e0b; }
.home_progress_card--steps .home_progress_value { color: #7c3aed; }
.home_progress_card--calories .home_progress_value { color: #dc2626; }

/* 健康情報タイル（旧・互換） */
.home_stat_grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6.5px;
}

.home_stat_tile {
    position: relative;
    border-radius: 9px;
    padding: 8.5px 6.5px 7.5px;
    text-align: center;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    min-width: 0;
}

.home_stat_tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-accent, #6366f1);
}

.home_stat_tile_icon {
    display: block;
    font-size: 13.5px;
    line-height: 1;
    margin-bottom: 3.5px;
}

.home_stat_tile_label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 2.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home_stat_tile_value {
    display: block;
    font-size: clamp(12px, 2.2vw, 15.5px);
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
}

.home_stat_tile_value small {
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin-left: 1px;
}

.home_stat_tile--weight { --stat-accent: #2563eb; }
.home_stat_tile--weight .home_stat_tile_value { color: #2563eb; }
.home_stat_tile--bmi { --stat-accent: #10b981; }
.home_stat_tile--bmi .home_stat_tile_value { color: #10b981; }
.home_stat_tile--bodyfat { --stat-accent: #f59e0b; }
.home_stat_tile--bodyfat .home_stat_tile_value { color: #f59e0b; }
.home_stat_tile--steps { --stat-accent: #8b5cf6; }
.home_stat_tile--steps .home_stat_tile_value { color: #7c3aed; }
.home_stat_tile--calories { --stat-accent: #ef4444; }
.home_stat_tile--calories .home_stat_tile_value { color: #dc2626; }

/* 目標設定タイル */
.home_goal_grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6.5px;
}

.home_goal_grid--core {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8.5px;
}

.home_goal_tile {
    border-radius: 9px;
    padding: 9px 7.5px 8.5px;
    text-align: center;
    background: linear-gradient(180deg, #fafbff 0%, #f3f4f6 100%);
    border: 1px solid #e5e7eb;
    min-width: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.home_goal_tile:focus-within {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.home_goal_tile_icon {
    display: block;
    font-size: 14.5px;
    margin-bottom: 3.5px;
}

.home_goal_tile label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home_goal_input {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2.5px;
}

.home_goal_input input {
    width: 100%;
    border: none;
    background: #fff;
    border-radius: 5.5px;
    padding: 5px 3.5px;
    font-size: clamp(12px, 2vw, 14.5px);
    font-weight: 700;
    text-align: center;
    color: #111827;
    box-shadow: inset 0 0 0 1px #d1d5db;
    outline: none;
}

.home_goal_input input:focus {
    box-shadow: inset 0 0 0 2px #6366f1;
}

.home_goal_unit {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.home_goal_tile--calorie .home_goal_input input { color: #dc2626; }
.home_goal_tile--weight .home_goal_input input { color: #2563eb; }
.home_goal_tile--aerobic .home_goal_input input { color: #059669; }
.home_goal_tile--mtraining .home_goal_input input { color: #d97706; }
.home_goal_tile--steps .home_goal_input input { color: #7c3aed; }

/* 設定カード群コンテナ（他ページ互換） */
.settings_cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1; /* 残りスペースを全て使用 */
    min-width: 320px;
    max-height: 450px; /* AIメッセージの高さに合わせる */
    color: #374151; /* ai_message_section の白文字継承を打ち消す */
}

/* 設定カード */
.settings_card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    flex: 1; /* 上下のカードで高さを分割 */
}

/* カードヘッダー */
.card_header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 7.5px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.card_header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* カードボディ */
.card_body {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 目標設定グリッド */
.goal_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 7.5px;
    margin-bottom: 10px;
}

/* ==============================
   現在の健康情報（メトリクス表示）
   ============================== */
.health_metrics {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: nowrap; /* 折り返さず縮小 */
}

.metric_card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12.5px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    flex: 1 1 0;      /* 均等に縮む */
    min-width: 0;     /* 内容に合わせて幅を縮小可能に */
}

.metric_card .metric_label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 3.5px;
    font-weight: 600;
    white-space: nowrap;
}

.metric_card .metric_value {
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: nowrap;
}

.metric_card .metric_value .value {
    font-size: clamp(12px, 4vw, 20px); /* 画面幅に応じて縮小 */
    font-weight: 800;
    letter-spacing: 0.5px;
}

.metric_card .metric_value .unit {
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
}

/* 軽いアクセントカラー */
.metric_card.weight .value { color: #2563eb; }
.metric_card.bmi .value { color: #10b981; }
.metric_card.bodyfat .value { color: #f59e0b; }

/* 平均歩数カードの可読性を強化（背景上でも白にならないように明示） */
.metric_card.steps_avg .metric_label { color: #6b7280 !important; }
.metric_card.steps_avg .metric_value { color: #374151 !important; }
.metric_card.steps_avg .metric_value .unit { color: #9ca3af !important; }

@media (max-width: 768px) {
    .metric_card {
        padding: 7.5px 9px;
    }
}

/* 横幅に余裕がある場合は4列表示 */
@media (min-width: 800px) {
    .goal_grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 中程度の幅では2列表示 */
@media (max-width: 799px) {
    .goal_grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 目標設定項目 */
.goal_item {
    margin-bottom: 0;
}

.goal_item label {
    display: block;
    margin-bottom: 4px;
    color: #374151;
    font-size: 12px;
}

/* 単位付き入力フィールド */
.input_with_unit {
    display: flex;
    align-items: center;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.input_with_unit:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.input_with_unit input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 5px 7.5px;
    font-size: 12px;
    outline: none;
    color: #374151;
}

.input_with_unit .unit {
    padding: 5px 7.5px;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    border-left: 1px solid #d1d5db;
    white-space: nowrap;
}

/* カードアクション */
.card_actions {
    margin-top: auto;
    text-align: center;
}

/* メモ項目 */
.memo_item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.memo_item textarea {
    width: 100%;
    flex: 1;
    min-height: 80px;
    padding: 7.5px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.4;
    resize: none;
    transition: border-color 0.2s ease;
}

.memo_item textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
    background: #ffffff;
}

/* 全体メモ WYSIWYG（Quill） */
.memo_editor_wrap {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.memo_editor_container {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    min-height: 160px;
    flex: 1;
}

.memo_editor_container .ql-toolbar {
    border: none;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 8px 8px 0 0;
    background: #fafafa;
}

.memo_editor_container .ql-container {
    border: none;
    font-size: 13px;
    min-height: 120px;
}

.memo_editor_container .ql-editor {
    min-height: 120px;
    line-height: 1.6;
    color: #374151;
}

.memo_editor_container .ql-editor.ql-blank::before {
    color: #9ca3af;
}

.memo_editor_container .ql-editor strong,
.memo_editor_container .ql-editor b {
    font-weight: 700;
}

.memo_editor_container .ql-editor em,
.memo_editor_container .ql-editor i {
    font-style: italic;
}

.memo_editor_container .ql-editor u {
    text-decoration: underline;
}

.memo_editor_container .ql-editor h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0.5em 0 0.25em;
}

.memo_editor_container .ql-editor h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0.5em 0 0.25em;
}

.memo_editor_container .ql-editor ul,
.memo_editor_container .ql-editor ol {
    padding-left: 1.5em;
    margin: 0.25em 0;
}

.memo_editor_container .ql-editor a {
    color: #4f46e5;
    text-decoration: underline;
}

.memo_editor_hint {
    margin-top: 6px;
    font-size: 12px;
    color: #888;
}

.memo_editor_source {
    display: none !important;
}

.memo_editor_wrap--minimal .memo_editor_container {
    border-radius: 6px;
    background: #f9fafb;
    min-height: 80px;
}

.memo_editor_wrap--minimal .memo_editor_container .ql-container {
    border: none;
    font-size: 12px;
}

.memo_editor_wrap--minimal .memo_editor_container .ql-editor {
    min-height: 80px;
    padding: 7.5px;
}

.memo_editor_wrap--minimal .memo_editor_container.ql-snow,
.memo_editor_wrap--minimal .ql-container.ql-snow {
    border: none;
}

/* ホーム：全体メモカード（スクロール・ヘッダータップで編集） */
.settings_card--memo {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.home_memo_panel.settings_card--memo {
    flex: 1 1 auto;
    height: var(--home-message-window-height);
    max-height: var(--home-message-window-height);
    min-height: 0;
}

.card_header--clickable {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 7.5px;
    transition: filter 0.2s ease;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.card_header--clickable:hover,
.card_header--clickable:focus {
    filter: brightness(1.08);
    outline: none;
}

.card_header--clickable:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.card_header--clickable h3 {
    flex: 1;
    pointer-events: none;
}

.card_header--clickable .card_header_action {
    pointer-events: none;
}

.card_header_action {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.92;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding: 2px 7.5px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    line-height: 1.4;
}

.card_header_action:hover,
.card_header_action:focus {
    background: rgba(255, 255, 255, 0.22);
    outline: none;
}

.settings_card--memo .card_body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 2.5px 7.5px 5px;
}

.settings_card--memo .memo_item {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ホーム：全体メモ表示専用（編集はモーダル） */
.settings_card--memo .memo_item,
.settings_card--memo .memo_display_wrap {
    justify-content: flex-start;
    align-items: stretch;
}

.settings_card--memo .memo_display_wrap {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 7px 5px;
    display: block;
}

.settings_card--memo .memo_display_wrap .memo_editor_source {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.settings_card--memo .memo_display {
    height: auto;
    min-height: 0;
    overflow: visible;
    font-size: 13px;
    line-height: 1.35;
    color: #374151;
    padding: 0;
    margin: 0;
    cursor: default;
    border: none;
    background: transparent;
    box-sizing: border-box;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
}

.settings_card--memo .memo_display p,
.settings_card--memo .memo_display ol,
.settings_card--memo .memo_display ul,
.settings_card--memo .memo_display pre,
.settings_card--memo .memo_display blockquote,
.settings_card--memo .memo_display h2,
.settings_card--memo .memo_display h3 {
    margin: 0 0 0.45em;
    padding: 0;
}

.settings_card--memo .memo_display > *:first-child {
    margin-top: 0;
}

.settings_card--memo .memo_display > *:last-child {
    margin-bottom: 0;
}

.settings_card--memo .memo_display strong,
.settings_card--memo .memo_display b {
    font-weight: 700;
}

.settings_card--memo .memo_display em,
.settings_card--memo .memo_display i {
    font-style: italic;
}

.settings_card--memo .memo_display u {
    text-decoration: underline;
}

.settings_card--memo .memo_display h2 {
    font-size: 18px;
    font-weight: 700;
}

.settings_card--memo .memo_display h3 {
    font-size: 15px;
    font-weight: 700;
}

.settings_card--memo .memo_display ul,
.settings_card--memo .memo_display ol {
    padding-left: 1.5em;
}

.settings_card--memo .memo_display a {
    color: #4f46e5;
    text-decoration: underline;
}

.settings_card--memo .memo_display_empty {
    color: #9ca3af;
    font-style: italic;
    margin: 0;
}

/* 全体メモ編集モーダル */
.memo_modal {
    z-index: 2500;
}

body.memo_modal_open {
    overflow: hidden;
}

.memo_modal_content {
    max-width: 720px;
    width: 92%;
    max-height: 90vh;
    margin: 3% auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.memo_modal .modal_body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    color: #374151;
}

.memo_modal .memo_editor_wrap {
    flex: 1;
    min-height: 280px;
}

.memo_modal .memo_editor_container {
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.memo_modal .memo_editor_container .ql-container {
    flex: 1;
    min-height: 220px;
}

.memo_modal .memo_status {
    font-size: 12px;
}

/* メモステータス */
.memo_status {
    margin-top: 5px;
    font-size: 12px;
    text-align: center;
    transition: all 0.2s ease;
    min-height: 12.5px; /* メッセージ行分の高さを常時確保 */
}

.memo_status.saving {
    color: #f59e0b;
}

.memo_status.success {
    color: #10b981;
}

.memo_status.error {
    color: #ef4444;
}

/* 目標設定モーダル */
.goal_modal {
    z-index: 2500;
}

body.goal_modal_open {
    overflow: hidden;
}

.goal_modal_content {
    max-width: 920px;
    width: 94%;
    max-height: 90vh;
    margin: 3% auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.goal_modal .modal_body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    color: #374151;
}

.goal_modal_lead {
    margin: 0 0 10px;
    font-size: 12px;
    color: #6b7280;
}

.goal_modal .home_goal_grid {
    margin-bottom: 5px;
}

.goal_modal_status {
    min-height: 12.5px;
    margin: 5px 0 7.5px;
    font-size: 12px;
    color: #6b7280;
}

.goal_modal .form_actions {
    margin-top: 2.5px;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .home_stat_grid,
    .home_goal_grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home_goal_grid--core {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .home_progress_grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home_goal_grid--core {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .ai_content_wrapper {
        gap: 12.5px;
    }

    .home_hero_row {
        flex-direction: column;
        --home-message-window-height: 380px;
    }

    .home_hero_row .message_window {
        width: 100%;
        max-width: none;
        height: var(--home-message-window-height);
        max-height: var(--home-message-window-height);
    }

    .home_memo_panel,
    .home_memo_panel.settings_card--memo {
        height: var(--home-message-window-height);
        max-height: var(--home-message-window-height);
        min-height: 0;
    }

    .home_dashboard {
        gap: 10px;
    }

    .settings_cards {
        min-width: auto;
    }
}

@media (max-width: 640px) {
    .home_stat_grid,
    .home_goal_grid,
    .home_progress_grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home_goal_grid--core {
        grid-template-columns: 1fr;
    }

    .ten_day_activity_goals {
        width: 100%;
        margin-left: 0;
    }

    .ten_day_goal_chip {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    .home_dashboard_panel {
        padding: 10px;
    }

    .home_dashboard_title h3 {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .settings_card {
        border-radius: 8px;
    }
    
    .card_header {
        padding: 6.25px 8.75px;
    }
    
    .card_header h3 {
        font-size: 12px;
    }
    
    .card_body {
        padding: 8.75px;
    }
    
    .goal_grid {
        gap: 5px;
    }
    
    .goal_item label {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .input_with_unit input {
        padding: 4px 6px;
        font-size: 12px;
    }
    
    .input_with_unit .unit {
        padding: 4px 6px;
        font-size: 12px;
    }
    
    .memo_item textarea {
        padding: 6px;
        font-size: 12px;
    }
}

/* ==========================================
   設定画面専用スタイル
   ========================================== */

/* 設定画面コンテナ */
.settings_container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* ページヘッダー */
.page_header {
    text-align: center;
    margin-bottom: 30px;
}

.page_header h1 {
    font-size: 25px;
    color: #374151;
    margin-bottom: 5px;
    font-weight: 700;
}

.page_header p {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

/* 設定フォーム */
.settings_form {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 設定セクション */
.settings_section {
    border-bottom: 1px solid #e5e7eb;
    padding: 20px;
}

.settings_section:last-of-type {
    border-bottom: none;
}

/* セクションヘッダー */
.section_header {
    margin-bottom: 20px;
}

.section_header h2 {
    font-size: 15px;
    color: #374151;
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 設定項目グリッド */
.settings_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

/* 設定項目 */
.setting_item {
    display: flex;
    flex-direction: column;
}

.setting_item label {
    display: block;
    margin-bottom: 7.5px;
    font-weight: 600;
    color: #374151;
    font-size: 12px;
}

/* メモセクション */
.memo_section {
    width: 100%;
}

.memo_section textarea {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    border: 2px solid #d1d5db;
    border-radius: 12px;
    background: #f9fafb;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

.memo_section textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #ffffff;
}

/* フォームアクション */
.form_actions {
    padding: 20px;
    background: #f9fafb;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.form_actions button {
    padding: 8.75px 20px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-width: 140px;
}

.btn_primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn_primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn_secondary {
    background: #ffffff;
    color: #6b7280;
    border: 2px solid #d1d5db;
}

.btn_secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* アラートメッセージ */
.alert {
    padding: 10px 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 12px;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .settings_container {
        padding: 10px;
    }
    
    .page_header {
        margin-bottom: 20px;
    }
    
    .page_header h1 {
        font-size: 20px;
    }
    
    .settings_section {
        padding: 15px;
    }
    
    .section_header h2 {
        font-size: 12.5px;
    }
    
    .settings_grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .form_actions {
        padding: 15px;
        flex-direction: column;
    }
    
    .form_actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .settings_container {
        padding: 5px;
    }
    
    .page_header h1 {
        font-size: 17.5px;
    }
    
    .settings_section {
        padding: 10px;
    }
    
    .settings_grid {
        gap: 10px;
    }
}

/* ===== 活動ログ管理 検索パネル ===== */
.activity_filter_panel {
    margin-bottom: 20px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 4px 6px rgba(15, 23, 42, 0.04),
        0 20px 48px rgba(79, 70, 229, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.activity_filter_panel_head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13.5px 17.5px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
    color: #fff;
}

.activity_filter_panel_title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.activity_filter_panel_icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    backdrop-filter: blur(4px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.activity_filter_panel_title h3 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.activity_filter_panel_title p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.88;
}

.activity_filter_result_badge {
    display: inline-flex;
    align-items: center;
    padding: 4.5px 10px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.activity_filter_body {
    padding: 15px 17.5px 12.5px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch; /* 期間カードの高さに分類・種類カードを揃える */
    gap: 13.5px 18px;
}

.activity_filter_block {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 11.5px 12.5px 12.5px;
}

/* 期間・分類・種類を横並びに */
.activity_filter_block--period { flex: 0 1 auto; }
.activity_filter_block--options { flex: 1 1 340px; }

.activity_filter_block_title {
    margin: 0 0 5.5px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 17px;
}

.activity_filter_period_row {
    display: flex;
    align-items: center;
    gap: 8px 14px;
    flex-wrap: wrap;
}

.activity_filter_dates {
    display: flex;
    align-items: center;
    gap: 7.5px;
}

.activity_filter_period_sep {
    font-size: 14px;
    font-weight: 700;
    color: #94a3b8;
    padding-bottom: 8.5px;
    flex-shrink: 0;
}

.activity_filter_field {
    flex: 1;
    min-width: 140px;
}

.activity_filter_field label,
.activity_filter_sort_label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 5.5px;
    min-height: 17px;
}

.activity_filter_field input[type="date"],
.activity_filter_select_wrap select {
    width: 100%;
    min-height: 40px;
    padding: 6px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit; /* 明朝体になるのを防ぐ */
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    line-height: 1.4;
}

/* 期間: 日付入力を必要十分な幅に（無駄に広げない） */
.activity_filter_block--period .activity_filter_field {
    flex: 0 0 auto;
    min-width: 0;
}

.activity_filter_block--period .activity_filter_field input[type="date"] {
    width: 160px;
}

.activity_filter_select_wrap select {
    padding-right: 25px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.activity_filter_field input[type="date"] {
    cursor: pointer;
}

.activity_filter_field input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1;
    width: 13.5px;
    height: 13.5px;
    margin-left: 2.5px;
}

.activity_filter_select_wrap {
    position: relative;
}

.activity_filter_select_wrap::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #94a3b8;
    pointer-events: none;
}

.activity_filter_field input[type="date"]:focus,
.activity_filter_select_wrap select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.activity_filter_chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 0;
}

.activity_filter_chip {
    padding: 4.5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    background: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.activity_filter_chip:hover {
    border-color: #6366f1;
    color: #4f46e5;
    background: #eef2ff;
    transform: translateY(-1px);
}

.activity_filter_chip--active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.activity_filter_chip--active:hover {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: #4338ca;
}

.activity_filter_options_grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12.5px 18px;
    align-items: flex-end;
}

.activity_filter_field--category .activity_filter_sort_label {
    margin-bottom: 5.5px;
}

/* 分類: 中身に合わせた幅のトグル。高さは種類セレクト(48px)に揃える */
.activity_filter_field--category {
    flex: 0 0 auto;
    min-width: 0;
}

.activity_filter_field--category .activity_filter_sort_pills {
    display: inline-flex;
    width: auto;
    height: 40px;
    box-sizing: border-box;
    align-items: center;
}

.activity_filter_field--category .activity_filter_sort_pill {
    flex: 0 0 auto;
}

.activity_filter_field--category .activity_filter_sort_pill span {
    padding: 6px 16px;
    font-size: 13px;
}

/* 種類: 余白を埋めて伸びるが広がりすぎない */
.activity_filter_field--type {
    flex: 1 1 240px;
    min-width: 200px;
    max-width: 340px;
}

.activity_filter_sort_pills {
    display: flex;
    gap: 5px;
    background: #fff;
    padding: 3.5px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.activity_filter_sort_pill {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

.activity_filter_sort_pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.activity_filter_sort_pill span {
    display: block;
    text-align: center;
    padding: 5.5px 7.5px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    border-radius: 9px;
    transition: all 0.18s ease;
}

.activity_filter_sort_pill input:checked + span {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.activity_list_toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8.5px;
    margin: 10px 0 7.5px;
    padding: 7.5px 10px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.activity_list_toolbar .activity_filter_sort_pills {
    flex: 0 1 auto;
    min-width: 280px;
}

.activity_list_toolbar .activity_filter_sort_pill span {
    white-space: nowrap;
    padding: 5.5px 10px;
}

.activity_filter_footer {
    padding: 10px 17.5px 15px;
    display: flex;
    justify-content: center;
}

.activity_filter_submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6.5px;
    min-width: 220px;
    padding: 9px 25px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #7c3aed 100%);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.activity_filter_submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.5);
}

.activity_filter_submit:active {
    transform: translateY(0);
}

/* 一覧テーブル */
.activity_list_card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.empty_state {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.empty_state svg {
    margin: 0 auto 16px;
    color: #d1d5db;
}

.empty_state p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.empty_state span {
    font-size: 14px;
    color: #9ca3af;
}

.table_wrapper {
    overflow-x: auto;
}

.modern_table {
    width: 100%;
    border-collapse: collapse;
}

.modern_table thead th {
    background: #f8fafc;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    border-bottom: 2px solid #e5e7eb;
    position: sticky;
    top: 0;
}

.modern_table tbody .table_row {
    transition: all 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.modern_table tbody .table_row:hover {
    background: #f8fafc;
}

.modern_table td {
    padding: 16px;
    font-size: 14px;
    color: #374151;
}

.date_cell {
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    font-size: 15px;
    letter-spacing: 0.01em;
}

.date_cell--created {
    color: #1e293b;
}

.date_cell--target {
    color: #475569;
    font-size: 14px;
}

/* 曜日1字を7曜で色分け（日付の区切りを見やすく） */
.date_cell .wd {
    font-weight: 800;
}
.wd-0 { color: #e11d48; } /* 日 赤 */
.wd-1 { color: #7c3aed; } /* 月 紫 */
.wd-2 { color: #ea580c; } /* 火 橙 */
.wd-3 { color: #0891b2; } /* 水 シアン */
.wd-4 { color: #16a34a; } /* 木 緑 */
.wd-5 { color: #ca8a04; } /* 金 金 */
.wd-6 { color: #2563eb; } /* 土 青 */

.category_badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.category_badge.aerobic {
    background: #ecfccb;
    color: #365314;
}

.category_badge.training {
    background: #fef3c7;
    color: #92400e;
}

.type_cell {
    font-weight: 500;
}

.calorie_cell {
    font-weight: 600;
    color: #059669;
}

.notes_cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b7280;
}

.actions_cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn_edit {
    background: #6366f1;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.btn_edit:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

.btn_delete {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.btn_delete:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* モーダル */
.modal_overlay {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.modal_overlay.is-open {
    display: flex;
}

.modal_container {
    background: white;
    border-radius: 16px;
    width: min(600px, 100%);
    max-height: min(90vh, calc(100vh - 20px));
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    margin: 0;
    flex-shrink: 0;
}

.modal_overlay.is-open .modal_container {
    transform: scale(1);
}

.modal_container--wide {
    width: min(920px, 100%);
    max-height: min(85vh, calc(100vh - 20px));
}

#home_activity_edit_modal.is-open {
    z-index: 10001;
}

/* SweetAlert2 をアプリモーダル（z-index:10000+）より前面に */
.swal2-container {
    z-index: 20000 !important;
}

.day_activity_empty_row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 25px 10px;
}

.day_activity_empty {
    margin: 0;
    padding: 0;
    text-align: center;
    color: #6b7280;
    font-size: 22px;
}

.day_activity_empty_add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.day_activity_empty_add:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.45);
}

.day_activity_table .actions_cell {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

#day_activity_modal .day_activity_table td,
#day_activity_modal .day_activity_table th {
    padding: 8px 10px;
}

.day_activity_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
}

.day_activity_btn--edit {
    background: #6366f1;
    color: #fff;
}

.day_activity_btn--edit:hover {
    background: #4f46e5;
}

.day_activity_btn--delete {
    background: #ef4444;
    color: #fff;
}

.day_activity_btn--delete:hover {
    background: #dc2626;
}

.modal_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal_header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal_close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
    color: #6b7280;
}

.modal_close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal_body {
    padding: 20px;
}

.form_row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form_group {
    flex: 1;
    min-width: 200px;
}

.form_group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
}

.form_group input,
.form_group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.form_group input:focus,
.form_group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form_group input:disabled {
    background: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
}

.form_group textarea {
    resize: vertical;
    font-family: inherit;
}

/* 活動タイプ：ボタン選択（有酸素・筋トレで区切り） */
.activity_type_picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity_type_group_head {
    font-size: 12.5px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
    padding-left: 5px;
    border-left: 4px solid #cbd5e1;
    line-height: 1.3;
}

.activity_type_group_head--aerobic {
    border-left-color: #10b981;
    color: #047857;
}

.activity_type_group_head--mtraining {
    border-left-color: #f59e0b;
    color: #b45309;
}

.activity_type_btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6.5px;
}

.activity_type_btn {
    width: auto;
    padding: 7px 11.5px;
    font-size: 12.5px;
    font-weight: 600;
    color: #374151;
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    border-radius: 7.5px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.activity_type_btn:hover {
    border-color: #a5b4fc;
    background: #eef2ff;
}

.activity_type_btn[data-category="aerobic"].is_selected {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.activity_type_btn[data-category="mtraining"].is_selected {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}

.modal_actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.btn_cancel {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn_cancel:hover {
    background: #e5e7eb;
}

/* ホーム画面 目標設定 横並び */
.goal_grid_horizontal {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.goal_grid_horizontal .goal_item {
    flex: 1;
    min-width: 140px;
    max-width: 180px;
}

.goal_grid_horizontal .goal_item label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    display: block;
    text-align: center;
}

.goal_grid_horizontal .input_with_unit {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #e5e7eb;
}

.goal_grid_horizontal .input_with_unit input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: #1f2937;
}

.goal_grid_horizontal .input_with_unit input:focus {
    outline: none;
    background: white;
    border-radius: 4px;
}

.goal_grid_horizontal .input_with_unit .unit {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 4px;
}

/* 平均消費カロリーカードのスタイル */
.metric_card.calories_avg {
    background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 100%);
    border: 1px solid #f59e0b;
}

.metric_card.calories_avg .metric_label {
    color: #92400e;
}

.metric_card.calories_avg .metric_value .value {
    color: #78350f;
}

/* 活動ログ管理 レスポンシブ対応 */
@media (max-width: 768px) {
    .activity_filter_panel_head {
        flex-direction: column;
        align-items: flex-start;
        padding: 11.5px 12.5px;
    }

    .activity_filter_body {
        padding: 11.5px 12.5px 3.5px;
    }

    .activity_filter_body {
        flex-direction: column;
    }

    .activity_filter_period_row {
        flex-direction: column;
        align-items: stretch;
    }

    .activity_filter_dates {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .activity_filter_block--period .activity_filter_field {
        flex: 1 1 auto;
    }

    .activity_filter_block--period .activity_filter_field input[type="date"] {
        width: 100%;
    }

    .activity_filter_period_sep {
        display: none;
    }

    .activity_filter_options_grid {
        flex-direction: column;
        align-items: stretch;
    }

    .activity_filter_field--type {
        max-width: none;
    }

    .activity_filter_field--category .activity_filter_sort_pills {
        display: flex;
        width: 100%;
    }

    .activity_filter_field--category .activity_filter_sort_pill {
        flex: 1;
    }

    .activity_filter_footer {
        padding: 8.5px 12.5px 12.5px;
    }

    .activity_filter_submit {
        width: 100%;
    }

    .modal_container {
        width: min(600px, 100%);
    }

    .modal_body {
        padding: 16px;
    }

    .form_row {
        flex-direction: column;
        gap: 16px;
    }

    .actions_cell {
        flex-direction: column;
        align-items: stretch;
    }

    .modern_table {
        font-size: 12px;
    }

    .modern_table td,
    .modern_table th {
        padding: 12px 8px;
    }

    /* 目標設定 モバイル対応 */
    .goal_grid_horizontal {
        flex-direction: column;
        gap: 12px;
    }

    .goal_grid_horizontal .goal_item {
        min-width: auto;
        max-width: none;
    }

    .goal_grid_horizontal .goal_item label {
        text-align: left;
        font-size: 13px;
    }
}

/* =====================================================
   AIチャットコーナー（func/ai_chat）
   ===================================================== */
#ai_chat .main_content {
    padding: 15px 20px 20px;
}

.web_chat_wrapper {
    max-width: 720px;
    margin: 0 auto;
}

.web_chat_panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 480px;
    max-height: 820px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(236, 72, 153, 0.12);
    border: 1px solid rgba(236, 72, 153, 0.15);
    overflow: hidden;
}

.web_chat_header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 50%, #ede9fe 100%);
    border-bottom: 1px solid rgba(236, 72, 153, 0.12);
    flex-shrink: 0;
}

.web_chat_header_avatar img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid #f9a8d4;
    object-fit: cover;
}

.web_chat_header_text h2 {
    font-size: 15.5px;
    color: #831843;
    margin: 0 0 2.5px;
}

.web_chat_header_text p {
    margin: 0;
    font-size: 12px;
    color: #9d174d;
    opacity: 0.85;
}

.web_chat_messages {
    flex: 1;
    overflow-y: auto;
    padding: 12.5px 10px;
    display: flex;
    flex-direction: column;
    gap: 7.5px;
    background: #fafafa;
}

.web_chat_bubble_row {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.web_chat_bubble_row.user {
    align-self: flex-end;
    align-items: flex-end;
}

.web_chat_bubble_row.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.web_chat_bubble {
    padding: 8.5px 11px;
    border-radius: 16px;
    font-size: 14.25px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.web_chat_bubble_row.user .web_chat_bubble {
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.web_chat_bubble_row.assistant .web_chat_bubble {
    background: #fff;
    color: #374151;
    border: 1px solid #f3e8ff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.web_chat_meta {
    font-size: 15.5px;
    color: #9ca3af;
    margin-top: 2.5px;
    padding: 0 2.5px;
}

.web_chat_typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12.5px;
    font-size: 12px;
    color: #9d174d;
    flex-shrink: 0;
}

.web_chat_typing[hidden] {
    display: none !important;
}

.web_chat_typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ec4899;
    animation: webChatTyping 1.2s infinite ease-in-out;
}

.web_chat_typing .dot:nth-child(2) { animation-delay: 0.15s; }
.web_chat_typing .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes webChatTyping {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

.web_chat_form {
    display: flex;
    align-items: flex-end;
    gap: 7.5px;
    padding: 10px 12.5px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.web_chat_form textarea {
    flex: 1;
    resize: none;
    min-height: 48px;
    max-height: 140px;
    padding: 7.5px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14.25px;
    line-height: 1.5;
    font-family: inherit;
}

.web_chat_form textarea:focus {
    outline: none;
    border-color: #ec4899;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

.web_chat_send_btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: transform 0.15s, opacity 0.15s;
}

.web_chat_send_btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.web_chat_send_btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sr_only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 768px) {
    #ai_chat .main_content {
        padding: 7.5px;
    }

    .web_chat_panel {
        height: calc(100vh - 120px);
        border-radius: 12px;
    }

    .web_chat_bubble_row {
        max-width: 92%;
    }

    .web_chat_bubble {
        font-size: 14.62px;
    }

    .web_chat_form textarea {
        font-size: 14.62px;
    }
}

/* =====================================================
   画像館 (#image_gallery)
   ===================================================== */
#image_gallery .gallery_section {
    max-width: 1200px;
    margin: 0 auto;
}

#image_gallery .gallery_page_header {
    margin-bottom: 16px;
}

#image_gallery .gallery_page_header h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

#image_gallery .gallery_page_desc {
    color: #666;
    font-size: 14px;
}

#image_gallery .gallery_tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

#image_gallery .gallery_tab {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 999px;
    background: #fff;
    color: #444;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#image_gallery .gallery_tab:hover {
    border-color: #ff6b9d;
    color: #ff6b9d;
}

#image_gallery .gallery_tab.active {
    background: #ff6b9d;
    border-color: #ff6b9d;
    color: #fff;
}

#image_gallery .gallery_panel {
    display: none;
}

#image_gallery .gallery_panel.active {
    display: block;
}

#image_gallery .gallery_toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

#image_gallery .gallery_upload_btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    background: #ff6b9d;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

#image_gallery .gallery_upload_btn:hover {
    background: #e85a8a;
}

#image_gallery .gallery_upload_hint {
    font-size: 12px;
    color: #888;
}

#image_gallery .gallery_panel_toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

#image_gallery .gallery_filter_fav {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    user-select: none;
}

#image_gallery .gallery_filter_fav input {
    width: 16px;
    height: 16px;
    accent-color: #ff6b9d;
}

#image_gallery .gallery_filter_fav span i {
    color: #ff6b9d;
}

#image_gallery .gallery_grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
}

#image_gallery .gallery_item_cell {
    position: relative;
}

#image_gallery .gallery_item_cell.is_filter_hidden {
    display: none;
}

#image_gallery .gallery_item {
    aspect-ratio: 1;
    padding: 0;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

#image_gallery .gallery_item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

#image_gallery .gallery_item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#image_gallery .gallery_fav_toggle {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: color 0.2s, transform 0.2s;
}

#image_gallery .gallery_fav_toggle:hover {
    transform: scale(1.08);
    color: #ff6b9d;
}

#image_gallery .gallery_fav_toggle.is_favorite {
    color: #ff6b9d;
}

#image_gallery .gallery_migrate_btn {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 4px 6px;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#image_gallery .gallery_migrate_btn:hover {
    background: #e0e7ff;
}

#image_gallery .gallery_migrate_btn:disabled {
    opacity: 0.6;
    cursor: default;
}

#image_gallery .gallery_migrate_btn.is_migrated {
    background: #ecfdf5;
    color: #059669;
    border-color: #6ee7b7;
}

#image_gallery .gallery_empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 30px 10px;
    font-size: 15px;
}

.gallery_modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.gallery_modal.is_open {
    display: block;
}

.gallery_modal_overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.gallery_modal_content {
    position: relative;
    z-index: 1;
    max-width: min(920px, 94vw);
    max-height: 94vh;
    margin: 3vh auto;
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: auto;
}

.gallery_modal_close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    z-index: 2;
}

.gallery_modal_close:hover {
    color: #333;
}

.gallery_modal_image_wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: calc(94vh - 120px);
}

.gallery_modal_image {
    max-width: 100%;
    max-height: calc(94vh - 120px);
    object-fit: contain;
    border-radius: 8px;
}

.gallery_modal_meta {
    width: 100%;
    margin-top: 10px;
    text-align: center;
}

.gallery_modal_filename {
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
}

.gallery_modal_mtime {
    font-size: 12px;
    color: #888;
    margin-top: 3px;
}

.gallery_modal_actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.gallery_fav_modal_btn {
    padding: 7px 14px;
    border: 1px solid #ff6b9d;
    background: #fff;
    color: #888;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.gallery_fav_modal_btn.is_favorite {
    background: #fff5f8;
    color: #ff6b9d;
}

.gallery_fav_modal_btn:hover {
    background: #fff5f8;
    color: #ff6b9d;
}

.gallery_delete_btn {
    padding: 7px 14px;
    border: 1px solid #e74c3c;
    background: #fff;
    color: #e74c3c;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.gallery_delete_btn:hover {
    background: #e74c3c;
    color: #fff;
}

/* SweetAlert2 を画像モーダルより前面に */
.swal2-container.gallery_swal_top {
    z-index: 20000 !important;
}

@media (max-width: 768px) {
    #image_gallery .gallery_grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .gallery_modal_content {
        margin: 2vh auto;
        padding: 10px;
    }
}
