/* ── 공통: 화면·인쇄 동일 레이아웃 (A4 가로 1페이지) ── */

.print-page,
.print-mode {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.print-body {
  width: 289mm;
  max-width: 289mm;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 202mm;
  max-height: 202mm;
  overflow: hidden;
  box-sizing: border-box;
}

.print-header {
  flex: 0 0 auto;
  text-align: center;
  margin-bottom: 1.5mm;
  position: relative;
}

.print-header h1 {
  font-size: 11pt;
  font-weight: 800;
  line-height: 1.2;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.print-subtitle {
  margin-top: 0;
  font-size: 7.5pt;
  line-height: 1.25;
  color: var(--text-muted);
}

.print-hint {
  margin: 8px auto 10px;
  max-width: 289mm;
  padding: 0 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}

.print-sheet {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.print-months {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 1mm;
}

.print-months--multi {
  gap: 0.5mm;
}

.print-month {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.print-month-title {
  flex: 0 0 auto;
  margin: 0 0 0.5mm;
  font-size: 7pt;
  font-weight: 800;
  line-height: 1.2;
  color: var(--primary);
  text-align: center;
}

.print-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 0 0 auto;
  gap: 1px;
  margin-bottom: 1px;
  min-width: 0;
}

.print-weekdays span {
  text-align: center;
  font-size: 7pt;
  font-weight: 700;
  padding: 1.5px;
  line-height: 1.25;
  background: var(--primary);
  color: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.print-weekdays span:first-child {
  background: #c62828;
}

.print-weekdays span:last-child {
  background: #1565c0;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex: 1 1 0;
  gap: 1px;
  min-height: 0;
  min-width: 0;
  grid-auto-rows: 1fr;
  align-content: stretch;
}

.print-cell {
  border: 1px solid #bbb;
  padding: 1.5px 2px;
  min-height: 0;
  height: 100%;
  font-size: 6.5pt;
  line-height: 1.25;
  background: #fafcfa;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.print-cell.empty {
  min-height: 0;
  background: #f5f5f5;
  border-color: #ddd;
  color: #bbb;
  font-size: 6.5pt;
}

.print-cal-day {
  opacity: 0.5;
}

.print-cell.fasting {
  background: var(--fasting);
  border-color: var(--fasting-border);
}

.print-cell.free-day {
  background: var(--free);
  border-color: var(--free-border);
}

.print-day-title {
  font-size: 7pt;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0;
  padding-bottom: 0;
  line-height: 1.25;
  border-bottom: 0.5px solid var(--border);
  text-align: center;
}

.print-cell.fasting .print-day-title {
  color: #e65100;
}

.print-cell.free-day .print-day-title {
  color: #3949ab;
}

.print-meals {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  line-height: 1.25;
  min-height: 0;
  overflow: hidden;
}

.print-meal {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.25;
  flex-shrink: 0;
}

.print-meal-icon,
.guide-icon,
.print-forbidden li::before {
  flex-shrink: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.print-meal-icon {
  font-size: 6.5pt;
  line-height: 1.25;
}

.print-meal-text {
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.25;
  font-weight: 600;
  color: #1a2e24;
}

.print-meal-text strong {
  font-weight: 700;
}

.print-exercise {
  padding-top: 1px;
  border-top: 0.5px dashed #ccc;
  font-weight: 600;
  font-size: 6pt;
  line-height: 1.25;
  display: flex;
  align-items: flex-start;
  gap: 2px;
  color: var(--primary);
  flex-shrink: 0;
}

.print-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 34mm;
  gap: 4mm;
  margin-top: 1mm;
  padding-top: 1.5mm;
  border-top: 1px solid var(--primary);
  min-width: 0;
  min-height: 34mm;
  max-height: 34mm;
  overflow: hidden;
  flex-shrink: 0;
  align-items: stretch;
}

.print-footer-col {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.print-footer h2 {
  font-size: 7.5pt;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 1.5px;
  line-height: 1.25;
  flex-shrink: 0;
}

.print-footer ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1 1 auto;
  gap: 0;
  margin: 0;
  padding: 0;
  min-height: 0;
}

.print-footer li {
  font-size: 6.5pt;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  display: flex;
  gap: 2px;
  align-items: flex-start;
}

.print-footer li > span:last-child {
  font-weight: 600;
}

.print-allowed li::before {
  content: "✓";
  flex-shrink: 0;
  font-weight: 800;
  color: var(--primary);
}

.print-forbidden li::before {
  content: "🚫";
  flex-shrink: 0;
}

.print-allowed-note {
  margin: 1px 0 0;
  padding: 0;
  font-size: 5.5pt;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-muted);
  flex-shrink: 0;
}

.print-grid--6rows .print-cell {
  font-size: 6pt;
  padding: 1px 1.5px;
}

.print-grid--6rows .print-day-title {
  font-size: 6.5pt;
}

.print-grid--6rows .print-meal-icon {
  font-size: 6pt;
}

.print-grid--6rows .print-exercise {
  font-size: 5.5pt;
}

.print-sheet--6rows .print-footer {
  flex: 0 0 32mm;
  min-height: 32mm;
  max-height: 32mm;
}

.print-sheet--6rows .print-footer h2 {
  font-size: 7pt;
}

.print-sheet--6rows .print-footer li {
  font-size: 6pt;
  line-height: 1.25;
}

.print-sheet--6rows .print-allowed-note {
  font-size: 5pt;
}

/* ── 2개월 식단: 같은 A4 가로 1페이지에 월별 그리드 2개 ── */

.print-sheet--multi .print-month {
  flex: 1 1 0;
}

.print-sheet--multi .print-month-title {
  font-size: 6.5pt;
  margin-bottom: 0.25mm;
}

.print-sheet--multi .print-weekdays span {
  font-size: 6pt;
  padding: 1px;
}

.print-sheet--multi .print-cell {
  font-size: 5.5pt;
  padding: 1px 1.5px;
}

.print-sheet--multi .print-day-title {
  font-size: 6pt;
}

.print-sheet--multi .print-meal-icon {
  font-size: 5.5pt;
}

.print-sheet--multi .print-exercise {
  font-size: 5pt;
}

.print-sheet--multi .print-footer {
  flex: 0 0 28mm;
  min-height: 28mm;
  max-height: 28mm;
  margin-top: 0.5mm;
  padding-top: 1mm;
  gap: 3mm;
}

.print-sheet--multi .print-footer h2 {
  font-size: 6.5pt;
}

.print-sheet--multi .print-footer li {
  font-size: 5.5pt;
  line-height: 1.2;
}

.print-sheet--multi .print-allowed-note {
  font-size: 4.5pt;
}

/* ── 화면 전용: 네비·배경·미리보기 프레임 ── */

@media screen {
  .print-page {
    background: #e8ece8;
    min-height: 100vh;
  }

  .print-app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 12px 32px;
  }

  .print-body {
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: var(--shadow);
    box-sizing: border-box;
    background: #fff;
  }

  .print-sheet {
    background: transparent;
  }
}

@media (max-width: 768px) {
  .print-app {
    padding: 12px 10px 28px;
  }

  .print-app .app-nav {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
  }

  .print-app .app-nav a,
  .print-app .btn-print-inline {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    -webkit-tap-highlight-color: transparent;
  }

  .print-app .btn-print-inline {
    margin-left: 0;
    flex: 1 1 auto;
    min-width: 100px;
  }

  .print-hint {
    font-size: 0.72rem;
    padding: 0 10px;
  }

  .print-body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 6px;
  }

  .print-months {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
  }

  .print-months::before {
    content: "← 좌우로 스크롤하여 전체 식단을 확인하세요";
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 8px 8px;
    line-height: 1.4;
    flex: 0 0 auto;
  }

  .print-month {
    min-width: 289mm;
    width: 289mm;
  }

  .print-footer {
    grid-template-columns: 1fr;
    gap: 8px;
    flex: 0 0 28mm;
    min-height: 28mm;
    max-height: 28mm;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .print-app .app-nav {
    width: 100%;
  }

  .print-app .app-nav a {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .print-app .btn-print-inline {
    flex: 1 1 100%;
    max-width: none;
  }

  .print-body::before {
    display: none;
  }
}

/* ── 패밀리 사이트 푸터 (화면 전용) ── */

@media screen {
  .print-app .app-footer {
    max-width: 289mm;
    margin: 20px auto 0;
  }
}

/* ── 인쇄 전용: 장식 제거·페이지 설정 ── */

@media print {
  @page {
    size: A4 landscape;
    margin: 4mm;
  }

  body.print-page {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .print-app {
    max-width: none;
    padding: 0;
  }

  .print-body {
    width: 100%;
    max-width: none;
    height: 202mm;
    max-height: 202mm;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-body::before {
    display: none !important;
    content: none;
  }

  .print-sheet {
    border: none;
    box-shadow: none;
  }

  .print-cell {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-footer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4mm;
    flex: 0 0 34mm;
    min-height: 34mm;
    max-height: 34mm;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .print-body,
  .print-sheet {
    page-break-after: avoid;
    break-after: avoid;
  }
}
