/* ==========================================================================
   FODMAP帳 - IBS食事・排便トラッカー 独自CSSシステム
   ========================================================================== */

/* 1. CSS設計用の変数定義
   ========================================================================== */
:root {
    /* テーマカラー */
    --primary: #047857;       /* emerald-700 */
    --primary-hover: #065f46; /* emerald-800 */
    --primary-bg: #ecfdf5;    /* emerald-50 */
    
    --teal: #0f766e;          /* teal-700 */
    --teal-bg: #f0fdfa;       /* teal-50 */
    --teal-border: #ccfbf1;   /* teal-100 */
    
    --amber: #b45309;         /* amber-700 */
    --amber-bg: #fffbeb;      /* amber-50 */
    --amber-border: #fef3c7;  /* amber-100 */
    
    --sky: #0369a1;           /* sky-700 */
    --sky-bg: #f0f9ff;        /* sky-50 */
    --sky-border: #e0f2fe;    /* sky-100 */
    
    --rose: #be123c;          /* rose-700 */
    --rose-bg: #fff1f2;       /* rose-50 */
    --rose-border: #ffe4e6;   /* rose-100 */
    
    --indigo: #4338ca;        /* indigo-700 */
    --indigo-bg: #eef2ff;     /* indigo-50 */
    --indigo-border: #c7d2fe; /* indigo-300 */
    
    /* ニュートラルカラー */
    --bg-app: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #1e293b;     /* slate-800 */
    --text-muted: #64748b;    /* slate-500 */
    --text-light: #94a3b8;    /* slate-400 */
    --border: #e2e8f0;        /* slate-200 */
    --border-light: #f1f5f9;  /* slate-100 */
    
    /* 角丸・影・アニメーション */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. 基本リセット & ヘルパー
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

.hidden {
    display: none !important;
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .5;
    }
}

