/* ================================================================
   칼로리 계산기 웹 — Orange Theme (#F97316)
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #F97316;
  --brand-dark:  #EA580C;
  --brand-light: #FFF7ED;
  --bg:          #FFFBF5;
  --surface:     #FFFFFF;
  --surface2:    #F8F8F8;
  --border:      #E5E7EB;
  --text:        #1A1A1A;
  --text-muted:  #6B7280;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 4px 20px rgba(0,0,0,.08);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.06);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; }
button { cursor: pointer; border: none; font-family: inherit; background: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout ────────────────────────────────────────────── */
.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
main { min-width: 0; overflow: hidden; }
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; padding: 16px 12px 40px; }
  .app-sidebar { display: none; }
}
@media (max-width: 520px) {
  .hero-title { font-size: 20px; }
  .hero-desc { font-size: 13px; }
  .input-row.three { flex-direction: column; }
  .meal-tabs { gap: 4px; }
  .meal-tab { font-size: 12px; padding: 8px 6px; }
  .goal-summary { flex-direction: column; }
}

/* ── Ad ────────────────────────────────────────────────── */
.ad-container { display: block; width: 100%; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 16px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ── Header ────────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #EA580C 0%, #F97316 60%, #FB923C 100%);
  padding: 16px 16px 28px;
  position: relative; overflow: hidden;
}
.main-header::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.main-header::after {
  content: ''; position: absolute; bottom: -30px; left: 20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 1;
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon {
  font-size: 28px; background: rgba(255,255,255,.2); border-radius: 12px;
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
}
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 2px; }
.btn-share {
  font-size: 13px; color: rgba(255,255,255,.9);
  padding: 7px 14px; border-radius: 20px;
  background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4);
  font-weight: 600; position: relative; z-index: 1; transition: background .15s;
}
.btn-share:hover { background: rgba(255,255,255,.3); }
.header-hero { max-width: 1100px; margin: 16px auto 0; position: relative; z-index: 1; }
.hero-title { font-size: 26px; font-weight: 900; color: #fff; letter-spacing: -.5px; }
.hero-desc { font-size: 15px; color: rgba(255,255,255,.85); margin-top: 4px; }

/* ── Screen ────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── App Card ──────────────────────────────────────────── */
.app-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.card-header-icon { font-size: 18px; }
.card-header-title { font-size: 15px; font-weight: 700; flex: 1; }
.card-body { padding: 20px; }

/* ── Calorie Ring ─────────────────────────────────────── */
.calorie-ring-wrap {
  position: relative; width: 140px; height: 140px; margin: 0 auto 16px;
}
.calorie-ring { width: 100%; height: 100%; }
.ring-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
}
.ring-value { font-size: 28px; font-weight: 900; color: var(--brand); line-height: 1; }
.ring-unit { font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ── Macro Row ────────────────────────────────────────── */
.macro-row {
  display: flex; justify-content: center; gap: 20px;
}
.macro-item { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.macro-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.macro-dot.carb { background: #3B82F6; }
.macro-dot.protein { background: #22C55E; }
.macro-dot.fat { background: #EAB308; }
.macro-label { color: var(--text-muted); font-weight: 500; }
.macro-val { font-weight: 700; color: var(--text); }

/* ── Meal Tabs ────────────────────────────────────────── */
.meal-tabs {
  display: flex; gap: 6px; margin-bottom: 14px;
}
.meal-tab {
  flex: 1; padding: 10px 8px; border-radius: 10px;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 13px; font-weight: 600; color: #666;
  transition: all .15s; text-align: center;
}
.meal-tab.active {
  border-color: var(--brand); background: var(--brand-light);
  color: var(--brand); font-weight: 800;
}

/* ── Meal List ────────────────────────────────────────── */
.meal-list { margin-bottom: 12px; min-height: 40px; }
.meal-empty {
  text-align: center; padding: 20px; font-size: 13px; color: var(--text-muted);
}
.meal-food-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #FAFAFA; border-radius: 10px;
  margin-bottom: 6px;
}
.meal-food-item .mf-name { flex: 1; font-size: 13px; font-weight: 600; color: #333; }
.meal-food-item .mf-serving { font-size: 11px; color: #999; }
.meal-food-item .mf-kcal { font-size: 14px; font-weight: 800; color: var(--brand); min-width: 60px; text-align: right; }
.meal-food-item .mf-delete {
  width: 24px; height: 24px; border-radius: 50%;
  background: #FEE2E2; color: #EF4444; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s;
}
.meal-food-item .mf-delete:hover { background: #FECACA; }
.meal-subtotal {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--brand-light);
  border-radius: 10px; margin-bottom: 12px;
}
.subtotal-label { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
.subtotal-value { font-size: 15px; font-weight: 800; color: var(--brand); }

/* ── Gender ────────────────────────────────────────────── */
.gender-row { display: flex; gap: 10px; margin-bottom: 14px; }
.gender-btn {
  flex: 1; padding: 12px; border-radius: 12px;
  border: 2px solid var(--border); background: #fff;
  font-size: 15px; font-weight: 600; color: #666;
  transition: all .2s; text-align: center;
}
.gender-btn.active {
  border-color: var(--brand); background: var(--brand-light);
  color: var(--brand); font-weight: 800;
}

/* ── Input ─────────────────────────────────────────────── */
.input-row { display: flex; gap: 10px; margin-bottom: 14px; }
.input-row.three { display: flex; gap: 8px; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 12px; font-weight: 700; color: #666; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; padding: 12px 32px 12px 10px;
  border: 2px solid var(--border); border-radius: 10px;
  font-size: 17px; font-weight: 700; text-align: center;
  outline: none; transition: border-color .2s; background: #fff;
}
.input-wrap input:focus { border-color: var(--brand); }
.input-wrap input::placeholder { color: #ccc; font-weight: 400; }
.input-unit {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #999; font-weight: 600; pointer-events: none;
}

/* ── Activity ──────────────────────────────────────────── */
.activity-section { margin-bottom: 16px; }
.activity-title { font-size: 14px; font-weight: 700; color: #333; margin-bottom: 8px; }
.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--border); background: #fff;
  transition: all .15s; text-align: left; width: 100%;
}
.activity-btn.active { border-color: var(--brand); background: var(--brand-light); }
.activity-btn .a-emoji { font-size: 18px; flex-shrink: 0; }
.activity-btn .a-text { display: flex; flex-direction: column; flex: 1; }
.activity-btn .a-label { font-size: 13px; font-weight: 700; color: #333; }
.activity-btn .a-desc { font-size: 11px; color: #999; }
.activity-btn .a-check { font-size: 14px; font-weight: 800; color: var(--brand); }

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; padding: 15px;
  background: var(--brand); color: #fff;
  border-radius: var(--radius-sm); font-size: 16px; font-weight: 800;
  box-shadow: 0 4px 16px rgba(249,115,22,.3); transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-outline {
  display: block; width: 100%; padding: 14px;
  border: 1.5px solid var(--brand); color: var(--brand);
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700;
  background: var(--surface); transition: background .15s;
}
.btn-outline:hover { background: var(--brand-light); }
.btn-share-result {
  display: block; width: 100%; padding: 14px; margin-bottom: 8px;
  background: var(--brand); color: #fff;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700;
}
.btn-share-result:hover { background: var(--brand-dark); }
.btn-restart {
  display: block; width: 100%; padding: 14px;
  border: 1.5px solid var(--brand); color: var(--brand);
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700;
  background: var(--surface);
}
.btn-restart:hover { background: var(--brand-light); }
.btn-back {
  font-size: 13px; font-weight: 600; color: var(--brand);
  margin-left: auto;
}

/* ── Search ───────────────────────────────────────────── */
.search-box {
  position: relative; margin-bottom: 8px;
}
.search-box input {
  width: 100%; padding: 14px 40px 14px 16px;
  border: 2px solid var(--border); border-radius: 12px;
  font-size: 15px; font-weight: 500; outline: none;
  transition: border-color .2s;
}
.search-box input:focus { border-color: var(--brand); }
.search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 20px; color: #999; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}
.search-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.search-results { display: flex; flex-direction: column; gap: 6px; }
.search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; background: #FAFAFA; border-radius: 10px;
  cursor: pointer; transition: background .15s;
}
.search-item:hover { background: var(--brand-light); }
.search-item .si-name { flex: 1; font-size: 13px; font-weight: 600; color: #333; }
.search-item .si-kcal { font-size: 14px; font-weight: 800; color: var(--brand); white-space: nowrap; }
.search-item .si-serving { font-size: 11px; color: #999; white-space: nowrap; }
.search-loading {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 20px; font-size: 14px; color: var(--text-muted);
}
.spinner {
  width: 20px; height: 20px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 400px; overflow: hidden;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--text); }
.modal-close { font-size: 24px; color: #999; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 20px; }
.serving-info { margin-bottom: 16px; }
.serving-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
}
.serving-row + .serving-row { border-top: 1px solid #f3f4f6; }
.serving-label { font-size: 13px; color: #888; }
.serving-value { font-size: 13px; font-weight: 600; color: #333; }
.serving-value.highlight { color: var(--brand); font-weight: 800; font-size: 15px; }
.serving-adjust {
  display: flex; align-items: center; justify-content: space-between;
  background: #FAFAFA; padding: 12px 16px; border-radius: 12px;
  margin-bottom: 14px;
}
.adjust-label { font-size: 14px; font-weight: 700; color: #333; }
.adjust-controls { display: flex; align-items: center; gap: 16px; }
.adjust-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.adjust-btn:hover { opacity: .85; }
.adjust-value { font-size: 20px; font-weight: 900; color: var(--brand); min-width: 40px; text-align: center; }
.meal-select { margin-bottom: 14px; }
.meal-select-label { font-size: 13px; font-weight: 700; color: #333; margin-bottom: 8px; display: block; }
.meal-select-btns { display: flex; gap: 6px; }
.meal-select-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 12px; font-weight: 600; color: #666; text-align: center;
  transition: all .15s;
}
.meal-select-btn.active {
  border-color: var(--brand); background: var(--brand-light);
  color: var(--brand); font-weight: 800;
}

/* ── Result ────────────────────────────────────────────── */
.result-hero {
  background: linear-gradient(135deg, var(--brand), #FB923C);
  padding: 36px 20px 28px; text-align: center; color: #fff;
  border-radius: var(--radius); margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.result-label { font-size: 14px; font-weight: 600; opacity: .85; }
.result-bmr { font-size: 52px; font-weight: 900; line-height: 1.1; margin: 4px 0; }
.result-bmr .unit { font-size: 20px; font-weight: 600; margin-left: 4px; }
.result-sub { font-size: 13px; opacity: .75; }

/* ── Compare Card ─────────────────────────────────────── */
.compare-card {
  background: #fff; border: 2px solid var(--brand);
  border-radius: var(--radius); padding: 20px; text-align: center;
  margin-bottom: 14px;
}
.compare-title { font-size: 13px; color: #888; margin-bottom: 4px; }
.compare-value { font-size: 36px; font-weight: 900; color: var(--brand); }
.compare-value .unit { font-size: 16px; font-weight: 600; margin-left: 2px; }
.compare-bar-wrap { margin: 16px 0 8px; }
.compare-bar-track {
  height: 16px; background: #F3F4F6; border-radius: 99px; overflow: hidden;
  position: relative;
}
.compare-bar-fill {
  height: 100%; border-radius: 99px; transition: width .6s ease;
}
.compare-bar-fill.under { background: linear-gradient(90deg, #22C55E, #4ADE80); }
.compare-bar-fill.over { background: linear-gradient(90deg, #F97316, #EF4444); }
.compare-bar-fill.good { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
.compare-label { font-size: 12px; color: var(--text-muted); }
.compare-desc { font-size: 14px; font-weight: 600; color: #333; margin-top: 8px; }

/* ── Goal Summary ─────────────────────────────────────── */
.goal-summary { display: flex; gap: 8px; margin-bottom: 14px; }
.goal-item {
  flex: 1; text-align: center; padding: 14px 8px;
  border-radius: 14px; display: flex; flex-direction: column; gap: 4px;
}
.goal-item.lose { background: #EFF6FF; }
.goal-item.maintain { background: #F0FDF4; }
.goal-item.gain { background: #FFF7ED; }
.goal-emoji { font-size: 20px; }
.goal-label { font-size: 11px; font-weight: 700; color: #666; }
.goal-value { font-size: 14px; font-weight: 800; color: #333; }

/* ── Meal Summary ─────────────────────────────────────── */
.meal-summary {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.meal-summary h3 { font-size: 15px; font-weight: 800; color: #333; margin-bottom: 12px; }
.meal-summary-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
}
.meal-summary-row + .meal-summary-row { border-top: 1px solid #f3f4f6; }
.ms-emoji { font-size: 18px; flex-shrink: 0; }
.ms-label { flex: 1; font-size: 13px; font-weight: 600; color: #555; }
.ms-count { font-size: 11px; color: #999; margin-right: 8px; }
.ms-kcal { font-size: 14px; font-weight: 800; color: var(--brand); min-width: 60px; text-align: right; }

/* ── Nutrient Section ─────────────────────────────────── */
.nutrient-section {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.nutrient-section h3 { font-size: 15px; font-weight: 800; color: #333; margin-bottom: 12px; }
.nutrient-bar-wrap { margin-bottom: 12px; }
.nutrient-label-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.nutrient-name { font-size: 13px; font-weight: 600; color: #555; }
.nutrient-val { font-size: 13px; font-weight: 700; color: #333; }
.nutrient-bar { height: 10px; background: #F3F4F6; border-radius: 99px; overflow: hidden; }
.nutrient-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.nutrient-fill.carb { background: #3B82F6; }
.nutrient-fill.protein { background: #22C55E; }
.nutrient-fill.fat { background: #EAB308; }

/* ── Info Card ─────────────────────────────────────────── */
.info-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.info-card h2 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.info-card p { font-size: 14px; color: #374151; line-height: 1.75; margin-bottom: 8px; }

/* ── Source Note ───────────────────────────────────────── */
.source-note { font-size: 11px; color: #bbb; text-align: center; line-height: 1.4; margin-bottom: 16px; }

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar {
  position: sticky; top: 24px;
  max-height: calc(100vh - 48px); overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; overflow: hidden; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Footer ────────────────────────────────────────────── */
.main-footer {
  border-top: 1px solid var(--border); padding: 20px;
  text-align: center; font-size: 12px; color: var(--text-muted);
}

/* ── Share Toast ───────────────────────────────────────── */
.share-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A1F36; color: #fff;
  padding: 12px 22px; border-radius: 99px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  opacity: 0; transition: opacity .2s, transform .2s;
  z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,.25); pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
