@import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@400;600&family=SF+Pro+Text:wght@400;600&display=swap');

:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --line: #e5e5ea;
  --accent: #0a84ff;
  --event: #e8f2ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.title { font-weight: 600; }
.subtitle { font-size: 12px; color: var(--muted); }

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  border: 1px solid var(--line);
  background: #fafafa;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.main {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

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

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.view-title { font-size: 22px; font-weight: 600; }
.view-sub { color: var(--muted); font-size: 14px; }

.nav button {
  border: 1px solid var(--line);
  background: white;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: 6px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.month-cell {
  background: var(--panel);
  min-height: 120px;
  padding: 8px;
  display: grid;
  grid-auto-rows: min-content;
  gap: 6px;
}

.month-cell .date {
  font-size: 12px;
  color: var(--muted);
}

.event-chip {
  background: var(--event);
  border-left: 3px solid var(--accent);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.week-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 240px;
}

.week-col .day-label {
  font-weight: 600;
  margin-bottom: 8px;
}

.day-list {
  display: grid;
  gap: 10px;
}

.day-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.day-card .time { font-weight: 600; color: var(--accent); }

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.admin-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.admin-row input {
  flex: 1 1 240px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-row button,
#addCalendar,
#reloadBtn,
#copyLink,
#unlockBtn,
#setPassBtn {
  border: 1px solid var(--line);
  background: white;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.sync-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.locked {
  color: var(--muted);
  margin-bottom: 10px;
}

.hidden { display: none; }

.calendar-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-item input {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.calendar-item button {
  border: 1px solid var(--line);
  background: #fff0f0;
  color: #b42318;
  border-radius: 6px;
  cursor: pointer;
  padding: 6px 8px;
}

.small { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show { opacity: 1; }

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: grid;
  justify-items: end;
  align-items: stretch;
  padding: 0;
  z-index: 20;
}

.drawer.hidden {
  display: none;
}

.drawer-card {
  background: var(--panel);
  width: min(420px, 92vw);
  height: 100%;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.2);
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  margin-bottom: 10px;
}

.drawer-title {
  font-size: 18px;
  font-weight: 600;
}

.drawer-sub {
  color: var(--muted);
  font-size: 13px;
}

.drawer-close {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.drawer-row {
  margin: 8px 0;
  font-size: 14px;
}

.drawer-notes {
  margin-top: 10px;
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--ink);
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

@media (max-width: 820px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tabs { flex-wrap: wrap; }
  .month-grid { grid-template-columns: repeat(2, 1fr); }
  .week-grid { grid-template-columns: repeat(1, 1fr); }
  .calendar-item { grid-template-columns: 1fr; }
}
