:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2331;
  --muted: #6b7280;
  --primary: #2f5fdb;
  --primary-dark: #24499f;
  --danger: #d64545;
  --success: #1e8e5a;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar .brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav a { margin-left: 16px; font-size: 0.95rem; text-decoration: none; color: var(--text); }
.topbar form { display: inline; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.container.wide { max-width: 1200px; }

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

h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

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

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
th { color: var(--muted); font-weight: 600; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}
textarea { resize: vertical; }

.error-banner {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f3c6c6;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card { width: 340px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.draft { background: #fff3d6; color: #8a6100; }
.badge.published { background: #e1f4ea; color: var(--success); }
.badge.assigned { background: #eef1fb; color: var(--primary); }
.badge.in_progress { background: #fff3d6; color: #8a6100; }
.badge.completed { background: #e1f4ea; color: var(--success); }

.question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.choice-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.choice-row input[type=text] { flex: 1; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: #eef1fb;
  color: var(--primary-dark);
}
.timer.low { background: #fdecec; color: var(--danger); }

.section-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.section-nav button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.85rem;
}
.section-nav button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.section-nav button.answered { border-color: var(--success); }

.chat-panel { display: flex; flex-direction: column; gap: 10px; }
.chat-log { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: #fafbfc; }
.chat-msg { margin-bottom: 10px; font-size: 0.9rem; white-space: pre-wrap; }
.chat-msg .who { font-weight: 700; margin-right: 6px; }

.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
