:root {
  --bg: #f7f7f5;
  --fg: #1f2328;
  --muted: #6b7280;
  --border: #d9d9d4;
  --card: #ffffff;
  --accent: #2b6cb0;
  --yes: #b6e3b6;
  --yes-fg: #1a5d1a;
  --maybe: #f6e3a1;
  --maybe-fg: #7a5a00;
  --no: #f4b4b4;
  --no-fg: #8b1a1a;
  --blank: #ececea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

button {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Calendar */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
}
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day.past  { color: #bbb; cursor: not-allowed; background: #fafaf8; }
.cal-day.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.cal-day.today { box-shadow: 0 0 0 2px #2b6cb033 inset; }

.selected-summary { margin-top: 10px; font-size: 0.9rem; color: var(--muted); }

/* Grid */
.grid-wrap { overflow-x: auto; }
table.grid {
  border-collapse: separate;
  border-spacing: 4px;
  margin-top: 8px;
}
table.grid th, table.grid td {
  padding: 0;
  text-align: center;
  vertical-align: middle;
}
table.grid th.name-col, table.grid td.name-col {
  text-align: left;
  padding: 6px 8px;
  min-width: 120px;
  max-width: 200px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid th.day {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  padding: 4px;
  min-width: 52px;
}
table.grid th.day .dow { display: block; font-weight: 600; color: var(--fg); }
table.grid td.cell {
  width: 52px;
  height: 40px;
  background: var(--blank);
  border-radius: 6px;
  color: var(--fg);
  font-weight: 600;
  font-size: 1rem;
}
table.grid td.cell.yes   { background: var(--yes);   color: var(--yes-fg); }
table.grid td.cell.maybe { background: var(--maybe); color: var(--maybe-fg); }
table.grid td.cell.no    { background: var(--no);    color: var(--no-fg); }
table.grid tr.me td.cell { cursor: pointer; box-shadow: inset 0 0 0 2px #2b6cb055; }
table.grid tr.me td.name-col { color: var(--accent); font-weight: 700; }

table.grid th.action-col, table.grid td.action-col {
  padding: 0 0 0 8px;
  text-align: left;
  min-width: 140px;
}
.save-inline {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 6px;
  white-space: nowrap;
}

tr.summary td { font-size: 0.8rem; color: var(--muted); padding-top: 6px; vertical-align: top; }
tr.summary td .tally {
  display: block;
  line-height: 1.25;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
tr.summary td .tally.yes   { color: var(--yes-fg); }
tr.summary td .tally.maybe { color: var(--maybe-fg); }
tr.summary td .tally.no    { color: var(--no-fg); }
tr.summary td .tally.zero  { color: #c9c9c4; font-weight: 500; }
tr.summary td.best {
  background: #fff7d6;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #e7cf6a;
}

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.legend .swatch {
  display: inline-block;
  width: 14px; height: 14px; border-radius: 4px;
  vertical-align: middle; margin-right: 4px;
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar > * { flex: 0 0 auto; }
.toolbar .grow { flex: 1 1 auto; min-width: 120px; }

.flash {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 8px;
}
