/* brd-tools-v5: one tool at a time, inputs beside results.
   Scoped to body.brdx so the other pages are untouched. */

.brdx {
  --brdx-header-h: 56px;
  --brdx-line: rgba(148, 163, 184, 0.26);
  --brdx-line-strong: rgba(125, 211, 252, 0.38);
  --brdx-surface: rgba(10, 19, 34, 0.72);
  --brdx-surface-2: rgba(18, 31, 53, 0.92);
  --brdx-field: #081120;
  --brdx-label: #c9d6e8;
  --brdx-dim: #9fb0c7;
}

/* ---------- compact page top ---------- */
.brdx .brd-safety-band { margin-top: 0.6rem; }
.brdx .brd-safety-band-inner { padding: 0.55rem 0.9rem; border-radius: 12px; gap: 0.8rem; }
.brdx .brd-safety-copy strong { font-size: 0.86rem; }
.brdx .brd-safety-copy p { margin: 0.15rem 0 0; font-size: 0.8rem; line-height: 1.35; }
.brdx .brd-safety-link { white-space: nowrap; font-size: 0.82rem; padding: 0.45rem 0.8rem; }

.brdx .brdx-main {
  margin-top: 0.8rem;
  padding: 1rem 1.1rem 1.4rem;
  border-radius: 18px;
}

.brdx-top { max-width: 62rem; margin-bottom: 0.9rem; }
.brdx-top .eyebrow { margin-bottom: 0.3rem; }
.brdx-top h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #fff;
}
.brdx-top .muted { margin: 0; font-size: 0.98rem; line-height: 1.5; }

/* ---------- tool tabs ---------- */
.brdx-tabs {
  position: sticky;
  top: var(--brdx-header-h);
  z-index: 20;
  display: flex;
  gap: 0.4rem;
  margin: 0 -0.35rem 1rem;
  padding: 0.45rem 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
  background: rgba(13, 24, 42, 0.96);
  border: 1px solid var(--brdx-line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}
.brdx-tabs a {
  flex: 1 0 auto;
  display: grid;
  gap: 0.1rem;
  min-width: 8.2rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--brdx-label);
  text-decoration: none;
}
.brdx-tabs a strong { font-size: 0.95rem; font-weight: 760; color: #eaf2ff; white-space: nowrap; }
.brdx-tabs a small { font-size: 0.76rem; color: var(--brdx-dim); white-space: nowrap; }
.brdx-tabs a:hover { background: rgba(96, 165, 250, 0.1); border-color: var(--brdx-line); }
.brdx-tabs a:focus-visible { outline: 2px solid #67e8f9; outline-offset: 1px; }
.brdx-tabs a[aria-current="true"] {
  background: #38d6c2;
  border-color: #38d6c2;
}
.brdx-tabs a[aria-current="true"] strong { color: #04212a; }
.brdx-tabs a[aria-current="true"] small { color: #0b3b44; }

/* With the script running, only the chosen tool is shown. Without it, all stack. */
.brdx-js [data-brdx-panel]:not(.brdx-active) { display: none; }

/* ---------- a tool ---------- */
.brdx-tool {
  margin: 0 0 1.2rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--brdx-line-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(30, 48, 78, 0.9), rgba(19, 34, 58, 0.94));
  scroll-margin-top: calc(var(--brdx-header-h) + 5rem);
}
.brdx-js .brdx-tool { margin-bottom: 0; }

.brdx-tool-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--brdx-line);
}
.brdx-tool-head .eyebrow { margin: 0 0 0.2rem; font-size: 0.74rem; }
.brdx-tool-head h2 { margin: 0; font-size: clamp(1.2rem, 1.8vw, 1.55rem); line-height: 1.2; color: #fff; }
.brdx-tool-head .muted { margin: 0.35rem 0 0; font-size: 0.92rem; }

.brdx-actions, .brdx-send { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }

.brdx-btn {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--brdx-line-strong);
  border-radius: 9px;
  background: rgba(8, 17, 32, 0.6);
  color: #dbeafe;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  width: auto;
}
.brdx-btn:hover { background: rgba(96, 165, 250, 0.16); color: #fff; }
.brdx-btn:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; }
.brdx-btn-solid { background: rgba(56, 214, 194, 0.14); border-color: rgba(56, 214, 194, 0.5); color: #d5fbf5; }
.brdx-btn.brdx-done { border-color: #34d399; color: #bbf7d0; }

.brdx-tool-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}

/* ---------- inputs ---------- */
.brdx-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.75rem 0.8rem;
}
.brdx-field { display: grid; align-content: start; gap: 0.3rem; margin: 0; min-width: 0; }
.brdx-field[hidden] { display: none; }
.brdx-field > span {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--brdx-label);
  letter-spacing: 0;
  text-transform: none;
}
.brdx-field input,
.brdx-field select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 10px;
  background: var(--brdx-field);
  color: #fff;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.brdx-field input:hover,
