:root {
  --accent: #667eea;
  --accent2: #764ba2;
  --accent-hover: #5568d3;
  --text: #333333;
  --text-muted: #666666;
  --border: #e0e0e0;
  --success: #10b981;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- registration overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  display: flex;
  /* "safe center" -- plain "center" clips the start of any content taller
     than the viewport (a classic centered-flexbox-overflow quirk: the
     browser centers first and only lets you scroll through the back half
     of the overflow, so scrollTop:0 still isn't the true top). "safe"
     falls back to start-alignment once content overflows, so a tall
     overlay (the About page) stays fully scrollable while a short one
     (the registration form) still centers normally. */
  align-items: safe center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 30px 0;
}

.overlay.hidden { display: none; }

.about-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  padding: 36px 40px;
  width: min(680px, 92vw);
  text-align: left;
}
.about-card h1 { font-size: 1.4rem; margin: 0 0 16px; color: var(--accent); text-align: center; }
.about-card h2 { font-size: 1.05rem; margin: 20px 0 10px; color: var(--text); }
.about-card h2:first-of-type { margin-top: 0; }
.about-card p { color: var(--text); font-size: 0.92rem; line-height: 1.6; margin: 0 0 12px; }
.about-card ul.criteria-list { margin: 0 0 12px; padding-left: 20px; }
.about-card ul.criteria-list li { font-size: 0.92rem; line-height: 1.6; margin-bottom: 10px; color: var(--text); }
.about-card ul.criteria-list li:last-child { margin-bottom: 0; }
.about-card a { color: var(--accent); }
.about-card .primary-button { margin-top: 16px; }

.name-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  padding: 32px;
  width: min(480px, 90vw);
  text-align: center;
}

.name-card h1 { font-size: 1.4rem; margin: 0 0 20px; color: var(--accent); }
.name-card p { color: var(--text-muted); font-size: 0.95rem; margin: 0; }

#confirm-submit-overlay .name-card p { margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .primary-button { flex: 1; margin-top: 0; }
.confirm-cancel-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1.02rem;
  font-weight: 600;
  background: #f0f0f0;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s ease;
}
.confirm-cancel-btn:hover { background: #e0e0e0; }

.evaluator-form {
  padding: 26px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.15);
  position: relative;
}

.form-group { margin-bottom: 18px; position: relative; text-align: left; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #2d3748;
  font-size: 0.92rem;
}
.form-group input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
  transform: translateY(-2px);
}
.form-group input::placeholder { color: #a0aec0; }

.form-group:nth-of-type(1)::before, .form-group:nth-of-type(2)::before, .form-group:nth-of-type(3)::before {
  position: absolute;
  left: 13px;
  bottom: 12px;
  font-size: 1.1rem;
  pointer-events: none;
  /* Without this, focusing the input (which gets `transform` below) hands
     it a new stacking context that -- because transform promotes an
     otherwise-static element into the same "positioned, z-index:auto"
     paint bucket as this absolutely-positioned icon, and it comes later
     in DOM order -- paints the input's own background over the icon. */
  z-index: 2;
}
.form-group:nth-of-type(1)::before { content: "\1F4E7"; }
.form-group:nth-of-type(2)::before { content: "\1F464"; }
.form-group:nth-of-type(3)::before { content: "\1F3DB"; }

.primary-button {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1.02rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5); }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- progress ---------- */

#progress-wrap {
  padding: 14px 20px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 14px 14px 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#progress-main {
  flex: 1 1 260px;
  min-width: 0;
}

#progress-bar {
  position: relative;
  height: 26px;
  border-radius: 13px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 13px;
  transition: width 0.4s ease;
}
#progress-label {
  /* Overlaid on the full bar (not just the fill), so it stays readable
     against both the colored fill and the plain gray track behind it --
     hence white text plus a dark shadow rather than a single flat color
     that would only have contrast against one of the two backgrounds. */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
#figure-position-label {
  text-align: center;
  font-size: calc(0.92rem + 2px);
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

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

#app-main {
  flex: 1 1 auto;
  display: flex;
  gap: 14px;
  min-height: 0;
  padding: 14px;
}

#context-pane {
  flex: 0 0 36%;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  padding: 24px 28px;
}
.paper-meta { margin: 0 0 16px; text-align: center; }
#paper-title { margin: 0 0 4px; font-size: 1.05rem; color: var(--text); }
#paper-authors { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

#figure-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  object-fit: contain;
}
.figure-number-line {
  margin: 10px 0 20px;
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  min-height: 1.2em;
}
#context-pane h2 {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 12px;
}
#context-text {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.7;
  white-space: pre-line;
  color: #444;
}

#captions-pane {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#questions-pane {
  flex: 0 0 26%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card h2 {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 8px;
}
#caption-a-text, #caption-b-text, #caption-c-text {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.5;
}

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

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
}
.field input[type="text"], .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: white;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}
.field input[type="text"]:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.questions-intro {
  margin: 0 0 16px;
  font-size: calc(0.92rem + 1px);
  font-weight: 600;
  color: var(--text);
}

fieldset.choice-question, fieldset.rank-question {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}
fieldset.choice-question legend, fieldset.rank-question legend {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 10px;
  padding: 0;
  white-space: normal;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.rank-row:last-child { margin-bottom: 0; }
.rank-label {
  flex: 0 0 42px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice-options label { position: relative; }
.choice-options input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.choice-options span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.choice-options input[type="radio"]:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}
.choice-options input[type="radio"]:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
}
.form-error:not(:empty) {
  margin-bottom: 8px;
}

/* Prev/Next in the progress bar -- same primary-button look (color,
   gradient, hover/disabled states) as the rest of the app's main actions,
   just sized compactly instead of the full-width form-button default. */
.nav-btn {
  width: auto;
  margin-top: 0;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 0.92rem;
}

/* ---------- narrow screens ---------- */

@media (max-width: 1100px) {
  body { height: auto; overflow-y: auto; }
  #app-main { flex-direction: column; }
  #context-pane, #captions-pane, #questions-pane { flex: 0 0 auto; }
}
