.bd { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 760px; margin: 0 auto 64px; }
.bd .panel, .bd-panel, .bd-pool { padding: 22px; }
.bd h2 { margin: 0 0 8px; font-size: 1.15rem; }
.bd .btn { min-height: 44px; touch-action: manipulation; }
.bd .btn[aria-disabled="true"] { opacity: .5; cursor: pointer; }
.bd-hint { margin: 4px 0 12px; color: var(--muted); font-size: .92rem; }

/* fields */
.bd-f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bd-f-l, .bd .field label { font-size: .85rem; font-weight: 700; }
.bd .field label small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.bd input[type="text"], .bd select {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255, 255, 255, .05); color: var(--ink); font: inherit; font-size: 16px;
}
.bd select {
  appearance: none; -webkit-appearance: none; color-scheme: dark; padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9b8ff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 14px center; background-repeat: no-repeat; background-size: 18px;
}
.bd select option { background: #1a1530; color: #e9e4fb; }
.bd input:focus-visible, .bd select:focus-visible { outline: 2px solid var(--violet-3); outline-offset: 2px; }
.bd-path { margin: 14px 0 4px; }

/* loot */
.bd-pool-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.bd-pool-head h2 { margin: 0; }
.bd-rolls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.bd-rolls .bd-hint { grid-column: 1 / -1; margin: 0; }
.bd-entries { display: grid; gap: 12px; margin: 0 0 14px; padding: 0; list-style: none; }
.bd-entry { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .03); }
.bd-entry-top { display: flex; align-items: center; gap: 8px; }
.bd-entry-top select { flex: 1; }
.bd-entry-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.bd-entry-row .bd-wide, .bd-wide { grid-column: 1 / -1; }
.bd-chance { color: var(--muted); font-size: .82rem; min-height: 1em; }
.bd-rm { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; touch-action: manipulation; }
.bd-rm:hover, .bd-rm:focus-visible { background: rgba(255, 255, 255, .08); color: var(--ink); }
.bd-add, .bd-addpool { width: 100%; border-style: dashed; }

/* output */
.bd-code { margin: 0 0 14px; padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, .3); font-size: .82rem; line-height: 1.5; -webkit-overflow-scrolling: touch; }
.bd-code code { display: block; padding: 0; background: transparent; font-family: var(--font-mono); white-space: pre; }
.bd-code code.is-placeholder { color: var(--muted); font-family: var(--font-body); font-size: .93rem; white-space: normal; }
.bd-errors { margin-bottom: 14px; padding: 12px 16px; border: 1px solid rgba(255, 120, 140, .5); border-radius: 14px; background: rgba(255, 90, 120, .1); font-size: .92rem; }
.bd-errors p { margin: 0; }
.bd-errors p + p { margin-top: 6px; }
.bd-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.bd-btns-tight { margin-top: 10px; }

/* recipe grid */
.bd-seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .04); }
.bd-seg label { flex: 1; position: relative; cursor: pointer; }
.bd-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bd-seg span { display: block; padding: .7rem .5rem; border-radius: 999px; text-align: center; font-weight: 700; font-size: .93rem; transition: background .2s ease; }
.bd-seg input:checked + span { background: linear-gradient(135deg, var(--violet-2), var(--violet-3)); color: #1a1030; }
.bd-seg input:focus-visible + span { outline: 2px solid var(--violet-3); outline-offset: 2px; }

.bd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 360px; margin: 0 auto 16px; }
.bd-cell {
  display: grid; place-items: center; aspect-ratio: 1; padding: 6px; overflow: hidden;
  border: 2px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .04); color: var(--ink);
  font: inherit; cursor: pointer; touch-action: manipulation; transition: border-color .15s ease, background .15s ease;
}
.bd-cell:hover { background: rgba(154, 120, 255, .1); }
.bd-cell.is-filled { background: rgba(154, 120, 255, .14); }
.bd-cell.is-sel { border-color: var(--violet-2); box-shadow: 0 0 0 3px rgba(154, 120, 255, .25); }
.bd-cell:focus-visible { outline: 2px solid var(--violet-3); outline-offset: 2px; }
.bd-cell-t { font-size: .78rem; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.bd-cell-e { color: var(--muted); font-size: 1.4rem; }
.bd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bd-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .04); cursor: pointer; touch-action: manipulation; }
.bd-chip input { width: 18px; height: 18px; accent-color: var(--violet-2); }
.bd-help ul { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: .93rem; }
.bd-help li { margin-bottom: 8px; }
.bd-help strong { color: var(--ink); }

