@import url("https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@400;500;600&family=Noto+Sans+KR:wght@400;500;600;700&display=swap");

*, *::before, *::after { box-sizing: border-box; }

:root {
  --g-blue: #1a73e8;
  --g-blue-hover: #1765cc;
  --g-red: #d50000;
  --g-bg: #f8fafd;
  --g-border: #dadce0;
  --g-text: #3c4043;
  --g-muted: #70757a;
  --g-today: #1a73e8;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-lg: 0 4px 16px rgba(60,64,67,.2), 0 8px 24px rgba(60,64,67,.12);
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "Noto Sans KR", "Google Sans Flex", Roboto, sans-serif;
  background: var(--g-bg);
  color: var(--g-text);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 헤더 */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--g-border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4285f4, #34a853 50%, #fbbc04 75%, #ea4335);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon svg { width: 22px; height: 22px; fill: #fff; }

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  color: #5f6368;
  letter-spacing: -0.02em;
}

.brand h1 span { color: var(--g-text); font-weight: 500; }

.nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon, .btn-text {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  border-radius: 50%;
  transition: background .15s;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-muted);
}

.btn-icon:hover { background: #f1f3f4; }

.btn-icon svg { width: 20px; height: 20px; fill: currentColor; }

.btn-today {
  padding: 8px 16px;
  border: 1px solid var(--g-border);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--g-text);
  background: #fff;
  margin-left: 4px;
}

.btn-today:hover { background: #f8f9fa; }

.month-label {
  font-size: 22px;
  font-weight: 400;
  color: var(--g-text);
  min-width: 180px;
  margin-left: 8px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 0 16px;
  height: 48px;
  border: none;
  border-radius: 24px;
  background: var(--g-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .15s, box-shadow .15s;
}

.btn-primary:hover {
  background: var(--g-blue-hover);
  box-shadow: var(--shadow-lg);
}

.btn-primary svg { width: 20px; height: 20px; fill: #fff; }

/* 캘린더 본문 */
.main {
  flex: 1;
  padding: 16px 20px 24px;
  overflow: auto;
}

.calendar-wrap {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--g-border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--g-border);
  background: #fff;
}

.weekday {
  padding: 10px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--g-muted);
  text-transform: uppercase;
}

.weekday.sun { color: var(--g-red); }

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(110px, 1fr);
}

.day-cell {
  min-height: 110px;
  border-right: 1px solid var(--g-border);
  border-bottom: 1px solid var(--g-border);
  padding: 4px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
  overflow: hidden;
}

.day-cell:nth-child(7n) { border-right: none; }

.day-cell:hover { background: #f8f9fa; }

.day-cell.other-month { background: #fafafa; }
.day-cell.other-month .day-num { color: #bdc1c6; }

.day-cell.today { background: #e8f0fe; }

.day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 2px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--g-text);
  border-radius: 50%;
}

.day-cell.today .day-num {
  background: var(--g-today);
  color: #fff;
}

.day-cell.sun .day-num { color: var(--g-red); }
.day-cell.other-month.sun .day-num { color: #e8a0a0; }

.events-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px 4px;
}

.event-chip {
  font-size: 11px;
  line-height: 1.3;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}

.event-chip:hover { filter: brightness(0.92); }

.event-chip.has-img::before {
  content: "📷 ";
  font-size: 10px;
}

.more-count {
  font-size: 11px;
  color: var(--g-muted);
  padding: 2px 6px;
}

/* 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  color: var(--g-muted);
  line-height: 1;
}

.modal-close:hover { background: #f1f3f4; }

.modal-body { padding: 20px 24px 24px; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--g-muted);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--g-border);
  border-radius: 8px;
  color: var(--g-text);
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--g-blue);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.field textarea { resize: vertical; min-height: 72px; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.color-picks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-pick {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s;
}

.color-pick:hover { transform: scale(1.1); }
.color-pick.active { border-color: #202124; box-shadow: 0 0 0 2px #fff inset; }

.image-zone {
  border: 2px dashed var(--g-border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}

.image-zone:hover,
.image-zone.dragover {
  border-color: var(--g-blue);
  background: #e8f0fe;
}

.image-zone input { display: none; }

.image-zone p {
  margin: 0;
  font-size: 13px;
  color: var(--g-muted);
}

.image-preview {
  margin-top: 12px;
  display: none;
  position: relative;
}

.image-preview.show { display: block; }

.image-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}

.image-preview .remove-img {
  margin-top: 8px;
  font-size: 12px;
  color: var(--g-red);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  gap: 12px;
}

.modal-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-danger {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--g-red);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.btn-danger:hover { background: #fce8e6; }

.btn-secondary {
  padding: 10px 20px;
  border: 1px solid var(--g-border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  color: var(--g-text);
}

.btn-secondary:hover { background: #f8f9fa; }

.btn-save {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--g-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.btn-save:hover { background: var(--g-blue-hover); }
.btn-save:disabled { opacity: 0.6; cursor: not-allowed; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  .month-label { font-size: 18px; min-width: 140px; }
  .days-grid { grid-auto-rows: minmax(80px, 1fr); }
  .day-cell { min-height: 80px; }
  .row-2 { grid-template-columns: 1fr; }
}

/* sidebar menu */
.app {
  flex-direction: row;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--g-border);
  padding: 16px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  z-index: 200;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  font-size: 18px;
  font-weight: 500;
  color: var(--g-text);
  border-bottom: 1px solid var(--g-border);
}

.side-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 0 24px 24px 0;
  color: var(--g-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s;
}

.menu-item svg {
  width: 20px;
  height: 20px;
  fill: var(--g-muted);
  flex-shrink: 0;
}

.menu-item:hover { background: #f1f3f4; }

.menu-item.active {
  background: #e8f0fe;
  color: var(--g-blue);
}

.menu-item.active svg { fill: var(--g-blue); }

/* mini calendar in menu */
.mini-cal-box {
  padding: 8px 4px 0;
  border-top: 1px solid var(--g-border);
}

.mini-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.mini-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--g-text);
}

.mini-nav {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  color: var(--g-muted);
  line-height: 1;
}

.mini-nav:hover { background: #f1f3f4; }

.mini-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  color: var(--g-muted);
  margin-bottom: 4px;
}

.mini-weekdays span:first-child { color: var(--g-red); }

.mini-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-day {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 11px;
  color: var(--g-text);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.mini-day:hover { background: #f1f3f4; }

.mini-day.other { color: #bdc1c6; }

.mini-day.today {
  background: var(--g-blue);
  color: #fff;
}

.mini-day.selected {
  outline: 2px solid var(--g-blue);
  outline-offset: -2px;
}

.mini-day.has-event::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--g-blue);
  margin: 1px auto 0;
}

.mini-day.today.has-event::after { background: #fff; }

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.btn-menu {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  margin-right: 4px;
}

.btn-menu svg { width: 22px; height: 22px; fill: var(--g-muted); }

.btn-menu:hover { background: #f1f3f4; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
}

.view-panel { display: none; }
.view-panel.active { display: block; }

.list-wrap {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--g-border);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.list-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 500;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--g-border);
  cursor: pointer;
}

.event-list li:last-child { border-bottom: none; }

.event-list .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-list .info { flex: 1; min-width: 0; }

.event-list .info strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
}

.event-list .info span {
  font-size: 12px;
  color: var(--g-muted);
}

.event-list .empty-msg {
  padding: 40px 0;
  text-align: center;
  color: var(--g-muted);
  cursor: default;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.show { display: block; }

  .btn-menu { display: flex; align-items: center; justify-content: center; }
}