:root {
  --green: #2f7d4f;
  --green-dark: #245f3d;
  --green-light: #e8f3ec;
  --bg: #f7f8f6;
  --card: #ffffff;
  --text: #1f2a22;
  --muted: #6b7a70;
  --border: #e3e8e3;
  --amber: #c97a14;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 48px;
}

/* Update banner */
#update-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: #1f6b41; color: #fff; padding: 10px 14px; font-size: .88rem; font-weight: 600;
  position: sticky; top: 0; z-index: 60; text-align: center;
}
#update-banner #update-text { line-height: 1.4; }
#update-banner button { flex: none; }
#update-banner button {
  background: #fff; color: var(--green-dark); border: none; border-radius: 999px;
  padding: 6px 14px; font-size: .85rem; font-weight: 700; cursor: pointer;
}
#update-banner button:disabled { opacity: .6; }

.version-note { margin: 18px 2px 0; font-size: .78rem; color: var(--muted); text-align: center; }

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  padding: 20px 18px 18px;
  padding-top: max(20px, env(safe-area-inset-top));
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-header h1 { font-size: 1.35rem; margin: 0; }
.subtitle { margin: 6px 0 0; font-size: .85rem; opacity: .9; }
.season-badge {
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.35);
  padding: 4px 10px; border-radius: 999px; font-size: .8rem; white-space: nowrap;
}

/* Tabs */
.tabs {
  display: flex; gap: 4px; padding: 10px 12px 0; position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.tab {
  flex: 1; border: none; background: transparent; padding: 10px 6px;
  font-size: .92rem; color: var(--muted); cursor: pointer; border-radius: 10px 10px 0 0;
  font-weight: 600;
}
.tab.active { color: var(--green-dark); background: var(--card); box-shadow: var(--shadow); }

main { padding: 14px 12px; }

/* Actions */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.btn {
  flex: 1 1 auto; min-width: 120px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .6; }

/* Plan cards */
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.day-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.day-top { display: flex; align-items: center; gap: 12px; }
.day-badge {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  background: var(--green-light); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem;
}
.day-meta { flex: 1; min-width: 0; }
.day-name { font-weight: 700; font-size: 1.05rem; }
.day-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; font-size: 1.1rem; cursor: pointer; color: var(--green-dark);
}
.day-health {
  margin-top: 10px; font-size: .85rem; color: var(--green-dark);
  background: var(--green-light); padding: 8px 10px; border-radius: 10px;
}
.link-btn {
  margin-top: 10px; background: none; border: none; color: var(--green);
  font-weight: 600; cursor: pointer; padding: 4px 0; font-size: .9rem;
}
.day-actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.day-actions .link-btn { margin-top: 0; }
.link-btn.swap { color: var(--amber); font-weight: 700; }
.recipe-detail { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 10px; }
.rd-section { margin-bottom: 12px; }
.rd-section h4 { margin: 0 0 6px; font-size: .9rem; color: var(--green-dark); }
.rd-section ul, .rd-section ol { margin: 0; padding-left: 18px; }
.rd-section li { margin-bottom: 4px; font-size: .9rem; }
.rd-section .q { color: var(--muted); font-size: .82rem; }
.pantry { color: var(--muted); font-size: .85rem; margin: 0; }

/* Shopping */
.hint { color: var(--muted); font-size: .85rem; margin: 0 4px 12px; }
.shop-group {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.shop-group h3 { margin: 0 0 8px; font-size: .98rem; }
.shop-group ul { list-style: none; margin: 0; padding: 0; }
.shop-group li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.shop-group li:last-child { border-bottom: none; }
.shop-group label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.shop-group input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
.shop-group input:checked + span { text-decoration: line-through; color: var(--muted); }
.pantry-group { background: #fffdf5; border-color: #f0e6c8; }
.shop-group li.has span { text-decoration: line-through; color: var(--muted); }

/* Section headers within shopping */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 4px; gap: 8px; }
.section-head h2 { font-size: 1.05rem; margin: 0; }
.mini-actions { display: flex; gap: 6px; }
.mini {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 5px 10px; border-radius: 999px; font-size: .78rem; cursor: pointer; font-weight: 600;
}
.section-head .count {
  background: var(--green); color: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: .82rem; font-weight: 700;
}

/* Buy list card */
.buy-card {
  background: var(--card); border: 2px solid var(--green); border-radius: var(--radius);
  padding: 14px; margin: 14px 0 12px; box-shadow: var(--shadow);
}
.buy-cat { font-size: .82rem; color: var(--muted); font-weight: 700; margin: 10px 0 4px; }
.buy-list { list-style: none; margin: 0; padding: 0; }
.buy-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.buy-list li:last-child { border-bottom: none; }
.buy-list label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.buy-list input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
.buy-list input:checked + span { text-decoration: line-through; color: var(--muted); }
.all-have { color: var(--green-dark); font-weight: 600; text-align: center; padding: 14px 0; }
.buy-card .actions { margin: 14px 0 0; }

/* Tips card */
.tips-card {
  background: var(--green-light); border: 1px solid #cfe3d6; border-radius: var(--radius);
  padding: 14px 16px; margin-top: 14px;
}
.tips-card h2 { font-size: 1.05rem; margin: 0 0 8px; color: var(--green-dark); }
.tips-list { margin: 0; padding-left: 2px; list-style: none; }
.tips-list li {
  font-size: .9rem; color: var(--text); margin-bottom: 10px; line-height: 1.55;
  padding-left: 2px;
}
.tips-list li:last-child { margin-bottom: 0; }

/* Settings */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  font-size: .95rem; background: #fff; color: var(--text);
}
.set-title { margin: 4px 0 8px; font-size: 1rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 22px 0 16px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #233; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
  max-width: 90%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #a33; }
