:root {
  --tools-bg: rgba(12, 14, 18, 0.96);
  --tools-panel: rgba(17, 20, 26, 0.9);
  --tools-panel-strong: rgba(21, 25, 31, 0.98);
  --tools-soft: rgba(255, 255, 255, 0.04);
  --tools-soft-strong: rgba(255, 255, 255, 0.08);
  --tools-border: rgba(255, 255, 255, 0.08);
  --tools-glow: rgba(255, 255, 255, 0.12);
  --tools-text: #edf2f7;
  --tools-muted: rgba(203, 214, 227, 0.7);
  --tools-accent: #dfe8f3;
  --tools-accent-2: #a9b5c7;
  --tools-success: #c7f7d3;
  --tools-shadow: 0 20px 44px rgba(0, 0, 0, 0.42);
}

#tools-store-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 80;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 15, 18, 0.7);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  color: rgba(240, 244, 250, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#tools-store-toggle:hover,
#tools-store-toggle:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(21, 24, 31, 0.88);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

#tools-store-toggle:active {
  transform: translateY(0) scale(0.98);
}

#tools-store-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

#tools-store-toggle path {
  stroke: currentColor;
}

#profile-card {
  position: relative;
}

#profile-card.tools-open {
  --rx: 0deg;
  --ry: 0deg;
  --tx: 0px;
  --tilt-y: 0px;
  --scale: 1;

  width: min(92vw, 560px);
  height: min(72vh, 560px);
  height: min(72dvh, 560px);
  min-height: 0;
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;

  overflow: hidden;
  transition: height 0.25s ease;
  top: clamp(0px, 3vh, 18px);
}

#profile-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: opacity 0.32s ease, transform 0.32s ease, visibility 0.32s ease;
}

#profile-card.tools-open #profile-shell {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985) translateY(10px);
}

.tools-store-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  height: 100%;
  padding: 18px 18px 14px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(15, 18, 24, 0.98), rgba(11, 13, 18, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 20px 40px rgba(0,0,0,0.38);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.985);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
  overflow: hidden;
}

#profile-card.tools-open .tools-store-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.tools-store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 6px 2px;
}

.tools-store-heading-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tools-store-badge {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(239, 244, 250, 0.9);
}

.tools-store-badge svg {
  width: 18px;
  height: 18px;
  display: block;
}

.tools-store-heading-wrap h3 {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: var(--tools-text);
}

.tools-kicker {
  margin-bottom: 3px;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tools-muted);
}

.tools-back-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--tools-text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tools-back-profile:hover,
.tools-back-profile:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.05);
}

.tools-back-profile svg {
  width: 14px;
  height: 14px;
  display: block;
}

.tools-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 4px;
}

.tools-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 0 12px;
}

.tools-search svg {
  width: 15px;
  height: 15px;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
}

.tools-search input {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 11px 0;
  color: var(--tools-text);
  font: inherit;
  outline: none;
}

.tools-search input::placeholder {
  color: rgba(255,255,255,0.48);
}

.tools-category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tools-category-btn {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: var(--tools-muted);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tools-category-btn:hover,
.tools-category-btn:focus-visible {
  border-color: rgba(255,255,255,0.15);
  color: var(--tools-text);
}

.tools-category-btn.active {
  color: #0b0d12;
  background: linear-gradient(135deg, rgba(234, 239, 245, 1), rgba(169, 181, 199, 1));
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(214, 223, 235, 0.18);
}

/* The available space below the header and toolbar */
.tools-stage {
  position: relative;
  display: flex;
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

/* Scrollable product list */
.tools-product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 11px;

  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  flex: 1 1 0;

  padding: 4px 4px 12px;
  overflow-x: hidden;
  overflow-y: auto;

  scrollbar-width: none;
  scrollbar-color: transparent transparent;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

/* Keep the top controls from shrinking */
.tools-store-header,
.tools-toolbar {
  flex-shrink: 0;
}

/* Allow search/category controls to fit smaller widths */
.tools-toolbar {
  min-width: 0;
}

.tools-category-list {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

/* Cards should never force the grid wider */
.tools-product-card {
  min-width: 0;
  box-sizing: border-box;
}

#profile-card.tools-detail-open .tools-toolbar,
#profile-card.tools-detail-open .tools-product-grid {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
}

#profile-card.tools-detail-open .tools-product-detail {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 560px) {
  .tools-product-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tools-product-grid,
.tools-product-detail,
.tools-category-list {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  scrollbar-color: transparent transparent !important;
}

.tools-product-grid::-webkit-scrollbar,
.tools-product-detail::-webkit-scrollbar,
.tools-category-list::-webkit-scrollbar,
.tools-product-grid::-webkit-scrollbar-thumb,
.tools-product-detail::-webkit-scrollbar-thumb,
.tools-category-list::-webkit-scrollbar-thumb {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}

.tools-product-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 120px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border-radius: 18px;
  padding: 12px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  opacity: 0;
  animation: tools-card-in 0.32s ease forwards;
}

.tools-product-card:hover,
.tools-product-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 18px 28px rgba(0,0,0,0.18);
}

