/* ── Tools dark sync (site warm-dark) + readable helper text ── */

html body {
  background: var(--design-canvas, #141413) !important;
  color: var(--design-body, #ccc9c0) !important;
}

html .ta-content .tool-search-input,
html body .tool-search-input {
  background: rgba(37, 35, 32, 0.96) !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
  color: #faf9f5 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html .tool-search-input::placeholder {
  color: #b8b4a8 !important;
  opacity: 1 !important;
}
html .tool-search-icon { color: #c4c0b6 !important; }
html .tool-search-clear { color: #c4c0b6 !important; }
html .tool-search-no-results {
  color: #c4c0b6 !important;
  background: rgba(37, 35, 32, 0.6) !important;
  border-color: rgba(250, 249, 245, 0.08) !important;
}

html .tool-card,
html .card-section {
  background: #252320 !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
  color: #ccc9c0 !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html .tools-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
  align-items: start !important;
}

html .tool-card {
  border-radius: 16px !important;
  overflow: hidden !important;
  background:
    linear-gradient(180deg, rgba(250, 249, 245, 0.03), transparent 34%),
    #252320 !important;
}

html .tool-card::before {
  top: 12px !important;
  bottom: 12px !important;
  left: 0 !important;
  right: auto !important;
  width: 3px !important;
  height: auto !important;
  border-radius: 0 4px 4px 0 !important;
  opacity: 1 !important;
}

html .tool-card:hover {
  border-color: rgba(204, 120, 92, 0.3) !important;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.26) !important;
  transform: translateY(-2px) !important;
}

html .tool-card.tool-expanded {
  overflow: visible !important;
  border-color: rgba(204, 120, 92, 0.32) !important;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(204, 120, 92, 0.1) !important;
  transform: none !important;
}

html .tool-header {
  background: transparent !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  min-height: 64px !important;
  padding: 14px 14px 8px 16px !important;
  gap: 10px !important;
}

html .tool-card.tool-expanded .tool-header {
  background: rgba(18, 17, 15, 0.45) !important;
  border-bottom: 1px solid rgba(250, 249, 245, 0.06) !important;
  box-shadow: none !important;
  border-radius: 16px 16px 0 0 !important;
}

html .tool-icon-wrap {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  background: var(--tool-icon-bg, rgba(204, 120, 92, 0.14)) !important;
  color: var(--tool-icon-color, #e0a48d) !important;
  border: 1px solid rgba(250, 249, 245, 0.08) !important;
  box-shadow: none !important;
}

html .tool-header-title,
html .page-title {
  color: #faf9f5 !important;
  font: 700 14.5px/1.25 Quicksand, Fredoka, sans-serif !important;
  letter-spacing: -0.01em !important;
}

html .tool-toggle,
html .tool-share {
  width: 34px !important;
  height: 34px !important;
  border-radius: 11px !important;
  color: #c4c0b6 !important;
  background: rgba(250, 249, 245, 0.05) !important;
  border: 1px solid rgba(250, 249, 245, 0.1) !important;
}

html .tool-toggle:hover,
html .tool-share:hover,
html .tool-toggle.open {
  color: #f3c4b2 !important;
  background: rgba(204, 120, 92, 0.14) !important;
  border-color: rgba(204, 120, 92, 0.28) !important;
}

html .usage-count {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  width: auto !important;
  max-width: calc(100% - 28px) !important;
  margin: 0 14px 12px 16px !important;
  padding: 5px 10px !important;
  border-radius: 999px !important;
  color: #c4c0b6 !important;
  background: rgba(250, 249, 245, 0.04) !important;
  border: 1px solid rgba(250, 249, 245, 0.08) !important;
  box-shadow: none !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
}
html .usage-count::before { content: none !important; }
html .usage-count .count-num,
html .usage-count span { color: #e0a48d !important; }
html .usage-count .badge-icon { color: #e0a48d !important; }

html .tool-card-inner {
  padding: 4px 14px 14px 16px !important;
  border-top: 0 !important;
  background: transparent !important;
}

html .tool-rank-badge {
  top: 12px !important;
  right: 88px !important;
}

html .card-section {
  background: rgba(18, 17, 15, 0.45) !important;
  border-color: rgba(250, 249, 245, 0.08) !important;
  box-shadow: none !important;
}

html .supported-logos .logo-icon {
  background: rgba(250, 249, 245, 0.06) !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
}

/* Primary readable text */
html .tool-card .form-label {
  color: #faf9f5 !important;
}

/* Input values — bright on dark fields */
html .tool-card .form-control,
html .tool-card .form-select,
html .tool-card textarea.form-control {
  color: #faf9f5 !important;
  background: rgba(250, 249, 245, 0.07) !important;
  border-color: rgba(250, 249, 245, 0.12) !important;
  -webkit-text-fill-color: #faf9f5 !important;
  caret-color: #faf9f5 !important;
}

/* Placeholders — lighter so they stay visible but secondary */
html .tool-card .form-control::placeholder,
html .tool-card .form-select::placeholder,
html .tool-card textarea.form-control::placeholder,
html .tool-card .form-control::-webkit-input-placeholder,
html .tool-card .form-control::-moz-placeholder {
  color: #b8b4a8 !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #b8b4a8 !important;
}

html .tool-card .form-control:focus,
html .tool-card .form-select:focus,
html .tool-card textarea.form-control:focus {
  border-color: rgba(204, 120, 92, 0.45) !important;
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.18) !important;
  color: #faf9f5 !important;
  background: rgba(250, 249, 245, 0.09) !important;
}

/* Helper / tip notes under inputs */
html .tool-card .form-text,
html .tool-card .text-muted,
html .tool-card small,
html .tool-card .small {
  color: #c9c4b8 !important;
  opacity: 1 !important;
}

/* Override common light-theme inline note colors inside tool cards */
html .tool-card [style*="color:#6b7280"],
html .tool-card [style*="color: #6b7280"],
html .tool-card [style*="color:#9ca3af"],
html .tool-card [style*="color: #9ca3af"],
html .tool-card [style*="color:#8b949e"],
html .tool-card [style*="color: #8b949e"],
html .tool-card [style*="color:#6e6b62"],
html .tool-card [style*="color: #6e6b62"],
html .tool-card [style*="color:#64748b"],
html .tool-card [style*="color: #64748b"],
html .tool-card [style*="color:#94a3b8"],
html .tool-card [style*="color: #94a3b8"],
html .tool-card [style*="color:#6c757d"],
html .tool-card [style*="color: #6c757d"] {
  color: #c9c4b8 !important;
}

/* Dark brown / purple titles meant for cream cards → bright on dark */
html .tool-card [style*="color:#92400e"],
html .tool-card [style*="color: #92400e"],
html .tool-card [style*="color:#5b21b6"],
html .tool-card [style*="color: #5b21b6"] {
  color: #f0dcc8 !important;
}

html .tool-card-inner {
  border-top-color: transparent !important;
}
html .btn-primary {
  background: #cc785c !important;
  border-color: transparent !important;
  color: #fff !important;
}
html .btn-outline-secondary,
html .btn-outline-primary,
html .btn-outline-danger {
  color: #faf9f5 !important;
  border-color: rgba(250, 249, 245, 0.14) !important;
}
html .alert {
  background: rgba(37, 35, 32, 0.9) !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
  color: #faf9f5 !important;
}
html .alert-danger { border-color: rgba(239, 68, 68, 0.35) !important; color: #fca5a5 !important; }
html .alert-info { border-color: rgba(59, 130, 246, 0.35) !important; color: #93c5fd !important; }
html .alert-success { border-color: rgba(16, 185, 129, 0.35) !important; color: #6ee7b7 !important; }

html .tool-result-modal {
  background: rgba(10, 9, 8, 0.78) !important;
}
html .tool-result-dialog {
  background: #1f1d1a !important;
  color: #faf9f5 !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
}
html .tool-result-title { color: #faf9f5 !important; }
html .tool-result-eyebrow { color: #e0a48d !important; }
html .tool-result-close {
  background: rgba(250, 249, 245, 0.04) !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
  color: #c4c0b6 !important;
}
html .tool-result-body {
  color: #ebe7df !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  min-height: 0 !important;
}
html .tool-result-body,
html .tool-result-body * {
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
html .tool-result-body pre,
html .tool-result-body code,
html .tool-result-body .json-scroll {
  white-space: pre-wrap !important;
  max-width: 100% !important;
}
html .tool-result-body .alert,
html .tool-result-body .card-section,
html .tool-result-body > div:not(.tool-result-card) {
  background: rgba(250, 249, 245, 0.04) !important;
  color: #ebe7df !important;
  border-color: rgba(250, 249, 245, 0.1) !important;
}
html .tool-toast-stack {
  top: max(16px, env(safe-area-inset-top, 0px) + 16px) !important;
  right: max(12px, env(safe-area-inset-right, 0px) + 12px) !important;
  bottom: auto !important;
  left: auto !important;
}
html .tool-toast-stack .tool-toast {
  background: #252320 !important;
  color: #faf9f5 !important;
  border-color: rgba(250, 249, 245, 0.12) !important;
}
html .tool-toast-stack .tool-toast.loading {
  border-color: rgba(204, 120, 92, 0.35) !important;
}

/* Tools page: compact hero so the grid isn't pushed below the fold */
html:has(#toolsGrid) .hero-profile {
  min-height: 0 !important;
  margin-top: -72px !important;
  padding: calc(72px + 1.1rem) 0 0.85rem !important;
}
html:has(#toolsGrid) .hero-video-bg {
  display: none !important;
}
html:has(#toolsGrid) .hero-video-bg.is-video-paused-tools {
  display: none !important;
}

/* Tools page: lighter cards while scrolling / hovering */
html:has(#toolsGrid) .tool-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16) !important;
  transition: border-color 0.15s ease !important;
}
html:has(#toolsGrid) .tool-card:hover {
  transform: none !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2) !important;
}
html:has(#toolsGrid) .tool-search-input {
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html:has(#toolsGrid) .hero-avatar-wrap {
  transform: scale(0.86);
  transform-origin: left center;
}
html:has(#toolsGrid) .hero-name {
  font-size: clamp(1.55rem, 3.2vw, 2.1rem) !important;
}
html:has(#toolsGrid) .hero-actions {
  margin-top: 0.55rem !important;
}
html:has(#toolsGrid) .tools-heading {
  scroll-margin-top: 96px;
}

html .tools-heading {
  margin-bottom: 16px;
  padding: 14px 14px 14px;
  border: 1px solid rgba(250,249,245,0.08);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(204,120,92,0.12), transparent 42%),
    rgba(37, 35, 32, 0.72);
}
html .tools-heading-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
html .tools-heading-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(204,120,92,0.16);
  border: 1px solid rgba(204,120,92,0.3);
  color: #e0a48d;
}
html .tools-heading-kicker {
  display: inline-flex; align-items: center;
  min-height: 26px; padding: 0 10px;
  border-radius: 999px;
  background: rgba(204,120,92,0.12);
  border: 1px solid rgba(204,120,92,0.24);
  color: #e8b39a;
  font: 600 12px/1 Quicksand, sans-serif;
}
html .tools-title {
  margin: 0;
  color: #faf9f5;
  font: 600 clamp(28px,4vw,36px)/1.1 Fredoka, Quicksand, sans-serif;
  letter-spacing: -0.03em;
}
html .tools-subtitle {
  margin: 6px 0 0;
  color: #c4c0b6;
  font: 500 14px/1.5 Quicksand, sans-serif;
}

/* Select options readable in dark UI */
html .tool-card .form-select option {
  background: #252320;
  color: #faf9f5;
}

/* ── Tools sort loading state ── */
html .tools-sort-stage {
  position: relative;
  min-height: 220px;
}

html .tools-sort-stage.is-sorting .tools-grid {
  opacity: 0.22;
  filter: blur(2px) saturate(0.7);
  pointer-events: none;
  user-select: none;
  transform: scale(0.985);
  transition:
    opacity 0.35s ease,
    filter 0.35s ease,
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

html .tools-sort-stage.is-sorted .tools-grid {
  opacity: 1;
  filter: none;
  pointer-events: auto;
  transform: none;
  animation: toolsGridReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html .tools-sort-overlay {
  position: fixed;
  /* Keep below sticky tabs/nav so navigation never gets trapped */
  inset: 0;
  top: 0;
  z-index: 1020;
  display: grid;
  place-items: center;
  padding: max(72px, env(safe-area-inset-top) + 64px) 16px max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: rgba(8, 7, 6, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

/* Only show when JS explicitly opts in — avoids covering tabs before boot */
html.tools-sorting .tools-sort-overlay:not(.is-done),
html .tools-sort-stage.is-sorting .tools-sort-overlay:not(.is-done) {
  opacity: 1;
  visibility: visible;
}

html .tools-sort-overlay.is-done,
html .tools-sort-overlay[hidden] {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  display: none !important;
}

/* Do NOT lock page scroll / trap clicks on tabs */
html.tools-sorting,
html.tools-sorting body {
  overflow: auto !important;
}

html.tools-sorting .tabs-section.site-tabs,
html.tools-sorting .sticky-navbar {
  pointer-events: auto !important;
  z-index: 1035 !important;
}

html .tools-sort-card {
  position: relative;
  width: min(340px, 100%);
  padding: 22px 22px 18px;
  border-radius: 18px;
  background: rgba(37, 35, 32, 0.94);
  border: 1px solid rgba(250, 249, 245, 0.1);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  overflow: hidden;
}

html .tools-sort-orb {
  position: absolute;
  width: 120px;
  height: 120px;
  left: 50%;
  top: -36px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(204, 120, 92, 0.28), transparent 68%);
  filter: blur(2px);
  pointer-events: none;
}

html .tools-sort-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 34px;
  margin: 4px auto 14px;
  position: relative;
  z-index: 1;
}

html .tools-sort-bars span {
  display: block;
  width: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e0a48d, #cc785c);
  animation: toolsSortBar 1s ease-in-out infinite;
}

html .tools-sort-bars span:nth-child(1) { height: 12px; animation-delay: 0s; }
html .tools-sort-bars span:nth-child(2) { height: 22px; animation-delay: 0.12s; }
html .tools-sort-bars span:nth-child(3) { height: 30px; animation-delay: 0.24s; }
html .tools-sort-bars span:nth-child(4) { height: 18px; animation-delay: 0.36s; }

html .tools-sort-title {
  margin: 0;
  position: relative;
  z-index: 1;
  color: #faf9f5;
  font: 600 16px/1.25 Fredoka, Quicksand, sans-serif;
  letter-spacing: -0.02em;
}

html .tools-sort-sub {
  margin: 6px 0 0;
  position: relative;
  z-index: 1;
  color: #c4c0b6;
  font: 500 13px/1.45 Quicksand, sans-serif;
}

html .tools-sort-track {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(250, 249, 245, 0.08);
}

html .tools-sort-fill {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, #cc785c, #e8a55a, transparent);
  animation: toolsSortSweep 1.1s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes toolsSortBar {
  0%, 100% { transform: scaleY(0.55); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes toolsSortSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

@keyframes toolsGridReveal {
  from {
    opacity: 0.2;
    transform: translateY(8px) scale(0.99);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (min-width: 1100px) {
  html .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html .tools-sort-bars span,
  html .tools-sort-fill,
  html .tools-sort-stage.is-sorted .tools-grid {
    animation: none !important;
  }
  html .tools-sort-stage.is-sorting .tools-grid {
    filter: none;
    transform: none;
  }
  html .tool-card:hover {
    transform: none !important;
  }
}

/* ── Mobile tools polish ── */
@media (max-width: 767px) {
  html .ta-container.py-3 {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  html .tools-heading {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 14px;
  }

  html .tools-heading-label {
    margin-bottom: 6px;
  }

  html .tools-heading-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  html .tools-title {
    font-size: 26px !important;
    line-height: 1.15 !important;
  }

  html .tools-subtitle {
    font-size: 13px !important;
    margin-top: 4px !important;
  }

  html .tool-search-wrap {
    margin-bottom: 12px !important;
  }

  html .ta-content .tool-search-input,
  html body .tool-search-input {
    min-height: 44px !important;
    padding: 12px 44px 12px 42px !important;
    font-size: 16px !important; /* avoid iOS zoom */
    border-radius: 14px !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22) !important;
  }

  html .tools-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  html .tool-card,
  html .card-section {
    border-radius: 14px !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  html .tool-card:hover {
    transform: none !important;
  }

  html .tool-header {
    min-height: 58px !important;
    padding: 12px 12px 8px 14px !important;
    gap: 8px !important;
  }

  html .tool-icon-wrap {
    width: 36px !important;
    height: 36px !important;
    border-radius: 11px !important;
    font-size: 17px !important;
  }

  html .tool-header-title,
  html .page-title {
    font-size: 14px !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    line-height: 1.3 !important;
  }

  html .tool-toggle,
  html .tool-share {
    width: 34px !important;
    height: 34px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  html .tool-rank-badge {
    top: 10px !important;
    right: 82px !important;
    font-size: 9.5px !important;
    padding: 2px 6px !important;
  }

  html .usage-count {
    margin: 0 12px 10px 14px !important;
    padding: 5px 9px !important;
    font-size: 11px !important;
    border-radius: 999px !important;
  }

  html .tool-card-inner {
    padding: 2px 12px 12px 14px !important;
  }

  html .tool-card .form-label {
    font-size: 13px !important;
    margin-bottom: 6px !important;
    line-height: 1.4 !important;
  }

  html .tool-card .form-control,
  html .tool-card .form-select,
  html .tool-card textarea.form-control {
    min-height: 44px !important;
    font-size: 16px !important;
    border-radius: 12px !important;
    padding: 10px 12px !important;
  }

  html .tool-card textarea.form-control {
    min-height: 96px !important;
  }

  html .tool-card .btn,
  html .tool-card .btn-primary {
    min-height: 44px !important;
    font-size: 14.5px !important;
    border-radius: 12px !important;
  }

  html .tool-card .form-text,
  html .tool-card .text-muted,
  html .tool-card small {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  html .supported-logos {
    gap: 8px !important;
    margin-top: 12px !important;
    justify-content: flex-start !important;
  }

  html .supported-logos .logo-icon {
    width: 36px !important;
    height: 36px !important;
    background: rgba(250, 249, 245, 0.06) !important;
    border-color: rgba(250, 249, 245, 0.1) !important;
  }

  html .tools-sort-stage {
    min-height: 160px;
  }

  html .tools-sort-stage.is-sorting .tools-grid {
    filter: none !important;
    opacity: 0.28 !important;
    transform: none !important;
  }

  html .tools-sort-card {
    width: min(300px, 100%);
    padding: 18px 16px 14px;
  }

  html .tools-sort-title {
    font-size: 15px;
  }

  html .tools-sort-sub {
    font-size: 12.5px;
  }

  html .tool-file-drop {
    min-height: 68px;
    padding: 12px;
  }
}

@media (max-width: 420px) {
  html .tools-heading-kicker {
    display: none;
  }

  html .tool-header {
    gap: 8px !important;
  }

  html .tool-header-title {
    font-size: 13.5px !important;
  }
}
