:root {
  color-scheme: light dark;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d0d5dd;
  --brand: #8f1d2c;
  --brand-strong: #6f1421;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --panel: #171c22;
    --text: #edf2f7;
    --muted: #a0aec0;
    --line: #2d3748;
    --brand: #d74b5f;
    --brand-strong: #f06b7d;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
.shell { width: min(1120px, 100%); margin: 0 auto; padding: 18px; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; color: var(--brand); }
.nav-links { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.nav-links > a { padding: 8px 10px; border-radius: 6px; font-weight: 650; }
.nav-links > a:hover { background: var(--panel); color: var(--brand); }
.nav-links form { margin: 0 0 0 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.panel, .auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.auth-card { width: min(440px, 100%); margin: 8vh auto 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.button, button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.button.secondary, button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: #b42318; }
button.danger:hover { background: #8f1d14; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
}
label { display: grid; gap: 6px; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stat { font-size: 28px; font-weight: 800; color: var(--brand); }
.hero { min-height: 68vh; display: grid; align-items: center; }
.hero h1 { font-size: clamp(36px, 7vw, 72px); line-height: 1; margin: 0; letter-spacing: 0; }
.hero p { font-size: 18px; max-width: 640px; color: var(--muted); }
.error { color: #c2410c; font-weight: 700; }
.success { color: #16794a; font-weight: 700; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
.text-link { text-decoration: underline; text-underline-offset: 3px; }
.table-scroll { overflow-x: auto; }
.table-actions { margin-top: 14px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.checkbox-label input { width: auto; min-height: auto; }
.participant-list { display: grid; gap: 8px; min-width: 260px; }
.participant-list div { display: grid; gap: 2px; }
.detail-line { display: block; margin-top: 2px; }
.chapter-options {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.chapter-options legend { font-weight: 700; margin-bottom: 6px; }
.chapter-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.chapter-choice input { width: auto; }

@media (max-width: 640px) {
  .shell { padding: 12px; }
  .nav { align-items: flex-start; }
  .nav-links { justify-content: flex-end; }
  .auth-card, .panel { padding: 16px; }
  .auth-card { margin-top: 4vh; }
  h1 { font-size: 28px; line-height: 1.1; margin: 0; }
  .button, button, input, textarea, select { min-height: 44px; }
}