@keyframes tools-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tools-product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.08), transparent 32%);
  pointer-events: none;
}

.tools-product-media {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 8px 18px rgba(0,0,0,0.18);
}

.tools-product-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.18);
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.2));
}

.tools-product-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tools-product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.tools-product-name {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--tools-text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tools-product-price {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: rgba(234, 239, 245, 0.86);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 4px 7px;
  white-space: nowrap;
}

.tools-product-description {
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--tools-muted);
  min-height: 34px;
  margin: 0;
}

.tools-product-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.52);
}

.tools-product-meta span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.tools-product-meta span:last-child {
  justify-self: end;
  line-height: 1;
  transform: translateY(-0.5px);
  padding-left: 2px;
}

.tools-product-detail {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;

  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 4px 4px 14px;

  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scrollbar-gutter: stable;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);

  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;
}

.tools-product-detail.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* Ensure hidden panels really disappear */
.tools-product-detail[hidden],
.tools-product-grid[hidden] {
  display: none !important;
}

#profile-card.tools-detail-open .tools-product-detail {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#profile-card.tools-detail-open .tools-product-grid {
  display: none;
}

.tools-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tools-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  color: var(--tools-text);
  cursor: pointer;
}

.tools-detail-back svg {
  width: 14px;
  height: 14px;
}

.tools-detail-top {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.025);
  padding: 12px;
}

.tools-detail-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.tools-detail-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.16);
}

.tools-detail-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
  color: var(--tools-text);
}

.tools-detail-sub {
  color: var(--tools-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tools-detail-body {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 12px;
}

.tools-panel-block {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
  padding: 12px;
}

.tools-panel-block h4 {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.62);
  margin: 0 0 10px;
}

.tools-detail-copy {
  margin: 0;
  color: var(--tools-muted);
  line-height: 1.7;
  font-size: 0.8rem;
}

.tools-features {
  list-style: none;
  display: grid;
  gap: 8px;
}

.tools-features li {
  position: relative;
  padding-left: 16px;
  color: var(--tools-text);
  font-size: 0.78rem;
  line-height: 1.55;
}

.tools-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.52em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(244, 247, 250, 0.9), rgba(171, 181, 197, 0.8));
}

.tools-detail-price-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tools-price-tag {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--tools-text);
}

.tools-license {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.68);
  line-height: 1.5;
}

.tools-price-list {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.tools-price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  font-size: 0.72rem;
}

.tools-price-row span {
  color: var(--tools-muted);
}

.tools-price-row strong {
  color: var(--tools-text);
  font-weight: 700;
}

.tools-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tools-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(135deg, rgba(239,243,247,0.98), rgba(179,192,208,0.92));
  color: #11151b;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.tools-cta:hover,
.tools-cta:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(218, 226, 235, 0.1);
}

.tools-cta.disabled {
  pointer-events: none;
  opacity: 0.52;
  filter: grayscale(0.2);
}

.tools-preview-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tools-preview-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
  min-height: 110px;
}

.tools-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 560px) {
  #tools-store-toggle {
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
  }

  #profile-card.tools-open {
    width: min(92vw, 560px);
    height: min(72dvh, 560px);
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  #profile-card.tools-open .tools-store-panel {
    padding: 12px;
    gap: 10px;
  }

  #profile-card.tools-open .tools-store-header {
    gap: 8px;
  }

  #profile-card.tools-open .tools-store-heading-wrap {
    min-width: 0;
  }

  #profile-card.tools-open .tools-back-profile {
    flex-shrink: 0;
    width: auto;
  }

  .tools-store-panel {
    padding: 12px 12px 10px;
    gap: 12px;
  }

  .tools-store-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tools-back-profile {
    width: 100%;
  }

  .tools-product-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tools-detail-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .tools-preview-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  #profile-card.tools-open .tools-product-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #profile-card.tools-open .tools-detail-body {
    grid-template-columns: minmax(0, 1fr);
  }

  #profile-card.tools-open .tools-preview-wrap {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-height: 500px) {
  #profile-card.tools-open {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
