:root {
  --bg: #ffffff;
  --line: #ebebea;
  --text: #37352f;
  --muted: #b9b9b6;
  --muted-bg: #fbfbfa;
  --accent: #2383e2;
  --today-bg: #f7faff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 10px;
}
.nav { display: flex; align-items: center; gap: 16px; }
.nav h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.nav-buttons { display: flex; gap: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); text-decoration: none; font-size: 15px;
  background: #fff; transition: background .12s;
}
.btn:hover { background: #f1f1f0; }
.today-btn { font-size: 13px; font-weight: 600; }

.sources { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line);
}
.chip.on { color: #1a7f37; border-color: #b7e0c0; background: #f0faf2; }
.chip.off { color: var(--muted); background: var(--muted-bg); }
.chip.admin { color: #b4690e; border-color: #f0d39a; background: #fff7e8; }
.chip.preview { color: #6940a5; border-color: #d9caf0; background: #f5f0fc; }
.chip.link { color: var(--accent); border-color: #bcdcfa; background: #eef6ff; text-decoration: none; }
.chip.link:hover { background: #e2eefe; }

.adminbar {
  padding: 7px 20px; font-size: 12px;
  background: #fff7e8; color: #8a5a12; border-bottom: 1px solid #f0d39a;
}

/* ── Banners ── */
.banner {
  margin: 12px 20px 0; padding: 10px 14px; border-radius: 8px;
  background: #fff8e6; border: 1px solid #f3e2b3; font-size: 12.5px;
}
.banner.error { background: #fdecec; border-color: #f3c2c2; }
.banner.preview-banner { background: #f5f0fc; border-color: #d9caf0; color: #5b3a91; }
.banner.preview-banner a { color: #6940a5; font-weight: 600; }
.banner code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; }

/* ── Weekday header ── */
.weekday-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
}
.weekday {
  padding: 8px 10px; font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
}
.weekday.sun { color: #e0564b; }
.weekday.sat { color: #2f72d4; }

/* ── Grid ── */
.grid { flex: 1; display: flex; flex-direction: column; }
.week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  flex: 1; min-height: 96px;
}
.cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 4px 6px 6px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.week .cell:last-child { border-right: none; }
.cell.muted { background: var(--muted-bg); }
.cell.muted .daynum { color: var(--muted); }
.cell.today { background: var(--today-bg); }

.daynum {
  font-size: 12px; font-weight: 600; color: #6f6e69;
  padding: 2px 2px 4px; align-self: flex-start;
}
.today-num {
  background: var(--accent); color: #fff;
  border-radius: 50%; min-width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

.events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.event-row { display: flex; align-items: center; gap: 2px; border-radius: 5px; }
.event-row .event { flex: 1; min-width: 0; }

/* 관리자 화면: 카테고리별 좌측 보더로 구분 */
.event-row.cat-private { box-shadow: inset 2px 0 0 #d44c47; opacity: .55; }
.event-row.cat-private .event { text-decoration: line-through; }
.event-row.cat-busy { box-shadow: inset 2px 0 0 #9b9a97; }
.event-row.cat-public { box-shadow: inset 2px 0 0 #448361; }

.cat-btn {
  flex: 0 0 auto; border: none; background: transparent; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 2px; border-radius: 4px; opacity: .65;
}
.cat-btn:hover { opacity: 1; background: rgba(0,0,0,.06); }
.cat-btn:disabled { opacity: .3; cursor: default; }
.event {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 5px; border-radius: 5px;
  text-decoration: none; color: var(--text);
  font-size: 12px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.event:hover { background: rgba(0,0,0,.05); }
.event .etitle { overflow: hidden; text-overflow: ellipsis; }
.event .etime { color: var(--muted); font-variant-numeric: tabular-nums; }

.event.all-day { background: transparent; }
.event .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.event .bar { width: 3px; height: 12px; border-radius: 2px; flex: 0 0 auto; }
.event.all-day:hover { background: rgba(0,0,0,.05); }

/* 모바일 칸 안 일정 칩 — 기본은 숨김, 좁은 화면에서만 노출 */
.cell-chips { display: none; flex-direction: column; gap: 2px; width: 100%; padding-top: 2px; }
.chip-ev {
  font-size: 10px; line-height: 1.3; color: var(--text);
  padding: 1px 3px 1px 5px; border-radius: 3px;
  background: #f3f3f2; box-shadow: inset 2px 0 0 var(--c);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-more { font-size: 9px; color: var(--muted); padding-left: 4px; line-height: 1.2; }

/* ── 날짜 상세 팝업 (바텀시트) — 기본 숨김 ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 50; display: none; }
.modal.show { display: block; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #fff; border-radius: 16px 16px 0 0;
  max-height: 80vh; overflow-y: auto; padding: 0 16px 24px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  position: sticky; top: 0; background: #fff; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.modal-empty { color: var(--muted); padding: 18px 4px; font-size: 14px; }
.modal-events .event-row { margin: 0; }
.modal-events .event {
  font-size: 15px; padding: 11px 10px; white-space: normal;
  border-bottom: 1px solid var(--line); border-radius: 0;
}
.modal-events .event-row:last-child .event { border-bottom: none; }
.modal-events .event .etitle { overflow: visible; white-space: normal; }
.modal-events .event .etime { display: inline; margin-right: 6px; color: var(--text); font-weight: 600; }
.modal-events .event .bar { height: 16px; }
.modal-events .event .dot { width: 10px; height: 10px; }
.modal-events .cat-btn { font-size: 20px; padding: 8px; }

@media (max-width: 720px) {
  .nav h1 { font-size: 16px; }
  .event .etime { display: none; }
  .week { min-height: 70px; }
}

/* ── 모바일: 위는 작은 점 달력, 아래는 선택일 일정 리스트 ── */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  body { height: auto; min-height: 100%; }
  .topbar {
    padding: 9px 12px; position: sticky; top: 0; background: #fff; z-index: 3;
    flex-direction: column; align-items: stretch; gap: 8px;
  }
  .nav { gap: 10px; justify-content: space-between; }
  .sources { gap: 5px; }
  .chip { font-size: 10px; padding: 2px 7px; max-width: 100%; }
  .chip.admin .email { display: none; }          /* 모바일: 긴 이메일 숨김 */
  .adminbar { font-size: 11px; padding: 6px 12px; line-height: 1.5; }
  .adminbar .ab-hint { display: none; }           /* 모바일: 설명 문구 숨김 */

  .weekday { padding: 6px 1px; font-size: 10px; text-align: center; }
  .grid { flex: 0 0 auto; }                 /* 그리드는 자기 높이만큼만 */
  .week { min-height: 62px; }
  .cell {
    padding: 2px 1px 3px; cursor: pointer;
    -webkit-tap-highlight-color: transparent; align-items: stretch;
  }
  .cell.selected { background: #eaf3fe; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 4px; }
  .daynum { font-size: 10px; padding: 0 0 1px 2px; align-self: flex-start; }
  .today-num { min-width: 17px; height: 17px; padding: 0 5px; }

  .events { display: none; }       /* 텍스트 목록 숨김 (팝업 소스로만 사용) */
  .cell-chips { display: flex; }    /* 칸 안 일정 칩 노출 */
}
