/* ================================================================
   JustOSINT — Main Stylesheet
   Dark theme, spacious, modern
   ================================================================ */

/* ── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font: inherit; }
input, textarea, select { font: inherit; }

/* ── CSS Variables ─────────────────────────── */
:root {
  --theme-transition-duration: 260ms;
  --theme-transition-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bg-base: #0d1117;
  --bg-raised: #161b22;
  --bg-card: #1c2128;
  --bg-card-hover: #21262d;
  --bg-input: #141720;
  --border: #30363d;
  --border-subtle: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #656d76;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --link-color: #58a6ff;
  --sidebar-w: 240px;
  --topbar-h: 58px;
  --panel-w: 380px;

  --discord-btn-border: rgba(114, 137, 218, 0.55);
  --discord-btn-bg-1: rgba(114, 137, 218, 0.26);
  --discord-btn-bg-2: rgba(88, 101, 242, 0.22);
  --discord-btn-text: #e6e9ff;
  --discord-btn-shadow-1: rgba(255,255,255,0.1);
  --discord-btn-shadow-2: rgba(35, 46, 111, 0.28);
  --discord-btn-hover-border: rgba(135, 154, 255, 0.9);
  --discord-btn-hover-bg-1: rgba(135, 154, 255, 0.35);
  --discord-btn-hover-bg-2: rgba(102, 120, 255, 0.3);
  --discord-btn-hover-text: #ffffff;
  --discord-btn-hover-shadow-1: rgba(255,255,255,0.14);
  --discord-btn-hover-shadow-2: rgba(35, 46, 111, 0.35);

  /* Requirement badge colors */
  --badge-open-bg: rgba(35, 134, 54, 0.18);
  --badge-open-text: #3fb950;
  --badge-open-border: rgba(63, 185, 80, 0.35);

  --badge-login-bg: rgba(187, 90, 0, 0.18);
  --badge-login-text: #f0883e;
  --badge-login-border: rgba(240, 136, 62, 0.35);

  --badge-api-bg: rgba(31, 111, 235, 0.18);
  --badge-api-text: #58a6ff;
  --badge-api-border: rgba(88, 166, 255, 0.35);

  --badge-paid-bg: rgba(163, 113, 247, 0.18);
  --badge-paid-text: #c084fc;
  --badge-paid-border: rgba(192, 132, 252, 0.35);

  --badge-install-bg: rgba(210, 153, 34, 0.15);
  --badge-install-text: #e3b341;
  --badge-install-border: rgba(227, 179, 65, 0.3);

  --badge-dork-bg: rgba(32, 178, 171, 0.15);
  --badge-dork-text: #2dd4bf;
  --badge-dork-border: rgba(45, 212, 191, 0.3);
}

[data-theme="light"] {
  --bg-base: #f7f9fc;
  --bg-raised: #ffffff;
  --bg-card: #f4f7fb;
  --bg-card-hover: #eef3f9;
  --bg-input: #ffffff;
  --border: #d4dde8;
  --border-subtle: #e6ecf3;
  --text-primary: #152033;
  --text-secondary: #42516b;
  --text-muted: #6f7f99;
  --accent: #2f6feb;
  --accent-hover: #3f7bf1;
  --link-color: #2f6feb;

  --discord-btn-border: rgba(88, 101, 242, 0.45);
  --discord-btn-bg-1: rgba(88, 101, 242, 0.14);
  --discord-btn-bg-2: rgba(88, 101, 242, 0.08);
  --discord-btn-text: #24304f;
  --discord-btn-shadow-1: rgba(255,255,255,0.65);
  --discord-btn-shadow-2: rgba(33, 52, 116, 0.12);
  --discord-btn-hover-border: rgba(88, 101, 242, 0.62);
  --discord-btn-hover-bg-1: rgba(88, 101, 242, 0.2);
  --discord-btn-hover-bg-2: rgba(88, 101, 242, 0.14);
  --discord-btn-hover-text: #111f42;
  --discord-btn-hover-shadow-1: rgba(255,255,255,0.72);
  --discord-btn-hover-shadow-2: rgba(33, 52, 116, 0.18);
}

a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; }

body {
  transition: background-color 0.2s ease, color 0.2s ease;
}

html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color var(--theme-transition-duration) var(--theme-transition-ease),
    color var(--theme-transition-duration) var(--theme-transition-ease),
    border-color var(--theme-transition-duration) var(--theme-transition-ease),
    box-shadow var(--theme-transition-duration) var(--theme-transition-ease),
    fill var(--theme-transition-duration) var(--theme-transition-ease),
    stroke var(--theme-transition-duration) var(--theme-transition-ease) !important;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-transitioning *,
  html.theme-transitioning *::before,
  html.theme-transitioning *::after {
    transition: none !important;
  }
}

