/* ── Header tool search (_topbar.php #ip-search, js/home/tool-search.js) ──
   theme.css/dark.css style every input and button with !important, so the
   controls here use html-body-scoped selectors to keep their own look. */
.ip-search { position: relative; flex: 1 1 auto; max-width: 460px; min-width: 0; margin: 0 8px; }
.ip-search-box { position: relative; display: flex; align-items: center; height: 40px; padding: 0 10px 0 38px; border-radius: 12px; background: var(--gray-100); border: 1px solid transparent; transition: background .18s, border-color .18s, box-shadow .18s; }
.ip-search-box:hover { background: #eceef2; }
.ip-search.active .ip-search-box { background: var(--white); border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(59, 130, 246, .14), 0 6px 20px rgba(37, 99, 235, .08); }
.ip-search-ico { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--gray-400); pointer-events: none; transition: color .18s; }
.ip-search.active .ip-search-ico { color: var(--blue-600); }
html body .ip-search .ip-search-input { flex: 1; min-width: 0; width: 100%; height: 38px; padding: 0 !important; margin: 0; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none !important; font-family: var(--sans) !important; font-size: 14px !important; color: var(--text) !important; -webkit-appearance: none; appearance: none; }
html body .ip-search .ip-search-input::placeholder { color: var(--gray-400); }
.ip-search-input::-webkit-search-cancel-button { display: none; }
.ip-search-kbd { flex-shrink: 0; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--gray-500); background: var(--white); border: 1px solid var(--gray-200); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; line-height: 1.5; }
.ip-search.active .ip-search-kbd { display: none; }
html body .ip-search button.ip-search-close, html body .ip-search button.ip-search-open { display: none !important; }