.bd-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 150; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); padding: 12px 20px; border: 1px solid var(--line); border-radius: 999px; background: rgba(30, 24, 56, .96); box-shadow: 0 8px 30px rgba(0, 0, 0, .4); font-size: .93rem; text-align: center; }
.bd-toast[hidden] { display: none; }

@media (max-width: 560px) {
  .bd { gap: 14px; }
  .bd .panel, .bd-panel, .bd-pool { padding: 18px 14px; border-radius: 22px; }
  .bd-btns .btn { flex: 1 1 100%; }
  .bd-btns-tight .btn { flex: 1; }
  .bd-seg span { padding: .75rem .3rem; font-size: .88rem; }
}

/* Custom dropdown */
.mc-dd { position: relative; flex: 1; min-width: 0; }
.mc-dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .05); color: var(--ink);
  font: inherit; font-size: 16px; text-align: left; cursor: pointer; touch-action: manipulation;
}
.mc-dd-btn:hover { background: rgba(255, 255, 255, .08); }
.mc-dd-btn:focus-visible, .mc-dd.is-open .mc-dd-btn { outline: 2px solid var(--violet-3); outline-offset: 2px; }
.mc-dd-btn svg { flex: none; width: 18px; height: 18px; color: var(--violet-3); transition: transform .2s ease; }
.mc-dd.is-open .mc-dd-btn svg { transform: rotate(180deg); }
.mc-dd-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-dd-list {
  position: absolute; z-index: 60; top: calc(100% + 6px); right: 0; left: 0; max-height: 260px; margin: 0; padding: 6px; overflow-y: auto;
  border: 1px solid rgba(201, 184, 255, .35); border-radius: 16px; background: #1a1530; box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  list-style: none; -webkit-overflow-scrolling: touch;
}
.mc-dd-list[hidden] { display: none; }
.mc-dd.is-up .mc-dd-list { top: auto; bottom: calc(100% + 6px); }
.mc-dd-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 12px;
  border-radius: 10px; color: var(--ink); font-size: 1rem; cursor: pointer;
}
.mc-dd-opt.is-active { background: rgba(154, 120, 255, .2); }
.mc-dd-opt[aria-selected="true"] { color: #fff; font-weight: 700; }
.mc-dd-opt[aria-selected="true"]::after { content: ""; flex: none; width: 16px; height: 16px; background: var(--violet-3); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat; }
@media (prefers-reduced-motion: reduce) { .mc-dd-btn svg { transition: none; } }

/* Toggle switch */
.bd-switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; margin-top: 6px; cursor: pointer; touch-action: manipulation; }
.bd-switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.bd-track { position: relative; flex: none; width: 46px; height: 26px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .08); transition: background .2s ease, border-color .2s ease; }
.bd-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .2s ease, background .2s ease; }
.bd-switch input:checked + .bd-track { border-color: var(--violet-2); background: rgba(154, 120, 255, .45); }
.bd-switch input:checked + .bd-track::after { transform: translateX(20px); background: #fff; }
.bd-switch input:focus-visible + .bd-track { outline: 2px solid var(--violet-3); outline-offset: 3px; }
.bd-switch-text { font-size: .93rem; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .bd-track, .bd-track::after { transition: none; } }

/* Trading table builder */
.tr-tier-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; align-items: end; }
.tr-first { margin: 0; align-self: center; }
.tr-trade-n { font-size: .95rem; }
.tr-row { display: flex; gap: 10px; }
.tr-grow { flex: 1; min-width: 0; }
.tr-qty { flex: none; width: 84px; }
.tr-more { margin-top: 4px; }
.tr-more summary { min-height: 44px; display: flex; align-items: center; color: var(--violet-3); font-weight: 700; font-size: .92rem; cursor: pointer; touch-action: manipulation; }
.tr-more .bd-entry-row { margin-bottom: 8px; }

.tr-pv-h { margin: 18px 0 8px; font-size: .95rem; color: var(--violet-3); }
.tr-pv-h:first-child { margin-top: 0; }
.tr-pv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .03); }
.tr-pv-want { display: flex; gap: 6px; }
.tr-pv-arrow { color: var(--muted); font-size: 1.2rem; }
.tr-pv-meta { margin-left: auto; color: var(--muted); font-size: .8rem; }
.tr-slot { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; max-width: 100%; padding: 0 12px; border: 2px solid rgba(201, 184, 255, .3); border-radius: 10px; background: rgba(0, 0, 0, .28); font-size: .85rem; text-transform: capitalize; }
.tr-slot.is-empty { color: var(--muted); border-style: dashed; }
.tr-slot-q { color: var(--violet-3); font-weight: 700; font-family: var(--font-mono); }
@media (max-width: 560px) {
  .tr-pv-meta { margin-left: 0; width: 100%; }
  .tr-qty { width: 72px; }
}
