/* ---------- 상단 AI 상담 버튼 ---------- */
.top-actions { display: flex; align-items: center; gap: 14px; }
.chat-open {
  background: linear-gradient(135deg, var(--brand), #23a07a); color: #fff; font-weight: 800;
  padding: 9px 16px; border-radius: 99px; box-shadow: 0 4px 14px rgba(47, 143, 78, .3);
}
.chat-open:hover { filter: brightness(1.06); }

/* ---------- AI 상담 패널 ---------- */
.chat-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 10, .25); z-index: 90; }
.chat {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 100;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0, 0, 0, .15);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease;
}
.chat.show { transform: none; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: relative; }
.chat-head small { display: block; color: var(--muted); font-size: .74rem; }
.chat-head .close { position: static; margin-left: auto; flex-shrink: 0; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-2); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: .9rem; line-height: 1.55; background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--brand); color: #fff; border: 0; border-radius: 16px; border-top-right-radius: 4px; }
.msg .acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.msg .acts button { background: var(--brand-2); color: var(--brand); font-weight: 700; }
.typing .bubble { display: flex; gap: 4px; padding: 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .3; transform: none; } 50% { opacity: 1; transform: translateY(-3px); } }
.chat-chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 0; scrollbar-width: none; }
.chat-chips button { white-space: nowrap; background: var(--surface-2); font-size: .8rem; padding: 6px 11px; border-radius: 99px; flex-shrink: 0; }
.chat-chips button:hover { background: var(--brand-2); color: var(--brand); }
.chat-form { display: flex; gap: 8px; padding: 12px 16px 16px; }
.chat-form input { flex: 1; border-radius: 99px; padding: 11px 16px; }
.chat-form button { border-radius: 50%; width: 44px; height: 44px; padding: 0; flex-shrink: 0; }

