*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f8f8f8;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1a1a1a;
  --color-muted: #6b7280;
  --color-border: #d1d5db;
  --color-selected: #e11d48;
  --radius: 8px;
  --space: 1rem;
}

body { font-family: system-ui, sans-serif; background: var(--color-bg); color: var(--color-text); min-height: 100vh; }

#app { max-width: 900px; margin: 0 auto; padding: var(--space); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.5rem; min-height: 44px; border: none;
  border-radius: var(--radius); cursor: pointer; font-size: 1rem; font-weight: 600;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--color-primary); border: 2px solid var(--color-primary); }
.btn-lg { width: 100%; font-size: 1.2rem; padding: 1rem; }

.card { background: var(--color-surface); border-radius: var(--radius); padding: 1.5rem; margin-bottom: var(--space); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.form-select { width: 100%; padding: 0.625rem 0.75rem; min-height: 44px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 1rem; background: var(--color-surface); }

.radio-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.radio-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 1rem; min-height: 44px;
  border: 2px solid var(--color-border); border-radius: var(--radius); cursor: pointer; font-size: 0.95rem;
}
.radio-option input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }
.radio-option:has(input:checked) { border-color: var(--color-primary); background: #eff6ff; }

.likert-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
.likert-option {
  min-width: 0; display: flex; flex-direction: column;
  align-items: center; gap: 0.3rem; padding: 0.5rem 0.25rem;
  border: 2px solid var(--color-border); border-radius: var(--radius);
  cursor: pointer; text-align: center; font-size: 0.75rem; line-height: 1.25;
}
.likert-option input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }
.likert-option:has(input:checked) { border-color: var(--color-primary); background: #eff6ff; }

.viz-container:empty {
  width: 100%; aspect-ratio: 16 / 9; background: #e5e7eb;
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--color-muted); font-weight: 600;
  border: 2px dashed var(--color-border);
}

@media (min-width: 768px) {
  .trial-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
}

.progress-bar { height: 6px; background: var(--color-border); border-radius: 3px; margin-bottom: 1rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); transition: width 0.3s; }

.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em;
}
.badge-training { background: #fef3c7; color: #92400e; }
.badge-main { background: #dbeafe; color: #1e40af; }

.text-muted { color: var(--color-muted); font-size: 0.9rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
p { line-height: 1.6; margin-bottom: 0.75rem; }

.animation-viz { display: flex; flex-direction: column; gap: 0.5rem; }
.animation-map { width: 100%; aspect-ratio: 16/9; max-height: 42vh; background: #f3f4f6; border-radius: var(--radius); }
.animation-controls { display: flex; align-items: center; gap: 0.5rem; }
.animation-scrubber { flex: 1; }
.animation-step-label { font-size: 0.85rem; color: var(--color-muted); min-width: 3.5rem; text-align: right; }

.region-shape {
  stroke: rgba(0, 0, 0, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke;
  transition: stroke 0.15s, stroke-width 0.15s;
}
.region-shape.highlighted { stroke: #f97316; stroke-width: 2; }
.region-shape.selected { stroke: var(--color-selected); stroke-width: 2.5; }
.region-shape.linked-hover { stroke: #1a1a1a; stroke-width: 1.5; }

.small-multiples-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.5rem; }
.small-multiples-panel { display: flex; flex-direction: column; gap: 0.25rem; }
.small-multiples-map { width: 100%; aspect-ratio: 1/1; background: #f3f4f6; border-radius: var(--radius); }
.small-multiples-label { font-size: 0.75rem; color: var(--color-muted); text-align: center; }

.projection-layout { display: flex; flex-direction: column; gap: 0.75rem; }
.projection-timeline { display: flex; flex-direction: column; gap: 2px; }
.projection-distance-bar { width: 100%; height: 10px; }
.distance-bar { display: grid; gap: 1px; height: 100%; }
.projection-matrix { width: 100%; height: 38vh; max-height: 320px; }
.matrix-grid { display: grid; gap: 1px; background: var(--color-border); width: 100%; height: 100%; }
.matrix-cell { transition: outline 0.1s; }
.matrix-cell.highlighted { outline: 2px solid #f97316; outline-offset: -2px; }
.matrix-cell.selected { outline: 2px solid var(--color-selected); outline-offset: -2px; }
.matrix-cell.linked-hover { outline: 2px solid #1a1a1a; outline-offset: -2px; }
.projection-minimap { width: 100%; aspect-ratio: 16/9; max-height: 28vh; background: #f3f4f6; border-radius: var(--radius); }
