/* Build an agent */

.back { font-size: 14px; font-weight: 600; text-decoration: none; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.builder-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.step { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.step h2 { display: flex; align-items: center; gap: 12px; font-family: var(--font-heading); font-weight: 600; font-size: 22px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--charcoal); color: var(--cream); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .field > .label-row label { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.label-row { display: flex; align-items: center; gap: 2px; }
.label-row .tip { margin-bottom: 6px; }
.field input[type="text"], .field textarea {
  font-size: 16px; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); width: 100%;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--oxblood); outline-offset: 1px; }

/* Templates */
.templates { display: flex; flex-wrap: wrap; gap: 8px; }
.templates button {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--white);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.templates button .mono { font-weight: 500; }
.templates button[aria-pressed="true"] { background: var(--charcoal); border-color: var(--charcoal); color: var(--cream); }

/* Choice cards (engine, hosting) and list (model) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.choice, .choice-row {
  position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--white); cursor: pointer;
}
.choice input, .choice-row input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked), .choice-row:has(input:checked) { border-color: var(--oxblood); box-shadow: inset 0 0 0 1px var(--oxblood); background: var(--picked-bg); }
.choice:has(input:focus-visible), .choice-row:has(input:focus-visible) { outline: 2px solid var(--oxblood); outline-offset: 2px; }
.choice:has(input:disabled), .choice-row:has(input:disabled) { cursor: not-allowed; opacity: 0.55; }
.choice img { width: 20px; height: 20px; object-fit: contain; margin-top: 2px; flex: none; }
.choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-text strong { font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.choice-text span { font-size: 13px; color: var(--text-3); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-row strong { font-family: var(--font-mono); font-weight: 500; font-size: 14px; }

.team-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg-option { position: relative; display: inline-flex; }
.seg-option input { position: absolute; opacity: 0; }
.seg-option span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--white); font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-option input:checked + span { background: var(--charcoal); border-color: var(--charcoal); color: var(--cream); }
.seg-option input:focus-visible + span { outline: 2px solid var(--oxblood); outline-offset: 2px; }

/* Apps and rules */
.app-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.app-chip { position: relative; display: inline-flex; }
.app-chip input { position: absolute; opacity: 0; }
.app-chip span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 13px; border-radius: 999px;
  border: 1px dashed var(--line-strong); background: transparent; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text-2);
}
.app-chip input:checked + span { border-style: solid; background: var(--white); color: var(--charcoal); }
.app-chip input:checked + span::before { content: "✓"; color: var(--ok); }
.app-chip input:disabled + span { cursor: default; }
.app-chip input:focus-visible + span { outline: 2px solid var(--oxblood); outline-offset: 2px; }

.rule-counts { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-app { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.rule-app + .rule-app { margin-top: 12px; }
.rule-app-head { padding: 12px 16px; background: var(--cream); border-bottom: 1px solid var(--line-soft); }
.rule-app-head strong { font-size: 15px; }
.rule-app-head span { display: block; font-size: 13px; color: var(--text-3); }
.rule { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 10px 16px; border-top: 1px solid var(--line-soft); }
.rule:first-of-type { border-top: 0; }
.rule-label { display: flex; flex-direction: column; min-width: 0; }
.rule-label strong { font-size: 15px; font-weight: 600; }
.rule-label span { font-size: 13px; color: var(--text-3); }
.rule-label .mono { font-size: 12px; }
.levels { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: var(--cream-tint); border: 1px solid var(--line); }
.levels label { position: relative; display: inline-flex; }
.levels input { position: absolute; opacity: 0; }
.levels span { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.levels input:focus-visible + span { outline: 2px solid var(--oxblood); outline-offset: 1px; }
.levels input[value="allow"]:checked + span { background: var(--ok-bg); color: var(--ok); }
.levels input[value="ask"]:checked + span { background: var(--ask-bg); color: var(--ask); }
.levels input[value="never"]:checked + span { background: var(--never-bg); color: var(--never); }

/* Budget */
.money-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.money { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); padding-left: 12px; }
.money:focus-within { outline: 2px solid var(--oxblood); outline-offset: 1px; }
.money .mono { color: var(--text-3); }
.money input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--font-mono); font-size: 18px; padding: 10px 12px 10px 6px; outline: none; }

/* Summary */
.summary { position: sticky; top: calc(var(--topbar) + 16px); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.summary h2 { font-family: var(--font-heading); font-weight: 600; font-size: 20px; }
.sum-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 14px; }
.sum-list dt { color: var(--text-3); }
.sum-list dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.sum-list .mono { font-size: 13px; }
.sum-total { padding-top: 6px; font-weight: 600; }
.sum-errors { background: var(--never-bg); color: var(--never); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.sum-errors ul { margin: 0; padding-left: 18px; }
.btn-wide { width: 100%; }

.done { padding: 28px; display: flex; flex-direction: column; gap: 14px; border-color: var(--done-line); background: var(--done-bg); }
.done h2 { font-family: var(--font-heading); font-weight: 600; font-size: 26px; }
.done p { color: var(--text-2); }
.request summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.request pre { margin: 8px 0 0; padding: 14px; background: var(--code-bg); color: var(--code-text); border-radius: 12px; font-size: 13px; overflow-x: auto; }

@media (max-width: 1100px) {
  .builder { grid-template-columns: 1fr; }
  .summary { position: static; }
}
@media (max-width: 520px) {
  .step { padding: 18px; }
  .rule { flex-direction: column; align-items: flex-start; }
}
