/* ----- reset & base ----- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Default Orange theme */
  --primary: #ff7a00;
  --primary-dim: rgba(255, 122, 0, 0.25);
  --primary-glow: rgba(255, 122, 0, 0.35);
  --border-color: rgba(255, 122, 0, 0.25);
  --card-bg: rgba(255, 255, 255, 0.05);
  --text-light: #fff;
  --text-muted: #aaa;
  --bg-bokeh:
    radial-gradient(60vmax 60vmax at 20% 30%, rgba(255, 140, 0, 0.20), transparent 60%),
    radial-gradient(50vmax 50vmax at 80% 70%, rgba(255, 90, 0, 0.20), transparent 60%),
    linear-gradient(180deg, rgba(255, 165, 0, 0.10), rgba(255, 120, 0, 0.05));
}

html,
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #0b0b0b;
  color: var(--primary);
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  transition: color 0.3s ease;
}

.bg {
  position: fixed;
  inset: 0;
  background: var(--bg-bokeh);
  filter: blur(14px);
  z-index: 0;
  pointer-events: none;
  transition: background 0.5s ease;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 8px;
}

/* ----- header / title row ----- */
.top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 24px;
}

.title {
  font-size: clamp(1.4rem, 3.6vw, 2.8rem);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
  text-shadow: 0 0 30px var(--primary-dim);
  margin: 0;
  flex: 1 1 auto;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 40px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: 0.25s;
  white-space: nowrap;
}
.header-btn:hover {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
  box-shadow: 0 0 24px var(--primary-glow);
}
.header-btn.add-tool-btn {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}
.header-btn.add-tool-btn:hover {
  background: var(--primary);
  filter: brightness(0.9);
  box-shadow: 0 0 32px var(--primary-glow);
}
.header-btn .icon-plus {
  font-size: 1.2rem;
  line-height: 1;
}

/* ----- Settings / Theme dropdown ----- */
.settings-wrapper {
  position: relative;
  display: inline-block;
}

.settings-btn {
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
}

.theme-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #1a1a1a;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 160px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
  z-index: 100;
  transition: border-color 0.3s ease;
}

.theme-dropdown.open {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.theme-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.theme-option.active {
  background: var(--primary-dim);
  color: var(--primary);
}

.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

/* ----- search + filter bar ----- */
.controls-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
  width: 100%;
}

.search-wrapper {
  position: relative;
  max-width: 480px;
  width: 100%;
}
#searchLaunchpad {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-bottom: 2px solid var(--primary);
  background: transparent;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease;
}
#searchLaunchpad::placeholder {
  color: var(--text-muted);
}
#searchLaunchpad:focus {
  border-bottom-color: #fff;
}

.group-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 0.9rem;
}
.filter-label {
  color: var(--text-muted);
  margin-right: 2px;
  font-weight: 500;
}
.group-filter-btn {
  color: var(--primary);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 30px;
  border: 1px solid transparent;
  transition: 0.2s;
  font-weight: 500;
  cursor: pointer;
}
.group-filter-btn:hover {
  background: var(--primary);
  color: #000;
}
.group-filter-btn.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* ----- tile grid ----- */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
}

.col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: 164px;
}