/* ── Top Bar ───────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-icon {
  color: var(--accent);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-credit {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-search {
  flex: 1;
  position: relative;
  max-width: 620px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-icon svg {
  width: 16px;
  height: 16px;
}

#searchInput {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 9px 36px 9px 36px;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

#searchInput::placeholder { color: var(--text-muted); }

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.12);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover { color: var(--text-primary); }
.search-clear.hidden { display: none; }

.search-clear svg {
  width: 14px;
  height: 14px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-secondary);
  padding: 7px 13px;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  width: 15px;
  height: 15px;
}

.topbar-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.topbar-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88,166,255,0.1);
}

#themeToggleBtn.theme-light {
  color: #e3b341;
  border-color: rgba(227, 179, 65, 0.45);
  background: rgba(227, 179, 65, 0.12);
}

#themeToggleBtn.theme-dark {
  color: #58a6ff;
  border-color: rgba(88, 166, 255, 0.45);
  background: rgba(88, 166, 255, 0.12);
}

/* ── App Body Layout ───────────────────────── */
#appBody {
  margin-top: var(--topbar-h);
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 18px 16px 8px;
}

#catNav {
  flex: 1;
  padding-bottom: 16px;
}

.sidebar-credit {
  border-top: 1px solid var(--border-subtle);
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-credit-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-credit-line {
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.sidebar-discord-btn {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--discord-btn-border);
  background: linear-gradient(180deg, var(--discord-btn-bg-1) 0%, var(--discord-btn-bg-2) 100%);
  color: var(--discord-btn-text);
  text-decoration: none;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 var(--discord-btn-shadow-1), 0 3px 10px var(--discord-btn-shadow-2);
  transition: all 0.18s ease;
}

.sidebar-discord-btn:hover {
  color: var(--discord-btn-hover-text);
  border-color: var(--discord-btn-hover-border);
  background: linear-gradient(180deg, var(--discord-btn-hover-bg-1) 0%, var(--discord-btn-hover-bg-2) 100%);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 var(--discord-btn-hover-shadow-1), 0 6px 16px var(--discord-btn-hover-shadow-2);
  text-decoration: none;
}

.sidebar-discord-btn:active {
  transform: translateY(0);
}

.sidebar-discord-btn .discord-glyph {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-radius: 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  gap: 8px;
}

.cat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cat-icon i,
.cat-icon svg {
  width: 100%;
  height: 100%;
}

.cat-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.cat-item.active {
  background: rgba(88,166,255,0.12);
  color: var(--accent);
  font-weight: 600;
}

.cat-item.all-item {
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  padding-bottom: 12px;
}

.cat-item.fav-item {
  color: #f1c232;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
  padding-top: 12px;
}

.cat-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cat-count {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
  padding: 1px 5px;
  border-radius: 10px;
  flex-shrink: 0;
}

.cat-item.active .cat-count {
  background: rgba(88,166,255,0.18);
  color: var(--accent);
}

/* ── Main Wrap ───────────────────────────── */
#mainWrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Filter Bar ──────────────────────────── */
#filterBar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#reqFilters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#facetFilters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#regionFilters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#safetyFilters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.req-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.facet-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.15s;
}

.region-filter,
.safety-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.15s;
}

.req-filter:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.facet-filter:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
}

.region-filter:hover,
.safety-filter:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
}

