body {
    font-family: sans-serif;
    text-align: center;
    margin: 20px;
    font-size: 16px;
    padding-bottom: 80px;  /* 一番下に「ゆとり」を作ってグラフの震えを防ぐ */
    overflow-x: hidden;    /* 見えない横揺れを完全に防ぐ */
}

h1 {
    font-size: 32px;
    margin-top: 10px;
    margin-bottom: 5px;
    color: #4CAF50;
}

#appScreen > div:first-child {
    margin-top: 0;
    padding-top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5px;
}

button {
    font-size: 14px;
    padding: 4px 8px;
}

select {
    font-size: 14px;
    padding: 6px;
    width: 60%;
    margin: 0 auto 10px;
    display: block;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
}

select option {
    text-align: center;
}

#pfcChart {
    width: 320px;
    height: 320px;
    margin: auto;
    display: block;
}

/* ===== テーブルのスマホ最適化 ===== */
#historyTable,
#totalTable {
    margin: auto;
    border-collapse: collapse;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
    table-layout: fixed;
}

#historyTable th,
#historyTable td,
#totalTable th,
#totalTable td {
    border: 1px solid #ccc;
    padding: 8px 4px;
    text-align: center;
    font-size: 14px;
    word-wrap: break-word;
}

#historyTable th:first-child,
#historyTable td:first-child,
#totalTable th:first-child,
#totalTable td:first-child {
    width: 28%;
    font-size: 13px;
}

/* 上の円グラフ（PFCバランス）用の枠 */
.chart-container {
    position: relative;
    width: 95%;
    max-width: 450px;
    height: 320px;
    margin: 20px auto;
}

/* 上の円グラフだけに100%を適用する */
.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 下の2つのグラフが震えないように、スマホ特有のハイライトを消す */
#weeklyChart, #twoMonthChart {
    -webkit-tap-highlight-color: transparent;
}

/* タブボタン */
.input-tabs button {
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    border: 1px solid #4CAF50;
    background-color: white;
    color: #4CAF50;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.input-tabs button.active-tab {
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
}

.food-name {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== 表のPFC色分け（背景のみ・文字は黒） ===== */
#totalTable th:nth-child(2), #totalTable td:nth-child(2),
#historyTable th:nth-child(2), #historyTable td:nth-child(2) {
    background-color: rgba(255, 99, 132, 0.15); 
}

#totalTable th:nth-child(3), #totalTable td:nth-child(3),
#historyTable th:nth-child(3), #historyTable td:nth-child(3) {
    background-color: rgba(255, 206, 86, 0.2); 
}

#totalTable th:nth-child(4), #totalTable td:nth-child(4),
#historyTable th:nth-child(4), #historyTable td:nth-child(4) {
    background-color: rgba(54, 162, 235, 0.15); 
}

#logoutBtn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#logoutBtn:hover {
    background-color: #d32f2f;
}

button[onclick="editProfile()"] {
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
}

.input-area input[type="text"],
.input-area input[type="number"],
.input-area select {
    font-size: 16px !important;
    padding: 10px !important;
    box-sizing: border-box;
}

#aiStatus {
    font-size: 14px;
    margin-top: 10px;
}

h2 {
    margin-top: 30px;
    margin-bottom: 5px;
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    display: block;
    text-align: left;
    padding-bottom: 3px;
}

.input-area {
    margin-bottom: 20px !important;
}

#weeklyChart {
    margin-top: 10px !important;
    margin-bottom: 30px !important;
}

/* ▼▼ IDを dinnerDrawer から menuDrawer に変更 ▼▼ */
#menuDrawer {
    position: fixed;
    top: 0;
    left: 0;
    width: calc(100vw - 75px);
    max-width: 340px;
    height: auto;
    max-height: 85vh;
    background-color: white;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    border-radius: 0 0 12px 0;
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
    display: flex;
}

.drawer-closed {
    transform: translateX(-105%); /* 影が見えないように少し多めにずらす */
    box-shadow: none; /* 閉じた時は影を消す */
}

.drawer-open {
    transform: translateX(0);
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2); /* 開いた時に影をつける */
}

#drawerTab {
    position: absolute;
    right: -50px;  /* ← 75px から 50px に変更（枠の幅と合わせる） */
    top: 0;
    width: 50px;   /* ← 75px から 50px に変更（枠の幅） */
    background-color: #ff9800;
    color: white;
    font-weight: bold;
    font-size: 14px;
    padding: 8px 0;
    border-radius: 0 0 10px 0;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    text-align: center;
    line-height: 1.4;
}

#drawerContent {
    width: 100%;
    padding: 15px;
    overflow-y: auto;
}

.suggest-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background-color: #fafafa;
    text-align: left;
}
.suggest-card h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
}
.suggest-card p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #555;
}

/* サブタブの共通スタイル */
.input-tabs button {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #4CAF50;
    background-color: white;
    color: #4CAF50;
    border-radius: 20px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.input-tabs button.active-tab {
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
}

/* セッション用モーダルのスクロール調整 */
#sessionEditor .workout-card {
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

#exDetailSettingsArea {
    text-align: center;
}
#exDetailSettingsArea > div {
    display: flex;
    flex-direction: column;
    align-items: center;
}
#exDetailSettingsArea .flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

#aiSummarySection {
    display: flex;
    flex-direction: column; /* ★横並びから縦並びに変更 */
    align-items: center;    /* ★中央揃えに変更 */
    margin: 30px 0 40px 0;
    padding: 0 10px;
    gap: 15px;
}

.ai-avatar {
    flex-shrink: 0;
    width: 100px;  /* ★変更 */
    height: 100px; /* ★変更 */
    border-radius: 50%;
    background-color: #e3f2fd;
    border: 3px solid #2196F3;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(33, 150, 243, 0.3);
}

.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-bubble {
    position: relative;
    background: #e3f2fd;
    border: 2px solid #2196F3;
    border-radius: 16px;
    padding: 20px;
    width: 100%; /* ★追加：横幅いっぱいに広げる */
    box-sizing: border-box; /* ★追加：はみ出し防止 */
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    text-align: left;
}

/* 吹き出しの尻尾（枠線用） */
.ai-bubble::before {
    content: "";
    position: absolute;
    top: -14px;              /* ★左から上に移動 */
    left: calc(50% - 12px);  /* ★中央に配置 */
    border-width: 0 12px 14px 12px; /* ★上向きの三角形に変更 */
    border-style: solid;
    border-color: transparent transparent #2196F3 transparent; /* ★色の向きを変更 */
}

/* ⑤ 吹き出しの尻尾（内側の色用）を「左」から「上」に変更 */
.ai-bubble::after {
    content: "";
    position: absolute;
    top: -10px;             /* ★左から上に移動 */
    left: calc(50% - 9px);  /* ★中央に配置 */
    border-width: 0 9px 11px 9px; /* ★上向きの三角形に変更 */
    border-style: solid;
    border-color: transparent transparent #e3f2fd transparent; /* ★色の向きを変更 */
}

.ai-bubble-title {
    font-size: 16px;
    font-weight: bold;
    color: #1565C0;
    margin-bottom: 12px;
    border-bottom: 1px dashed #90caf9;
    padding-bottom: 8px;
}

.ai-bubble-text {
    font-size: 15px;
    color: #333;
    line-height: 1.6;
    margin-bottom: 18px;
    min-height: 60px; /* 文字が無くても高さを維持 */
    font-weight: bold;
}

.ai-generate-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
    transition: all 0.2s ease;
}

.ai-generate-btn:active {
    background-color: #1976D2;
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.4);
}

.ai-generate-btn:disabled {
    background-color: #90caf9;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}