.tile-link {
  display: block;
  width: 100%;
  padding: 2px;
  border-radius: 18px;
  background: transparent;
  text-decoration: none;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.tile-link:hover {
  transform: scale(1.04);
  background: var(--primary);
  box-shadow: 0 0 28px var(--primary-glow);
}
.tile-link:hover .tile {
  background: transparent;
}
.tile-link:hover .tile .tile-name {
  color: #000;
}
.tile-link:hover .tile .tile-sub {
  color: #222;
}
.tile-link:hover .tile .tile-badge {
  background: #000;
  color: var(--primary);
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 220px;
  padding: 12px 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border-radius: 18px;
  border: 0.5px solid var(--border-color);
  text-align: center;
  box-sizing: border-box;
  transition: background 0.2s, border-color 0.3s ease;
}

.tile-icon {
  max-width: 96px;
  max-height: 96px;
  width: auto;
  height: auto;
  margin-bottom: 8px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.tile-name {
  display: block;
  width: 100%;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em;
  transition: color 0.2s;
}

.tile-sub {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em;
  transition: color 0.2s;
}

.tile-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 14px;
  border-radius: 40px;
  background: #c0392b;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

/* "ADD NEW TOOL" special tile */
.tile.add-tool {
  border: 1.5px dashed var(--primary);
  background: rgba(255, 122, 0, 0.06);
}
.tile-link:hover .tile.add-tool {
  background: var(--primary);
  border-color: var(--primary);
}
.tile-link:hover .tile.add-tool .tile-name {
  color: #000;
}
.tile.add-tool .tile-icon-plus {
  font-size: 3.2rem;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
  transition: color 0.2s;
}
.tile-link:hover .tile.add-tool .tile-icon-plus {
  color: #000;
}

/* ----- group sections ----- */
.group-section {
  width: 100%;
  margin-bottom: 28px;
}
.group-header {
  text-align: left;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  padding: 0.4rem 0 0.2rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  width: 100%;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.group-header-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}
.group-header-link:hover {
  color: #fff;
  text-decoration: underline;
}

.group-tiles.row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
}

.no-results {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 2.4rem 0;
  text-align: center;
  width: 100%;
}

/* ----- modal ----- */
.modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}
.modal.show {
  display: flex !important;
}
.modal-content {
  width: 90%;
  max-width: 520px;
  max-height: 70vh;
  overflow-y: auto;
  background: #0f0f0f;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  text-align: center;
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease;
}
@media (max-width: 600px) {
  .modal-content {
    padding: 20px 16px;
    max-height: 80vh;
  }
}
.modal-content h2 {
  color: var(--primary);
  text-align: left;
  font-size: 1.3rem;
  margin-bottom: 8px;
  transition: color 0.3s ease;
}
.modal-content button {
  padding: 10px 22px;
  border-radius: 40px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--primary);
  color: #000;
  cursor: pointer;
  transition: 0.2s;
}
.modal-content button:hover {
  background: var(--primary);
  filter: brightness(0.9);
  box-shadow: 0 0 24px var(--primary-glow);
}
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
}
.input-group {
  position: relative;
  margin-top: 12px;
}
.input-group input {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 2px solid var(--primary);
  background: transparent;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease;
}
.input-group input::placeholder {
  color: transparent;
}
.input-group label {
  position: absolute;
  left: 12px;
  top: 10px;
  color: var(--text-muted);
  transition: 0.2s;
  pointer-events: none;
  font-size: 0.95rem;
}
.input-group input:focus+label,
.input-group input:not(:placeholder-shown)+label {
  top: -10px;
  left: 8px;
  font-size: 0.75rem;
  color: var(--primary);
}

#toolList {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  text-align: left;
}
#toolList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255, 122, 0, 0.08);
  transition: 0.15s;
}
#toolList li:hover {
  background: rgba(255, 122, 0, 0.10);
}
#toolList li.highlight {
  background: var(--primary);
  color: #000;
  font-weight: 600;
  border-radius: 8px;
}
.tool-name {
  flex: 1;
  word-break: break-word;
}
.tool-price {
  margin-left: 10px;
  white-space: nowrap;
}
.tool-currency {
  margin-left: 4px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
  flex-wrap: wrap;
}
.pagination li {
  display: inline-block;
}
.pagination a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  transition: 0.2s;
  font-size: 0.85rem;
}
.pagination a:hover {
  background: var(--primary);
  color: #000;
}
.pagination .active a {
  background: var(--primary);
  color: #000;
}
.pagination .disabled a {
  color: #555;
  pointer-events: none;
}

/* ----- overlay spinner ----- */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primary);
  z-index: 999;
}
#overlay>div {
  text-align: center;
}
.spinner {
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 14px auto;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* ----- responsive tweaks ----- */
@media (max-width: 720px) {
  .top-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .col {
    width: 140px;
  }
  .tile {
    height: 190px;
    padding: 8px 6px;
  }
  .tile-icon {
    max-width: 76px;
    max-height: 76px;
  }
  .tile-name {
    font-size: 0.8rem;
  }
  .tile-sub {
    font-size: 0.65rem;
  }
  .tile-badge {
    font-size: 0.6rem;
    padding: 2px 10px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }
  .col {
    width: 120px;
  }
  .tile {
    height: 160px;
    border-radius: 14px;
  }
  .tile-icon {
    max-width: 64px;
    max-height: 64px;
  }
  .tile-name {
    font-size: 0.7rem;
  }
  .tile-sub {
    font-size: 0.55rem;
  }
  .tile-badge {
    font-size: 0.5rem;
    padding: 1px 8px;
  }
  .group-filter-bar {
    font-size: 0.75rem;
    gap: 4px 8px;
  }
  .group-filter-btn {
    padding: 2px 8px;
  }
  .header-btn {
    font-size: 0.75rem;
    padding: 6px 14px;
  }
  .theme-dropdown {
    right: -10px;
    min-width: 140px;
  }
}