@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --bg: #EEF2FF;
  --card: #ffffff;
  --text: #0F172A;
  --text-secondary: #475569;
  --primary: #2563EB;
  --primary-dark: #1E40ED;
  --primary-light: #EFF6FF;
  --border: #E2E8F0;
  --muted: #64748B;
  --success: #059669;
  --shadow: 0 4px 24px -4px rgba(37, 99, 235, 0.14), 0 1px 4px rgba(0,0,0,0.06);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 60%, rgba(219, 234, 254, 0.9) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 10%, rgba(224, 231, 255, 0.7) 0%, transparent 50%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 780px;
  margin: 2rem auto;
  background: var(--card);
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* === HEADER === */
header {
  padding: 2rem 2.5rem 1.75rem;
  background: linear-gradient(155deg, #F8FAFF 0%, #EEF2FF 100%);
  border-bottom: 1px solid #E0E7FF;
}

.eyebrow {
  display: inline-block;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.75rem;
  background: rgba(37, 99, 235, 0.1);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.2;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.925rem;
  line-height: 1.6;
}

/* === PROGRESS === */
.progress-wrap {
  padding: 1.1rem 2.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

#progress-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

#step-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

.progress {
  background: #E0E7FF;
  border-radius: 999px;
  height: 5px;
}

#progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #60A5FA, #2563EB);
  border-radius: inherit;
  width: 11%;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === FORM AREA === */
form {
  padding: 2rem 2.5rem;
}

/* === STEPS === */
.step {
  display: none;
  gap: 1.25rem;
}

.step.active {
  display: grid;
  animation: stepFadeIn 0.3s ease;
}

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

/* === LABELS & INPUTS === */
label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

input:not([type='radio']):not([type='file']):not([type='checkbox']),
textarea,
select {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 0.925rem;
  color: var(--text);
  background: #FAFBFF;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
  width: 100%;
}

input:not([type='radio']):not([type='file']):not([type='checkbox']):focus,
textarea:focus,
select:focus {
  border-color: #60A5FA;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: #fff;
}

textarea {
  resize: vertical;
}

/* === HINTS === */
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.55;
}

/* === ACTIONS / BUTTONS === */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

button {
  border: none;
  padding: 0.8rem 1.25rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.925rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
}

#prev {
  background: #F1F5F9;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

#prev:hover {
  background: #E2E8F0;
  color: var(--text);
}

button.primary {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: #fff;
  box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.45);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -2px rgba(37, 99, 235, 0.55);
}

button.primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px -2px rgba(37, 99, 235, 0.35);
}

/* === RADIO OPTIONS === */
.radio-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.925rem;
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #FAFBFF;
  color: var(--text-secondary);
}

.radio-option:hover {
  border-color: #93C5FD;
  background: var(--primary-light);
  color: var(--primary);
}

.radio-option input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.radio-label-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-hint {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: #64748b;
  line-height: 1.4;
}

/* === DROPZONE === */
.dropzone {
  border: 2px dashed #CBD5E1;
  border-radius: 16px;
  min-height: 150px;
  padding: 2rem 1.5rem;
  background: #F8FAFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.35rem;
  transition: all 0.25s ease;
  cursor: pointer;
}

.dropzone input[type='file'] {
  display: none;
}

.dropzone:hover,
.dropzone.drag-active {
  border-color: #60A5FA;
  background: var(--primary-light);
}

.dropzone.drag-active {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.dropzone-icon {
  color: #93C5FD;
  margin-bottom: 0.25rem;
}

.dropzone-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.dropzone-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

/* === SELECTED FILES === */
.selected-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.selected-files li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F8FAFF;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.selected-files li span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.remove-file-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 5px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.remove-file-btn:hover {
  color: #DC2626;
  background: #FEF2F2;
}

/* === STL VIEWER === */
.viewer {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  background: #fff;
}

.stl-viewers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.75rem;
}

.stl-viewer-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  background: #F8FAFF;
}

