:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #f1f4f9;
  --border: #e2e6ef;
  --border-strong: #cbd3e1;
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --success: #0f766e;
  --success-soft: #f0fdfa;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* Mobile top bar */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px 12px;
}

.mobile-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mobile-step-text {
  font-size: 13px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--surface-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 16.66%;
  transition: width 220ms ease;
}

/* Main two-column layout */
.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 64px;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

/* Left sidebar rail */
.sidebar {
  position: sticky;
  top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.brand-gem {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.brand-sub {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 22px;
  line-height: 1.45;
}

.step-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-nav-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.step-nav-btn:hover {
  background: var(--surface-subtle);
}

.step-nav-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.step-badge {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
  flex-shrink: 0;
  margin-top: 1px;
}

.step-nav-btn.is-active .step-badge {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.step-nav-btn.is-answered:not(.is-active) .step-badge {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.step-nav-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.step-nav-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.step-nav-count {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.sidebar-reset {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.sidebar-reset:hover {
  color: var(--danger);
}

/* Main form card */
.form-stage {
  min-width: 0;
  max-width: 720px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 38px 32px;
}

.step-header {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.step-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin: 0 0 8px;
}

.step-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 10px;
  color: var(--ink);
}

.step-desc {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 15px;
  max-width: 60ch;
}

.step-panel {
  display: none;
}

.step-panel.is-active {
  display: block;
}

/* Form fields */
.field-group {
  margin-bottom: 28px;
}

.field-group:last-of-type {
  margin-bottom: 8px;
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.4;
}

.field-num {
  color: var(--ink-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

.field-hint {
  margin: 0 0 11px;
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.text-input,
.textarea-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.textarea-input {
  min-height: 92px;
  resize: vertical;
}

.text-input::placeholder,
.textarea-input::placeholder {
  color: #94a3b8;
}

.text-input:focus,
.textarea-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.sub-input {
  margin-top: 10px;
}

/* Interactive chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease;
}

.chip:hover {
  border-color: var(--ink-secondary);
  color: var(--ink);
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Option cards for visual vibe / scope */
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-card {
  appearance: none;
  text-align: left;
  padding: 14px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.option-card:hover {
  border-color: var(--ink-secondary);
}

.option-card.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.option-card-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 4px;
}

.option-card.is-selected .option-card-title {
  color: var(--accent);
}

.option-card-desc {
  display: block;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* Action bar */
.action-bar {
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--surface-subtle);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.error-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 13.5px;
  display: none;
}

.error-banner.is-visible {
  display: block;
}

/* Confirmation view */
.confirmation-view {
  display: none;
}

.confirmation-view.is-active {
  display: block;
}

.confirm-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.confirm-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--surface-subtle);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--ink);
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 24px;
}

.markdown-preview {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  max-height: 360px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

@media (max-width: 900px) {
  .mobile-header {
    display: block;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 18px 14px 48px;
    gap: 18px;
  }

  .sidebar {
    display: none;
  }

  .stage-card {
    padding: 24px 20px 22px;
  }

  .step-title {
    font-size: 23px;
  }

  .option-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
