/* 하루식단 — 공통 스타일 (사용자 앱 + 관리자) */
:root {
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;

  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-2: #f0f3ee;
  --ink: #1b2620;
  --muted: #66746b;
  --line: #e2e8e0;
  --brand: #2a9d6a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f4ec;
  --brand-deep: #1d7a51;
  --carb: #f0a43a;
  --protein: #4a88f0;
  --fat: #e4674f;
  --water: #4db6e8;
  --danger: #d64545;
  --danger-soft: #fdeaea;
  --warn-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 16px rgba(20, 40, 30, .06);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101512; --surface: #182019; --surface-2: #1f2a22; --ink: #e8efe9; --muted: #90a096;
    --line: #2a372d; --brand: #3dbb85; --brand-ink: #08130d; --brand-soft: #1c3528; --brand-deep: #62d3a0;
    --danger-soft: #3a1d1d; --warn-soft: #3a3016; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -.02em; }
h2 { font-size: 17px; letter-spacing: -.01em; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ───────── 앱 셸: 모바일(하단 탭) → 태블릿(좌측 레일) → 데스크톱(사이드바) ───────── */
.app { min-height: 100dvh; }
.main { padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 720px; margin: 0 auto; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-item {
  -webkit-touch-callout: none; user-select: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; background: none; border: 0;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item[aria-current="page"] { color: var(--brand-deep); }
.nav-fab { position: relative; }
.nav-fab .fab {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(42, 157, 106, .45);
}
.nav-fab .fab svg { width: 28px; height: 28px; }
.nav-fab span.lbl { margin-top: 30px; }
.nav-foot { display: none; }

@media (min-width: 768px) {
  .app { display: grid; grid-template-columns: 76px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100dvh; width: 76px; grid-template-columns: 1fr; align-content: start;
    grid-auto-rows: 64px; padding: 12px 0; border-top: 0; border-right: 1px solid var(--line); gap: 4px;
  }
  .nav-brand { display: grid; place-items: center; height: 48px; margin-bottom: 8px; color: var(--brand-deep); }
  .nav-brand svg { width: 30px; height: 30px; }
  .nav-brand span { display: none; }
  .nav-fab .fab { position: static; transform: none; width: 44px; height: 44px; box-shadow: none; margin-bottom: 2px; }
  .nav-fab .fab svg { width: 24px; height: 24px; }
  .nav-fab span.lbl { margin-top: 0; }
  .nav-foot { display: none; }
  .main { padding: 24px 28px 40px; max-width: 980px; }
}
@media (min-width: 1200px) {
  .app { grid-template-columns: 248px 1fr; }
  .nav { width: 248px; padding: 20px 14px; grid-auto-rows: 48px; }
  .nav-brand { display: flex; justify-content: flex-start; gap: 10px; padding: 0 10px; font-weight: 800; font-size: 19px; height: 52px; margin-bottom: 10px; color: var(--ink); }
  .nav-brand svg { color: var(--brand); }
  .nav-brand span { display: inline; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 12px; font-size: 15px; }
  .nav-item:hover { background: var(--surface-2); }
  .nav-item[aria-current="page"] { background: var(--brand-soft); }
  .nav-fab .fab { width: 32px; height: 32px; margin: 0; }
  .nav-fab .fab svg { width: 20px; height: 20px; }
  .nav-fab { background: var(--brand); color: var(--brand-ink); }
  .nav-fab:hover { background: var(--brand-deep) !important; }
  .nav-fab .fab { background: transparent; }
  .nav-fab[aria-current="page"] { background: var(--brand); }
  .main { max-width: 1120px; padding: 32px 40px 56px; }
}

/* 페이지 헤더 */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.date-nav { display: flex; align-items: center; gap: 4px; }
.date-nav .label { min-width: 120px; text-align: center; font-weight: 700; font-size: 17px; }

/* ───────── 컴포넌트 ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.ic { width: 18px; height: 18px; flex: none; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-deep); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 90px; resize: vertical; }
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
input[type="date"].input { min-height: 46px; appearance: none; -webkit-appearance: none; text-align: left; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
.input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px;
}
.chip[aria-pressed="true"], .chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; min-height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--brand-soft); color: var(--brand-deep); }
.badge.warn { background: var(--warn-soft); color: #9a6a00; }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); font-size: 13px; }
.notice.info { background: var(--brand-soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* 리스트 */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; }
.list .sub { font-size: 13px; color: var(--muted); }
.list .kcal { font-weight: 700; white-space: nowrap; }
.list button.row-btn { all: unset; display: flex; flex: 1; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }

/* 요약 링 + 영양소 바 */
.ring-wrap { display: grid; grid-template-columns: 148px 1fr; gap: 16px; align-items: center; }
.ring { position: relative; width: 148px; height: 148px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 13; stroke-linecap: round; }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--brand); transition: stroke-dashoffset .5s ease; }
.ring.over .bar { stroke: var(--danger); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .center b { font-size: 28px; line-height: 1.1; letter-spacing: -.02em; }
.ring .center span { font-size: 12px; color: var(--muted); }
.macro { margin-bottom: 10px; }
.macro:last-child { margin-bottom: 0; }
.macro .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.macro .top b { font-weight: 700; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

/* 홈 레이아웃: 모바일 1열 → 데스크톱 2열(기록 | 요약·코치 고정) */
.home-grid { display: grid; gap: 14px; }
/* 모바일: 요약 → 코치 → 끼니 → 수분·체중 순. 데스크톱: 왼쪽 끼니 / 오른쪽 고정 패널 */
.home-side { display: contents; }
.home-side > :nth-child(1) { order: 0; }
.home-side > :nth-child(2) { order: 1; }
.home-grid > .stack { order: 2; }
.home-side > :nth-child(3) { order: 3; }
@media (min-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 20px; }
  .home-side { display: grid; gap: 14px; align-content: start; position: sticky; top: 24px; order: 1; }
  .home-grid > .stack { order: 0; }
  .home-side .ring-wrap { grid-template-columns: 1fr; justify-items: center; }
  .home-side .ring-wrap > div:last-child { width: 100%; }
  .home-side .quick { grid-template-columns: 1fr; }
}
.meal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.meal-head h2 { display: flex; align-items: center; gap: 8px; }
.meal-head .tot { font-weight: 700; color: var(--muted); font-size: 14px; }

.coach-card { background: linear-gradient(135deg, var(--brand-soft), var(--surface)); }
.coach-card .msg { white-space: pre-line; font-size: 15px; }
.coach-card .who { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--brand-deep); margin-bottom: 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.avatar svg { width: 16px; height: 16px; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick .tile { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.quick .tile .v { font-size: 20px; font-weight: 800; }
.quick .tile .row { gap: 6px; flex-wrap: wrap; }
.quick .btn.sm { padding: 0 10px; }

/* 바텀시트 / 모달 */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(10, 20, 14, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); animation: up .2s; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -8px auto 14px; }
@media (min-width: 768px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; max-height: 88dvh; padding-bottom: 20px; }
  .sheet .grab { display: none; }
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 20px; font-weight: 700; line-height: 1; }
.stepper input { width: 70px; text-align: center; font-weight: 800; font-size: 20px; border: 0; background: transparent; }

.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 80; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 768px) { .toast-host { bottom: 24px; } }
.toast { background: #1b2620; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: up .2s; max-width: 420px; }
.toast.error { background: var(--danger); }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; height: 18px; }
@keyframes sk { to { background-position: -200% 0; } }

/* 기록 추가 */
.add-tabs { margin: 4px 0 14px; }
.photo-drop { display: grid; place-items: center; gap: 8px; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.photo-drop:hover { border-color: var(--brand); }
.photo-drop svg { width: 38px; height: 38px; color: var(--brand); }
.photo-preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.photo-preview { display: grid; place-items: center; min-height: 120px; }
.photo-stage { position: relative; max-width: 100%; }
.photo-preview img { display: block; max-width: 100%; max-height: 300px; width: auto; height: auto; }
@media (max-width: 999px) { .photo-preview img { max-height: 42vh; } } /* 모바일: 결과(칼로리)가 사진 아래에서 바로 보이게 */
.photo-tags { position: absolute; inset: 0; pointer-events: none; }
.photo-tag { position: absolute; transform: translate(-50%, -50%); max-width: 46%; padding: 3px 9px 3px 20px; border-radius: 999px; background: rgba(255,255,255,.92); color: #111; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.photo-tag::before { content: ""; position: absolute; left: 7px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--brand); }
.photo-preview .busy { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; display: grid; place-content: center; justify-items: center; gap: 10px; }
.basket { scroll-margin-top: 12px; }
.basket-bar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 16px; background: var(--ink); color: var(--bg); border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 700; }
.basket-bar .btn { min-height: 38px; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
@media (min-width: 768px) { .basket-bar { left: auto; right: 24px; bottom: 20px; width: 360px; } }
@media (min-width: 1000px) { .basket-bar { display: none; } }
.conf { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.conf.hi { background: var(--brand-soft); color: var(--brand-deep); }
.conf.mid { background: var(--warn-soft); color: #9a6a00; }
.conf.lo { background: var(--danger-soft); color: var(--danger); }
.add-layout { display: grid; gap: 14px; }
@media (min-width: 1000px) { .add-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } .add-layout .basket { position: sticky; top: 24px; } }

/* 통계 / 차트 */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile-stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.tile-stat .l { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.stats-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .stats-grid { grid-template-columns: 1fr 1fr; } .stats-grid .wide { grid-column: 1 / -1; } }

/* 코치 채팅 */
.chat { display: grid; gap: 10px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-line; }
.bubble.me { justify-self: end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.bubble.coach { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); display: flex; gap: 8px; background: var(--bg); padding-top: 8px; }
@media (min-width: 768px) { .chat-input { bottom: 12px; } }
.coach-layout { display: grid; gap: 14px; }
@media (min-width: 1000px) { .coach-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }

/* 인증 화면 */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 26px; margin-bottom: 6px; }
.auth-logo svg { width: 34px; height: 34px; color: var(--brand); }

/* 온보딩 */
.wizard { max-width: 520px; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i { flex: 1; height: 5px; border-radius: 5px; background: var(--line); }
.steps i.on { background: var(--brand); }
.choice { display: grid; gap: 10px; }
.choice button { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.choice button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.choice b { display: block; }
.choice span { font-size: 13px; color: var(--muted); }
.result-big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; color: var(--brand-deep); }

/* ───────── 관리자 ───────── */
.admin-main { max-width: 1240px; }
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.tbl td.wrap { white-space: normal; min-width: 220px; }
table.tbl th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.r, table.tbl th.r { text-align: right; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.photo-grid .ph { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.photo-grid .meta { padding: 10px; font-size: 12px; display: grid; gap: 4px; }
.pager-u { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.pager-u .btn { min-width: 84px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { max-width: 280px; min-height: 40px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.switch:first-of-type { border-top: 0; }
.switch input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .ring-wrap { grid-template-columns: 124px 1fr; gap: 12px; }
  .ring { width: 124px; height: 124px; }
  .ring .center b { font-size: 23px; }
  .tiles { grid-template-columns: 1fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 관리자 상단바 */
.admin-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.admin-bar .inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px 0; }
.admin-bar .top { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding-bottom: 8px; }
.admin-bar .top svg { width: 24px; height: 24px; color: var(--brand); }
.admin-bar nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.admin-bar nav a { display: flex; align-items: center; gap: 6px; padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.admin-bar nav a svg { width: 18px; height: 18px; }
.admin-bar nav a[aria-current="page"] { color: var(--brand-deep); border-bottom-color: var(--brand); }
.admin-wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
@media (min-width: 768px) { .admin-wrap { padding: 28px 28px 56px; } .admin-bar .inner { padding: 12px 28px 0; } }

/* ═══════════ v2 — 정렬 보정 + 2026 트렌드 마감 (색상 토큰은 그대로) ═══════════ */
:root {
  --radius: 20px; --radius-sm: 14px; --ease: cubic-bezier(.22, .8, .24, 1);
  --brand-grad: linear-gradient(135deg, #36b47d 0%, #2a9d6a 100%);
}
/* 빈 화면에서 본문이 내용 폭으로 쪼그라드는 버그 수정: grid item + margin:auto 는 shrink-wrap 된다 */
.main { width: 100%; min-width: 0; }
.main > * { animation: rise .32s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

h1 { font-size: 24px; letter-spacing: -.028em; }
h2 { font-size: 18px; letter-spacing: -.018em; }
.page-head { margin-bottom: 18px; gap: 12px; }
.stack-sm { display: grid; gap: 8px; justify-items: start; }

/* 카드 · 버튼 */
.card { border-radius: var(--radius); padding: 18px; }
.btn { border-radius: 14px; font-weight: 650; transition: transform .12s var(--ease), background-color .15s, border-color .15s, box-shadow .15s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand-grad); border-color: transparent; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 28%, transparent); }
.btn.primary:hover { background: var(--brand-grad); filter: brightness(.94); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-deep); box-shadow: none; }
.btn.soft:hover { background: color-mix(in srgb, var(--brand-soft) 78%, var(--brand) 22%); }
.btn.sm { border-radius: 12px; }
.icon-btn { border-radius: 50%; }

/* 입력: 채움형 + 포커스 링 */
.input { background-color: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.input:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
.input:focus { outline: none; background-color: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 40px; background-repeat: no-repeat; background-position: right 14px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2366746b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
/* 날짜 입력: 어디를 눌러도 달력이 열린다 */
input[type="date"].input { position: relative; padding-right: 46px; background-repeat: no-repeat; background-position: right 14px center; min-height: 46px; text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2366746b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E"); }
input[type="date"].input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.datebtn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, transform .12s var(--ease); white-space: nowrap; }
.datebtn .ic { color: var(--brand-deep); }
.datebtn:hover { border-color: var(--brand); }
.datebtn:active { transform: scale(.98); }
.datebtn:focus-within { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.datebtn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; font-size: 16px; z-index: 1; }
.datebtn input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.date-nav { gap: 8px; justify-content: center; }
.date-nav .icon-btn { background: var(--surface); border: 1px solid var(--line); }
.date-nav .icon-btn[disabled] { opacity: .35; }

/* 세그먼트 · 칩 */
.seg { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { border-radius: 11px; min-height: 38px; transition: background-color .15s, color .15s; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chip { transition: background-color .15s, border-color .15s, color .15s, transform .12s var(--ease); }
.chip:active { transform: scale(.96); }

/* 하단 탭바: 모바일은 떠 있는 유리 알약형 */
@media (max-width: 767px) {
  :root { --nav-h: 80px; }
  .nav { left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); height: 66px; padding: 0 6px; border: 1px solid var(--line); border-radius: 28px;
    background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5); box-shadow: 0 14px 34px rgba(8, 18, 12, .2); }
  .nav-fab .fab { top: -20px; box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-grad); }
  .main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 28px); }
}
@media (min-width: 768px) { .nav-fab .fab { background: var(--brand-grad); } }

/* 끼니 카드 · 목록 · 빈 상태 */
.meal-head { gap: 12px; margin-bottom: 4px; }
.meal-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.meal-title h2 { display: block; }
.meal-title .tot { font-size: 14px; font-weight: 700; color: var(--muted); }
.meal-empty { color: var(--muted); font-size: 14px; padding: 8px 0 2px; }
.list > li { padding: 14px 0; }
.empty { padding: 36px 16px; }
.empty-ico { width: 60px; height: 60px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; margin: 0 auto 12px; }
.empty-ico .ic { width: 26px; height: 26px; }
.skeleton-page { display: grid; gap: 14px; }
.skeleton { border-radius: 16px; }

/* 차트: 실제 px 로 그려서 글자 크기가 일정 */
.chart-box { width: 100%; min-height: 200px; }
.chart { display: block; max-width: 100%; }
.chart text { font-size: 12px; font-weight: 500; }
.chart .grid-line { stroke-dasharray: 2 4; }

/* 관리자 */
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.table-wrap { border-radius: var(--radius); box-shadow: var(--shadow); }
table.tbl tbody tr { transition: background-color .12s; }
table.tbl tbody tr:hover td { background: var(--surface-2); }
.toolbar select.input { min-height: 40px; max-width: 200px; }
.tile-stat { border-radius: 16px; }
.photo-grid .ph { border-radius: 16px; }
@media (hover: hover) { .card { transition: box-shadow .2s var(--ease), transform .2s var(--ease); } }

/* v2 보정 */
.page-head.top { align-items: flex-start; }
@media (min-width: 1200px) {
  .nav-fab { background: var(--brand-grad); }
  .nav-fab .fab { background: transparent; box-shadow: none; }
}
.quick .meter { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.quick .tile { border-radius: 16px; }

/* 로고 링크 */
.brand-link { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; border-radius: 10px; }
.brand-link:hover { color: var(--brand-deep); }
a.nav-brand { text-decoration: none; color: var(--brand-deep); cursor: pointer; }
@media (min-width: 1200px) { a.nav-brand { color: var(--ink); } a.nav-brand:hover { background: var(--surface-2); } }

/* 내비 "기록": 항상 칠해진 버튼이 아니라 다른 메뉴와 같은 규칙(현재 화면일 때만 강조) + 작은 + 아이콘 */
.nav-fab .fab { color: #fff; }
@media (min-width: 768px) {
  .nav-fab { background: transparent !important; color: var(--muted); }
  .nav-fab:hover { background: var(--surface-2) !important; }
  .nav-fab .fab { width: 30px; height: 30px; margin: 0 0 2px; background: var(--brand-grad); box-shadow: none; }
  .nav-fab .fab svg { width: 16px; height: 16px; }
  .nav-fab[aria-current="page"] { color: var(--brand-deep); }
}
@media (min-width: 1200px) {
  .nav-fab .fab { margin: 0; }
  .nav-fab[aria-current="page"] { background: var(--brand-soft) !important; }
}

/* 촬영 시작 · 결과 카드 */
.scan-modes { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; margin-bottom: 12px; }
.scan-modes button { padding: 0 6px; }
.scan-start { text-align: center; padding: 22px 16px; }
.scan-ico { width: 64px; height: 64px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); }
.scan-ico svg { width: 30px; height: 30px; }
.btn.lg { min-height: 52px; font-size: 16px; }
.btn svg.ic { width: 16px; height: 16px; margin-right: 6px; }
.res-title { font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.serv-val { min-width: 44px; text-align: center; font-weight: 800; font-size: 18px; }
.serv-val small { font-size: 11px; font-weight: 600; margin-left: 2px; color: var(--muted); }
.kcal-big { display: grid; justify-items: start; margin: 12px 0 10px; padding: 14px 16px; border-radius: 16px; background: var(--brand-soft); }
.kcal-big b { font-size: 38px; line-height: 1.1; color: var(--brand-deep); }
.kcal-big b small { font-size: 15px; margin-left: 3px; font-weight: 700; }
.mchips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mchip { display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); font-size: 12px; }
.mchip span { color: var(--muted); }
.mchip b { font-size: 16px; }
.mchip.c { border-left: 4px solid #e9a23b; } .mchip.p { border-left: 4px solid #4b86d9; } .mchip.f { border-left: 4px solid #d96a5b; }
.dish-li { align-items: flex-start; }
.ing-list { list-style: none; margin: 6px 0 0; padding: 0 0 0 10px; border-left: 2px solid var(--line); display: grid; gap: 3px; font-size: 12.5px; }
.ing-list li { display: flex; justify-content: space-between; gap: 10px; }

/* 전체 화면 카메라 */
body.cam-open { overflow: hidden; }
.cam { position: fixed; inset: 0; z-index: 200; background: #000; color: #fff; display: grid; overflow: hidden; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam.nocam .cam-video, .cam.nocam .cam-frame { display: none; }
.cam-frame { position: absolute; left: 50%; top: 46%; width: min(86vw, 520px); height: min(56vh, 520px); transform: translate(-50%, -50%); border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); border: 2px solid rgba(255,255,255,.85); pointer-events: none; }
.cam[data-mode="barcode"] .cam-frame { height: min(24vh, 200px); }
.cam[data-mode="label"] .cam-frame { border-radius: 10px; }
.cam-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) 14px 0; }
.cam-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; }
.cam-btn[hidden] { display: none; }
.cam-btn[aria-pressed="true"] { background: #ffd54a; color: #111; }
.cam-btn svg { width: 22px; height: 22px; }
.cam-hint { position: absolute; left: 0; right: 0; top: calc(max(14px, env(safe-area-inset-top)) + 54px); margin: 0; text-align: center; font-size: 14px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.7); padding: 0 16px; }
.cam-msg { position: absolute; left: 16px; right: 16px; bottom: 210px; text-align: center; font-size: 14px; display: grid; gap: 10px; justify-items: center; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.cam.nocam .cam-msg { bottom: auto; top: 38%; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 12px calc(14px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 14px; background: linear-gradient(transparent, rgba(0,0,0,.6) 40%); }
.cam-shutter { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 0; display: grid; place-items: center; }
.cam-shutter span { width: 54px; height: 54px; border-radius: 50%; background: #fff; transition: transform .1s; }
.cam-shutter:active span { transform: scale(.88); }
.cam-shutter[hidden], .cam-manual[hidden] { display: none; }
.cam-manual { display: flex; gap: 8px; width: min(100%, 420px); }
.cam-manual .input { flex: 1; }
.cam-tabs { display: flex; gap: 6px; max-width: 100%; overflow-x: auto; }
.cam-tab { border: 0; border-radius: 999px; padding: 8px 14px; background: rgba(255,255,255,.16); color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; }
.cam-tab[aria-selected="true"] { background: #fff; color: #111; }