.brdx-field select:hover { border-color: rgba(125, 211, 252, 0.7); }
.brdx-field input:focus,
.brdx-field select:focus {
  outline: 2px solid #38d6c2;
  outline-offset: 1px;
  border-color: #38d6c2;
}
.brdx-field input::placeholder { color: #6f8198; font-weight: 500; }

/* Help text appears only for the field being edited. */
.brdx-help {
  display: none;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #cfe0f5;
  padding: 0.45rem 0.55rem;
  border-left: 3px solid #38d6c2;
  border-radius: 0 8px 8px 0;
  background: rgba(8, 17, 32, 0.7);
}
.brdx-field:focus-within .brdx-help { display: block; }
.brdx[data-brdx-help="all"] .brdx-help { display: block; }

.brdx-cell-bar {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--brdx-line);
  border-radius: 12px;
  background: var(--brdx-surface);
}
.brdx-cell-summary { display: grid; gap: 0.15rem; }
.brdx-cell-summary strong { font-size: 1rem; color: #fff; }
.brdx-cell-summary small { font-size: 0.85rem; line-height: 1.4; color: var(--brdx-dim); }

.brdx-more {
  margin-top: 0.8rem;
  border: 1px solid var(--brdx-line);
  border-radius: 12px;
  background: var(--brdx-surface);
}
.brdx-more > summary {
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 760;
  color: #dbeafe;
  cursor: pointer;
}
.brdx-more > summary:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; border-radius: 10px; }
.brdx-more[open] > summary { border-bottom: 1px solid var(--brdx-line); }
.brdx-more > .brdx-fields { padding: 0.8rem; }

