:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: #191f28;
  --muted: #6b7684;
  --dark: #202632;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

button, a { color: inherit; }
button { font: inherit; cursor: pointer; }
a { text-underline-offset: 3px; }
:focus-visible { outline: 2px solid #3182f6; outline-offset: 3px; }

.dishes { margin: 0; padding: 0; list-style: none; }
.dishes strong { display: block; font-weight: 700; line-height: 1.22; letter-spacing: -.037em; }
.dishes small { display: block; margin-top: 6px; line-height: 1.25; }
.weekday { font-size: .72em; font-weight: 500; }
.meal-status { margin: 0; text-align: center; line-height: 1.3; }
.masthead { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media screen {
  html { background: #f2f4f6; }

  .page {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: clamp(24px, 4vw, 40px) 0 8px;
  }

  .hero { margin-bottom: clamp(16px, 2.4vw, 24px); text-align: center; }

  .hero h1 {
    margin: 0;
    font-size: clamp(22px, 2.4vw, 28px);
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1.15;
  }


  .card, .day-column, .allergy-key {
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(20, 30, 50, .05), 0 8px 24px rgba(20, 30, 50, .05);
  }

  .today { padding: clamp(16px, 2vw, 22px); }

  .today-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: clamp(10px, 1.4vw, 14px);
  }

  .today-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }


  .today-title h2 { margin: 0; font-size: clamp(18px, 1.9vw, 22px); font-weight: 800; letter-spacing: -.035em; }

  .lunch-countdown {
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef4ff;
    color: #2a6fdb;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }

  .today-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

  #today-date, #today-calories {
    padding: 5px 11px;
    border-radius: 999px;
    background: #f2f4f6;
    font-size: 13px;
    font-weight: 700;
  }

  #today-calories { background: #fff4e6; color: #d9730d; }
  .weekday { color: var(--muted); }

  .today .day-content { padding: 0; }
  .today .dishes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

  .today .dishes li {
    padding: 12px 14px;
    border-radius: 12px;
    background: #f7f8fa;
  }

  .today .dishes strong { font-size: clamp(16px, 1.55vw, 18px); }
  .dishes small { margin-top: 4px; color: var(--muted); font-size: 12px; }
  .meal-status { margin-block: 22px; color: #8b95a1; font-size: 14px; }
  .today .meal-status { margin-block: 14px; }
  .retry-today { margin-top: 4px; }

  .week-link {
    display: block;
    width: fit-content;
    margin: 12px auto 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
  }

  .weekly { margin-top: clamp(20px, 3vw, 28px); }

  .week-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
  }

  .week-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }

  .week-heading h2 {
    margin: 0;
    font-size: clamp(17px, 1.6vw, 19px);
    font-weight: 800;
    letter-spacing: -.03em;
  }

  .week-range { margin: 0; color: var(--muted); font-weight: 600; }
  .sheet-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
  .week-controls { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: #e8ebee; }

  .week-controls button {
    min-height: 34px;
    padding: 0 14px;
    font-size: 13px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #4e5968;
    font-weight: 650;
  }

  .week-controls button:not(:disabled):hover { background: #fff; }
  .week-controls button:disabled { color: #a0a8b3; cursor: default; }

  #print {
    min-height: 38px;
    padding: 0 16px;
    font-size: 13px;
    border: 0;
    border-radius: 999px;
    background: var(--dark);
    color: #fff;
    font-weight: 700;
  }

  #print:disabled { background: #c9ced6; cursor: default; }

  .load-error {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #fff;
  }

  .load-error p { margin: 0; }

  .load-error button, .retry-today {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: #e8ebee;
    font-weight: 650;
  }

  .meal-plan { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
  .day-column { overflow: hidden; }
  .day-column.is-today { box-shadow: 0 0 0 2px var(--dark), 0 8px 24px rgba(20, 30, 50, .08); }

  .date-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 14px 12px 4px;
    font-size: clamp(14px, 1.3vw, 16px);
    font-weight: 800;
    letter-spacing: -.03em;
  }

  .today-badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--dark);
    color: #fff;
    font-size: 11px;
    letter-spacing: 0;
  }

  .day-content { padding: 4px 12px 14px; }
  .dishes li { padding-block: 8px; }
  .dishes li + li { border-top: 1px dashed #dde1e6; }
  .meal-plan .dishes strong { font-size: clamp(14px, 1.15vw, 15px); }
  .today .dishes li + li { border-top: 0; }

  .allergy-key {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-top: 12px;
    padding: 12px 16px;
    color: #4e5968;
    font-size: 12px;
    line-height: 1.4;
  }

  .allergy-key strong { color: #191f28; }
  .allergy-key ul { display: flex; flex: 1 1 70%; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; }
  .site-footer { margin: 20px 0 28px; text-align: center; font-size: 13px; color: var(--muted); }

  .notice {
    width: min(420px, calc(100% - 32px));
    padding: 24px 22px 18px;
    border: 0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(20, 30, 50, .22);
    text-align: center;
  }

  .notice::backdrop { background: rgba(25, 31, 40, .45); }
  .notice p { margin: 0 0 20px; font-size: 18px; line-height: 1.6; text-wrap: balance; }
  .notice strong { font-weight: 800; }

  .notice button {
    min-height: 40px;
    padding: 0 28px;
    border: 0;
    border-radius: 999px;
    background: var(--dark);
    color: #fff;
    font-weight: 700;
  }

  @media (max-width: 1000px) {
    .today .dishes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .meal-plan { grid-template-columns: 1fr; }
  }

  @media (max-width: 560px) {
    .page { width: calc(100% - 24px); }
    .today .dishes, .meal-plan { grid-template-columns: 1fr; }
    .sheet-actions, #print { width: 100%; }
    .week-controls { width: 100%; }
    .week-controls button { flex: 1; }
  }
}

@page { size: A4 landscape; margin: 9mm; }

@media print {
  :root { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  html, body { background: #fff; }
  .page { width: 100%; padding: 0; }
  .notice, .hero, .today, .week-bar, .load-error, .site-footer { display: none !important; }

  .masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: baseline;
    column-gap: 4mm;
    margin-bottom: 4mm;
    padding-bottom: 2.5mm;
    border-bottom: 1mm solid #141414;
  }

  .school-name, .date-range { margin: 0; font-size: 11pt; font-weight: 650; }
  .print-title { margin: 0; font-size: 20pt; font-weight: 850; letter-spacing: -.045em; line-height: 1.2; }
  .date-range { text-align: end; }

  .meal-plan { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 145mm; border: 1px solid #272727; }
  .day-column + .day-column { border-inline-start: 1px solid #555; }

  .date-heading {
    display: grid;
    place-items: center;
    min-height: 10mm;
    margin: 0;
    padding: 2mm;
    background: #141414;
    color: #fff;
    font-size: 13pt;
    font-weight: 750;
    line-height: 1.2;
    white-space: nowrap;
  }

  .today-badge { display: none; }
  .day-content { padding: 2mm 3mm 3mm; }
  .dishes li { padding-block: 2.5mm; break-inside: avoid; }
  .dishes li + li { border-top: 1px dashed #aaa; }
  .dishes strong { font-size: 13pt; font-weight: 800; }
  .dishes small { margin-top: 1mm; color: #555; font-size: 9pt; }
  .meal-status { margin-top: 19mm; color: #696969; font-size: 10pt; }

  .allergy-key {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1mm 4mm;
    margin-top: 3mm;
    padding: 2mm 3mm;
    border: 1px solid #737373;
    color: #3b3b3b;
    font-size: 8pt;
    line-height: 1.4;
  }

  .allergy-key strong { color: #141414; }
  .allergy-key ul { display: flex; flex: 1 1 72%; flex-wrap: wrap; gap: 1mm 3mm; margin: 0; padding: 0; list-style: none; }
}
