/* ═══════════════════════════════════════════════════════════
   Builder page. Inherits every token, button, form and footer
   style from styles.css. Same accent, same two radii:
     interactive -> --r-pill      containers -> --r
   Density is deliberately higher here than the homepage: this is
   a tool, so rows are tighter and specs stay visible.
   ═══════════════════════════════════════════════════════════ */

/* ─── Tool header ────────────────────────────────────────── */
.toolhead {
  padding-block: clamp(32px, 5vw, 56px) clamp(20px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(70% 140% at 88% 0%, var(--green-soft), transparent 62%),
    var(--ink);
}
.toolhead h1 {
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.025em;
  margin-bottom: 10px;
}
.toolhead p { color: var(--text-mid); max-width: 60ch; }

/* ─── Workbench ──────────────────────────────────────────── */
.bench { padding-block: clamp(24px, 4vw, 40px) clamp(48px, 7vw, 80px); }
.bench__inner {
  display: grid;
  grid-template-columns: 1fr 360px;   /* parts | summary */
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}

.bench__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.bench__bar h2 { font-size: 1.15rem; letter-spacing: -.01em; }

/* ─── Slot rows ──────────────────────────────────────────── */
.slot {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .2s, background-color .2s;
}
.slot + .slot { margin-top: 8px; }
.slot:hover { border-color: var(--line-2); }
.slot.is-filled { background: var(--surface-2); }
.slot.is-bad { border-color: var(--green-line); }

.slot__icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--text-mute);
  font-size: 1.5rem;
}
.slot__thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--ink);
}

.slot__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.slot__cat { font-size: .76rem; color: var(--text-mute); }
.slot__name {
  font-weight: 700;
  font-size: .95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot__empty { font-size: .92rem; color: var(--text-mute); }
.slot__price { font-weight: 700; font-size: .9rem; white-space: nowrap; }

.slot__actions { display: flex; align-items: center; gap: 6px; }
.iconbtn--sm { width: 32px; height: 32px; font-size: 1rem; }

/* ─── Summary ────────────────────────────────────────────── */
.bench__side { position: sticky; top: 88px; }
.summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.summary h2 { font-size: 1.1rem; letter-spacing: -.01em; }

.summary__stats {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-block: 1px solid var(--line);
}
.summary__stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
}
.summary__stats > div + div { border-top: 1px solid var(--line); }
.summary__stats dt { font-size: .84rem; color: var(--text-mute); }
.summary__stats dd { margin: 0; font-size: .88rem; font-weight: 700; }

/* Three real states, one accent. Severity reads from weight and
   iconography, never from a second colour. */
