:root {
  --bg: #0b0e16;
  --bg-soft: #121726;
  --panel: #161c2e;
  --panel-2: #1c2438;
  --border: #28324b;
  --text: #e6eaf4;
  --muted: #93a0bd;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --green: #22c55e;
  --orange: #f97316;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2238 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 22, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.home-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.home-btn:hover {
  border-color: var(--primary-2);
}
.home-btn:active {
  transform: translateY(1px);
}
.home-icon {
  font-size: 15px;
  line-height: 1;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.brand-dot {
  color: var(--primary-2);
}
.brand-sub {
  color: var(--muted);
  font-size: 13px;
}

.stage {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 120px;
}

.screen {
  display: none;
  animation: fade 0.35s ease;
}
.screen.active {
  display: block;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.5);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-choice {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 120px;
}
.btn-choice:hover {
  border-color: var(--primary-2);
}

/* ---------- Landing ---------- */
.landing {
  max-width: 720px;
  margin: 8vh auto 0;
  text-align: center;
}
.landing-prompt {
  font-size: 38px;
  font-weight: 800;
  margin-bottom: 28px;
  background: linear-gradient(135deg, #fff, #b9c2e6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.landing-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: left;
}
.landing-textbox {
  width: 100%;
  background: transparent;
  border: none;
  resize: vertical;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
  outline: none;
}
.landing-textbox::placeholder {
  color: var(--muted);
}
.landing-submit {
  margin-top: 12px;
  width: 100%;
}
.landing-hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 14px;
}
.status {
  margin-top: 14px;
  color: var(--muted);
  min-height: 18px;
}
.status.error,
.error {
  color: #f87171;
}

/* ---------- Clarification / questions ---------- */
.clarify-wrap,
.refine-main,
.catalog-main {
  max-width: 720px;
  margin: 0 auto;
}
.clarify-header {
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 18px;
}
.q-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.q-summary {
  color: var(--primary-2);
  font-size: 15px;
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 0 16px;
}
.q-prompt {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 22px;
}
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.option-cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 22px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.option-cell:hover {
  border-color: var(--primary-2);
  transform: translateY(-1px);
}
.option-cell.selected {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.yesno-row {
  display: flex;
  gap: 14px;
}
.yesno-row .btn {
  flex: 1;
  padding: 18px;
  font-size: 16px;
}
.text-input,
.text-area {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 14px;
  outline: none;
  margin-bottom: 16px;
}
.text-area {
  min-height: 90px;
  resize: vertical;
}
.text-input:focus,
.text-area:focus {
  border-color: var(--primary-2);
}

/* Budget */
.budget-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 44px;
  font-weight: 800;
  margin: 6px 0 18px;
}
.budget-dollar {
  color: var(--muted);
}
.budget-amount {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 44px;
  font-weight: 800;
  width: 200px;
  text-align: center;
  outline: none;
}
.budget-slider {
  width: 100%;
  accent-color: var(--primary);
}
.budget-range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 18px;
}

.loading {
  color: var(--muted);
  padding: 30px;
  text-align: center;
}

/* ---------- Builds ---------- */
.understanding {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.understanding h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.understanding ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}
.understanding li {
  margin: 4px 0;
}
.provisional-note {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  margin: 0 0 16px;
}

.variant-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.variant-tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.variant-tab.active {
  color: var(--text);
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

.build-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.build-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.build-visual {
  display: flex;
  flex-direction: column;
}
.build-variant-tag {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-2);
}
.build-variant-tag.spend_less {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
.build-variant-tag.push_performance {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
}
.three-host {
  width: 100%;
  height: 320px;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, #1a2236, #0d1120);
  border: 1px solid var(--border);
  overflow: hidden;
}
.three-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}
.build-oneliner {
  color: var(--muted);
  margin-top: 14px;
  font-size: 15px;
}

.build-details {
  display: flex;
  flex-direction: column;
}
.build-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.build-name-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  outline: none;
  padding: 4px 0;
}
.build-name-input:focus {
  border-bottom-color: var(--primary-2);
}
.build-price {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
}
.component-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
.component-list li {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.comp-cat {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-name {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comp-price {
  color: var(--muted);
}
.highlights {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
.highlights li {
  position: relative;
  padding-left: 18px;
  margin: 6px 0;
  color: var(--text);
  font-size: 14px;
}
.highlights li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--primary-2);
}
.build-summary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.build-summary summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-2);
}
.build-summary p {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 14px;
}
.btn-select {
  margin-top: auto;
}

/* ---------- Refinement / Catalog side layouts ---------- */
.refine-layout,
.catalog-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
.side-summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 90px;
}
.side-title {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.side-summary h4 {
  margin: 0 0 10px;
  font-size: 15px;
}
.side-summary ul {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
.side-summary li {
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.side-summary li span {
  color: var(--muted);
  font-size: 11px;
  margin-right: 6px;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}

.catalog-root {
  margin-top: 16px;
}
.catalog-section {
  margin-bottom: 22px;
}
.catalog-section h3 {
  font-size: 14px;
  color: var(--primary-2);
  margin: 0 0 10px;
  letter-spacing: 1px;
}
.catalog-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.catalog-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.ci-name {
  font-weight: 600;
  font-size: 14px;
}
.ci-price {
  color: #fff;
  font-weight: 700;
  margin: 6px 0;
}
.ci-why {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Chat widget ---------- */
.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
}
.chat-fab {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
}
.chat-fab.pulse {
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
  }
  50% {
    box-shadow: 0 8px 34px rgba(99, 102, 241, 0.9);
  }
}
.chat-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 340px;
  height: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-panel.hidden {
  display: none;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.chat-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 3px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
}
.chat-input:focus {
  border-color: var(--primary-2);
}
.chat-send {
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .build-layout,
  .refine-layout,
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .side-summary {
    position: static;
  }
}
