/* ========== 색상 ========== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --cell: #f3f4f6;
  --ink: #1a1d23;
  --muted: #6b7280;
  --line: #e4e6ea;
  --sun: #d92d20;
  --sat: #1d5fd1;
  --on-color: #ffffff;
  --notice-bg: #fff6e8;
  --notice-ink: #8a3b0a;
  --notice-line: #f0a33a;

  --g-A: #d6334c;
  --g-B: #cf5a0c;
  --g-C: #9a6c00;
  --g-D: #22844d;
  --g-E: #1b6dcc;
  --g-F: #6f46d4;
  --g-G: #bf2d84;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d22;
    --cell: #23272e;
    --ink: #eceef1;
    --muted: #9aa1ab;
    --line: #2d3239;
    --sun: #ff7a6e;
    --sat: #7aaeff;
    --on-color: #111317;
    --notice-bg: #2b2114;
    --notice-ink: #f5c58a;
    --notice-line: #b7741c;

    --g-A: #ff7085;
    --g-B: #ff9c55;
    --g-C: #eec14a;
    --g-D: #56c98f;
    --g-E: #64aefc;
    --g-F: #ab93ff;
    --g-G: #f173bf;
  }
}

.g-A, .hit-A { --c: var(--g-A); }
.g-B, .hit-B { --c: var(--g-B); }
.g-C, .hit-C { --c: var(--g-C); }
.g-D, .hit-D { --c: var(--g-D); }
.g-E, .hit-E { --c: var(--g-E); }
.g-F, .hit-F { --c: var(--g-F); }
.g-G, .hit-G { --c: var(--g-G); }

/* ========== 기본 ========== */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ========== 머리말 ========== */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  padding: 10px 16px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .02em;
}

.hero {
  text-align: center;
  padding: 28px 0 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 800;
  letter-spacing: -.02em;
}

.updated {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.verse {
  margin: 10px auto 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 13px;
}

.verse cite { font-style: normal; white-space: nowrap; }

/* ========== 휴무 표시 배지 ========== */
.badge {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 15%, transparent);
}

.badge.on {
  color: var(--on-color);
  background: var(--c);
}

/* ========== 오늘 카드 ========== */
.today {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
}

.today-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.today-date {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.today-off {
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 800;
}

.today-off .badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 17px;
}

.link-btn {
  border: 1px solid var(--line);
  background: var(--cell);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.upcoming {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.upcoming-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
}

.upcoming ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upcoming li {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--cell);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.upcoming li.is-today {
  background: var(--ink);
  color: var(--surface);
}

/* ========== 도구 모음 (연도 · 조) ========== */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 14px -16px 0;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.years {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--cell);
  border: 1px solid var(--line);
}

.seg {
  border: 0;
  border-radius: 8px;
  padding: 6px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.seg[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(0 0 0 / .12);
}

.groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--surface);
  color: var(--c);
  font-weight: 800;
}

.chip[aria-pressed="true"] {
  background: var(--c);
  border-color: var(--c);
  color: var(--on-color);
}

.chip.clear {
  --c: var(--muted);
  font-weight: 600;
}

.chip.clear[hidden] { display: none; }

/* ========== 안내 ========== */
.notice {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--notice-line);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  font-size: 13px;
}

/* ========== 달력 ========== */
.calendar {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 16px;
}

.month {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 10px 10px;
  scroll-margin-top: 130px;
}

.month.current {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 20%, transparent);
}

.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 8px;
}

.month-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 800;
}

.now {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.count {
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 3px;
}

th {
  padding: 2px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

th.sun { color: var(--sun); }
th.sat { color: var(--sat); }

td {
  height: 52px;
  padding: 4px 0 5px;
  border-radius: 8px;
  text-align: center;
  vertical-align: top;
}

td.day { background: var(--cell); }

.num {
  display: inline-block;
  min-width: 22px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

.sun .num { color: var(--sun); }
.sat .num { color: var(--sat); }

td.today .num {
  background: var(--ink);
  color: var(--surface);
}

.offs {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 3px;
}

/* 조를 고르면: 그 조 휴무일은 진하게, 나머지 배지는 흐리게 */
.has-selection .badge:not(.on) {
  color: var(--muted);
  background: transparent;
  opacity: .55;
}

td.hit {
  background: color-mix(in srgb, var(--c) 17%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 60%, transparent);
}

/* ========== 규칙 설명 · 꼬리말 ========== */
.rule {
  margin: 24px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.rule summary {
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.rule ul { margin: 10px 0 2px; padding-left: 20px; }
.rule li + li { margin-top: 4px; }
.rule b { color: var(--ink); }

.site-footer {
  margin-top: 48px;
  padding: 24px 16px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.site-footer p { margin: 0 0 8px; }

/* ========== 좁은 화면 ========== */
@media (max-width: 480px) {
  .today { padding: 14px; }
  /* 1줄: 연도 + 선택 해제, 2줄: 7개 조를 한 줄에 */
  .toolbar { gap: 8px; }
  .chip.clear { order: 2; margin-left: auto; padding: 5px 12px; }
  .groups {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
  }
  .groups .chip { padding: 5px 0; font-size: 14px; }
  .month { padding: 12px 6px 8px; }
  table { border-spacing: 2px; }
  td { height: 50px; }
  .badge { width: 17px; height: 17px; font-size: 10.5px; border-radius: 4px; }
  .offs { gap: 1px; }
}

/* ========== 인쇄 ========== */
@media print {
  .site-header, .today, .toolbar, .site-footer, .rule { display: none; }
  body { background: #fff; }
  .calendar { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .month { break-inside: avoid; border-color: #ccc; }
}
