:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #dcdad3;
  --row-alt: #faf9f6;
  --accent: #ffaa22;
  --accent-hover: #f29a0c;
  --accent-text: #1d1d1b;
  --error: #b3261e;
  --error-bg: #fdecea;
  --ok: #1b6e3a;
  --ok-bg: #e6f4ea;
  --warn: #7a4f00;
  --warn-bg: #fff4dc;
  --info: #1a4f8b;
  --info-bg: #e7effa;
  --radius: 10px;
  --focus: 0 0 0 3px rgb(255 170 34 / 0.5);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

[hidden] {
  display: none !important;
}

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

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.15rem;
}

a {
  color: inherit;
}

/* ---------- layout ---------- */

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.shell.wide {
  max-width: 1200px;
  padding-top: 24px;
}

.masthead {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.card > h2 {
  margin-bottom: 16px;
}

.card.narrow {
  max-width: 420px;
  margin: 48px auto;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
}

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

.done p {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.done p:first-child {
  font-weight: 600;
}

/* ---------- form controls ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--accent-hover);
}

button {
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--accent-hover);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

button.ghost {
  background: transparent;
  border-color: var(--border);
}

button.ghost:hover {
  background: var(--row-alt);
}

.error {
  margin: 0;
  color: var(--error);
  font-style: italic;
}

.error:empty {
  display: none;
}

.banner {
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 8px;
  background: var(--error-bg);
  font-style: normal;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.copy-row button {
  flex: none;
}

/* ---------- question tables ---------- */

.questions {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.questions th {
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 8px;
  border-bottom: 2px solid var(--border);
}

.questions td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.questions td:last-child {
  width: 9rem;
}

.questions tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.question-label {
  font-weight: 700;
  margin-right: 4px;
}

.warning {
  margin: 8px 0 0;
  font-weight: 700;
}

.answer {
  font-weight: 600;
}

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

.answer-missing {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 640px) {
  .card {
    padding: 18px 16px;
  }

  .questions thead {
    display: none;
  }

  .questions,
  .questions tbody,
  .questions tr,
  .questions td {
    display: block;
    width: 100%;
  }

  .questions tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }

  .questions tbody tr:nth-child(even) {
    background: none;
  }

  .questions td {
    padding: 0;
    border: 0;
  }

  .questions td:last-child {
    width: 100%;
    padding-top: 10px;
  }
}

/* ---------- admin ---------- */

.topbar {
  background: var(--text);
  color: #fff;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.topbar .brand {
  font-weight: 700;
  text-decoration: none;
  font-size: 1.05rem;
}

.topbar .brand span {
  color: var(--accent);
}

.topbar button.ghost {
  color: #fff;
  border-color: rgb(255 255 255 / 0.35);
}

.topbar button.ghost:hover {
  background: rgb(255 255 255 / 0.1);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-grid .stack {
  max-width: none;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.result {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.notice.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.notice.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

input[type='search'] {
  max-width: 260px;
}

.table-wrap {
  overflow-x: auto;
}

.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.list th {
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 8px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.list td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.list tbody tr {
  cursor: pointer;
}

.list tbody tr:hover {
  background: var(--row-alt);
}

.list a {
  font-weight: 600;
  text-decoration: none;
}

.list a:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-sent {
  background: var(--row-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.status-started {
  background: var(--info-bg);
  color: var(--info);
}

.status-answered {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-complete {
  background: var(--ok-bg);
  color: var(--ok);
}

.back {
  display: inline-block;
  margin-bottom: 16px;
  font-weight: 600;
  text-decoration: none;
}

.back:hover {
  text-decoration: underline;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 0 0 20px;
}

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

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
}

@media (max-width: 640px) {
  /* Invite list becomes stacked rows: name + status, then email, then dates. */
  .list thead {
    display: none;
  }

  .list,
  .list tbody {
    display: block;
  }

  .list tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
  }

  .list td {
    padding: 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .list td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .list td:nth-child(2),
  .list td:nth-child(4),
  .list td:nth-child(5) {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.9rem;
  }

  .list td:nth-child(4)::before {
    content: 'Created ';
  }

  .list td:nth-child(5)::before {
    content: 'Completed ';
  }

  .facts {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .facts dd {
    margin-bottom: 10px;
  }

  input[type='search'] {
    max-width: none;
  }
}