/* Dropdown */
.ip-search-drop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 380px; z-index: 300; background: var(--white); border: 1px solid var(--gray-200); border-radius: 16px; box-shadow: 0 18px 50px rgba(15, 23, 42, .16), 0 4px 12px rgba(15, 23, 42, .06); overflow: hidden; animation: ipsIn .14s ease-out; }
.ip-search-drop[hidden] { display: none; }
@keyframes ipsIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ip-search-drop::before { content: ''; display: block; height: 3px; background: linear-gradient(90deg, var(--blue-600), var(--indigo-500)); }
.ip-search-list { list-style: none; margin: 0; padding: 6px; max-height: min(62vh, 520px); overflow-y: auto; }
.ips-label { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gray-400); }
html body .ip-search button.ips-clear { display: inline !important; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; font-size: 11px !important; font-weight: 600 !important; text-transform: none; letter-spacing: 0; color: var(--blue-600) !important; cursor: pointer; }
.ips-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ips-item.sel { background: var(--blue-50); }
.ips-ic { flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.ips-ic svg { width: 17px; height: 17px; }
.ips-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ips-title { font-size: 13.5px; font-weight: 600; color: var(--gray-900); line-height: 1.35; }
.ips-desc { font-size: 12px; color: var(--gray-500); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ips-ext { margin-left: 4px; color: var(--gray-400); font-weight: 400; }
.ips-cat { flex-shrink: 0; font-size: 10.5px; font-weight: 600; color: var(--gray-400); }
.ips-item.sel .ips-cat { color: var(--blue-600); }
.ips-item mark { background: rgba(250, 204, 21, .45); color: inherit; padding: 0 1px; border-radius: 3px; }
.ips-note { padding: 10px 10px 6px; font-size: 12px; color: var(--gray-400); }
.ips-empty { display: flex; flex-direction: column; gap: 4px; padding: 26px 16px; text-align: center; font-size: 13.5px; color: var(--gray-700); }
.ips-empty span { font-size: 12px; color: var(--gray-400); }

.ip-search-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--gray-100); background: var(--gray-50); font-size: 11px; color: var(--gray-400); }
.ip-search-foot kbd { font-family: var(--mono); font-size: 10px; padding: 0 5px; margin: 0 1px; border: 1px solid var(--gray-200); border-bottom-width: 2px; border-radius: 4px; background: var(--white); color: var(--gray-500); }
.ip-search-web { color: var(--blue-600) !important; font-weight: 600; text-decoration: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.ip-search-web:hover { text-decoration: underline !important; }

/* Category colours (icon tiles) */
.ips-g-ws { background: #ede9fe; color: #6d28d9; }
.ips-g-net { background: #dbeafe; color: #1d4ed8; }
.ips-g-util { background: #e0e7ff; color: #4338ca; }
.ips-g-conv, .ips-g-fmt { background: #e0f2fe; color: #0369a1; }
.ips-g-dev { background: #fce7f3; color: #be185d; }
.ips-g-emb { background: #dcfce7; color: #15803d; }
.ips-g-elec { background: #fef3c7; color: #b45309; }
.ips-g-comm { background: #ffe4e6; color: #be123c; }
.ips-g-iot, .ips-g-viz { background: #ccfbf1; color: #0f766e; }
.ips-g-site { background: var(--gray-100); color: var(--gray-600); }

/* Briefly ring the section a result jumped to. */
@keyframes tsFlash { 0%, 60% { box-shadow: 0 0 0 3px rgba(59, 130, 246, .55); background-color: rgba(59, 130, 246, .08); } 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0); background-color: transparent; } }
.ts-flash { animation: tsFlash 1.8s ease-out; border-radius: 8px; }

/* Narrow desktop: the online pill and clock need the room. */
@media (max-width: 1199px) { .ip-search { max-width: 340px; } .ip-search-kbd { display: none; } }

/* Tablet and phone: an icon in the bar; the box opens as a sheet under it. */
@media (max-width: 900px) {
    .ip-search { flex: 0 0 auto; margin: 0 0 0 auto; position: static; }
    html body .ip-search button.ip-search-open { display: flex !important; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0 !important; border-radius: 10px !important; border: 1px solid var(--gray-200) !important; background: var(--white) !important; color: var(--gray-700) !important; box-shadow: none !important; }
    .ip-search-open svg { width: 18px; height: 18px; }
    .ip-search .ip-search-box, .ip-search .ip-search-drop { display: none; }
    .ip-search.sheet { position: absolute; left: 0; right: 0; top: 0; z-index: 400; margin: 0; max-width: none; padding: 11px 12px; background: var(--white); box-shadow: 0 10px 30px rgba(15, 23, 42, .18); }
    .ip-search.sheet .ip-search-box { display: flex; height: 40px; }
    .ip-search.sheet .ip-search-drop:not([hidden]) { display: block; position: static; min-width: 0; margin-top: 10px; border-radius: 14px; box-shadow: none; }
    .ip-search.sheet .ip-search-list { max-height: calc(100vh - 170px); }
    html body .ip-search.sheet button.ip-search-open { display: none !important; }
    html body .ip-search.sheet button.ip-search-close { display: flex !important; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0 !important; margin-left: 6px; border: 0 !important; border-radius: 8px !important; background: var(--gray-200) !important; color: var(--gray-600) !important; font-size: 12px !important; box-shadow: none !important; }
    .ip-search-foot .ip-search-keys { display: none; }
    /* Room for the search icon: the bar's 24px side margins are spare on a phone. */
    .ip-topbar-inner { width: 100% !important; gap: 10px !important; }
    .ip-topbar-right { gap: 8px !important; }
    .ip-search-web { max-width: 100%; }
    .ips-cat { display: none; }
}

/* Dark */
html[data-theme="dark"] .ip-search-box { background: #1e293b; }
html[data-theme="dark"] .ip-search-box:hover { background: #253248; }
html[data-theme="dark"] .ip-search.active .ip-search-box { background: #0f172a; border-color: #3b82f6; box-shadow: 0 0 0 4px rgba(59, 130, 246, .2); }
html[data-theme="dark"] body .ip-search .ip-search-input { background: transparent !important; border: 0 !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .ip-search-kbd, html[data-theme="dark"] .ip-search-foot kbd { background: #0f172a; border-color: #334155; color: #94a3b8; }
html[data-theme="dark"] .ip-search-drop { background: #1e293b; border-color: #334155; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .ips-item.sel { background: #334155; }
html[data-theme="dark"] .ips-title { color: #f1f5f9; }
html[data-theme="dark"] .ips-desc, html[data-theme="dark"] .ips-empty { color: #94a3b8; }
html[data-theme="dark"] .ips-item.sel .ips-cat { color: #93c5fd; }
html[data-theme="dark"] .ips-item mark { background: rgba(234, 179, 8, .35); color: #fef9c3; }
html[data-theme="dark"] .ip-search-foot { background: #0f172a; border-color: #334155; }
html[data-theme="dark"] .ips-ic { filter: saturate(.85) brightness(.9); }
html[data-theme="dark"] .ip-search.sheet { background: #0f172a; }
html[data-theme="dark"] body .ip-search button.ip-search-open { background: #1e293b !important; border-color: #334155 !important; color: #cbd5e1 !important; }
html[data-theme="dark"] body .ip-search.sheet button.ip-search-close { background: #334155 !important; color: #cbd5e1 !important; }

/* Small phones (360px class) */
@media (max-width: 380px) {
    .ip-topbar-inner { gap: 6px !important; }
    html body .ip-search button.ip-search-open { width: 34px; height: 34px; }
}
