/* Your own strategy -- rule builder. Uses the portal's own theme variables (dashboard.py :root). */
#custom-builder { margin-top: 10px; padding: 12px; background: var(--bg-2); border: 1px solid var(--bd-1);
                  border-left: 3px solid var(--acc); border-radius: 6px; font-size: 12px; color: var(--tx-1); }
#custom-builder[hidden] { display: none; }
#custom-builder .cb-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
#custom-builder .cb-title { font-weight: 700; font-size: 13px; color: var(--tx-0); }
#custom-builder .cb-tpl { display: flex; gap: 6px; }
#custom-builder .cb-tpl select { flex: 1; min-width: 0; }
#custom-builder .cb-about { color: var(--tx-2); font-size: 11px; line-height: 1.45; }
#custom-builder .cb-rule { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
#custom-builder label { color: var(--tx-1); font-size: 11px; font-weight: 600; }
#custom-builder textarea { width: 100%; box-sizing: border-box; resize: vertical; padding: 6px 8px;
                           background: var(--bg-1); border: 1px solid var(--bd-1); border-radius: 4px;
                           color: var(--tx-0); font: 12px/1.45 "JetBrains Mono", ui-monospace, Consolas, monospace; }
#custom-builder textarea:focus, #custom-builder input:focus, #custom-builder select:focus {
  outline: 2px solid var(--acc); outline-offset: 0; border-color: var(--acc); }
#custom-builder .cb-sub { margin: 10px 0 6px; font-weight: 700; color: var(--tx-0); font-size: 12px; }
#custom-builder .cb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
#custom-builder .cb-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#custom-builder .cb-pair { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 4px; }
#custom-builder input, #custom-builder select { width: 100%; box-sizing: border-box; padding: 4px 6px;
                           background: var(--bg-1); border: 1px solid var(--bd-1); border-radius: 3px;
                           color: var(--tx-0); font-size: 12px; font-family: inherit; }
#custom-builder input:disabled { opacity: 0.5; }
#custom-builder button { padding: 5px 10px; background: var(--bg-1); color: var(--tx-0); border: 1px solid var(--bd-2);
                         border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
#custom-builder button:hover { border-color: var(--acc); }
#custom-builder button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
#custom-builder .cb-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
#custom-builder #cb-status { font-size: 11px; line-height: 1.45; }
#custom-builder .cb-ok { color: var(--ok); }
#custom-builder .cb-bad { color: var(--bad); }
#custom-builder .cb-help { margin-top: 12px; }
#custom-builder .cb-help summary { cursor: pointer; color: var(--acc); font-weight: 600; }
#custom-builder .cb-help p { color: var(--tx-2); margin: 6px 0; line-height: 1.45; }
#custom-builder .cb-ops { margin: 6px 0 8px; padding-left: 18px; color: var(--tx-2); line-height: 1.5; }
#custom-builder .cb-ref { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 11px; }
#custom-builder .cb-ref th, #custom-builder .cb-ref td { text-align: left; padding: 3px 6px;
                           border-bottom: 1px solid var(--bd-1); vertical-align: top; }
#custom-builder .cb-ref th { color: var(--tx-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
#custom-builder .cb-ref code { color: var(--tx-0); font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; white-space: nowrap; }
@media (max-width: 520px) { #custom-builder .cb-grid { grid-template-columns: 1fr; } }

/* Light theme: widgets/theme_widget.py overrides only some variables (--bg-2 stays dark), so the
   builder sets its own light colours -- otherwise headings go dark-on-dark and vanish. */
html[data-theme="light"] #custom-builder { background: #f6f8fa; border-color: #d0d7de;
                                           border-left-color: #0969da; color: #57606a; }
html[data-theme="light"] #custom-builder .cb-title,
html[data-theme="light"] #custom-builder .cb-sub { color: #1f2328; }
html[data-theme="light"] #custom-builder label,
html[data-theme="light"] #custom-builder .cb-about,
html[data-theme="light"] #custom-builder .cb-help p,
html[data-theme="light"] #custom-builder .cb-ops,
html[data-theme="light"] #custom-builder .cb-ref th { color: #57606a; }
html[data-theme="light"] #custom-builder textarea,
html[data-theme="light"] #custom-builder input,
html[data-theme="light"] #custom-builder select,
html[data-theme="light"] #custom-builder button { background: #ffffff; color: #1f2328; border-color: #d0d7de; }
html[data-theme="light"] #custom-builder .cb-help { background: transparent; }
html[data-theme="light"] #custom-builder .cb-help summary { color: #0969da; }
html[data-theme="light"] #custom-builder .cb-ref td { border-bottom-color: #e1e6eb; }
html[data-theme="light"] #custom-builder .cb-ref code { color: #1f2328; }
html[data-theme="light"] #custom-builder .cb-ok { color: #1a7f37; }
html[data-theme="light"] #custom-builder .cb-bad { color: #cf222e; }
