/* ─── Variables ───────────────────────────────────────────── */
:root {
  --bg:           #0c0a14;
  --bg-card:      #161322;
  --bg-input:     #1c1830;
  --bg-hover:     #221e35;
  --border:       #342e50;
  --border-light: #443c66;
  --accent:       #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #a78bfa;
  --accent-glow:  rgba(124, 58, 237, 0.28);
  --accent2:      #06b6d4;
  --text:         #f0ecf9;
  --text-muted:   #c0badb;
  --text-dim:     #918baf;
  --star:         #fbbf24;
  --danger:       #ef4444;
  --radius:       10px;
  --radius-sm:    7px;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ─── Base ────────────────────────────────────────────────── */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ─── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 9px; }

.header-right { display: flex; align-items: center; gap: 12px; }

.lang-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--accent);
  color: white;
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.45);
}
.logo svg { display: block; width: 100%; height: 100%; }

.header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.header-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-light);
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ─── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  padding: 10px 14px 10px 34px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-dim); }

/* ─── Main body ──────────────────────────────────────────── */
.main-body { display: flex; flex: 1; min-height: 0; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 190px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  font-family: inherit;
}
.cat-btn:hover  { background: var(--bg-hover); color: var(--text); }
.cat-btn.active { background: rgba(124, 58, 237, 0.16); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.35); }

.cat-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cat-dot.star { background: none !important; color: var(--star); font-size: 10px; width: auto; line-height: 1; }

.cat-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 10.5px; color: var(--text-dim); flex-shrink: 0; }
.cat-btn.active .cat-count { color: var(--accent-light); }

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 2px; }

/* Add your AI button */
.add-tool-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-light);
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
  margin-top: 2px;
}
.add-tool-btn:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: var(--accent);
  color: white;
}

/* ─── Content / tool grid ────────────────────────────────── */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.tool-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
@media (max-width: 900px) {
  .tool-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .tool-list { grid-template-columns: 1fr; }
}
.tool-list::-webkit-scrollbar { width: 5px; }
.tool-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

/* ─── Tool card ───────────────────────────────────────────── */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 13px 11px;
  transition: border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
}
.tool-card:hover { border-color: var(--border-light); transform: translateY(-1px); }

.tool-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

/* Avatar — initials variant */
.tool-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

/* Avatar — emoji variant */
.tool-avatar--emoji {
  font-size: 22px;
  font-weight: normal;
  color: inherit;
  border-radius: 10px;
}

.tool-title-wrap { flex: 1; min-width: 0; padding-top: 2px; }

.tool-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 2px 3px;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.1s;
}
.fav-btn:hover  { transform: scale(1.2); }
.fav-btn.active { color: var(--star); }

.del-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 3px;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.1s;
}
.del-btn:hover { color: var(--danger); transform: scale(1.1); }

.tool-description {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 10px;
  flex: 1;
}

.tool-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.open-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
  font-family: inherit;
}
.open-btn:hover { color: var(--accent-light); border-color: rgba(124, 58, 237, 0.4); background: rgba(124, 58, 237, 0.1); }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 58, 237, 0.15);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.modal-close-btn:hover { color: var(--text); background: var(--bg-hover); }

.modal-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-body > .modal-label:first-child { margin-top: 0; }

.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-input::placeholder { color: var(--text-dim); }

.modal-select {
  cursor: pointer;
  appearance: auto;
}
.modal-select option { background: #1d182c; color: var(--text); }

.modal-emoji-input { font-size: 20px; text-align: center; padding: 6px 10px; }

/* Row layout for emoji + category */
.modal-row {
  display: flex;
  gap: 12px;
}
.modal-field { display: flex; flex-direction: column; }
.modal-field .modal-input { width: 100%; }
.modal-emoji-input { width: 68px; }
.modal-field--grow { flex: 1; }

.modal-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 10px;
  min-height: 18px;
}

.modal-footer {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-cancel-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.modal-cancel-btn:hover { background: var(--bg-hover); color: var(--text); }

.modal-save-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}
.modal-save-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4); }

/* ─── Help FAB ─────────────────────────────────────────────── */
.help-fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.help-fab:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5);
}

/* ─── Help Modal ───────────────────────────────────────────── */
.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.help-overlay.open { display: flex; }

.help-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 58, 237, 0.15);
  animation: modal-in 0.18s ease;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.help-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.help-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.help-close-btn:hover { color: var(--text); background: var(--bg-hover); }

.help-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.help-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.1);
  border-radius: 8px;
}

.help-item p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.help-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.help-ok-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 24px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}
.help-ok-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4); }

/* ─── Help Disclaimer ──────────────────────────────────────── */
.help-disclaimer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.help-disclaimer p {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0;
}
