/* 식사장부 — shadcn 스타일 토큰 + 컴팩트 카드 + 폰트 3단계(요구 1·4·5) */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #16a34a;
  --primary-fg: #ffffff;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --fs: 16px; /* 기본 폰트 스케일 */
  --gap: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #131c2e; --fg: #e5e9f0; --muted: #94a3b8; --border: #24314a;
  }
}
/* 폰트 3단계 (요구 5) */
html[data-font="large"] { --fs: 19px; }
html[data-font="xlarge"] { --fs: 22px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  padding-bottom: 72px; /* tabbar 공간 */
  -webkit-text-size-adjust: 100%;
}

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; flex: 1; text-align: center; }
.brand { font-weight: 700; color: var(--primary); }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 1px solid var(--border); background: var(--card);
  border-radius: 10px; font-size: 1em; color: var(--fg);
}
.icon-btn sup { font-size: 0.6em; }

.content { max-width: 560px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: var(--gap); }

/* 컴팩트 카드(요구 1: 넓이/높이 과대 금지) */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
}
.card-title { margin: 0 0 8px; font-size: 0.92em; font-weight: 600; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.stat-label { font-size: 0.8em; color: var(--muted); }
.stat-value { font-size: 1.5em; font-weight: 700; margin-top: 2px; }
.stat-sub { font-size: 0.75em; color: var(--danger); }

.greet { font-size: 1.15em; font-weight: 600; padding: 4px 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.82em; }
.center { text-align: center; }

/* 리스트 */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 2px; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.list-row span { color: var(--muted); font-size: 0.85em; }
.list-row b { font-weight: 600; }
.list-row .rt-time { min-width: 44px; }
.list-row .btn { margin-left: auto; }

/* KV */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.kv li:first-child { border-top: 0; }
.kv span { color: var(--muted); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--fg); font-weight: 600; font-size: 1em; cursor: pointer;
  text-decoration: none; width: 100%; margin-top: 8px;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-lg { min-height: 50px; }
.btn-xl { min-height: 64px; font-size: 1.2em; }
.btn-xs { min-height: 32px; width: auto; padding: 0 10px; font-size: 0.8em; margin: 0; }
.danger { color: var(--danger); }
.btn-primary.danger { color: #fff; background: var(--danger); }

/* 폼 */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field span { font-size: 0.85em; color: var(--muted); }
.field input, .field select {
  min-height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--fg); font-size: 1em;
}
.alert { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 10px; border-radius: 10px; font-size: 0.9em; }
.link { display: block; text-align: center; color: var(--primary); margin-top: 12px; }
.auth-card { max-width: 400px; margin: 24px auto; }
.auth-h1 { margin: 0 0 4px; font-size: 1.4em; }

/* 세그먼트(폰트 선택) */
.seg { display: flex; gap: 8px; }
.seg-btn { flex: 1; min-height: 46px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--fg); font-weight: 600; }
.seg-btn.on { background: var(--primary); color: #fff; border-color: transparent; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick .btn { margin-top: 0; }

/* 인증 게이트/완료 */
.gate-card, .done-card { text-align: center; padding: 22px 16px; }
.gate-store { font-size: 1.3em; font-weight: 700; }
.gate-name { color: var(--muted); margin-top: 4px; }
.gate-remain { margin-top: 8px; font-weight: 600; color: var(--primary); }
.done-check { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 2em; line-height: 64px; }
.done-title { font-size: 1.2em; font-weight: 700; margin-bottom: 12px; }

/* 하단 탭바(요구 4) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; color: var(--muted); text-decoration: none; font-size: 0.72em; }
.tab.on { color: var(--primary); }
.tab-icon { font-size: 1.3em; }

/* 햄버거 사이드 드로어(요구 4) */
.drawer { position: fixed; inset: 0; z-index: 40; display: none; }
.drawer.open { display: block; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }
.drawer-panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 76%; max-width: 300px;
  background: var(--card); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 4px;
  transform: translateX(-100%); transition: transform 0.2s ease;
}
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head { font-weight: 700; padding: 8px 8px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.drawer-link { padding: 12px 8px; border-radius: 8px; color: var(--fg); text-decoration: none; }
.drawer-link:active { background: var(--bg); }

#rt-status { padding: 4px 0 8px; }
.rt-new { animation: flash 1.2s ease; }
@keyframes flash { from { background: rgba(22, 163, 74, 0.18); } to { background: transparent; } }