.stl-viewer-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.stl-canvas {
  cursor: grab;
  width: 100%;
  height: 220px;
  background: radial-gradient(circle at center, #EEF2FF, #C7D2FE);
  border-radius: 10px;
}

.stl-canvas:active {
  cursor: grabbing;
}

/* === STL ANALYSIS === */
.stl-analysis {
  margin-top: 0.75rem;
}

.stl-analysis[data-state="pending"] {
  display: none;
}

.stl-analysis__spinner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.stl-analysis__spinner-ring {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: stlAnalysisSpin 0.8s linear infinite;
}

@keyframes stlAnalysisSpin {
  to { transform: rotate(360deg); }
}

.stl-analysis__results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  animation: stepFadeIn 0.3s ease;
}

.stl-analysis__metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0;
}

.stl-analysis__label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stl-analysis__value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.stl-analysis__badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stl-analysis__badge--low {
  background: #D1FAE5;
  color: #065F46;
}

.stl-analysis__badge--medium {
  background: #FEF3C7;
  color: #92400E;
}

.stl-analysis__badge--high {
  background: #FFEDD5;
  color: #9A3412;
}

.stl-analysis__badge--very-high {
  background: #FEE2E2;
  color: #991B1B;
}

.stl-analysis__detail {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

.stl-analysis__wall-pass {
  color: #059669;
}

.stl-analysis__wall-pass::after {
  content: " \2713";
}

.stl-analysis__wall-fail {
  color: #DC2626;
}

.stl-analysis__wall-fail::after {
  content: " \26A0";
}

.stl-analysis__wall-na {
  color: var(--muted);
}

.stl-analysis__hint {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.stl-analysis__error {
  color: #DC2626;
  font-size: 0.82rem;
  margin: 0.4rem 0 0;
}

.stl-analysis__confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
}

.stl-analysis__confirm p {
  flex: 1 1 100%;
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: #475569;
}

.stl-confirm-yes,
.stl-confirm-no {
  padding: 0.3rem 0.8rem;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
}

.stl-confirm-yes {
  background: #2563EB;
  color: #fff;
  border-color: #2563EB;
}

.stl-confirm-yes:hover { background: #1D4ED8; border-color: #1D4ED8; }

.stl-confirm-no {
  background: transparent;
  color: #64748B;
  border-color: #CBD5E1;
}

.stl-confirm-no:hover { background: #F1F5F9; }

.stl-analysis__skip {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #94A3B8;
  font-style: italic;
}

@media (max-width: 500px) {
  .stl-analysis__results {
    grid-template-columns: 1fr;
  }
}

.stl-material-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-top: 0.6rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #FAFBFF;
  flex-wrap: wrap;
}

.stl-file-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
  max-width: 22ch;
}

.stl-material-controls {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.stl-material-controls select {
  flex: 0 0 auto;
}

.stl-color-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem 0.3rem 0.45rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.color-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.color-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.color-chip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

@media (max-width: 540px) {
  .stl-file-name {
    max-width: 100%;
    flex-basis: 100%;
  }
}

/* === DATE HINT === */
.date-hint {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.date-hint--warn {
  background: #FFF7ED;
  color: #92400E;
  border: 1px solid #FED7AA;
}

/* === SUMMARY === */
#summary {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

#summary dl {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  margin: 0;
}

#summary dt {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.7rem 1rem;
  background: #F8FAFF;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#summary dd {
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
  color: var(--text);
}

#summary dt:last-of-type,
#summary dd:last-of-type {
  border-bottom: none;
}

/* === SUBMIT STATUS === */
#submit-status {
  font-weight: 600;
  margin-top: 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

/* === CONFIRMATION STEP === */
.confirmation-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 0;
  gap: 0.4rem;
}

.confirmation-icon {
  width: 64px;
  height: 64px;
  background: #DCFCE7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.step[data-step='9'] h2 {
  font-size: 1.35rem;
}

.step[data-step='9'] p {
  margin: 0.25rem 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* === UTILITY === */
.hidden {
  display: none !important;
}
