* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e9ecef;
  --border-hover: #d0d5dd;
  --text: #1a1a2e;
  --text-muted: #8b8fa3;
  --text-light: #b0b4c5;
  --primary: #4f6ef7;
  --primary-light: #eef1ff;
  --primary-dark: #3b55d9;
  --red: #ef4444;
  --red-light: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.12), 0 4px 20px rgba(0,0,0,0.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.sidebar-header { margin-bottom: 24px; }

.btn-new {
  width: 100%;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.btn-new:hover { background: var(--primary-dark); }

.btn-new-inline {
  margin-top: 12px;
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

.sidebar-section { margin-bottom: 20px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upcoming-list { display: flex; flex-direction: column; gap: 6px; }

.upcoming-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.upcoming-item:hover { background: var(--bg); }
.upcoming-item .title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.upcoming-item .time {
  font-size: 11px;
  color: var(--text-muted);
}
.upcoming-empty {
  font-size: 13px;
  color: var(--text-light);
  padding: 12px;
}

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-toggle { display: none; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-nav h2 {
  font-size: 18px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

.nav-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.nav-arrow:hover { border-color: var(--text-muted); color: var(--text); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-today {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  color: var(--text);
}
.btn-today:hover { border-color: var(--text-muted); }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.12s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* Weekdays */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 12px 16px 6px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Grid */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  overflow-y: auto;
  background: var(--surface);
}

.day-cell {
  min-height: 100px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.day-cell:nth-child(7n) { border-right: none; }
.day-cell:hover { background: var(--bg); }
.day-cell.other { opacity: 0.35; }

.day-cell .num {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell.today .num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-weight: 600;
}

.day-cell .dots {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-cell .dot {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  line-height: 1.6;
}

.day-cell .dot.more {
  background: transparent;
  color: var(--text-light);
  font-size: 10px;
  padding: 0 6px;
}

/* Day Detail Modal */
.day-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-event-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  gap: 12px;
  transition: background 0.12s;
}
.day-event-row:hover { background: var(--border); }

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

.day-event-info .title {
  font-size: 14px;
  font-weight: 600;
}

.day-event-info .time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.day-event-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.day-event-actions .icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 14px;
}
.day-event-actions .icon-btn.edit:hover { background: var(--primary-light); color: var(--primary); }
.day-event-actions .icon-btn.del:hover { background: var(--red-light); color: var(--red); }

.day-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
}

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.2s ease;
}

.modal-day {
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-day .modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
}
.modal-head h3 { font-size: 17px; font-weight: 600; }

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

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}
.modal-input:focus { outline: none; border-color: var(--primary); }
.modal-input::placeholder { color: var(--text-light); }

.modal-row {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.modal-row-eq {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 460px) {
  .modal-row-eq {
    grid-template-columns: 1fr;
  }
}

.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.modal-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  margin-top: 12px;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
}
.modal-textarea:focus { outline: none; border-color: var(--primary); }
.modal-textarea::placeholder { color: var(--text-light); }

.modal-foot {
  display: flex;
  justify-content: space-between;
  padding: 0 24px 20px;
}

.modal-foot-right { display: flex; gap: 8px; }

.btn-cancel {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s;
}
.btn-cancel:hover { border-color: var(--text-muted); }

.btn-save {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.btn-save:hover { background: var(--primary-dark); }

.btn-del {
  padding: 8px 16px;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.btn-del:hover { background: var(--red-light); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  background: #1a1a2e;
  color: white;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Loading */
.loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #sidebar.open { display: flex; position: fixed; inset: 0; z-index: 100; width: 100%; }
  .sidebar-toggle { display: flex; }
  .day-cell { min-height: 70px; padding: 4px 6px; }
  .topbar { padding: 12px 16px; }
  .day-cell .dot { font-size: 8px; padding: 1px 4px; }
  .modal-day { max-width: 95%; }
}
