
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-tint: rgba(37, 99, 235, 0.1);
  --success: #16a34a;
  --error: #dc2626;
  --bg: #f9fafb;
  --card-bg: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

:root.dark {
  --bg: #1f2937;
  --card-bg: #111827;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --border: #374151;
  --primary-tint: rgba(96, 165, 250, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

header, footer {
  background: var(--card-bg);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}

header {
  position: relative;
  padding: 2rem 3rem;
}

/* Tool pages carry a back-link pinned top-left; give the title clearance
   so it never collides with it, regardless of how long the title is. */
header:has(.back-link) {
  padding-top: 3.75rem;
}

/* Sticky header on every page except the homepage (which has its own taller
   brand header — keeping that one sticky would eat too much viewport). Tool,
   privacy, about, and 404 pages all use the plain (non .site-header) header. */
header:not(.site-header) {
  position: sticky;
  top: 0;
  z-index: 50;
}

header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  color: var(--primary);
}

/* Homepage-only: a modern left-aligned brand lockup instead of the
   centered-hero layout tool pages use. Scoped to .site-header so tool
   pages' back-link/title/toggle header is completely untouched. */
.site-header { text-align: left; }

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.site-logo {
  flex-shrink: 0;
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.brand-text h1 { font-size: 1.5rem; }

header .tagline {
  margin: 0.15rem 0 0;
  max-width: 32rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 500;
}

header .badge { margin-top: 1rem; }

nav a {
  margin: 0 10px;
  text-decoration: none;
  color: var(--primary);
}

nav a:hover {
  color: var(--primary-dark);
}

main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 2rem auto;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.3s;
}

/* Homepage: let tool cards float on the page background instead of
   sitting inside one big boxed card */
main.home {
  max-width: 1080px;
  width: 100%;
  background: transparent;
  box-shadow: none;
  padding: 2.5rem 2rem;
}

.search-row { margin-bottom: 1.5rem; }
/* #toolSearch.tool-search (not just .tool-search): the homepage now also
   loads tools.css for its pill-link styling, and tools.css's
   input[type="text"] rule (element+attribute selector) outranks a bare
   class selector — the id raises specificity enough to keep this pill
   shape instead of tools.css's plain rounded-corner monospace input. */
#toolSearch.tool-search {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
#toolSearch.tool-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.quick-access { margin-bottom: 2rem; }
.quick-access h2 { font-size: 1rem; margin-bottom: 0.9rem; color: var(--text); }

.hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }
.no-results { margin-top: 0.5rem; }

.tab-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0.75rem 1.25rem;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

/* The homepage now also loads tools.css (for its .related-tools-list /
   .quick-access pill styling), whose generic button rule adds a gradient,
   shadow, and hover-lift transform to every <button>. Reset those
   explicitly here so tab buttons stay flat text tabs, not pill buttons —
   same reasoning as the .toggle-theme resets below. */
.tab-btn:hover,
.tab-btn:active,
.tab-btn:focus-visible {
  transform: none;
  box-shadow: none;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel[hidden] { display: none; }

.toggle-theme {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 1.2rem;
  font-weight: normal;
  cursor: pointer;
  color: var(--primary);
}
/* Tool pages also load tools.css, whose generic button styling (shadow,
   padding, hover-lift) would otherwise leak in here since this rule doesn't
   touch those properties — reset them explicitly to stay a bare icon. */
.toggle-theme:hover,
.toggle-theme:active,
.toggle-theme:focus-visible {
  transform: none;
  box-shadow: none;
  background: none;
}

footer {
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  box-shadow: none;
}

footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
footer a:hover { color: var(--primary); }

.footer-categories { margin-top: 0.4rem; font-size: 0.85rem; }

/* Placeholder for ad units — swap the inner content for a real ad network's
   code once available. Kept visually distinct (dashed border) so it never
   looks like a broken UI element while ads aren't live yet. */
.ad-slot {
  /* Hidden from visitors until real ads (Auto ads or manual units) are
     wired in — the divs stay in the DOM across all pages so activating
     them later is a one-line change here, not another 23-file batch edit.
     To reactivate: change this to "display: flex" (needed for the
     align-items/justify-content below to have any effect). */
  display: none;

  margin: 1.5rem auto;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-height: 90px;
  align-items: center;
  justify-content: center;
}

.tool-album {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

/* Sub-categorized tool grid (currently used inside the Text Tools tab,
   which has too many tools for one flat grid). Each .tool-group holds a
   heading plus its own nested .tool-album grid — the outer .tool-groups
   just stacks the groups vertically. */
.tool-groups {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tool-group-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Search filtering hides a whole group (via inline style) when none of its
   tiles match the query, so an empty heading never floats on its own. */
.tool-group[hidden] { display: none; }

.tool-tile {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: left;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.new-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--success);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-tile .tool-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--primary-tint);
  margin-bottom: 1rem;
}

.tool-tile img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.tool-tile h3 {
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.tool-tile p {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.tool-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

/* Homepage-only "why use this" trust strip + Popular Tools, shown below
   the tool grid regardless of which tab is active. */
.home-highlights { margin-top: 2.5rem; }

.highlight-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.highlight-card {
  text-align: center;
  padding: 1.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
}

.highlight-icon {
  display: block;
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.highlight-card h3 { font-size: 1rem; margin-bottom: 0.35rem; color: var(--text); }
.highlight-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

@media (max-width: 640px) {
  header {
    padding: 1.75rem 1.25rem;
  }
  main.home {
    padding: 1.5rem 1rem;
  }
}

.breadcrumbs {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumbs .sep { margin: 0 0.35rem; }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: 500; }

.scroll-top-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-top-btn:hover { border-color: var(--primary); }
