/* RSVP app: one small hand-written stylesheet, mobile-first, no CDN. Nothing here relies on inline styles (CSP). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --line: #d9dee6;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok-bg: #e6f4ea;   --ok-text: #14532d;
  --warn-bg: #fff4d6; --warn-text: #7a4b00;
  --err-bg: #fde7e5;  --err-text: #8a1c14;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b212a;
    --text: #e8ecf2;
    --muted: #9aa5b5;
    --line: #2f3844;
    --accent: #6ea3ff;
    --accent-text: #08101c;
    --danger: #ff8a80;
    --ok-bg: #12301d;   --ok-text: #a8e6bb;
    --warn-bg: #3a2c08; --warn-text: #ffd98a;
    --err-bg: #3a1613;  --err-text: #ffb4ab;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 1rem 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0.5rem 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.small { font-size: 0.8rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 16px 48px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.site-header .wrap { padding-bottom: 0; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 56px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.tag { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: var(--accent); color: var(--accent-text); border-radius: 4px; padding: 1px 6px; vertical-align: 2px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.nav a, .link { color: var(--accent); text-decoration: none; font: inherit; padding: 10px 0; min-height: 44px; display: inline-flex; align-items: center; }
.link { background: none; border: 0; cursor: pointer; }
form.inline { display: inline; margin: 0; }

/* cards and layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.narrow { max-width: 28rem; margin-left: auto; margin-right: auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.page-head h1 { margin-right: auto; }
.grid2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
ul.plain { list-style: none; padding: 0; margin: 0; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin: 0 0 14px; }
input[type="text"], input[type="tel"], input[type="url"], input[type="number"], input[type="search"],
input[type="password"], input[type="date"], input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.family { border-top: 1px solid var(--line); padding-top: 12px; }
.choice { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; margin: 0; }
.choice input { width: 22px; height: 22px; flex: none; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 4px 0 0; }
.field-error { color: var(--err-text); font-size: 0.875rem; margin: 4px 0 0; }
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix { display: inline-flex; align-items: center; padding: 0 10px; background: var(--bg); border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); }
.prefixed input { border-radius: 0 8px 8px 0; }
.search { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.search input[type="search"], .search select { flex: 1 1 12rem; width: auto; }
.filters { display: grid; gap: 0 16px; grid-template-columns: 1fr; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-small { min-height: 36px; padding: 4px 12px; }

/* messages */
.flash { border-radius: 8px; padding: 10px 14px; margin: 12px 0; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-warning { background: var(--warn-bg); color: var(--warn-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.banner { border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.banner-cancelled { background: var(--err-bg); color: var(--err-text); border: 1px solid var(--err-text); }

/* badges */
.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); white-space: nowrap; }
.badge-going, .badge-published, .badge-import-new { background: var(--ok-bg); color: var(--ok-text); }
.badge-interested, .badge-draft, .badge-import-exists { background: var(--warn-bg); color: var(--warn-text); }
.badge-not_going, .badge-cancelled, .badge-import-invalid, .badge-import-duplicate { background: var(--err-bg); color: var(--err-text); }
.badge-none, .badge-inactive { background: var(--line); color: var(--muted); }

/* guest event list and page */
.event-card { padding: 0; }
.event-link { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 8px; text-decoration: none; color: var(--text); }
.event-title { font-weight: 700; font-size: 1.05rem; }
.event-when { color: var(--accent); }
.event-meta { padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.facts { display: grid; grid-template-columns: 1fr; margin: 0; }
.facts dt { font-weight: 600; color: var(--muted); font-size: 0.875rem; margin-top: 10px; }
.facts dt:first-child { margin-top: 0; }
.facts dd { margin: 0; }
.description { white-space: pre-line; margin-top: 16px; }
.last-changed { font-size: 0.9rem; margin-top: 16px; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: 0.85rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 16px; }
.tab { padding: 10px 14px; text-decoration: none; color: var(--text); border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: 0; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.tab-active { background: var(--surface); border-color: var(--line); font-weight: 700; }
.tab-n { font-size: 0.8rem; background: var(--line); border-radius: 999px; padding: 0 7px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.note { max-width: 18rem; overflow-wrap: anywhere; }
tr.inactive td { color: var(--muted); opacity: 0.7; }
.row-actions { white-space: nowrap; }
details summary { cursor: pointer; color: var(--accent); min-height: 32px; }
.set-rsvp { display: grid; gap: 8px; min-width: 14rem; padding: 8px 0; white-space: normal; }
.set-rsvp .choice { min-height: 32px; }

@media (min-width: 40rem) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); align-items: end; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .facts { grid-template-columns: 9rem 1fr; }
  .facts dt { margin-top: 0; padding: 4px 0; }
  .facts dd { padding: 4px 0; }
  .btn-block { display: inline-flex; width: auto; }
}
