/* 우리 집 식단 달력 — 아이보리·화이트 다이어리 느낌 */
:root {
  --bg: #fbf8f1;
  --paper: #ffffff;
  --ink: #3f362d;
  --muted: #8a7e70;
  --line: #ebe3d6;
  --line-strong: #d9cdb9;
  --accent: #8a6d4b;
  --accent-soft: #f3ebdf;
  --green: #4f7a52;
  --green-soft: #e7f0e3;
  --amber: #b07a1f;
  --amber-soft: #fbf0d9;
  --blue: #5d7488;
  --blue-soft: #e8eef3;
  --red: #b4483b;
  --red-soft: #f8e4e0;
  --radius: 12px;
  --tap: 44px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  line-height: 1.5;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 20px 0 10px; }
h3 { font-size: 1rem; margin: 12px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.view { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* 상단·하단 메뉴 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(251, 248, 241, .96);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topnav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.topnav a, .bottomnav a {
  text-decoration: none; color: var(--muted); border-radius: 8px; white-space: nowrap;
}
.topnav a { padding: 6px 10px; }
.topnav a.active, .bottomnav a.active { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: none; justify-content: space-around;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; padding: 4px 6px; font-size: .78rem; min-width: 56px; }
.bottomnav a span { font-size: 1.2rem; line-height: 1.3; }
@media (max-width: 760px) {
  .topnav .wide-only { display: none; }
  .bottomnav { display: flex; }
}
@media (min-width: 761px) { body { padding-bottom: 24px; } }

/* 카드·버튼·입력 */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2, .card-head h3 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
button, .btn {
  min-height: var(--tap); padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--red); border-color: #e3bcb5; }
button.small, .btn.small { min-height: 34px; padding: 4px 10px; font-size: .875rem; }
button.icon { min-width: var(--tap); justify-content: center; padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; min-height: var(--tap);
  max-width: 100%;
}
textarea { width: 100%; min-height: 90px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; min-height: 38px; padding: 4px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; min-height: 36px;
  background: #fff; font-size: .9rem; cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

/* 배지 */
.badge {
  display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; line-height: 1;
  padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.recommended { background: var(--blue-soft); color: var(--blue); border: 1px dashed #9fb2c2; }
.badge.planned { background: var(--amber-soft); color: var(--amber); }
.badge.cooked { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--red-soft); color: var(--red); }
.badge.plain { background: #f4f1ea; color: var(--muted); }
.spice { color: var(--red); letter-spacing: -2px; }
.spice-0 { color: var(--green); letter-spacing: 0; }
.stars { color: #c99a2e; letter-spacing: -1px; }

/* 경고 */
.notice { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: .92rem; }
.notice.info { background: var(--blue-soft); }
.notice.warn { background: var(--amber-soft); }
.notice.error { background: var(--red-soft); color: #7d2b22; }
.notice.ok { background: var(--green-soft); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* 달력 */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--paper); border-radius: var(--radius); overflow: hidden; }
.cal th { font-size: .82rem; color: var(--muted); padding: 6px 0; font-weight: 500; border-bottom: 1px solid var(--line); }
.cal th:last-child, .cal td:last-child .dnum { color: var(--red); }
.cal td { vertical-align: top; border: 1px solid var(--line); height: 112px; padding: 0; }
.cal td.other { background: #faf8f4; }
.cal td.other .cell { opacity: .55; }
.cal td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cell { display: block; height: 100%; padding: 4px 5px; color: inherit; text-decoration: none; font-size: .8rem; overflow: hidden; }
.cell:hover { background: #fdfbf6; }
.cell .top { display: flex; align-items: center; gap: 3px; margin-bottom: 2px; }
.cell .dnum { font-weight: 600; font-size: .85rem; }
.cell .m { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .o { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.recommended { background: #fff; border: 1.5px dashed var(--blue); }
.dot.planned { background: var(--amber); }
.dot.cooked { background: var(--green); }
@media (max-width: 600px) {
  .cal td { height: 76px; }
  .cell { font-size: .72rem; padding: 3px; }
  .cell .o.side { display: none; }
}
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: 8px 0; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }

/* 하루 식단 목록 */
.dish-list { list-style: none; padding: 0; margin: 0; }
.dish-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.dish-list li:last-child { border-bottom: 0; }
.role { font-size: .75rem; padding: 3px 7px; border-radius: 6px; background: #f4f1ea; color: var(--muted); min-width: 52px; text-align: center; }
.role.main { background: #f6e6d8; color: #8a4b22; }
.role.soup { background: #e3eef0; color: #2f6470; }
.dish-name { font-weight: 600; }
.reason { font-size: .82rem; color: var(--muted); width: 100%; padding-left: 60px; }
@media (max-width: 600px) { .reason { padding-left: 0; } }
.edit-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.edit-row .btns { display: flex; gap: 4px; }
@media (max-width: 600px) {
  .edit-row { grid-template-columns: 84px 1fr; }
  .edit-row .btns { grid-column: 1 / -1; justify-content: flex-end; }
}

/* 평가 */
.fb { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.fb-grid { display: grid; grid-template-columns: 88px 1fr; gap: 8px 10px; align-items: center; }
.fb-grid .lbl { font-size: .88rem; color: var(--muted); }
.score { display: flex; gap: 4px; flex-wrap: wrap; }
.score button { min-width: 40px; min-height: 40px; padding: 0; justify-content: center; }
.score button.on { background: #c99a2e; border-color: #c99a2e; color: #fff; font-weight: 700; }
.who { display: flex; gap: 6px; }

/* 레시피 */
.recipe-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.recipe-item { display: block; text-decoration: none; color: inherit; }
.recipe-item .card { height: 100%; margin: 0; }
.recipe-item .meta { font-size: .85rem; color: var(--muted); }
table.plain { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.plain th, table.plain td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.table-wrap { overflow-x: auto; }
.ing-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 80px auto; gap: 6px; margin-bottom: 6px; }
.ing-row input, .edit-row input, .edit-row select { min-width: 0; width: 100%; }
@media (max-width: 480px) { .ing-row { grid-template-columns: minmax(0, 1fr) 60px 60px 40px; gap: 4px; } }
ol.steps { padding-left: 22px; }
ol.steps li { margin-bottom: 6px; }

/* 장보기 */
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.shop-item.done .name { text-decoration: line-through; color: var(--muted); }
.shop-item .uses { font-size: .82rem; color: var(--muted); grid-column: 1 / -1; }
.shop-item .checks { display: flex; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; min-height: 38px; cursor: pointer; background: #fff; }
.check input { min-height: auto; width: 18px; height: 18px; }

/* 주간 추천 */
.day-card .dish-list li { align-items: flex-start; }
.day-card .acts { display: flex; gap: 4px; margin-left: auto; }

/* 알림·대화상자 */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50;
  max-width: calc(100vw - 32px); font-size: .95rem;
}
.toast.error { background: var(--red); }
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 85vh; }
.dialog::backdrop { background: rgba(60, 50, 40, .35); }
.dialog .inner { padding: 16px; }
.pick-list { max-height: 55vh; overflow-y: auto; margin-top: 8px; }
.pick-list button { width: 100%; justify-content: space-between; margin-bottom: 6px; text-align: left; }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }

/* 메뉴를 누르면 그 자리에서 펼쳐지는 레시피 */
.dish-row { flex-direction: column; align-items: stretch !important; gap: 2px !important; }
.dish-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 4px 0; min-height: 40px; flex-wrap: wrap;
}
.dish-toggle:hover { border: 0; background: #fdfbf6; }
.dish-toggle .chev { color: var(--muted); font-size: .8rem; }
.dish-row .reason { padding-left: 0; }
.dish-detail { background: #fcfaf5; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 4px 0 6px; }
.inline-recipe p { margin: 4px 0; }
.inline-recipe ol.steps { margin: 6px 0; }
.acts-row { margin-top: 8px; gap: 6px; }
.cook-ings { columns: 2; column-gap: 24px; padding-left: 18px; }
@media (max-width: 600px) { .cook-ings { columns: 1; } }
@media print { .topbar, .bottomnav, .no-print { display: none !important; } body { background: #fff; } .card { border: 0; } }
