:root {
  --fg: #1a1a1a;
  --bg: #fafafa;
  --muted: #666;
  --border: #d4d4d4;
  --accent: #10b981;
  --accent-soft: #6ee7b7;
  --danger: #fca5a5;
  --danger-fg: #b91c1c;
  --cell-empty: #eee;
}

* { box-sizing: border-box; }

body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-width: 960px;
  margin: auto;
  padding: 24px;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 16px 0 8px; }

a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger-fg); background: #fef2f2; border: 1px solid var(--danger); padding: 8px 12px; border-radius: 4px; margin: 8px 0; }

/* Landing */
.landing {
  max-width: 520px;
  margin: 48px auto;
  text-align: center;
}
.landing h1 { font-size: 2rem; margin-bottom: 4px; }
.landing .subtitle { color: var(--muted); margin-bottom: 32px; }
.landing form { text-align: left; margin-top: 24px; }

/* Forms */
form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 0.85rem; color: var(--muted); }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: white;
  color: var(--fg);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
button, .btn {
  font: inherit;
  padding: 10px 16px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: white;
  border-radius: 3px;
  cursor: pointer;
}
button:hover, .btn:hover { opacity: 0.88; }
button.secondary, .btn.secondary {
  background: white;
  color: var(--fg);
}
button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Datepicker */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; color: var(--muted); }
.datepicker {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: white;
  padding: 10px 12px;
  user-select: none;
}
.dp-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 10px;
}
.dp-mode-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.dp-mode-label select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.85rem;
}
.datepicker.mode-specific .dp-dow-wrap { display: none; }
.datepicker.mode-dow .dp-specific-wrap { display: none; }

.dp-weekdays {
  display: grid;
  grid-template-columns: 2.2em repeat(7, 1fr) 3em;
  gap: 2px;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
}
.dp-spec-grid {
  display: grid;
  grid-template-columns: 2.2em repeat(7, 1fr) 3em;
  gap: 2px;
}
.dp-week-label, .dp-week-year {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
}
.dp-day {
  aspect-ratio: 1;
  background: var(--cell-empty);
  border: none;
  border-radius: 2px;
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  padding: 0;
  cursor: pointer;
}
.dp-day.past { color: #bbb; cursor: not-allowed; background: transparent; }
.dp-day.selected { background: var(--accent); color: white; }
.dp-day:hover:not(.past):not(.selected) { background: var(--accent-soft); }
.dp-controls {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
.dp-controls button {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.dp-dow-hint { margin: 0 0 8px; font-size: 0.75rem; }
.dp-dow-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.dp-dow-col {
  height: 120px;
  background: var(--cell-empty);
  border: none;
  border-radius: 2px;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
}
.dp-dow-col .dp-dow-letter { font-weight: 600; font-size: 0.9rem; }
.dp-dow-col:hover:not(.selected) { background: var(--accent-soft); }
.dp-dow-col.selected { background: var(--accent); color: white; }

.dp-summary { margin-top: 10px; font-size: 0.75rem; }

/* Event page */
body:has(.event-page) { max-width: 1120px; }
.event-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: flex-start;
}
.event-page > header.event-header { grid-column: 1 / -1; margin-bottom: 8px; }
.event-page > .panel { min-width: 0; }
.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.share-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  max-width: 520px;
}
.share-url {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.85rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f4f4f4;
  color: var(--fg);
}
.copy-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: white;
  color: var(--fg);
  border: 1px solid var(--border);
}
.copy-btn.copied {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

@media (max-width: 900px) {
  .event-page { grid-template-columns: 1fr; }
}

/* Identify */
.identify {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}
.identify input { flex: 1 1 120px; }
.identify button { flex-shrink: 0; }
.me { font-size: 0.9rem; color: var(--muted); margin: 0 0 12px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
.linkish:hover { color: inherit; }
.hint { font-size: 0.85rem; padding: 10px 12px; background: #f0f0f0; border-radius: 3px; }

/* Grid (shared by personal + heatmap) */
.grid {
  display: grid;
  grid-template-columns: auto repeat(var(--cols), minmax(0, 1fr));
  gap: 2px;
  user-select: none;
}
.grid-corner { }
.grid-day-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 4px 2px;
  white-space: nowrap;
}
.grid-time-label {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0 6px 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 1;
  white-space: nowrap;
}
.cell {
  min-height: 22px;
  background: var(--cell-empty);
  cursor: pointer;
  border-radius: 1px;
}
.cell.selected { background: var(--accent); }
.cell.preview-add { background: var(--accent-soft); }
.cell.preview-remove { background: var(--danger); }
#grid.disabled .cell {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Heatmap cells (read-only) */
.heatmap .cell { cursor: default; }
.heatmap .cell.heat[data-count="0"] { background: var(--cell-empty); }
.heatmap .cell.heat:not([data-count="0"]) {
  background: rgba(16, 185, 129, var(--intensity, 0.2));
}
.heatmap .cell.heat:hover:not([data-count="0"]) {
  outline: 1px solid var(--fg);
}

/* Results */
.participant-list {
  font-size: 0.85rem;
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.participant-list .pill {
  display: inline-block;
  background: #eef2f7;
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 0.8rem;
}
.results-legend {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.results-legend .legend-swatch {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  background: rgba(16, 185, 129, var(--intensity, 0.2));
}
.best-slots { margin-top: 16px; }
.best-slots h3 { font-size: 0.9rem; margin: 0 0 6px; }
.best-slots ol { margin: 0; padding-left: 20px; font-size: 0.85rem; }
.best-slots li { margin-bottom: 2px; }
.best-slot-time { font-variant-numeric: tabular-nums; }
