@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/inter-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/inter-latin-800-normal.woff2") format("woff2");
}

:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2330;
  --panel: #11161f;
  --border: #2a3441;
  --border-soft: #222b36;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --muted: #6b7785;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --accent-soft: rgba(59, 130, 246, 0.15);
  /* Soft grey gradient for icon tiles that have no defined color of their own */
  --icon-tile: linear-gradient(145deg, #5a6675 0%, #48515f 55%, #3a4250 100%);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --ok: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--bg-elev), var(--panel));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
.brand-text { display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .2px; line-height: 1.15; }
.brand-text .path {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.1;
  color: var(--muted);
  max-width: 360px;
  display: inline-block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s ease;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: #fca5a5; border-color: rgba(239,68,68,.3); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  display: grid; place-items: center;
  transition: all .12s ease;
}
.icon-btn:hover { background: var(--bg-elev2); color: var(--text); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  height: calc(100vh - 59px);
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-section { padding: 14px 14px 10px; border-bottom: 1px solid var(--border-soft); }
.sidebar-section.grow { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
.hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.palette { display: flex; flex-direction: column; gap: 8px; }
.palette-block {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: all .12s ease;
}
.palette-block:hover { border-color: var(--accent); background: var(--bg-elev2); transform: translateY(-1px); }
.palette-block:active { cursor: grabbing; }
.palette-block .pb-icon { font-size: 18px; }
.palette-block strong { display: block; font-size: 13px; }
.palette-block small { color: var(--muted); font-size: 11px; }

.filter {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 10px;
}
.filter:focus { outline: none; border-color: var(--accent); }

.section-nav { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.section-nav li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
}
.section-nav li:hover { background: var(--bg-elev); color: var(--text); }
.section-nav li .nav-handle { cursor: grab; color: var(--muted); font-size: 13px; }
.section-nav li .nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-nav li .nav-count { color: var(--muted); font-size: 11px; }
.section-nav li.dim { display: none; }

.sidebar-foot {
  padding: 10px 14px; border-top: 1px solid var(--border-soft); font-size: 11px;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-btn { width: 100%; }
.app-credit { font-size: 10px; color: var(--muted); line-height: 1.4; }
.app-credit a { color: var(--text-dim); text-decoration: none; }
.app-credit a:hover { color: var(--accent); text-decoration: underline; }
.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--text-dim); text-decoration: none;
}
.linklike:hover { color: var(--accent); text-decoration: underline; }

/* Changelog modal content */
.changelog { font-size: 13px; line-height: 1.6; color: var(--text); }
.changelog h1 { font-size: 18px; margin: 0 0 12px; }
.changelog h2 {
  font-size: 15px; margin: 20px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border-soft); color: var(--text);
}
.changelog h3 { font-size: 13px; margin: 14px 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }
.changelog ul { margin: 6px 0; padding-left: 20px; }
.changelog li { margin: 3px 0; color: var(--text-dim); }
.changelog p { margin: 6px 0; color: var(--text-dim); }
.changelog a { color: var(--accent); text-decoration: none; }
.changelog a:hover { text-decoration: underline; }
.changelog code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 4px; color: var(--text);
}

/* ---------- Canvas ---------- */
.canvas { overflow-y: auto; padding: 22px; }
.groups {
  column-gap: 18px;
  column-width: 360px;
}
.group {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 18px;
  break-inside: avoid;
  overflow: hidden;
  display: inline-block;
  width: 100%;
}
.group.drag-ghost { opacity: .4; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elev2);
  border-bottom: 1px solid var(--border);
}
.group-drag { cursor: grab; }
.drag-handle { color: var(--muted); cursor: grab; user-select: none; font-size: 14px; }
.drag-handle:active { cursor: grabbing; }
.group-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
}
.group-name:hover { border-color: var(--border); }
.group-name:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.count-pill {
  font-size: 11px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
}
.group-actions { display: flex; gap: 2px; }

.service-list { padding: 8px; min-height: 14px; display: flex; flex-direction: column; gap: 6px; }
.service-list.drag-over { background: var(--accent-soft); border-radius: 8px; }