/* ---------- 마이페이지 ---------- */
.mypage { grid-column: 1 / -1; }
.my-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.my-col { display: flex; flex-direction: column; gap: 20px; }
.my-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.my-card h2 { font-size: 1.05rem; margin: 0; }
.my-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.my-card .sub { color: var(--muted); font-size: .85rem; margin: 0 0 14px; }
.my-card-head .sub { margin: 0; }
.mode-badge { font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.mode-badge.on { background: var(--brand-2); color: var(--brand); }

.my-profile { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, var(--brand-2), var(--surface)); }
.avatar { width: 72px; height: 72px; border-radius: 50%; font-size: 2.4rem; background: var(--surface); box-shadow: var(--shadow); flex-shrink: 0; padding: 0; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.who input { font-size: 1.2rem; font-weight: 800; border: 1px solid transparent; background: transparent; padding: 2px 6px; margin-left: -6px; width: 100%; }
.who input:hover, .who input:focus { border-color: var(--line); background: var(--surface); }
.goal-line { font-size: .84rem; color: var(--muted); }
.goal-line a { color: var(--brand); font-weight: 700; margin-left: 4px; }
.my-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.my-badges span { font-size: .76rem; font-weight: 700; background: var(--surface); border: 1px solid var(--line); padding: 3px 9px; border-radius: 99px; }

.today-wrap { display: flex; gap: 20px; align-items: center; }
.ring {
  --p: 0; width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0);
  display: flex; align-items: center; justify-content: center;
}
.ring.over { background: conic-gradient(var(--danger) 100%, var(--surface-2) 0); }
.ring > div { width: 118px; height: 118px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring b { font-size: 1.6rem; line-height: 1.1; }
.ring small { color: var(--muted); font-size: .74rem; }
.ring em { font-style: normal; font-size: .76rem; font-weight: 800; color: var(--brand); margin-top: 2px; }
.ring.over em { color: var(--danger); }
.nut-rows { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.nut-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 8px; align-items: center; font-size: .84rem; }
.nut-row b { font-size: .86rem; white-space: nowrap; }
.nut-row b small { color: var(--muted); font-weight: 500; }
.bar.c .bar-fill { background: #f2a33a; }
.bar.f .bar-fill { background: #9b7bd6; }
.bar.s .bar-fill { background: #7a8b99; }
.bar.p .bar-fill { background: #3b82c4; }
.coach { margin: 14px 0 0; font-size: .86rem; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }

.week { margin-bottom: 4px; }
.wplot { position: relative; height: 140px; display: flex; align-items: flex-end; gap: 8px; margin-top: 18px; }
.wcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.wlabels { display: flex; gap: 8px; margin-top: 6px; }
.wlabels small { flex: 1; text-align: center; font-size: .74rem; color: var(--muted); }
.wbar { width: 100%; max-width: 38px; background: var(--brand); border-radius: 8px 8px 3px 3px; position: relative; transition: height .5s; opacity: .8; }
.wbar.today { opacity: 1; box-shadow: 0 0 0 2px var(--brand-2); }
.wbar.over { background: var(--accent); }
.wbar.none { background: var(--line); }
.wbar span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .68rem; font-weight: 700; white-space: nowrap; margin-bottom: 2px; }
.wplot .target-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--danger); opacity: .6; pointer-events: none; z-index: 1; }
.wplot .target-line span { position: absolute; right: 0; top: -17px; font-size: .68rem; color: var(--danger); font-weight: 700; }
#mySampleWeek { margin-top: 10px; }

.my-upload .pick-btns { margin-top: 4px; }
.food-analyzing { position: relative; max-width: 320px; margin: 0 auto; border-radius: 16px; overflow: hidden; }
.food-analyzing img { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.food-scan { position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(47, 200, 120, .45) 50%, transparent 60%); background-size: 100% 200%; animation: foodScan 1.2s linear infinite; }
@keyframes foodScan { from { background-position: 0 100%; } to { background-position: 0 -100%; } }

.fr-top { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.fr-top img { width: 96px; height: 96px; object-fit: cover; border-radius: 14px; flex-shrink: 0; }
.fr-top h3 { font-size: 1.35rem; margin: 4px 0 2px; }
.fr-top small { color: var(--muted); font-size: .82rem; }
.fr-badge { font-size: .72rem; font-weight: 800; background: var(--brand-2); color: var(--brand); padding: 2px 8px; border-radius: 99px; }
.fr-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: .86rem; }
.fr-row > span { width: 34px; color: var(--muted); flex-shrink: 0; }
.seg-group { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg-group button { background: transparent; padding: 5px 11px; font-size: .84rem; border-radius: 8px; }
.seg-group button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 800; color: var(--brand); }
.fr-nut { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 6px; margin: 14px 0 10px; }
.fr-nut > div { background: var(--surface-2); border-radius: 12px; padding: 10px 6px; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.fr-nut b { font-size: .98rem; }
.fr-nut small { font-size: .7rem; color: var(--muted); }
.fr-nut .big { background: var(--brand); color: #fff; }
.fr-nut .big b { font-size: 1.5rem; line-height: 1.1; }
.fr-nut .big small { color: rgba(255, 255, 255, .85); }
.fr-goal { font-size: .85rem; margin-bottom: 8px; }
.fr-goal .bar { margin-top: 5px; }
.fr-comment, .fr-warn, .fr-note { font-size: .82rem; border-radius: 10px; padding: 8px 11px; margin: 8px 0; }
.fr-comment { background: var(--surface-2); }
.fr-warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.fr-note { color: var(--muted); padding: 0; }
.fr-alt { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: .82rem; }
.fr-alt > span { color: var(--muted); }
.fr-alt input { width: 170px; padding: 6px 10px; font-size: .82rem; }
.fr-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

.my-meals { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.my-meals li { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 14px; padding: 8px 10px; }
.my-meals img, .my-meals .em { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.my-meals .em { background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 1.7rem; }
.my-meals li > div { flex: 1; min-width: 0; }
.my-meals small { display: block; color: var(--muted); font-size: .76rem; }
.my-meals .kc { font-weight: 800; text-align: right; white-space: nowrap; font-size: .9rem; }
.my-meals .del { background: none; color: var(--muted); padding: 4px 6px; }
.my-meals .del:hover { color: var(--danger); }
.my-meals .empty-meal { justify-content: center; color: var(--muted); font-size: .88rem; padding: 18px; background: transparent; border: 1px dashed var(--line); }

@media (max-width: 960px) { .my-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  .chat-open { padding: 8px 12px; font-size: .85rem; }
  .today-wrap { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; }
  .fr-nut { grid-template-columns: repeat(3, 1fr); }
  .fr-nut .big { grid-column: span 3; }
  .my-card { padding: 16px; }
  .fr-alt input { width: 100%; }
}