.req-filter.active {
  background: rgba(88,166,255,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.facet-filter.active {
  background: rgba(88,166,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.region-filter.active,
.safety-filter.active {
  background: rgba(88,166,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.safety-filter[data-safety="caution"].active {
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.45);
  color: #ff7b72;
}

.safety-filter[data-safety="screened"].active {
  background: rgba(63, 185, 80, 0.12);
  border-color: rgba(63, 185, 80, 0.4);
  color: #3fb950;
}

.req-filter[data-req="open"].active    { background: var(--badge-open-bg); border-color: var(--badge-open-border); color: var(--badge-open-text); }
.req-filter[data-req="login"].active   { background: var(--badge-login-bg); border-color: var(--badge-login-border); color: var(--badge-login-text); }
.req-filter[data-req="api"].active     { background: var(--badge-api-bg); border-color: var(--badge-api-border); color: var(--badge-api-text); }
.req-filter[data-req="paid"].active    { background: var(--badge-paid-bg); border-color: var(--badge-paid-border); color: var(--badge-paid-text); }
.req-filter[data-req="install"].active { background: var(--badge-install-bg); border-color: var(--badge-install-border); color: var(--badge-install-text); }
.req-filter[data-req="dork"].active    { background: var(--badge-dork-bg); border-color: var(--badge-dork-border); color: var(--badge-dork-text); }

.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-dot.open    { background: var(--badge-open-text); }
.badge-dot.login   { background: var(--badge-login-text); }
.badge-dot.api     { background: var(--badge-api-text); }
.badge-dot.paid    { background: var(--badge-paid-text); }
.badge-dot.install { background: var(--badge-install-text); }
.badge-dot.dork    { background: var(--badge-dork-text); }

#resultMeta {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Tool Grid ───────────────────────────── */
#toolGrid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#toolGrid::-webkit-scrollbar { width: 6px; }
#toolGrid::-webkit-scrollbar-track { background: transparent; }
#toolGrid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Tool Card ───────────────────────────── */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}

.tool-card:hover {
  border-color: #3d444d;
  background: var(--bg-card-hover);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.card-title a {
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.3;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title a:hover { color: var(--accent); text-decoration: none; }

.card-fav {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-fav:hover {
  border-color: #f1c232;
  color: #f1c232;
  background: rgba(241, 194, 50, 0.14);
}

.card-fav.pinned {
  color: #f1c232;
  border-color: rgba(241, 194, 50, 0.6);
  background: rgba(241, 194, 50, 0.16);
}

.card-fav svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.card-fav.pinned svg {
  fill: currentColor;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.req-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  letter-spacing: 0.02em;
  border: 1px solid;
  white-space: nowrap;
}

.req-badge.open    { background: var(--badge-open-bg); color: var(--badge-open-text); border-color: var(--badge-open-border); }
.req-badge.login   { background: var(--badge-login-bg); color: var(--badge-login-text); border-color: var(--badge-login-border); }
.req-badge.api     { background: var(--badge-api-bg); color: var(--badge-api-text); border-color: var(--badge-api-border); }
.req-badge.paid    { background: var(--badge-paid-bg); color: var(--badge-paid-text); border-color: var(--badge-paid-border); }
.req-badge.install { background: var(--badge-install-bg); color: var(--badge-install-text); border-color: var(--badge-install-border); }
.req-badge.dork    { background: var(--badge-dork-bg); color: var(--badge-dork-text); border-color: var(--badge-dork-border); }

.meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid;
  white-space: nowrap;
}

.meta-badge.region {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.28);
}

.meta-badge.safety.screened {
  background: rgba(63, 185, 80, 0.12);
  color: #3fb950;
  border-color: rgba(63, 185, 80, 0.35);
}

.meta-badge.safety.caution {
  background: rgba(248, 81, 73, 0.12);
  color: #ff7b72;
  border-color: rgba(248, 81, 73, 0.35);
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-category {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Empty State ─────────────────────────── */
#emptyState {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 10px;
  padding: 60px 24px;
}

#emptyState.hidden { display: none; }

.empty-icon { font-size: 2.5rem; opacity: 0.5; display: inline-flex; align-items: center; justify-content: center; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-sub { font-size: 0.85rem; }

.empty-icon svg {
  width: 34px;
  height: 34px;
}

/* ── Side Panels ─────────────────────────── */
.side-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel:not(.hidden) {
  transform: translateX(0);
}

.side-panel.hidden {
  display: flex; /* Keep in flex so transition works */
  transform: translateX(100%);
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.panel-title svg {
  width: 15px;
  height: 15px;
}

.panel-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.panel-close:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.panel-close svg {
  width: 14px;
  height: 14px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Overlay ─────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
  backdrop-filter: blur(2px);
  transition: opacity 0.2s;
}
#overlay.hidden { display: none; }

/* ── Profile Panel ───────────────────────── */
.panel-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.field-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-help {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.hidden-file-input {
  display: none;
}

.profile-image-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, var(--bg-card-hover), var(--bg-card));
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-initial {
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
}

.profile-avatar-preview {
  width: 48px;
  height: 48px;
}

.profile-avatar-preview .profile-avatar-initial {
  font-size: 1rem;
}

.field-group input,
.field-group textarea,
.field-group select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 0.85rem;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: var(--accent);
}

.field-group input::placeholder,
.field-group textarea::placeholder { color: var(--text-muted); }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.small-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 5px 12px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.small-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.small-btn svg {
  width: 14px;
  height: 14px;
}

.row-gap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Profile List Items ──────────────────── */
.profile-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: grab;
  transition: border-color 0.15s;
}
.profile-item:hover { border-color: var(--accent); }
.profile-item.dragging { opacity: 0.5; }

.profile-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-item-main {
  min-width: 0;
  flex: 1;
}

.profile-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}
.profile-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.profile-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}

/* ── Favorites Panel ─────────────────────── */
.fav-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.fav-list-item:last-child { border-bottom: none; }

.fav-item-name {
  font-size: 0.85rem;
  flex: 1;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-item-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.fav-unpin {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fav-unpin:hover { color: #f85149; }

.fav-unpin svg {
  width: 14px;
  height: 14px;
}

.empty-fav {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 20px 0;
  text-align: center;
}

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }

/* ── Category header in grid ─────────────── */
.grid-section-header {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 2px 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

/* ── Scrollbar for main grid ─────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
}

@media (max-width: 680px) {
  #sidebar { display: none; }
  #toolGrid { grid-template-columns: 1fr; }
  .topbar-btn .btn-label { display: none; }
  .brand-credit { display: none; }
  :root { --panel-w: 100%; }
}

/* ── Category section in "All" view ─────── */
.cat-section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 6px;
}

.cat-section-title h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cat-section-title span {
  font-size: 0.75rem;
  color: var(--text-muted);
}
