/* ── Dev Toolkit / Protocol Tools / Electronics (js/toolkit.js) ──
   Used on the homepage tabs and the /tools/*.php pages, so every
   theme variable has a fallback for pages that do not define it. */
.tk-kit { --tk-bd: var(--gray-200, #e5e7eb); --tk-soft: var(--gray-100, #f3f4f6); --tk-sub: var(--gray-500, #6b7280); --tk-acc: var(--blue-600, #2563eb); --tk-surf: var(--surface, #fff); --tk-text: var(--text, #111827); color: var(--tk-text); }
html[data-theme="dark"] .tk-kit { --tk-bd: #334155; --tk-soft: #0f172a; --tk-sub: #94a3b8; }

.tk-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tk-tab { background: var(--tk-soft); color: var(--tk-sub); border: 1px solid var(--tk-bd); padding: 7px 14px; border-radius: 100px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.tk-tab:hover { border-color: var(--tk-acc); color: var(--tk-acc); }
.tk-tab.active { background: var(--tk-acc); border-color: var(--tk-acc); color: #fff; }
.tk-panel { display: none; }
.tk-panel.active { display: block; }

.tk-box { background: var(--tk-surf); border: 1px solid var(--tk-bd); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.tk-box-h { font-size: 15px; font-weight: 700; margin: 0 0 2px; color: var(--tk-text); }
.tk-kit .tk-box-sub { font-size: 12px; color: var(--tk-sub); margin: 0 0 12px; line-height: 1.5; }

.tk-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.tk-row > .tk-f { flex: 1 1 140px; min-width: 0; }
.tk-row > .tk-f.wide { flex: 3 1 260px; }
.tk-row > .tk-f.narrow { flex: 0 1 110px; }
.tk-lbl { display: block; font-size: 11px; font-weight: 600; color: var(--tk-sub); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.tk-inp, .tk-sel, .tk-ta { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--tk-bd); border-radius: 8px; font-size: 13px; background: var(--tk-surf); color: var(--tk-text); font-family: inherit; height: auto; }
.tk-ta { min-height: 74px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.tk-inp:focus, .tk-sel:focus, .tk-ta:focus { outline: none; border-color: var(--tk-acc); }
.tk-inp[type="color"] { padding: 2px; height: 36px; cursor: pointer; }
.tk-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--tk-text); margin: 0 12px 0 0; font-weight: 400; cursor: pointer; }
.tk-chk input { margin: 0; }

.tk-btn, .tk-go { background: var(--tk-acc); color: #fff; border: none; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.tk-btn:hover, .tk-go:hover { filter: brightness(.92); }
.tk-sample { background: none; border: 1px dashed var(--tk-bd); color: var(--tk-sub); padding: 3px 9px; border-radius: 100px; font-size: 11px; cursor: pointer; margin: 0 4px 4px 0; }
.tk-sample:hover { border-color: var(--tk-acc); color: var(--tk-acc); }
.tk-copy { background: var(--tk-surf); border: 1px solid var(--tk-bd); color: var(--tk-sub); padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; vertical-align: middle; margin-left: 4px; }
.tk-copy:hover { border-color: var(--tk-acc); color: var(--tk-acc); }
.tk-copy.done { background: #10b981; border-color: #10b981; color: #fff; }

.tk-out { margin-top: 12px; font-size: 13px; }
.tk-table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12.5px; }
.tk-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--tk-sub); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--tk-bd); background: var(--tk-soft); }
.tk-table td { padding: 6px 8px; border-bottom: 1px solid var(--tk-bd); vertical-align: top; word-break: break-word; }
.tk-out { overflow-x: auto; }
.tk-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--tk-soft); color: var(--tk-text); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.tk-pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--tk-soft); color: var(--tk-text); border: 1px solid var(--tk-bd); border-radius: 8px; padding: 10px 12px; margin: 0 0 6px; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; }
.tk-frame { font-size: 15px; font-weight: 600; letter-spacing: .04em; color: var(--tk-acc); }
.tk-result { margin-bottom: 8px; }
.tk-h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tk-sub); margin: 14px 0 4px; }
.tk-meta { font-size: 12px; color: var(--tk-sub); margin: 6px 0; line-height: 1.6; }
.tk-kit .tk-muted, .tk-muted { color: var(--tk-sub); font-size: 11.5px; }
.tk-err { color: #dc2626; font-weight: 600; }
.tk-ok { color: #059669; font-weight: 700; }
.tk-warn { color: #d97706; font-weight: 700; }
.tk-bad { color: #dc2626; font-weight: 700; }
.tk-verdict { padding: 8px 12px; border-radius: 8px; font-weight: 600; margin: 8px 0; font-size: 13px; }
.tk-verdict.ok { background: #ecfdf5; color: #047857; }
.tk-verdict.warn { background: #fffbeb; color: #b45309; }
.tk-verdict.bad { background: #fef2f2; color: #b91c1c; }
html[data-theme="dark"] .tk-verdict.ok { background: #064e3b; color: #6ee7b7; }
html[data-theme="dark"] .tk-verdict.warn { background: #451a03; color: #fcd34d; }
html[data-theme="dark"] .tk-verdict.bad { background: #450a0a; color: #fca5a5; }

.tk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 10px; }
.tk-card { background: var(--tk-soft); border: 1px solid var(--tk-bd); border-radius: 10px; padding: 10px 12px; }
.tk-card-l { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--tk-sub); }
.tk-card-v { font-size: 18px; font-weight: 700; color: var(--tk-acc); margin-top: 2px; word-break: break-word; }

.tk-jwt-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
@media (max-width: 700px) { .tk-jwt-grid { grid-template-columns: 1fr; } }
.tk-json { color: #7c3aed; }
html[data-theme="dark"] .tk-json { color: #c4b5fd; }

.tk-swatches { display: flex; gap: 16px; margin-bottom: 8px; }
.tk-swatches > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tk-swatch { width: 72px; height: 44px; border-radius: 8px; border: 1px solid var(--tk-bd); display: block; }

.tk-ieee { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; letter-spacing: .05em; word-break: break-all; }
.tk-ieee span { padding: 3px 4px; border-radius: 4px; }
.tk-ieee .s { background: #fee2e2; color: #991b1b; }
.tk-ieee .e { background: #dcfce7; color: #166534; margin: 0 3px; }
.tk-ieee .m { background: #dbeafe; color: #1e40af; }

.tk-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .tk-two { grid-template-columns: 1fr; } }
.tk-two > .tk-box { margin-bottom: 0; min-width: 0; }
.tk-panel > .tk-two + .tk-box, .tk-panel > .tk-two + .tk-two { margin-top: 14px; }

/* Homepage only: theme.css styles every button, input, select and textarea
   with !important (and dark.css again with button:not(.btn-primary)), so the
   toolkit's own controls need a heavier selector plus !important to keep
   their look. Harmless on the /tools pages, which have no such rules. */
html body .tk-kit button.tk-tab, html body .tk-kit button.tk-copy, html body .tk-kit button.tk-go, html body .tk-kit button.tk-sample {
    display: inline-block !important; box-shadow: none !important; line-height: 1.3 !important; font-family: inherit !important; transform: none !important; white-space: nowrap !important; gap: 0 !important;
}
html body .tk-kit button.tk-tab { background: var(--tk-soft) !important; color: var(--tk-sub) !important; border: 1px solid var(--tk-bd) !important; padding: 7px 14px !important; border-radius: 100px !important; font-size: 13px !important; font-weight: 600 !important; }
html body .tk-kit button.tk-tab:hover { border-color: var(--tk-acc) !important; color: var(--tk-acc) !important; }
html body .tk-kit button.tk-tab.active { background: var(--tk-acc) !important; border-color: var(--tk-acc) !important; color: #fff !important; }
html body .tk-kit button.tk-copy { background: var(--tk-surf) !important; border: 1px solid var(--tk-bd) !important; color: var(--tk-sub) !important; padding: 2px 8px !important; border-radius: 6px !important; font-size: 11px !important; font-weight: 600 !important; }
html body .tk-kit button.tk-copy:hover { border-color: var(--tk-acc) !important; color: var(--tk-acc) !important; }
html body .tk-kit button.tk-copy.done { background: #10b981 !important; border-color: #10b981 !important; color: #fff !important; }
html body .tk-kit button.tk-go { background: var(--tk-acc) !important; border: 1px solid var(--tk-acc) !important; color: #fff !important; padding: 8px 16px !important; border-radius: 8px !important; font-size: 13px !important; font-weight: 600 !important; }
html body .tk-kit button.tk-sample { background: transparent !important; border: 1px dashed var(--tk-bd) !important; color: var(--tk-sub) !important; padding: 3px 9px !important; border-radius: 100px !important; font-size: 11px !important; font-weight: 500 !important; }
html body .tk-kit button.tk-sample:hover { border-color: var(--tk-acc) !important; color: var(--tk-acc) !important; }
html body .tk-kit .tk-inp, html body .tk-kit .tk-sel, html body .tk-kit .tk-ta {
    background: var(--tk-surf) !important; color: var(--tk-text) !important; border: 1px solid var(--tk-bd) !important; border-radius: 8px !important; padding: 8px 10px !important; font-size: 13px !important; box-shadow: none !important; font-family: inherit !important; height: auto !important;
}
html body .tk-kit .tk-ta { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-size: 12.5px !important; }
html body .tk-kit .tk-inp[type="color"] { padding: 2px !important; height: 36px !important; }
html body .tk-kit .tk-inp:focus, html body .tk-kit .tk-sel:focus, html body .tk-kit .tk-ta:focus { border-color: var(--tk-acc) !important; }
html body .tk-kit .tk-sel { padding-right: 24px !important; }