.brdx-note {
  margin-top: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-left: 3px solid #f5b84b;
  border-radius: 0 10px 10px 0;
  background: rgba(245, 184, 75, 0.08);
  font-size: 0.86rem;
  line-height: 1.45;
  color: #dbe6f5;
}
.brdx-note strong { display: block; margin-bottom: 0.25rem; color: #fde9bd; }
.brdx-note p { margin: 0; }

/* ---------- results ---------- */
.brdx-results {
  position: sticky;
  top: calc(var(--brdx-header-h) + 4.6rem);
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
  border: 1px solid var(--brdx-line);
  border-radius: 14px;
  background: var(--brdx-surface);
}

.brdx .brd-tool-verdict {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--brdx-line);
  border-left-width: 6px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  color: #e2ecfa;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
}
.brdx .brd-tool-verdict::before {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brdx .brd-tool-verdict.good { border-color: #34d399; background: rgba(22, 163, 74, 0.2); color: #e7fdf0; }
.brdx .brd-tool-verdict.good::before { content: "Good"; color: #6ee7b7; }
.brdx .brd-tool-verdict.ok { border-color: #38d6c2; background: rgba(56, 214, 194, 0.13); color: #e3fbff; }
.brdx .brd-tool-verdict.ok::before { content: "OK"; color: #67e8f9; }
.brdx .brd-tool-verdict.warn { border-color: #f59e0b; background: rgba(245, 158, 11, 0.2); color: #fff6e3; }
.brdx .brd-tool-verdict.warn::before { content: "Caution"; color: #fcd34d; }
.brdx .brd-tool-verdict.danger { border-color: #ef4444; background: rgba(153, 27, 27, 0.42); color: #ffe9e9; }
.brdx .brd-tool-verdict.danger::before { content: "Stop"; color: #fca5a5; }

.brdx-meter-row { display: grid; gap: 0.3rem; }
.brdx-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  container-type: inline-size;
  background: rgba(8, 17, 32, 0.9);
  border: 1px solid var(--brdx-line);
}
.brdx-meter span {
  display: block;
  width: 0;
  max-width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399 0%, #facc15 62%, #ef4444 100%);
  background-size: 100cqw 100%;
  transition: width 0.2s ease;
}
.brdx-meter-label { font-size: 0.82rem; color: var(--brdx-dim); }

.brdx-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr));
  gap: 0.5rem;
}
.brdx-tiles-key { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.brdx-tile {
  display: grid;
  align-content: start;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--brdx-line);
  border-radius: 10px;
  background: var(--brdx-surface-2);
}
.brdx-tile label {
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brdx-dim);
}
.brdx-tile strong {
  font-size: 1.05rem;
  font-weight: 780;
  line-height: 1.2;
  color: #fff;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.brdx-tile small { font-size: 0.78rem; line-height: 1.3; color: var(--brdx-dim); overflow-wrap: anywhere; }
.brdx-tile-key { border-color: var(--brdx-line-strong); background: rgba(8, 17, 32, 0.82); padding: 0.7rem 0.8rem; }
.brdx-tile-key strong { font-size: 1.5rem; color: #7ff0df; }

.brdx-send { padding-top: 0.15rem; }
.brdx-send-label { font-size: 0.82rem; font-weight: 700; color: var(--brdx-dim); }

/* ---------- strip table ---------- */
.brdx-table-controls { max-width: 56rem; margin-bottom: 0.8rem; }
.brdx-table-note { margin: 0 0 0.6rem; font-size: 0.88rem; color: #fde9bd; }
.brdx-table-wrap { overflow-x: auto; border: 1px solid var(--brdx-line); border-radius: 12px; background: var(--brdx-surface); }
.brdx .brd-tools-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.brdx .brd-tools-table th,
.brdx .brd-tools-table td { padding: 0.6rem 0.8rem; text-align: left; white-space: nowrap; font-size: 0.95rem; border-bottom: 1px solid var(--brdx-line); }
.brdx .brd-tools-table th { font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brdx-dim); background: rgba(8, 17, 32, 0.7); }
.brdx .brd-tools-table tr:last-child td { border-bottom: 0; }
.brdx .brd-tools-table th:nth-child(6),
.brdx .brd-tools-table td:nth-child(6) { display: none; }
.brdx .brd-tools-table tr.brdx-row-ok td { background: rgba(22, 163, 74, 0.16); color: #e7fdf0; }
.brdx .brd-tools-table tr.brdx-row-ok td:nth-child(4)::after { content: "  meets need"; font-size: 0.76rem; font-weight: 700; color: #6ee7b7; }
.brdx .brd-tools-table tr.brdx-row-low td { color: #8496ad; }

/* ---------- lower page ---------- */
.brdx .brd-decoder-entry { margin-top: 1.4rem; }
.brdx-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.brdx-notes .panel { padding: 1rem 1.1rem; border: 1px solid var(--brdx-line); border-radius: 14px; background: var(--brdx-surface); }
.brdx-notes h2 { margin: 0 0 0.45rem; font-size: 1.08rem; color: #fff; }
.brdx-notes p { margin: 0 0 0.6rem; font-size: 0.92rem; line-height: 1.55; color: #cbd8ea; }
.brdx-notes .brd-reference-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0; }

.brdx-guide { margin-top: 1rem; border: 1px solid var(--brdx-line); border-radius: 14px; background: var(--brdx-surface); }
.brdx-guide > summary { padding: 0.75rem 1rem; font-weight: 760; color: #dbeafe; cursor: pointer; }
.brdx-guide .brd-reader-guide { margin: 0; padding: 0 0.6rem 0.8rem; max-width: none; }

/* Room for the chat button so it never covers the last control. */
.brdx .footer { padding-bottom: 4.5rem; }

/* ---------- narrow screens ---------- */
@media (max-width: 980px) {
  .brdx-tool-body { grid-template-columns: minmax(0, 1fr); }
  .brdx-results { position: static; }
}
@media (max-width: 640px) {
  .brdx .brdx-main { padding: 0.75rem 0.7rem 1rem; }
  .brdx .brd-safety-band-inner { flex-direction: column; align-items: flex-start; }
  .brdx-tool { padding: 0.8rem 0.75rem 0.9rem; }
  .brdx-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem 0.6rem; }
  .brdx-field-wide { grid-column: 1 / -1; }
  .brdx-tiles, .brdx-tiles-key { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brdx-tile-key strong { font-size: 1.25rem; }
  .brdx-tabs a { min-width: 7.2rem; padding: 0.45rem 0.65rem; }
}
@media (prefers-reduced-motion: reduce) {
  .brdx-meter span { transition: none; }
}
