:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #23272f;
  --border: #2e333d;
  --text: #f2f3f5;
  --text-dim: #9aa0ab;
  --accent: #4f8cff;
  --yes: #2fb872;
  --no: #e5484d;
  --maybe: #d8a33d;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --border: #e1e3e8;
    --text: #16181d;
    --text-dim: #666d78;
    --accent: #2f6fed;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: 2rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.9rem 1rem 0;
}

.topbar h1 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.65rem 0.5rem;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.view.hidden {
  display: none;
}

.prompt {
  font-size: 1rem;
  color: var(--text-dim);
  margin: 0.25rem 0 1rem;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

@media (min-width: 480px) {
  .name-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.name-btn {
  padding: 0.9rem 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.name-btn:active {
  background: var(--surface-2);
}

.hidden {
  display: none !important;
}

#current-name {
  color: var(--accent);
  font-weight: 700;
}

.date-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.date-row .date-label {
  font-weight: 600;
  white-space: nowrap;
}

.status-group {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  justify-content: flex-end;
}

.status-btn {
  flex: 1;
  max-width: 4.5rem;
  padding: 0.55rem 0.3rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.status-btn[data-status="yes"].selected {
  background: var(--yes);
  border-color: var(--yes);
  color: #fff;
}

.status-btn[data-status="maybe"].selected {
  background: var(--maybe);
  border-color: var(--maybe);
  color: #fff;
}

.status-btn[data-status="no"].selected {
  background: var(--no);
  border-color: var(--no);
  color: #fff;
}

.submit-btn {
  width: 100%;
  margin-top: 1.1rem;
  padding: 0.9rem;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.submit-btn:active {
  opacity: 0.85;
}

.save-status {
  min-height: 1.2rem;
  text-align: center;
  color: var(--yes);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.link-btn {
  display: block;
  margin: 1rem auto 0;
  background: none;
  border: none;
  color: var(--text-dim);
  text-decoration: underline;
  font-size: 0.9rem;
  cursor: pointer;
}

.results-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.results-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

table.results-table th,
table.results-table td {
  padding: 0.5rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.results-table th.date-col {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
}

table.results-table td.date-col {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
}

table.results-table thead th {
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
}

table.results-table tbody tr:nth-child(even) {
  background: var(--surface);
}

table.results-table tbody tr.best-date {
  background: color-mix(in srgb, var(--yes) 18%, var(--surface));
}

.cell-yes { color: var(--yes); font-weight: 700; }
.cell-no { color: var(--no); opacity: 0.6; }
.cell-maybe { color: var(--maybe); font-weight: 700; }
.cell-blank { color: var(--text-dim); opacity: 0.4; }

.summary-col {
  font-weight: 700;
  color: var(--text);
}
