:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-border: #e2e2e7;
  --color-text: #1c1c1f;
  --color-text-muted: #6b6b75;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-danger: #dc2626;
  --color-slot-empty: #ffffff;
  --color-slot-hover: #ede9fe;
  --color-slot-selected: #4f46e5;
  --color-slot-selected-text: #ffffff;
  --color-others-marked: #e3e3e8;
  --color-others-marked-hover: #d7d7de;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* --- Login page --- */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.muted {
  color: var(--color-text-muted);
  margin: 0 0 8px;
  font-size: 14px;
}

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.error-text {
  color: var(--color-danger);
  font-size: 13px;
  margin: 0;
}

/* --- Top bar --- */

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

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

main#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

/* --- Buttons --- */

.btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
}

.btn:hover {
  background: #f4f4f6;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: transparent;
}

.btn-text {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
}

.btn-text:hover {
  color: var(--color-danger);
  background: transparent;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Event list --- */

.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: 60px 0;
}

.event-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.event-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.event-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.event-card-name {
  margin: 0 0 4px;
  font-size: 16px;
}

.event-card-location {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.event-card-location:empty {
  display: none;
}

.event-card-meta {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* --- Form (new event) --- */

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-row input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  font-size: 14px;
  margin-bottom: 16px;
  padding: 0;
}

.back-link:hover {
  color: var(--color-text);
}

.page-heading {
  font-size: 20px;
  margin: 0 0 4px;
}

.page-subheading {
  color: var(--color-text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}

/* --- Week navigation (for the day/hour picker) --- */

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.week-nav-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.week-nav-label {
  font-size: 14px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

.hour-range-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.hour-range-controls select {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

/* --- Calendar grid (shared by create + respond views) --- */

.calendar-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  user-select: none;
}

.calendar-scroll {
  overflow-x: auto;
}

.calendar-grid {
  display: grid;
  min-width: 600px;
}

.cal-header-row {
  display: grid;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 5;
}

.cal-corner {
  border-right: 1px solid var(--color-border);
}

.cal-day-header {
  text-align: center;
  padding: 8px 4px;
  border-right: 1px solid var(--color-border);
  font-size: 12px;
}

.cal-day-header .dow {
  font-weight: 600;
  color: var(--color-text);
  display: block;
}

.cal-day-header .dom {
  color: var(--color-text-muted);
  display: block;
  font-size: 11px;
}

.cal-body {
  display: grid;
  grid-template-columns: 56px 1fr;
}

.cal-hours-col {
  display: grid;
  border-right: 1px solid var(--color-border);
}

.cal-hour-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: right;
  padding: 0 8px;
  position: relative;
  top: -6px;
}

.cal-days-area {
  display: grid;
  position: relative;
}

.cal-day-col {
  border-right: 1px solid var(--color-border);
  display: grid;
}

.cal-day-col:last-child {
  border-right: none;
}

.cal-slot {
  border-bottom: 1px solid #f0f0f3;
  background: var(--color-slot-empty);
  position: relative;
}

.cal-slot:nth-child(2n) {
  background: #fcfcfd;
}

.cal-slot.selectable:hover {
  background: var(--color-slot-hover);
}

/* Grey underlay showing slots OTHER respondents picked, visible while a
   person is choosing their own availability. Declared before .selected so
   that if a cell is both "marked by others" and the current user's own
   selection, the purple .selected style wins visually. */
.cal-slot.others-marked {
  background: var(--color-others-marked);
}

.cal-slot.others-marked:hover {
  background: var(--color-others-marked-hover);
}

.others-count-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  line-height: 1;
  color: var(--color-text-muted);
  font-weight: 600;
  pointer-events: none;
}

.cal-slot.selected {
  background: var(--color-slot-selected);
}

.cal-slot.selected .others-count-badge {
  color: rgba(255, 255, 255, 0.75);
}

.cal-slot.selected:hover {
  background: var(--color-primary-hover);
}

/* Heatmap intensity levels for the "view responses" grid */
.cal-slot.heat-0 { background: var(--color-slot-empty); }
.cal-slot.heat-1 { background: #ede9fe; }
.cal-slot.heat-2 { background: #c7bdf7; }
.cal-slot.heat-3 { background: #a394f1; }
.cal-slot.heat-4 { background: #7c6aea; }
.cal-slot.heat-5 { background: var(--color-primary); }

.cal-slot.heat-count {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: rgba(0,0,0,0.55);
}

.cal-slot.heat-5 .heat-label, .cal-slot.heat-4 .heat-label {
  color: rgba(255,255,255,0.9);
}

/* --- Respond view --- */

.respond-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 800px) {
  .respond-layout {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 80px;
}

.sidebar h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.respondent-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.respondent-list li {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  background: #f6f5fb;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  border: none;
  background: none;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 10px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}
