/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #4CAF50;
  --brand-dark: #2E7D32;
  --brand-light: #E8F5E9;
  --bg: #F5FBF5;
  --surface: #FFFFFF;
  --surface2: #F1F8F1;
  --border: #DCEDC8;
  --text: #1A1A1A;
  --text-muted: #777;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(76,175,80,.12);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --vote-red: #E0334C;
  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 { 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;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
}

/* ── Ad containers ─────────────────────────────────────── */
.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: var(--brand);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}
.main-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.main-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.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-change-school, .btn-share-home {
  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;
  cursor: pointer;
  transition: background .15s;
}
.btn-change-school:hover, .btn-share-home:hover { background: rgba(255,255,255,.3); }
.header-btns { display: flex; gap: 8px; position: relative; z-index: 1; }

/* ── App Card ──────────────────────────────────────────── */
.app-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

/* ── Type Tabs ─────────────────────────────────────────── */
.type-tabs {
  display: flex;
  gap: 8px;
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.type-tab {
  padding: 7px 16px;
  border-radius: 20px 20px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  transition: all .15s;
}
.type-tab.active {
  background: var(--brand);
  color: #fff;
}

/* ── Search ────────────────────────────────────────────── */
.search-wrap {
  padding: 14px 16px 0;
  position: relative;
}
.search-row {
  display: flex;
  gap: 8px;
}
.search-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 15px;
  outline: none;
  background: var(--bg);
  transition: border-color .15s;
}
.search-row input:focus { border-color: var(--brand); }
.search-row button {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.search-row button:hover { background: var(--brand-dark); }

/* ── Recent Queries Dropdown ───────────────────────────── */
.recent-queries-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 16px; right: 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  border: 1px solid var(--border);
  z-index: 100;
}
.rq-header {
  padding: 8px 12px 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.rq-item {
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rq-item:hover { background: var(--bg); }

/* ── Section Block ─────────────────────────────────────── */
.section-block { padding: 14px 16px 0; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

/* ── Recent School Card ────────────────────────────────── */
.recent-school-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background .15s;
}
.recent-school-card:hover { background: var(--brand-light); }
.recent-school-info .school-name { font-size: 15px; font-weight: 600; color: var(--text); }
.recent-school-info .school-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.recent-school-actions { display: flex; align-items: center; gap: 8px; }
.chip-select {
  font-size: 12px;
  color: var(--brand);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--brand-light);
}
.chip-delete {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  cursor: pointer;
}
.chip-delete:hover { background: #FFE0E0; color: #E00; border-color: #FFAAAA; }

/* ── Ranking ───────────────────────────────────────────── */
.rank-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.rank-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.rank-medal { font-size: 22px; }
.rank-dish { font-size: 16px; font-weight: 700; flex: 1; }
.rank-count { font-size: 13px; color: var(--vote-red); font-weight: 700; }
.rank-schools { display: flex; flex-wrap: wrap; gap: 5px; }
.rank-share-btn {
  width: 100%;
  margin-top: 4px;
  padding: 13px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.2px;
  transition: opacity .15s;
}
.rank-share-btn:hover { opacity: .88; }

.rank-school-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 500;
}

/* ── Search Results ────────────────────────────────────── */
.search-result-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background .15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }
.result-name { font-size: 15px; font-weight: 600; color: var(--text); }
.result-sub { font-size: 13px; color: var(--text-muted); }
.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}
.search-loading { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ── Date Nav ──────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 8px;
  background: var(--brand);
  color: #fff;
}
.nav-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: #fff;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.nav-btn:hover { background: rgba(255,255,255,.4); }
.nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.date-center { flex: 1; text-align: center; }
.date-label { font-size: 14px; opacity: .9; }
.day-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,.25);
  color: #fff;
  border-radius: 20px;
  padding: 2px 14px;
}
.day-badge.today {
  background: rgba(255,255,255,.95);
  color: var(--brand);
}
.swipe-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0 8px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

/* ── Meal Card ─────────────────────────────────────────── */
.meal-section { padding: 16px; border-bottom: 1px solid var(--border); }
.meal-section:last-child { border-bottom: none; }
.meal-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.meal-type-label { font-size: 15px; font-weight: 700; }
.meal-cal { font-size: 12px; color: var(--text-muted); }