.service-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: border-color .12s ease, transform .05s ease;
}
.service-card:hover { border-color: var(--border); }
.service-card.sortable-ghost { opacity: .35; }
.service-card.sortable-chosen { border-color: var(--accent); }
.svc-icon, .icon-preview-btn { position: relative; }
.svc-icon {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center;
  background: var(--icon-tile);
  border-radius: 7px; overflow: hidden;
}
.svc-icon img { width: 24px; height: 24px; object-fit: contain; }
.svc-icon img[src=""], .svc-icon img:not([src]) { display: none; }
.icon-fallback { color: var(--muted); font-weight: 700; font-size: 13px; }

/* Iconify icons are injected as inline <svg> rather than fetched one-by-one as
   images. They paint with currentColor, which is what makes the editor's color
   control instant — setting `color` needs no new request. */
.svc-icon svg { width: 24px; height: 24px; color: var(--text); }
.icon-preview-btn svg { width: 28px; height: 28px; color: var(--text); }
.svc-main { flex: 1; min-width: 0; }
.svc-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-sub {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.svc-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s ease; }
.service-card:hover .svc-actions { opacity: 1; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state p { font-size: 16px; margin-bottom: 16px; }

/* ---------- Drawer ---------- */
.drawer-overlay, .modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
}
.drawer-overlay { justify-content: flex-end; }
.drawer {
  width: 440px; max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head, .modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.drawer-head h2, .modal-head h2 { margin: 0; font-size: 15px; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.field input[type="text"], .field input[type="password"], .advanced textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
}
.field input:focus, .advanced textarea:focus { outline: none; border-color: var(--accent); }

.icon-field { display: flex; align-items: center; gap: 8px; }
.icon-field input { flex: 1; }
.icon-preview-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  background: var(--icon-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-preview-btn:hover { border-color: var(--accent); }
.icon-preview-btn img { width: 28px; height: 28px; object-fit: contain; }
.icon-preview-btn img[src=""], .icon-preview-btn img:not([src]) { display: none; }

.icon-color-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.color-toggle input { width: 15px; height: 15px; accent-color: var(--accent); }
.icon-color-row input[type="color"] {
  width: 38px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer;
}
.icon-color-row input[type="color"]:disabled { opacity: .4; cursor: not-allowed; }
.color-val { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.color-hint { font-size: 12px; color: var(--muted); }
.icon-color-field.unsupported .color-toggle { opacity: .5; }

.advanced { border-top: 1px solid var(--border-soft); padding-top: 12px; }
.advanced summary { cursor: pointer; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.advanced textarea { font-family: var(--mono); font-size: 12px; margin-top: 8px; resize: vertical; }
.adv-error { color: #fca5a5; font-size: 12px; margin-top: 6px; min-height: 14px; }

/* ---------- Modal ---------- */
.modal {
  margin: auto;
  width: 720px; max-width: 94vw; max-height: 88vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }
.modal-overlay, .drawer-overlay { animation: fadeIn .15s ease; }
.modal-body { padding: 18px; overflow: auto; }
.modal-body pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin: 0;
  white-space: pre; overflow: auto;
}

/* ---------- Icon chooser ---------- */
.icon-modal {
  --src-w: 224px;
  width: 1040px; height: min(84vh, 860px);
  overflow: hidden;
}
/* The title sits over the sources and the search over the results, so the
   two columns line up from the header down. */
.icon-head {
  display: grid; grid-template-columns: var(--src-w) 1fr auto;
  align-items: center; gap: 0 14px; padding: 12px 14px 12px 0;
}
.icon-head h2 { padding-left: 20px; white-space: nowrap; }
.icon-search { position: relative; }
.icon-search input {
  width: 100%; height: 38px; padding: 0 12px 0 38px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.icon-search input::placeholder { color: var(--muted); }
.icon-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-search-glyph, .icon-search .spinner {
  position: absolute; left: 12px; top: 50%; margin-top: -8px;
  width: 16px; height: 16px; pointer-events: none;
  transition: opacity .15s ease;
}
.icon-search-glyph, .icon-empty-art svg {
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
/* While a search runs the magnifier turns into the spinner. */
.icon-search .spinner { opacity: 0; }
.icon-search.is-busy .spinner { opacity: 1; }
.icon-search.is-busy .icon-search-glyph { opacity: 0; }
.spinner {
  display: inline-block; box-sizing: border-box;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: conn-spin .7s linear infinite;
}

.icon-body { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--src-w) 1fr; }

/* Sources sidebar */
.icon-sources {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px 12px; min-height: 0; overflow-y: auto;
  background: rgba(0, 0, 0, .16);
  border-right: 1px solid var(--border);
}
.src-label {
  padding: 0 10px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted);
}
.src {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-dim); font-family: var(--font); text-align: left; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.src:hover { background: var(--bg-elev); color: var(--text); }
.src.active { background: var(--accent-soft); border-color: rgba(59, 130, 246, .35); color: var(--text); }
.src:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.src-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.src-text strong { font-size: 13px; font-weight: 600; }
.src-text small {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.src-dot {
  width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 3px rgba(255, 255, 255, .04);
}
.src-dot.b-all { background: conic-gradient(#93c5fd, #67e8f9, #86efac, #fcd34d, #d8b4fe, #93c5fd); }
.src-dot.b-dash { background: #93c5fd; }
.src-dot.b-mdi { background: #67e8f9; }
.src-dot.b-fa { background: #fcd34d; }
.src-dot.b-svg { background: #86efac; }
.src-dot.b-up { background: var(--text-dim); }
.src-count {
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-elev2); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 999px;
}
.src-sep { height: 1px; margin: 8px 6px; background: var(--border-soft); }
.src-foot {
  margin-top: auto; padding: 14px 6px 0;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.recolor { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recolor input[type="color"] {
  width: 34px; height: 26px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer;
}
.recolor input[type="color"]:disabled { opacity: .35; cursor: not-allowed; }
.recolor.is-off .color-toggle { opacity: .45; cursor: not-allowed; }
.src-note { margin: 0; font-size: 11px; line-height: 1.45; color: var(--muted); }
.src-note:empty { display: none; }
.ext-link { color: var(--accent); font-size: 12px; text-decoration: none; white-space: nowrap; }
.ext-link:hover { text-decoration: underline; }

/* Results */
.icon-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.icon-pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 8px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.icon-status { font-size: 12px; color: var(--muted); }
.upload-controls { display: flex; align-items: center; gap: 8px; }
.icon-results {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; padding: 16px 18px 20px; align-content: start;
}
.icon-results:empty { display: none; }

.icon-cell {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 13px 6px 10px;
  background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  cursor: pointer; outline: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease,
              box-shadow .15s ease, opacity .2s ease, filter .2s ease;
  animation: cellIn .22s ease backwards;
  animation-delay: calc(var(--i, 0) * 6ms);
}
@keyframes cellIn { from { opacity: 0; transform: translateY(5px); } }
.icon-cell:hover { background: var(--bg-elev2); border-color: var(--border); transform: translateY(-1px); }
.icon-cell:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-cell.is-current { border-color: var(--accent); background: var(--accent-soft); }
.icon-cell.is-current::before {
  content: "✓"; position: absolute; top: 5px; left: 7px;
  font-size: 11px; font-weight: 700; color: #bfdbfe;
}
/* The last results stay put, dimmed, until the next ones arrive. */
.icon-results.is-busy .icon-cell:not(.is-skel) { opacity: .4; filter: saturate(.5); pointer-events: none; }

.icon-cell .cell-art {
  position: relative; overflow: hidden;
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--icon-tile); border-radius: 10px;
}
.icon-cell .cell-art img, .icon-cell .cell-art svg { width: 30px; height: 30px; }
.icon-cell .cell-art img { object-fit: contain; }
.icon-cell .cell-art img:not([src]) { display: none; }
.icon-cell .cell-art svg { color: var(--text); }
.cell-art.is-loading .icon-fallback { display: none; }
/* Two lines, so names that share a long prefix stay told apart. */
.icon-cell .cell-label {
  max-width: 100%; line-height: 1.3;
  font-size: 11px; color: var(--text-dim); text-align: center;
  overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.icon-cell .cell-badge {
  display: none; position: absolute; top: 5px; right: 5px;
  font-size: 8px; font-weight: 700; letter-spacing: .3px;
  padding: 1px 4px; border-radius: 4px;
  background: var(--bg); color: var(--text-dim); border: 1px solid var(--border);
}
.icon-results.show-badges .cell-badge { display: block; }
.cell-badge.b-dash { color: #93c5fd; border-color: #2b4a6b; }
.cell-badge.b-mdi { color: #67e8f9; border-color: #1d5662; }
.cell-badge.b-fa { color: #fcd34d; border-color: #6b5a1e; }
.cell-badge.b-si { color: #d8b4fe; border-color: #4a2b6b; }
.cell-badge.b-svg { color: #86efac; border-color: #1e5a3a; }
.icon-cell .cell-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: #fca5a5;
  font-size: 11px; line-height: 18px; text-align: center; cursor: pointer;
  opacity: 0; transition: opacity .12s ease;
}
.icon-cell:hover .cell-del, .icon-cell:focus-within .cell-del { opacity: 1; }
.icon-cell .cell-del:hover { background: var(--danger-soft); border-color: var(--danger); }

/* Loading: a sweep across each tile until its icon is drawn, and across
   placeholder tiles before any results exist. */
.cell-art.is-loading::after,
.icon-cell.is-skel .cell-art::after,
.icon-cell.is-skel .cell-label::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, .08) 50%, transparent 75%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 160% 0; } to { background-position: -60% 0; } }
.icon-cell.is-skel { cursor: default; pointer-events: none; animation: none; }
.icon-cell.is-skel .cell-art { background: var(--bg-elev2); }
.icon-cell.is-skel .cell-label {
  position: relative; overflow: hidden;
  width: 60%; height: 9px; margin: 2px 0 1px; border-radius: 4px;
  background: var(--bg-elev2);
}

/* Idle, empty and error states */
.icon-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px 40px 64px; text-align: center;
  animation: fadeIn .2s ease;
}
.icon-empty-art {
  width: 56px; height: 56px; margin-bottom: 8px;
  display: grid; place-items: center;
  background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: 16px;
}
.icon-empty-art svg { width: 24px; height: 24px; }
.icon-empty h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.icon-empty p { margin: 0; max-width: 400px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.icon-empty-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
  margin-top: 14px;
}
.icon-empty-actions:empty { display: none; }
.chip-lead { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chip {
  padding: 5px 12px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--font); font-size: 12px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--bg-elev2); }

.icon-drop {
  position: absolute; inset: 10px; z-index: 2;
  display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  background: rgba(13, 17, 23, .85);
  font-weight: 600; color: var(--text);
  pointer-events: none;
}

@media (max-width: 760px) {
  .icon-modal { height: 92vh; }
  .icon-head { grid-template-columns: 1fr auto; padding-left: 0; }
  .icon-search { grid-column: 1 / -1; grid-row: 2; margin: 10px 0 0 14px; }
  .icon-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .icon-sources {
    flex-direction: row; overflow-x: auto; padding: 8px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .src { width: auto; flex: 0 0 auto; }
  .src-label, .src-sep, .src-text small, .src-note, .ext-link { display: none; }
  .src-foot { margin: 0 0 0 4px; padding: 0 6px; border-top: none; justify-content: center; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-elev2); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-size: 13px; min-width: 200px;
  animation: toastIn .2s ease;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.backup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.backup-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); font-size: 13px;
}
.backup-list .bk-name { font-family: var(--mono); flex: 1; }
.backup-list .bk-meta { color: var(--muted); font-size: 11px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(59, 130, 246, 0.16), transparent 70%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 30px 28px 22px;
  background: linear-gradient(180deg, var(--bg-elev), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}
.login-mark { width: 44px; height: 44px; border-radius: 10px; align-self: center; }
.login-card h1 { margin: 0; font-size: 19px; text-align: center; }
.login-sub { margin: -8px 0 4px; font-size: 13px; color: var(--muted); text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.flash {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-elev2);
}
.flash--error { background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }
.flash--success { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); color: #86efac; }
.form-error { margin: 0; font-size: 13px; color: #fca5a5; }
.login-remember { font-size: 13px; color: var(--text-dim); }
.login-submit { width: 100%; padding: 10px 14px; font-size: 14px; }
.login-credit { margin-top: 4px; text-align: center; }
.logout-form { margin: 0; display: flex; }
.btn-block { width: 100%; }

/* Turnstile widget — centred, and never wider than the card. */
.cf-turnstile { display: flex; justify-content: center; min-height: 65px; }
.cf-turnstile iframe { max-width: 100%; }

/* ---------- First-run wizard ---------- */
.wizard { gap: 12px; }
.wiz-dots { display: flex; justify-content: center; gap: 6px; margin: 2px 0 6px; }
.wiz-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); transition: background .2s ease; }
.wiz-dot.is-active { background: var(--accent); }
.wiz-step { display: none; flex-direction: column; gap: 14px; }
.wiz-step.is-active { display: flex; }
.wiz-title { margin: 0; font-size: 16px; }
.wiz-text { margin: -6px 0 0; font-size: 13px; line-height: 1.55; color: var(--text-dim); }
/* Pulled up under a step title; on a step that has none, it sits on its own. */
.wiz-step > .wiz-text:first-child { margin-top: 0; }
.wiz-text a { color: var(--accent); }
.wiz-text code, .wiz-list code { font-family: var(--mono); font-size: 12px; }
.wiz-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; color: var(--text-dim); }
.wiz-path {
  margin: -4px 0 0; padding: 9px 11px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.wiz-path code { font-family: var(--mono); font-size: 11px; word-break: break-all; color: var(--text-dim); }
/* The connection step can run taller than the window. Cap the card at the
   viewport and scroll inside it, so the page itself never gets a scrollbar
   and the step's buttons stay put. The cap is measured against the viewport,
   not the wrapper: the wrapper's height is auto, so a percentage max-height
   there would resolve to none and the card would overflow the page anyway. */
.wizard { max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); }
.wizard > * { flex-shrink: 0; }
.wizard > .wiz-step { flex-shrink: 1; min-height: 0; overflow: hidden; }
.wiz-body {
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0; overflow-y: auto;
}
.wizard-wide .wiz-body { gap: 12px; }
/* The opening and closing steps are a short message and a button — let them
   breathe, while the form and picker steps stay compact. */
.wizard.is-roomy,
.wizard.is-roomy .wiz-step,
.wizard.is-roomy .wiz-body { gap: 2rem; }
.wizard.is-roomy .wiz-nav { margin-top: 0; }
.wiz-nav { display: flex; gap: 10px; margin-top: 2px; }
.wiz-nav .btn { flex: 1; }
.wizard .hint { margin: 0; }

/* ---------- Homepage connection picker ----------
   Shared by the first-run wizard and the in-app "Homepage connection" dialog. */
.login-wrap-wide { max-width: 520px; }
.wizard-wide .wiz-step { gap: 12px; }

.conn { display: flex; flex-direction: column; gap: 12px; }
.conn-status { font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.conn-status.busy::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; vertical-align: -1px; animation: conn-spin .7s linear infinite;
}
@keyframes conn-spin { to { transform: rotate(360deg); } }
.conn-status.good { color: #86efac; }
.conn-status.warn { color: #fcd34d; }
.conn-status.bad { color: #fca5a5; }

.conn-note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--text-dim); }
.conn-note.ok { color: var(--text); }
.conn-note.sel { margin: -2px 0 0; }
.conn-note.sel.bad { color: #fca5a5; }
.conn-note code, .conn-fix code { font-family: var(--mono); font-size: 11px; }
.conn-docker { display: flex; flex-direction: column; gap: 10px; }
.conn-fix {
  padding: 11px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, .35);
  border-radius: var(--radius-sm);
}
.conn-fix p { margin: 0 0 6px; font-size: 12px; line-height: 1.55; }
.conn-fix pre {
  margin: 0; padding: 9px 11px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  white-space: pre; overflow-x: auto;
}

.conn-list { display: flex; flex-direction: column; gap: 8px; }
.conn-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, background .15s ease;
}
.conn-item:hover { border-color: var(--border); }
.conn-item.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.conn-item input[type="radio"] { margin: 3px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.conn-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.conn-path { font-family: var(--mono); font-size: 12px; color: var(--text); word-break: break-all; }
.conn-host, .conn-why { font-size: 11px; line-height: 1.5; color: var(--muted); }
.conn-host code { font-family: var(--mono); word-break: break-all; }
.conn-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.conn-tags:empty { display: none; }
.conn-tag {
  font-style: normal; font-size: 10px; font-weight: 600; letter-spacing: .3px;
  padding: 2px 6px; border-radius: 999px;
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text-dim);
}
.conn-tag.best { background: var(--accent-soft); border-color: rgba(59, 130, 246, .45); color: #bfdbfe; }
.conn-tag.ok { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); color: #86efac; }
.conn-tag.warn { background: rgba(252, 211, 77, .12); border-color: rgba(252, 211, 77, .35); color: #fcd34d; }
.conn-tag.bad { background: var(--danger-soft); border-color: rgba(239, 68, 68, .35); color: #fca5a5; }

.conn-input {
  margin-top: 5px; width: 100%; padding: 7px 9px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--mono); font-size: 12px;
}
.conn-input:focus { outline: none; border-color: var(--accent); }
.conn-error { margin: 0; font-size: 12px; color: #fca5a5; }
.conn-foot { display: flex; justify-content: flex-end; }
.conn-field { margin-top: 14px; }
.conn-field .hint { margin: 0; }
.conn-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* The header path doubles as the button that opens the dialog. */
.brand-text button.path {
  background: none; border: none; padding: 0; cursor: pointer;
  text-align: left; font-family: var(--mono);
}
.brand-text button.path:hover { color: var(--text-dim); text-decoration: underline; }

/* ---------- About ---------- */
.about-modal { width: 520px; }
.about-modal .modal-body { display: flex; flex-direction: column; gap: 18px; }
.about-head { display: flex; align-items: center; gap: 14px; }
.about-mark { width: 52px; height: 52px; border-radius: 12px; flex: 0 0 52px; }
.about-name { margin: 0 0 3px; font-size: 16px; font-weight: 700; }
.about-version { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); }
.about-tag { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.about-tag code { font-family: var(--mono); font-size: 12px; }
.about-tag a { color: var(--accent); text-decoration: none; }
.about-tag a:hover { text-decoration: underline; }

.about-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.about-links a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.about-links a:hover { border-color: var(--accent); background: var(--bg-elev2); }
.al-icon { font-size: 16px; line-height: 1; width: 20px; text-align: center; flex: 0 0 20px; }
.al-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.al-text strong { font-size: 13px; font-weight: 600; }
.al-text small { font-size: 11px; color: var(--muted); word-break: break-word; }

.about-notes { border-top: 1px solid var(--border-soft); padding-top: 14px; }
.about-notes > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-dim);
  list-style: none; display: flex; align-items: center; gap: 7px;
}
.about-notes > summary::-webkit-details-marker { display: none; }
.about-notes > summary::before { content: "▸"; font-size: 11px; color: var(--muted); }
.about-notes[open] > summary::before { content: "▾"; }
.about-notes > summary:hover { color: var(--text); }
/* The changelog is long: give it its own scroll rather than stretching the dialog. */
.about-notes .changelog { max-height: 40vh; overflow-y: auto; margin-top: 12px; padding-right: 4px; }
.about-notes .changelog h1 { font-size: 15px; }

.about-copy {
  margin: 0; padding-top: 2px;
  font-size: 12px; color: var(--muted); text-align: center;
}
.about-copy a { color: var(--text-dim); text-decoration: none; }
.about-copy a:hover { color: var(--accent); text-decoration: underline; }
