:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #24211e;
  --muted: #6b645c;
  --border: #dcd6ce;
  --accent: #5b3fa8;
  --accent-text: #ffffff;
  --error: #b3261e;
  --free: #b7e4c0;
  --maybe: #fbe69a;
  --busy: #f4b4ad;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh; /* dvh ignores the phone browser's collapsing address bar */
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.25rem;
}

h2 {
  font-size: 1.5rem;
}

.loading,
.muted {
  color: var(--muted);
}

.logo {
  display: block;
  width: 100%;
  height: auto;
}

.topbar .logo {
  width: auto;
  height: 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen p {
  margin: 0;
}

.login {
  padding-top: 15vh;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-weight: 600;
}

/* Under 16px, iOS zooms the page when the field is focused. */
input,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  padding: 12px;
  resize: vertical;
}

button {
  min-height: var(--tap);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-text);
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.button-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}

.text-button {
  min-width: var(--tap);
  padding: 0 8px;
  background: none;
  color: var(--accent);
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 10px;
  background: var(--border);
}

.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  background: var(--surface);
}

.selector {
  margin-bottom: 0;
}

.selector a {
  padding: 4px;
  font-size: 0.875rem;
  line-height: 1.2;
  text-align: center;
}

h3 {
  margin: 8px 0 0;
  font-size: 1.0625rem;
  line-height: 1.3;
}

.night-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.night {
  display: block;
  min-height: var(--tap);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.night-day {
  font-weight: 600;
}

.needs-answer {
  color: var(--accent);
  font-weight: 600;
}

.plan-note {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
}

.event-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status {
  flex-shrink: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--maybe);
  font-size: 0.8125rem;
  font-weight: 600;
}

.status[data-status="confirmed"] {
  background: var(--free);
}

.status[data-status="cancelled"] {
  background: var(--busy);
}

.event-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#event-notes {
  white-space: pre-wrap; /* keeps the line breaks people typed */
}

.rsvp-list {
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  list-style: none;
}

.rsvp-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.rsvp-list li + li {
  border-top: 1px solid var(--border);
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.choice-row:empty,
.event-actions:empty,
.calendar-action:empty {
  display: none;
}

.secondary {
  width: 100%;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
}

.choice {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.event-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.danger {
  width: 100%;
  border: 1px solid var(--error);
  background: none;
  color: var(--error);
}

.choice:disabled,
.secondary:disabled,
.danger:disabled {
  opacity: 0.6;
  cursor: default;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.month-nav h2 {
  font-size: 1.25rem;
}

.nav-button {
  width: var(--tap);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.5rem;
}

.nav-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.calendar-head,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-head {
  margin-bottom: -12px; /* tucks the weekday letters up against the grid */
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.calendar {
  min-height: 340px; /* keeps the page from jumping while a month loads */
  align-content: start;
  touch-action: pan-y; /* the page scrolls vertically; sideways is our swipe */
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.day:disabled {
  opacity: 0.4;
  cursor: default;
}

.day.today {
  border: 2px solid var(--accent);
}

.day[data-status="free"] {
  background: var(--free);
}

.day[data-status="maybe"] {
  background: var(--maybe);
}

.day[data-status="busy"] {
  background: var(--busy);
}

/* The word backs up the color, so red and green don't rely on color vision. */
.day-status {
  min-height: 1em;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1;
}

.error {
  color: var(--error);
}

.error:empty {
  display: none;
}