/* 메뉴 요약 */
.menu-summary {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 10px;
}
.subsection-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.dish-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.dish-chip {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}

/* 영양 정보 */
.nutrition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 10px;
}
.nutrition-grid .full-row { grid-column: 1 / -1; }
.ntr-row { display: flex; justify-content: space-between; }
.ntr-name { color: var(--text-muted); }
.ntr-value { font-weight: 600; color: var(--text); }

/* 알레르기 */
.allergen-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #FFFBF0;
  border: 1px solid #FFE58F;
  margin-bottom: 10px;
  font-size: 12px;
}
.allergen-label { font-size: 11px; color: #A67C00; font-weight: 600; margin-bottom: 6px; }
.allergen-row { display: flex; gap: 6px; margin-bottom: 4px; }
.allergen-row:last-child { margin-bottom: 0; }
.allergen-dish { color: var(--text); font-weight: 600; white-space: nowrap; }
.allergen-list { color: #856404; }

/* 투표 */
.vote-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #FFF8F8;
  border: 1px solid #FFE0E0;
  margin-bottom: 10px;
}
.vote-label { font-size: 11px; color: #E05050; font-weight: 600; margin-bottom: 8px; }
.vote-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vote-chip {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 20px;
  background: #fff;
  color: #666;
  font-weight: 700;
  border: 2px solid #ddd;
  transition: all .15s;
  cursor: pointer;
}
.vote-chip:hover { border-color: var(--vote-red); color: var(--vote-red); }
.vote-chip.voted {
  background: var(--vote-red);
  color: #fff;
  border-color: var(--vote-red);
  box-shadow: 0 2px 8px rgba(224,51,76,.3);
}

/* 공유 */
.share-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background .15s;
}
.share-btn:hover { background: var(--brand-light); color: var(--brand-dark); }

/* ── Day Nav Buttons ───────────────────────────────────── */
.day-nav-btns {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.day-nav-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background .15s;
}
.day-nav-btn:hover { background: var(--brand-light); color: var(--brand-dark); }

/* ── Disclaimer ────────────────────────────────────────── */
.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 10px 16px 14px;
  line-height: 1.6;
}

/* ── Week ──────────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 8px;
  background: var(--brand);
  color: #fff;
}
.week-label { flex: 1; text-align: center; font-size: 15px; font-weight: 700; color: #fff; }

.week-day-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.week-day-card:last-child { border-bottom: none; }
.week-day-card:hover { background: var(--bg); }
.week-day-card.today-card {
  background: var(--brand-light);
  border-left: 3px solid var(--brand);
}
.week-day-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.week-day-circle {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #DDD;
  color: #555;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.week-day-circle.today-circle { background: var(--brand); color: #fff; }
.week-day-date { font-size: 13px; color: var(--text-muted); }
.week-today-badge {
  font-size: 11px;
  background: var(--brand);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 4px;
}
.week-detail-hint { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.week-dish-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.week-dish-chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 500;
}
.week-no-meal { font-size: 13px; color: var(--text-muted); }

/* ── Tab Bar ───────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.tab-btn {
  flex: 1;
  padding: 12px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  transition: color .15s;
}
.tab-btn span:first-child { font-size: 22px; }
.tab-btn.active { color: var(--brand); font-weight: 700; }

/* ── Error / Empty ─────────────────────────────────────── */
.error-box {
  margin: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
}
.error-box.quota { background: #FFF3CD; border: 1px solid #FFD700; }
.error-box.network { background: #FFF0F0; border: 1px solid #FFCCCC; }
.error-title { font-weight: 700; margin-bottom: 4px; }
.error-sub { color: var(--text-muted); font-size: 13px; }
.retry-btn {
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.no-meal-box {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: 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; }
.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; }

/* ── SEO Guide ─────────────────────────────────────────── */
.guide-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.guide-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .guide-grid { grid-template-columns: 1fr; } }
.guide-card { background: var(--surface2); border-radius: var(--radius-sm); padding: 14px; border-left: 4px solid var(--brand); }
.guide-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.guide-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── FAQ ───────────────────────────────────────────────── */
.faq-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.faq-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.faq-a { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

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

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Loading spinner ───────────────────────────────────── */
.loading-box {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
