:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #d7dce3;
  --accent: #3f00ff; /* ultramarine blue */
  --accent-soft: #e3dcff;
  --accent-border: #c6b3ff;
  --accent-strong: #2b168c;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 8px;
  flex-wrap: wrap;
}

.brand { font-size: 20px; font-weight: 700; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tab, .nav-btn, button, input[type="color"] {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-btn { padding: 8px 10px; }
.logout { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; }

.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  padding: 12px;
}

.calendar-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-height: 600px;
}

.notes-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.notes-section { margin-bottom: 14px; }
.notes-section:last-child { margin-bottom: 0; }
.notes-subheader { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.notes-title { font-weight: 700; }
.notes-subtext { font-size: 13px; color: var(--muted); }

.notes-form textarea, .notes-form input[type="text"], .notes-form input[type="datetime-local"], .notes-form input[type="password"], .notes-form input[type="date"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  resize: none;
}

.notes-form button { margin-top: 12px; }
.status { margin-top: 8px; color: var(--muted); font-size: 13px; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.view h2 { margin: 0; }

.timeline {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  height: 1440px;
  overflow-y: auto;
}

.hour-row {
  position: relative;
  height: 60px;
  border-bottom: 1px dashed var(--border);
  padding-left: 60px;
  color: var(--muted);
  font-size: 12px;
}

.hour-label { position: absolute; left: 12px; top: 6px; font-weight: 600; }

.event-block {
  position: absolute;
  left: 70px;
  right: 12px;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: #1f2937;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.event-block .time { font-size: 12px; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 6px;
}

.day-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.day-cell .date-num { font-weight: 700; }
.day-cell .event-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  border: 1px solid var(--accent-border);
}

.notes-header h2 { margin: 0 0 8px; }

.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.danger { background: var(--danger); color: #fff; border-color: var(--danger); }

.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  width: min(500px, 90vw);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; }
.modal-header button { background: transparent; border: none; font-size: 20px; cursor: pointer; }

#eventForm label { display: block; margin-top: 10px; font-weight: 600; }
#eventForm input[type="text"],
#eventForm input[type="datetime-local"],
#eventForm textarea,
#eventForm input[type="color"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.checkbox { display: flex; align-items: center; gap: 6px; font-weight: 500; }

.modal-actions { display: flex; gap: 8px; margin-top: 12px; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-container { width: 360px; padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.auth-container h1 { margin-top: 0; text-align: center; }
.panel { display: grid; gap: 10px; }
.panel button { width: 100%; }
.alert { padding: 10px; border-radius: 6px; margin-bottom: 10px; }
.alert.error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .calendar-panel { min-height: 500px; }
  .timeline { height: 900px; }
  .controls { flex-wrap: wrap; gap: 6px; }
  .controls .tab, .controls .nav-btn, .controls input[type="date"], .controls .logout { width: auto; }
  .month-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .day-cell { min-height: 100px; }
  .notes-panel { order: 2; }
}

@media (max-width: 640px) {
  .top-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .controls { width: 100%; }
  .controls input[type="date"] { flex: 1; min-width: 140px; }
  .controls .logout { display: none; }
  .layout { padding: 8px; gap: 8px; }
  .calendar-panel, .notes-panel { padding: 10px; }
  .month-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .event-block { left: 60px; right: 8px; }
}
