/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f9fafb;
  line-height: 1.5;
}

/* App shell */
#app-content {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Wizard step layout */
.wizard-step {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.step-content {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px;
}

.step-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.step-description {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 20px;
}

/* Bottom bar */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-row .form-label {
  margin-bottom: 0;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #1f2937;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.form-input:disabled,
.form-textarea:disabled {
  background: #f9fafb;
  cursor: not-allowed;
}

.form-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  resize: none;
  line-height: 1.6;
}

.form-input-narrow {
  width: 64px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
  background: #f3f4f6;
}

.btn-danger-text {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.btn-danger-text:hover {
  color: #b91c1c;
  text-decoration: underline;
}

/* Chip name overflow */
.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* Chips (review page) */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.chip.selected {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  font-weight: 500;
}

.chip.success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.chip.warning {
  background: #fefce8;
  border-color: #fde047;
  color: #854d0e;
}

.chip.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.chip-add {
  border-style: dashed;
  border-color: #d1d5db;
  color: #6b7280;
  background: transparent;
}

.chip-add:hover {
  border-color: #9ca3af;
  color: #374151;
}

.chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}

.chip.selected .chip-badge {
  background: #bfdbfe;
  color: #1e3a8a;
}

.chip.success .chip-badge {
  background: #bbf7d0;
  color: #14532d;
}

.chip.warning .chip-badge {
  background: #fef08a;
  color: #713f12;
}

.chip.error .chip-badge {
  background: #fecaca;
  color: #7f1d1d;
}

/* Progress bar */
.progress-bar {
  display: flex;
  gap: 3px;
  height: 6px;
  margin-bottom: 16px;
  border-radius: 3px;
  overflow: hidden;
}

.progress-segment {
  flex: 1;
  background: #e5e7eb;
  transition: background-color 0.3s;
}

.progress-segment:first-child { border-radius: 3px 0 0 3px; }
.progress-segment:last-child  { border-radius: 0 3px 3px 0; }

.progress-segment.active {
  background: repeating-linear-gradient(
    -45deg,
    #3b82f6,
    #3b82f6 4px,
    #60a5fa 4px,
    #60a5fa 8px
  );
  background-size: 16px 16px;
  animation: progress-stripe 0.6s linear infinite;
}

.progress-segment.success { background: #22c55e; }
.progress-segment.partial { background: #eab308; }
.progress-segment.none    { background: #ef4444; }

@keyframes progress-stripe {
  0%   { background-position: 0 0; }
  100% { background-position: 16px 0; }
}

/* Progress log */
.progress-log {
  font-size: 13px;
  color: #6b7280;
}

.progress-line {
  padding: 3px 0;
  border-bottom: 1px solid #f3f4f6;
}

.progress-line:last-child {
  border-bottom: none;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-text {
  flex: 1;
}

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
}

.alert-close:hover {
  opacity: 1;
}

/* Detail panel */
.detail-panel {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  overflow: hidden;
}

.detail-panel.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.detail-panel.warning {
  background: #fefce8;
  border-color: #fde047;
}

.detail-panel.error {
  background: #fef2f2;
  border-color: #fecaca;
}

/* Review detail */
.review-detail p {
  margin-bottom: 4px;
}

.review-detail p:last-child {
  margin-bottom: 0;
}

/* Question list */
.question-list ul {
  list-style: none;
  margin-top: 8px;
}

.question-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  line-height: 1.5;
}

.question-list li:last-child {
  border-bottom: none;
}

.question-description {
  color: #6b7280;
  font-size: 12px;
}

.question-ref {
  color: #9ca3af;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Result */
.result-panel {
  padding: 32px 24px;
  text-align: center;
}

.result-panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-summary {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 20px;
}

/* Spinner / htmx indicator */
.htmx-indicator {
  display: none;
  font-size: 13px;
  color: #6b7280;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
  align-items: center;
}

.htmx-request button[type="submit"] {
  display: none;
}

.spinner {
  align-items: center;
  font-size: 13px;
  color: #6b7280;
}

.spinner::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  flex-shrink: 0;
}

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

/* Tooltip */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 4px;
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.tooltip-wrap:hover::after {
  opacity: 1;
}

/* Utility */
.hidden { display: none !important; }
.text-muted { color: #6b7280; }
.text-sm { font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
