/* ── Builder ────────────────────────────────────────────── */

.builder { padding-top: 16px; max-width: 760px; margin: 0 auto; width: 100%; }

.builder-head { text-align: center; margin-bottom: 40px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.builder-head h1 { font-size: clamp(30px, 4.6vw, 42px); letter-spacing: -0.03em; }
.builder-head p { color: var(--muted); max-width: 46ch; }

.progress-rail {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 320px;
  margin-top: 4px;
}

.progress-rail span {
  height: 3px;
  flex: 1;
  border-radius: var(--r-pill);
  background: var(--line);
  transition: background 0.4s var(--ease);
}

.progress-rail span.is-done { background: var(--accent); }

.block {
  padding: 30px 30px 32px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: border-color 0.3s var(--ease);
}

.block:focus-within { border-color: var(--line-hi); }

.block-head { display: flex; align-items: baseline; gap: 14px; }
.block-index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  padding-top: 3px;
  flex: none;
}
.block-title { font-size: 20px; letter-spacing: -0.02em; }
.block-note { font-size: 14px; color: var(--muted); margin-top: 5px; line-height: 1.55; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Selectable option cards (interaction mode) */

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .option-grid { grid-template-columns: 1fr; } }

.option {
  text-align: left;
  padding: 22px 22px 24px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.option:hover { border-color: var(--line-hi); transform: translateY(-2px); }

.option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.option-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-hi);
  color: var(--accent);
  margin-bottom: 3px;
}
.option-icon svg { width: 17px; height: 17px; }
.option[aria-pressed="true"] .option-icon { background: var(--accent); color: var(--on-accent); }

.option-title { font-weight: 600; font-size: 16px; }
.option-body { font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* Knowledge sources */

.source-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.tab {
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.tab:hover { color: var(--text); border-color: var(--line-hi); }
.tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }

.dropzone {
  border: 1.5px dashed var(--line-hi);
  border-radius: var(--r-md);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 14.5px;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone strong { color: var(--text); font-weight: 600; }

.source-list { display: flex; flex-direction: column; gap: 9px; }

.source-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  animation: rise 0.35s var(--ease);
}

.source-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.source-icon svg { width: 15px; height: 15px; }

.source-main { flex: 1; min-width: 0; }
.source-name { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-meta { font-size: 12.5px; color: var(--subtle); }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.16s var(--ease);
  flex: none;
}
.icon-btn:hover { color: var(--danger); background: rgba(217, 128, 128, 0.1); }
.icon-btn svg { width: 14px; height: 14px; }

/* Toggle */

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
}

.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-hi);
  background: var(--surface-hi);
  cursor: pointer;
  flex: none;
  margin-top: 2px;
  transition: background 0.22s var(--ease), border-color 0.22s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.24s var(--ease), background 0.22s var(--ease);
}

.switch[aria-pressed="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-pressed="true"]::after { transform: translateX(18px); background: #fff; }

.submit-bar {
  position: sticky;
  bottom: 18px;
  margin-top: 26px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-hi);
  background: rgba(12, 14, 22, 0.86);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

:root[data-theme="light"] .submit-bar { background: rgba(255, 255, 255, 0.9); }

.submit-summary { font-size: 13.5px; color: var(--muted); }
.submit-summary strong { color: var(--text); font-weight: 600; }

/* ── Progressive disclosure ("+ More details") ──────────── */

.more-bar { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); margin-top: 2px; }

.more-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px dashed var(--line-hi);
  background: transparent;
  color: var(--subtle);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.more-btn:hover { color: var(--text); border-color: var(--accent); border-style: solid; background: var(--accent-soft); }
.more-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); border-style: solid; background: var(--accent-soft); }
.more-btn svg { width: 13px; height: 13px; transition: transform 0.2s var(--ease); }
.more-btn[aria-expanded="true"] svg { transform: rotate(45deg); }

.more-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  animation: rise 0.32s var(--ease);
}

/* ── Block head with an action on the right ─────────────── */

.block-head--split { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }

.gear-btn {
  width: 34px; height: 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
  transition: all 0.18s var(--ease);
}

.gear-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); transform: rotate(45deg); }
.gear-btn svg { width: 16px; height: 16px; }
.gear-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ── Sliders ────────────────────────────────────────────── */

.slider-row { display: flex; flex-direction: column; gap: 7px; }
.slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.slider-value { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line-hi);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: none;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 17px; height: 17px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ── Radio-style choice list (visibility) ───────────────── */

.choice-list { display: flex; flex-direction: column; gap: 10px; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.choice:hover { border-color: var(--line-hi); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.choice-radio {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line-hi);
  flex: none;
  margin-top: 2px;
  display: grid; place-items: center;
  transition: border-color 0.18s var(--ease);
}

.choice[aria-pressed="true"] .choice-radio { border-color: var(--accent); }
.choice[aria-pressed="true"] .choice-radio::after {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.choice-icon { color: var(--muted); flex: none; margin-top: 1px; }
.choice[aria-pressed="true"] .choice-icon { color: var(--accent); }
.choice-body { flex: 1; min-width: 0; }
/* These are spans (a <button> may not contain block-level flow content in a way
   that survives every browser's parser), so they need explicit block display. */
.choice-title { display: block; font-size: 14.5px; font-weight: 500; }
.choice-note { display: block; font-size: 13px; color: var(--subtle); line-height: 1.5; margin-top: 2px; }

.choice-detail {
  margin: -2px 0 0 32px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.3s var(--ease);
}
