:root {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #ddd;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --gray-bg: #606060;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100vh; }

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

h1 { font-size: 1.6em; margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 1.3em; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 1.05em; margin: 0; font-weight: 600; }
p  { margin: 0 0 12px; }

/* Layout */
.container {
  max-width: 1900px;
  margin: 0 auto;
  padding: 20px 24px;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 32px;
  max-width: 540px;
  margin: 60px auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.hint { color: var(--text-muted); font-size: 0.9em; margin-top: 6px; }
.muted { color: var(--text-muted); }

/* Forms */
label { display: block; margin-bottom: 6px; font-weight: 500; }

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1em;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button { cursor: pointer; font-family: inherit; font-size: 1em; font-weight: 500; }

.btn-primary, .btn-secondary, .btn-danger {
  padding: 10px 20px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: white; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f5f5f5; }

.btn-danger { background: white; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-text { background: none; color: var(--primary); border: none; padding: 6px 8px; font-weight: 500; }
.btn-text:hover { text-decoration: underline; }

.intro-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.done-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ============================================================ */
/* Task view: two-column layout                                 */
/* ============================================================ */

.task-container { padding: 16px 24px; }

.task-header {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.header-left { font-size: 0.95em; }
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.progress-bar {
  height: 4px;
  background: #e5e5e5;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.25s;
}

.save-status {
  font-size: 0.85em;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.save-status-saving { background: #fef3c7; color: #92400e; }
.save-status-saved  { background: #dcfce7; color: #166534; }
.save-status-error  { background: #fee2e2; color: #991b1b; }
.save-status-idle   { display: none; }

.task-main {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: flex-start;
}

/* Images panel (left) */
.images-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: var(--gray-bg);
  padding: 16px;
  border-radius: 8px;
}

.image-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-card .thumb {
  width: 100%;
  max-width: 512px;
  height: auto;
  aspect-ratio: 1 / 1;
  background: black;
  display: block;
  cursor: zoom-in;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.image-card .thumb:hover {
  border-color: var(--primary);
}

.image-label {
  color: white;
  font-weight: 700;
  font-size: 1.05em;
  letter-spacing: 1.5px;
}

.image-help {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85em;
  text-align: center;
  margin: 4px 0 0;
}

.image-error {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #222;
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.9em;
  text-align: center;
  padding: 20px;
}

/* Questions panel (right, sticky) */
.questions-panel {
  position: sticky;
  top: 16px;
}

.response-form {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.q-block {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}

.q-block legend {
  font-weight: 600;
  font-size: 0.98em;
  margin-bottom: 10px;
  padding: 0;
}

.q-preference {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.radio-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.radio-stack label {
  font-weight: 400;
  cursor: pointer;
  padding: 6px 8px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.radio-stack label:hover {
  background: #f9fafb;
}
.radio-stack label:has(input:checked) {
  background: #eff6ff;
  border-color: var(--primary);
}

.ordinal-instructions {
  font-style: italic;
  color: var(--text-muted);
  margin: 4px 0 10px;
  font-size: 0.9em;
}

.ordinal-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.ordinal-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 400;
  margin: 0;
  background: white;
  transition: background 0.12s, border-color 0.12s;
}
.ordinal-label:hover {
  background: #f9fafb;
  border-color: #b0b0b0;
}
.ordinal-label input { margin: 0 0 4px; }
.ordinal-label:has(input:checked) {
  background: #eff6ff;
  border-color: var(--primary);
}
.ordinal-value { font-weight: 700; font-size: 0.95em; }
.ordinal-text { font-size: 0.7em; color: var(--text-muted); line-height: 1.1; margin-top: 2px; }

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

/* ============================================================ */
/* Image modal (click to enlarge)                                */
/* ============================================================ */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.image-modal.hidden { display: none; }

.modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.modal-content h2 {
  color: white;
  margin: 0;
  font-size: 1.1em;
  letter-spacing: 2px;
  font-weight: 700;
}

#modal-img {
  width: 512px;
  height: 512px;
  background: black;
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

.modal-nav {
  display: flex;
  gap: 10px;
}
.modal-switch {
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
}
.modal-switch:hover {
  background: rgba(255, 255, 255, 0.2);
}
.modal-switch.active {
  background: var(--primary);
  border-color: var(--primary);
}

.modal-hint {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8em;
  margin-top: 4px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Misc */
.success-msg { color: var(--success); font-weight: 500; }
.error-msg { color: var(--danger); margin-top: 8px; }
.warning-msg { color: var(--warning); font-weight: 500; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

/* Responsive — stack on narrow screens */
@media (max-width: 1280px) {
  .task-main {
    grid-template-columns: 1fr;
  }
  .questions-panel {
    position: static;
  }
}
