:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #3b6ef5;
  --accent-soft: #e7eeff;
  --good: #1f9d55;
  --bad: #d9534f;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem;
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.evaluator { display: flex; align-items: center; gap: 0.5rem; }
.evaluator label { font-size: 0.85rem; color: var(--muted); }
.evaluator input {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
}

/* Landing / welcome */
.landing {
  display: flex;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
.landing-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  max-width: 680px;
  width: 100%;
}
.landing-card h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.landing-card h3 { margin: 1.5rem 0 0.5rem; font-size: 1rem; color: var(--muted); }
.landing-intro { color: var(--ink); margin: 0 0 0.5rem; }
.instructions { margin: 0; padding-left: 1.2rem; }
.instructions li { margin-bottom: 0.55rem; }
.landing-label {
  display: block;
  margin: 1.5rem 0 0.4rem;
  font-weight: 600;
}
#landing-name {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
}
#start-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
#start-btn:hover { filter: brightness(1.05); }
.landing-error { color: var(--bad); min-height: 1.2em; margin: 0.5rem 0 0; font-size: 0.9rem; }

/* Pair picker */
.pair-picker {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.pair-field { flex: 1; }
.pair-field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
.pair-field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}
.pair-vs { padding-bottom: 0.6rem; color: var(--muted); font-weight: 600; }
#pair-count { margin: 0.5rem 0 0; }

#progress-wrap {
  max-width: 980px;
  margin: 1rem auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
#progress-bar {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}
#progress-text { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

/* Main */
main, .footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.query-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}
#query-text { margin: 0.6rem 0 0; font-size: 1.1rem; font-weight: 600; white-space: pre-wrap; }

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.answer-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.answer-card h2 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--muted); }
.answer-body {
  font-size: 0.97rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.5rem;       /* room so text isn't hidden under the scrollbar */
  overscroll-behavior: contain; /* scrolling the box doesn't scroll the page */
}
/* Rendered Markdown inside the answer boxes */
.answer-body p { margin: 0 0 0.6rem; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body ul, .answer-body ol { margin: 0.3rem 0 0.7rem; padding-left: 1.4rem; }
.answer-body li { margin-bottom: 0.3rem; }
.answer-body h1, .answer-body h2, .answer-body h3, .answer-body h4 {
  margin: 0.8rem 0 0.4rem;
  line-height: 1.3;
  color: var(--ink);
}
.answer-body h1 { font-size: 1.1rem; }
.answer-body h2 { font-size: 1.05rem; }
.answer-body h3 { font-size: 1rem; }
.answer-body h4 { font-size: 0.97rem; }
.answer-body strong { font-weight: 700; }
.answer-body code {
  background: #f1f3f5;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.9em;
}
.answer-body hr { border: none; border-top: 1px solid var(--line); margin: 0.8rem 0; }
.answer-body a { color: var(--accent); }
/* Slimmer, subtler scrollbar inside the answer boxes */
.answer-body::-webkit-scrollbar { width: 8px; }
.answer-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}
.answer-body::-webkit-scrollbar-thumb:hover { background: #c7ccd2; }
.answer-body { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.answer-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Choice buttons */
.choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}
.choice {
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.choice:hover { border-color: var(--accent); }
.choice.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.choice[data-choice="both"].active { background: var(--good); border-color: var(--good); }
.choice[data-choice="neither"].active { background: var(--bad); border-color: var(--bad); }

/* Comment */
.comment-panel { margin-top: 1rem; }
.comment-panel label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  gap: 1rem;
}
.nav button {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.nav button:hover:not(:disabled) { border-color: var(--accent); }
.nav button:disabled { opacity: 0.45; cursor: not-allowed; }
.save-status { font-size: 0.85rem; color: var(--good); min-height: 1.2em; }

/* Footer */
.footer {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}
.footer h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.optional { font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.footer-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.footer-actions button {
  padding: 0.6rem 1.1rem;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
#export-link, #export-link-csv {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
#export-link:hover, #export-link-csv:hover { text-decoration: underline; }
#export-link.disabled, #export-link-csv.disabled {
  color: var(--muted);
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}

.notice {
  background: #fff8e1;
  border: 1px solid #f0e0a0;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .answers { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr 1fr; }
}