.animate-fadeIn {
    animation: fadeIn 0.2s ease-out forwards;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* スクロールバー */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

/* 3. レイアウト
   ========================================================================== */
.main-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.header-container {
    max-width: 56rem; /* 4xl */
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon-bg {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: #a7f3d0; /* emerald-300 */
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 10px;
    color: #d1fae5; /* emerald-100 */
    opacity: 0.9;
    font-family: monospace;
}

.auth-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-loading-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(6, 78, 59, 0.4); /* emerald-900/40 */
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.avatar-img {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
}

.avatar-fallback {
    width: 1rem;
    height: 1rem;
    color: #a7f3d0;
}

.user-name {
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .user-name {
        display: none;
    }
}

.btn-logout {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0.125rem;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.btn-logout:hover {
    color: #a7f3d0;
}

.app-main {
    flex: 1;
    max-width: 56rem; /* 4xl */
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* 4. タブバー
   ========================================================================== */
.tab-bar {
    background-color: var(--bg-card);
    padding: 0.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background-color: var(--border-light);
    color: var(--text-main);
}

.tab-btn--active {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: var(--shadow-sm);
}

/* 5. 記録ページグリッドレイアウト
   ========================================================================== */
.timeline-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .timeline-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
    
    .timeline-left {
        grid-column: span 7 / span 7;
    }
    
    .timeline-right {
        grid-column: span 5 / span 5;
    }
}

.left-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* 6. カード・フォーム
   ========================================================================== */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
}

.card-icon-wrapper {
    padding: 0.375rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon-wrapper--teal { background-color: var(--teal-bg); color: var(--teal); }
.card-icon-wrapper--amber { background-color: var(--amber-bg); color: var(--amber); }
.card-icon-wrapper--sky { background-color: var(--sky-bg); color: var(--sky); }
.card-icon-wrapper--rose { background-color: var(--rose-bg); color: var(--rose); }

.card-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 0.5rem;
}

/* 入力要素 */
.input-text {
    flex: 1;
    background-color: var(--border-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.input-text:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-bg);
}

.input-select {
    background-color: var(--border-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.input-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-bg);
}

.input-range {
    width: 100%;
    height: 0.5rem;
    background-color: var(--border);
    border-radius: 9999px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
}

.input-range::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background-color: var(--sky);
    transition: var(--transition);
}

.input-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* ボタン関係 */
.btn {
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.625rem 1.25rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn--primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn--primary:hover {
    background-color: var(--primary-hover);
}

.btn--secondary {
    background-color: var(--border-light);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background-color: var(--border);
}

.btn--danger {
    background-color: var(--rose);
    color: #ffffff;
}

.btn--danger:hover {
    background-color: #9f1239;
}

.btn--disabled {
    background-color: var(--border) !important;
    color: #ffffff !important;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.btn-pill {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
}

/* 食べ方選択ボタン */
.ingest-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.ingest-btn {
    border: 1px solid var(--border);
    background-color: var(--border-light);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
}

.ingest-btn:hover {
    background-color: var(--border);
}

.ingest-btn--active.ingest-btn--all {
    border-color: #a7f3d0;
    background-color: var(--primary-bg);
    color: #065f46;
}

.ingest-btn--active.ingest-btn--soup_left {
    border-color: #fde68a;
    background-color: var(--amber-bg);
    color: #92400e;
}

.ingest-btn--active.ingest-btn--only_ingredients {
    border-color: var(--indigo-border);
    background-color: var(--indigo-bg);
    color: #3730a3;
}

/* ブリストルスケールグリッド */
.bristol-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.bristol-btn {
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border);
    background-color: var(--border-light);
    color: var(--text-muted);
    transition: var(--transition);
}

.bristol-btn:hover {
    background-color: var(--border);
}

.bristol-btn--indigo-active { background-color: var(--indigo) !important; color: #ffffff !important; border-color: #312e81 !important; font-weight: 700; }
.bristol-btn--indigo { background-color: var(--indigo-bg); color: var(--indigo); border-color: var(--indigo-border); font-weight: 500; }

.bristol-btn--sky-active { background-color: var(--sky) !important; color: #ffffff !important; border-color: #0c4a6e !important; font-weight: 700; }
.bristol-btn--sky { background-color: var(--sky-bg); color: var(--sky); border-color: var(--sky-border); font-weight: 500; }

.bristol-btn--emerald-active { background-color: var(--primary) !important; color: #ffffff !important; border-color: var(--primary-hover) !important; font-weight: 700; }
.bristol-btn--emerald { background-color: var(--primary-bg); color: var(--primary); border-color: #a7f3d0; font-weight: 500; }

.bristol-btn--rose-active { background-color: var(--rose) !important; color: #ffffff !important; border-color: #881337 !important; font-weight: 700; }
.bristol-btn--rose { background-color: var(--rose-bg); color: var(--rose); border-color: var(--rose-border); font-weight: 500; }

.guide-box {
    padding: 0.625rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: start;
}

.guide-box--red { background-color: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.guide-box--blue { background-color: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.guide-box--green { background-color: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.guide-box--yellow { background-color: #fefce8; border-color: #fef08a; color: #854d0e; }
.guide-box--amber { background-color: #fef3c7; border-color: #fcd34d; color: #92400e; }
.guide-box--rose { background-color: #ffe4e6; border-color: #fecdd3; color: #9f1239; }

/* お薬リスト */
.medicine-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.medicine-btn {
    background-color: var(--rose-bg);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition);
}

.medicine-btn:hover {
    background-color: #ffe4e6;
}

.medicine-btn:active {
    transform: scale(0.95);
}

/* 7. タイムラインエリア
   ========================================================================== */
.timeline-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 500px;
    height: calc(100vh - 210px);
    max-height: 800px;
}

.timeline-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    background-color: rgba(248, 250, 252, 0.5); /* slate-50/50 */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.timeline-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    flex: 1;
    margin-right: 0.5rem;
}

.timeline-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-badge {
    background-color: var(--primary-bg);
    border: 1px solid #a7f3d0;
    color: var(--primary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 700;
    font-family: monospace;
    flex-shrink: 0;
}

.timeline-filter-clear {
    font-size: 9px;
    color: var(--primary);
    border: 1px solid #6ee7b7;
    background: transparent;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.timeline-filter-clear:hover {
    background-color: var(--primary);
    color: #ffffff;
}

.timeline-btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-lg);
    padding: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.timeline-btn-icon:hover {
    color: var(--primary);
    background-color: var(--primary-bg);
    border-color: #a7f3d0;
}

.timeline-events-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* タイムラインアイテム */
.timeline-date-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    margin-top: 0.5rem;
}

.timeline-date-badge {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    font-family: monospace;
    background-color: var(--border-light);
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
}

.timeline-date-line {
    flex-grow: 1;
    height: 1px;
    background-color: var(--border);
}

.timeline-item-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    background-color: #ffffff;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
}

.timeline-item-card:hover {
    border-color: var(--text-light);
}

.timeline-item-card:active {
    background-color: var(--border-light);
}

.timeline-item-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.timeline-item-icon {
    padding: 0.375rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-item-icon--teal { background-color: var(--teal-bg); border-color: var(--teal-border); color: var(--teal); }
.timeline-item-icon--amber { background-color: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }
.timeline-item-icon--sky { background-color: var(--sky-bg); border-color: var(--sky-border); color: var(--sky); }
.timeline-item-icon--rose { background-color: var(--rose-bg); border-color: var(--rose-border); color: var(--rose); }

.timeline-item-content {
    flex-grow: 1;
}

.timeline-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
}

.timeline-item-time {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    font-family: monospace;
}

.timeline-item-delete {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.timeline-item-delete:hover {
    color: var(--rose);
}

.timeline-item-details {
    font-size: 0.75rem;
}

.timeline-item-details__title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.timeline-item-details__flex-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.timeline-item-details__text {
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-size: 11px;
}

/* 食事・排便などのタグ */
.tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    margin-top: 0.25rem;
}

.tag--high-fodmap {
    background-color: var(--rose-bg);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.tag--low-fodmap {
    background-color: var(--primary-bg);
    color: var(--primary);
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
}

.tag--high-fodmap-edit {
    background-color: var(--rose-bg);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    font-weight: 700;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.tag--high-fodmap-edit button {
    background: transparent;
    border: none;
    color: #fda4af;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.tag--high-fodmap-edit button:hover {
    color: var(--rose);
}

/* 8. 分析レポートビュー
   ========================================================================== */
.analysis-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .analysis-summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.analysis-summary-card {
    border-radius: var(--radius-xl);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border);
}

.analysis-summary-card--rose { background-color: var(--rose-bg); border-color: var(--rose-border); }
.analysis-summary-card--teal { background-color: var(--teal-bg); border-color: var(--teal-border); }
.analysis-summary-card--slate { background-color: var(--border-light); border-color: var(--border); }

.analysis-summary-icon {
    padding: 0.625rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.analysis-summary-icon--rose { background-color: #fecdd3; color: var(--rose); }
.analysis-summary-icon--teal { background-color: #ccfbf1; color: var(--teal); }
.analysis-summary-icon--slate { background-color: var(--border); color: var(--text-muted); }

.analysis-summary-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

.analysis-summary-value {
    font-size: 1.5rem;
    font-weight: 900;
    font-family: monospace;
}

.analysis-summary-value--rose { color: #4c0519; }
.analysis-summary-value--teal { color: #042f2e; }

.analysis-summary-unit {
    font-size: 0.75rem;
    font-weight: 700;
}

.analysis-summary-unit--rose { color: var(--rose); }
.analysis-summary-unit--teal { color: var(--teal); }

.analysis-dominant {
    font-size: 0.875rem;
    font-weight: 700;
    display: block;
    margin-top: 0.125rem;
}
.analysis-dominant--none { color: var(--text-main); }
.analysis-dominant--danger { color: #b91c1c; }
.analysis-dominant--info { color: #0284c7; }
.analysis-dominant--mixed { color: #0d9488; }

/* トリガー比率表示 */
.trigger-bar-card {
    background-color: var(--border-light);
    border-radius: var(--radius-xl);
    padding: 1rem;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.trigger-bar-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.trigger-bar-legend {
    display: flex;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-item--food { color: #b91c1c; }
.legend-item--mental { color: #0369a1; }

.legend-color-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
}
.legend-color-dot--food { background-color: #f43f5e; }
.legend-color-dot--mental { background-color: #0ea5e9; }

.progress-bar-container {
    width: 100%;
    height: 1rem;
    background-color: var(--border);
    border-radius: 9999px;
    overflow: hidden;
    display: flex;
}

.progress-bar-segment--food {
    height: 100%;
    background: linear-gradient(to right, #f87171, #f43f5e);
    transition: var(--transition);
}

.progress-bar-segment--mental {
    height: 100%;
    background: linear-gradient(to right, #38bdf8, #6366f1);
    transition: var(--transition);
}

.analysis-desc-muted {
    font-size: 10px;
    color: var(--text-light);
}

/* 9. データテーブル (ランキング・辞書)
   ========================================================================== */
.table-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-container--scrollable {
    max-height: 400px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    text-align: left;
    font-size: 0.75rem;
    border-collapse: collapse;
}

.data-table th {
    background-color: var(--border-light);
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table th.sticky-th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 0.75rem;
}

.table-row {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.table-row:hover {
    background-color: var(--border-light);
}

.table-row:last-child {
    border: 0;
}

.table-cell--center {
    text-align: center;
}

.table-cell--bold {
    font-weight: 700;
    color: var(--text-main);
}

.table-cell--danger {
    color: var(--rose);
}

.table-cell--desc {
    color: #475569;
}

.table-cell--muted {
    color: var(--text-light);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid transparent;
}

.badge--high {
    background-color: var(--rose-bg);
    color: var(--rose);
    border-color: var(--rose-border);
}

.badge--low {
    background-color: var(--primary-bg);
    color: var(--primary);
    border-color: #a7f3d0;
}

.group-tag {
    background-color: var(--border-light);
    color: var(--text-muted);
    font-family: monospace;
    font-size: 9px;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* 分析空状態 */
.empty-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
}

.empty-placeholder-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.empty-placeholder-desc {
    font-size: 10px;
    margin-top: 0.125rem;
}

/* 10. メッセージボックス
   ========================================================================== */
.msg-box {
    padding: 0.625rem;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    font-size: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: start;
}

.msg-box--success {
    background-color: rgba(6, 78, 59, 0.8);
    color: #a7f3d0;
    border-color: #065f46;
}

.msg-box--danger {
    background-color: rgba(136, 19, 55, 0.8);
    color: #fecdd3;
    border-color: #881337;
}

.msg-box--info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* 11. モーダル
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(15, 23, 42, 0.6); /* slate-900/60 */
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #ffffff;
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.2s ease-out forwards;
    width: 100%;
}

.modal-content--md { max-width: 28rem; /* max-w-md */ }
.modal-content--sm { max-width: 24rem; /* max-w-sm */ }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    display: block;
}

.modal-value-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1rem;
}

.modal-ai-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.modal-ai-status span {
    font-weight: 700;
    font-size: 10px;
    color: var(--teal);
    letter-spacing: 0.05em;
}

.modal-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.modal-value-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
}

.modal-footer {
    display: flex;
    gap: 0.625rem;
    margin-top: 0.5rem;
}

.modal-footer .btn {
    flex: 1;
}

/* カレンダーフィルターモーダル内部 */
.cal-mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
    padding: 0.25rem;
    background-color: var(--border-light);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.cal-mode-btn {
    padding: 0.375rem 0;
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.cal-mode-btn:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.cal-mode-btn--active {
    background-color: #ffffff !important;
    color: var(--primary) !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.cal-month-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem;
}

.cal-nav-btn {
    background: transparent;
    border: none;
    padding: 0.375rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.cal-nav-btn:hover {
    background-color: var(--border-light);
}

.cal-month-label {
    font-weight: 800;
    color: var(--text-main);
    font-size: 0.75rem;
    font-family: monospace;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.cal-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.cal-day-btn {
    height: 2.25rem;
    position: relative;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: var(--transition);
}

.cal-day-btn--current {
    color: var(--text-main);
}

.cal-day-btn--current:hover {
    background-color: var(--primary-bg);
    border-color: #a7f3d0;
}

.cal-day-btn--other {
    color: #cbd5e1; /* slate-300 */
}

.cal-day-btn--other:hover {
    background-color: var(--border-light);
}

.cal-day-btn--today {
    background-color: var(--amber-bg) !important;
    font-weight: 700;
    border-color: #fde68a !important;
    color: var(--amber) !important;
}

.cal-day-btn__dot {
    position: absolute;
    bottom: 0.25rem;
    width: 4px;
    height: 4px;
    background-color: var(--primary);
    border-radius: 50%;
}

/* 12. トーストポップアップ
   ========================================================================== */
.toast-popup {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background-color: #0f172a; /* slate-900 */
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.625rem 1rem;
    border-radius: 9999px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-icon--success {
    color: #34d399; /* emerald-400 */
}

/* 13. 写真解析 & カロリー記録
   ========================================================================== */
.meal-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (min-width: 640px) {
    .meal-input-row {
        flex-wrap: nowrap;
    }
}

.btn--photo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 0.55rem 0.875rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.2);
    transition: var(--transition);
    white-space: nowrap;
}

.btn--photo:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(13, 148, 136, 0.3);
}

.btn--photo:active {
    transform: translateY(0);
}

.photo-analyzing-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border: 1.5px dashed #10b981;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.photo-analyzing-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.photo-analyzing-title {
    font-size: 0.875rem;
    font-weight: 800;
    color: #065f46;
}

.photo-analyzing-desc {
    font-size: 0.75rem;
    color: #047857;
}

.calorie-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: #fef3c7; /* amber-100 */
    color: #92400e; /* amber-800 */
    border: 1px solid #fde68a; /* amber-200 */
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

/* 今日の残りカロリー表示ウィジェット */
.daily-calorie-box {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    flex-shrink: 0;
}

.daily-calorie-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.375rem;
}

.daily-calorie-title {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-main);
}

.daily-calorie-icon {
    color: #ea580c; /* flame orange */
}

.daily-calorie-target-wrap {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.daily-calorie-target-label {
    font-size: 0.6875rem;
}

.daily-calorie-target-val {
    font-weight: 700;
    color: var(--text-main);
    font-family: monospace;
}

.daily-calorie-edit-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 0.125rem 0.3125rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.daily-calorie-edit-btn:hover {
    background-color: var(--primary-bg);
    color: var(--primary);
    border-color: #a7f3d0;
}

.daily-calorie-edit-form {
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.5rem;
    animation: fadeIn 0.2s ease-in-out;
}

.daily-calorie-edit-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.daily-calorie-edit-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.daily-calorie-input {
    width: 90px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    color: var(--text-main);
    text-align: right;
    outline: none;
    font-family: monospace;
}

.daily-calorie-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(4, 120, 87, 0.15);
}

.daily-calorie-btn-save,
.daily-calorie-btn-cancel {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.6875rem !important;
    border-radius: var(--radius-sm) !important;
}

.daily-calorie-body {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.daily-calorie-main {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
}

.daily-calorie-value-wrap {
    display: flex;
    align-items: baseline;
    gap: 0.125rem;
}

.daily-calorie-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: monospace, sans-serif;
    line-height: 1;
    letter-spacing: -0.025em;
    transition: color 0.2s ease;
}

.daily-calorie-value--normal {
    color: var(--primary);
}

.daily-calorie-value--warn {
    color: var(--amber);
}

.daily-calorie-value--over {
    color: var(--rose);
}

.daily-calorie-unit {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
}

.daily-calorie-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 0.0625rem 0.375rem;
    border-radius: 9999px;
    line-height: 1.4;
    white-space: nowrap;
}

.daily-calorie-badge--normal {
    background-color: var(--primary-bg);
    color: var(--primary);
    border: 1px solid #a7f3d0;
}

.daily-calorie-badge--warn {
    background-color: var(--amber-bg);
    color: var(--amber);
    border: 1px solid var(--amber-border);
}

.daily-calorie-badge--over {
    background-color: var(--rose-bg);
    color: var(--rose);
    border: 1px solid var(--rose-border);
}

.daily-calorie-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.daily-calorie-sub strong {
    color: var(--text-main);
    font-family: monospace;
}

.daily-calorie-separator {
    color: var(--text-light);
}

.daily-calorie-progress-track {
    width: 100%;
    height: 6px;
    background-color: var(--border-light);
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
}

.daily-calorie-progress-bar {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

.daily-calorie-progress-bar--normal {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.daily-calorie-progress-bar--warn {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.daily-calorie-progress-bar--over {
    background: linear-gradient(90deg, #f43f5e 0%, #be123c 100%);
}