.status {
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--ink);
}
.status h3 {
  font-size: .93rem;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.status p { font-size: .85rem; color: var(--text-mute); }
.status ul { margin: 0; padding-inline-start: 18px; display: grid; gap: 7px; }
.status li { font-size: .85rem; color: var(--text-mid); line-height: 1.65; }

.status--ok  { border-color: var(--green-line); background: var(--green-soft); }
.status--ok h3 { color: var(--green); }
.status--bad { border-color: var(--green-line); }
.status--bad h3 { color: var(--green); }
.status--bad i, .status--ok i { font-size: 1.15rem; }

.summary__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.summary__total span { font-size: .88rem; color: var(--text-mute); }
.summary__total strong { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.summary__total small { font-size: .72rem; font-weight: 500; color: var(--text-mute); }

.summary .btn { width: 100%; }
.summary__hint { font-size: .78rem; color: var(--text-mute); line-height: 1.6; }

/* ─── Order mode: two mutually exclusive choices ─────────── */
.modes { display: grid; gap: 8px; }
.modes h3 { font-size: .88rem; margin-bottom: 2px; }

.mode {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: start;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s, background-color .2s, transform .18s var(--ease);
}
.mode:hover:not(:disabled) { border-color: var(--green-line); }
.mode:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.mode:disabled { opacity: .4; cursor: not-allowed; }

.mode i { font-size: 1.35rem; color: var(--text-mute); }
.mode__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode__title { font-weight: 700; font-size: .92rem; }
.mode__desc { font-size: .76rem; color: var(--text-mute); line-height: 1.5; }

/* Selected state. Only ever one at a time. */
.mode.is-on {
  border-color: var(--green);
  background: var(--green-soft);
}
.mode.is-on i { color: var(--green); }
.mode.is-on .mode__title { color: var(--green); }

.modes__hint { font-size: .78rem; color: var(--text-mute); line-height: 1.6; margin-top: 2px; }

/* ─── Order panel extras ─────────────────────────────────── */
.order__mode {
  display: inline-block;
  align-self: flex-start;
  width: fit-content;
  margin-bottom: 14px;
  padding: 4px 13px;
  border-radius: var(--r-pill);
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: var(--green);
  font-size: .8rem;
  font-weight: 700;
}
.order__warn {
  margin-top: 12px;
  font-size: .82rem;
  color: var(--text-mute);
  line-height: 1.7;
}

/* ─── Picker dialog ──────────────────────────────────────── */
.picker {
  width: min(760px, 94vw);
  max-height: min(82dvh, 760px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.picker:not([open]) { display: none; }
.picker::backdrop { background: rgba(0, 0, 0, .68); backdrop-filter: blur(3px); }

.picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.picker__head h2 { font-size: 1.05rem; letter-spacing: -.01em; }

.picker__list {
  list-style: none;
  margin: 0;
  padding: 12px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}

.opt {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--ink);
  transition: border-color .2s;
}
.opt:hover { border-color: var(--line-2); }
.opt.is-on { border-color: var(--green); background: var(--green-soft); }
.opt.is-off { opacity: .55; }

.opt__media {
  width: 84px; height: 64px;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.opt__media img { width: 100%; height: 100%; object-fit: cover; }
.opt__media.is-empty img { display: none; }

.opt__body { min-width: 0; }
.opt__body h4 { font-size: .95rem; margin-bottom: 3px; }
.opt__note { font-size: .8rem; color: var(--text-mute); }
.opt__why {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--green);
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.55;
}
.opt__why i { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

.opt__buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  white-space: nowrap;
}

/* ─── Order panel ────────────────────────────────────────── */
.order {
  padding-block: clamp(40px, 6vw, 72px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.order__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
.order__list h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  letter-spacing: -.02em;
  margin-bottom: 16px;
}
.order__list dl { margin: 0; border-top: 1px solid var(--line); }
.order__list dl > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.order__list dt { font-size: .84rem; color: var(--text-mute); flex-shrink: 0; }
.order__list dd { margin: 0; font-size: .88rem; font-weight: 600; text-align: end; }

.order__sum {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
}
.order__sum span { font-size: .9rem; color: var(--text-mute); }
.order__sum strong { font-size: 1.3rem; font-weight: 800; }
.order__sum small { font-size: .74rem; font-weight: 500; color: var(--text-mute); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .bench__inner { grid-template-columns: 1fr; }
  .bench__side { position: static; }
  .order__inner { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .slot {
    grid-template-columns: 48px 1fr auto;
    grid-template-areas: 'icon main actions' 'price price price';
    row-gap: 10px;
  }
  .slot__icon, .slot__thumb { grid-area: icon; width: 48px; height: 48px; }
  .slot__main { grid-area: main; }
  .slot__actions { grid-area: actions; }
  .slot__price {
    grid-area: price;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .opt {
    grid-template-columns: 64px 1fr;
    grid-template-areas: 'media body' 'buy buy';
    row-gap: 12px;
  }
  .opt__media { grid-area: media; width: 64px; height: 52px; }
  .opt__body { grid-area: body; }
  .opt__buy {
    grid-area: buy;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  /* Bottom sheet on small screens: reachable with a thumb. */
  .picker {
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    margin: 0;
    position: fixed;
    inset: auto 0 0 0;
    border-radius: var(--r) var(--r) 0 0;
    border-bottom: 0;
  }
}
