/* ============================================================
   ToolsHub — Main Stylesheet
   Version: 1.0.0
   All styles for the multi-tool website.
   ============================================================ */

/* ---------- CSS Custom Properties (Theme) ---------- */
:root {
  color-scheme: light;
  /* Brand Colors */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-light: #e0e7ff;
  --color-secondary: #0ea5e9;
  --color-accent: #f59e0b;

  /* Light Theme */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --bg-code: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);

  /* Spacing / Layout */
  --nav-height: 64px;
  --container-max: 1200px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: .2s ease;

  /* Category Colors */
  --cat-images: #ec4899;
  --cat-pdf: #ef4444;
  --cat-code: #8b5cf6;
  --cat-text: #10b981;
  --cat-dev: #f97316;
  --cat-calc: #06b6d4;
}

/* Dark Theme */
[data-theme="dark"] {
  color-scheme: dark;
  --color-primary-light: rgba(99,102,241,.15);
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-alt: #334155;
  --bg-code: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.4);
}

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

html {
  background: var(--bg-body);
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol { list-style: none; }

/* ---------- Utility Classes ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.visually-hidden { composes: sr-only; }

/* ---------- Navigation ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  height: var(--nav-height);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.navbar__brand svg {
  width: 32px;
  height: 32px;
  color: var(--color-primary);
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.navbar__links a {
  padding: .5rem .875rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.navbar__links a:hover,
.navbar__links a.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
[data-theme="dark"] .navbar__links a:hover,
[data-theme="dark"] .navbar__links a.active {
  background: rgba(99,102,241,.15);
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Theme Toggle */
.theme-toggle {
  width: 40px; height: 40px;
  border: none;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
[data-theme="dark"] .theme-toggle:hover {
  background: rgba(99,102,241,.15);
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0;
}
.menu-toggle svg { width: 24px; height: 24px; }

/* Mobile Nav */
@media (max-width: 768px) {
  .menu-toggle { display: flex; align-items: center; justify-content: center; }

  .navbar__links {
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    bottom: 0;
    background: var(--bg-surface);
    flex-direction: column;
    padding: 1.5rem;
    gap: .25rem;
    transform: translateX(100%);
    transition: transform .3s ease;
    overflow-y: auto;
    z-index: 999;
  }
  .navbar__links.open {
    transform: translateX(0);
  }
  .navbar__links a {
    width: 100%;
    padding: .75rem 1rem;
    font-size: 1rem;
  }
}

/* ---------- Hero Section ---------- */
.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--bg-body) 60%);
}
[data-theme="dark"] .hero {
  background: linear-gradient(135deg, rgba(99,102,241,.12) 0%, var(--bg-body) 60%);
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin-bottom: .75rem;
}

.hero__title span {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__subtitle {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* Search Bar */
.search-bar {
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: .875rem 1rem .875rem 3rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.search-bar input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-bar__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + .5rem);
  left: 0; right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}
.search-results.active { display: block; }

.search-results a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  color: var(--text-primary);
  transition: background var(--transition);
}
.search-results a:hover,
.search-results a:focus {
  background: var(--bg-surface-alt);
}
.search-results__empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}
.search-results .search-cat {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .2rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  color: var(--text-muted);
}

/* ---------- Category Sections ---------- */
.categories {
  padding: 2rem 0 4rem;
}

.category-section {
  margin-bottom: 3rem;
}

.category-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--border-color);
}

.category-header__icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.category-header__icon svg { width: 20px; height: 20px; }

.category-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

/* Tool Cards Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  text-decoration: none;
  color: inherit;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  color: inherit;
}
.tool-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
}
.tool-card p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Category color coding */
.cat-images { background: var(--cat-images); }
.cat-pdf { background: var(--cat-pdf); }
.cat-code { background: var(--cat-code); }
.cat-text { background: var(--cat-text); }
.cat-dev { background: var(--cat-dev); }
.cat-calc { background: var(--cat-calc); }

/* ---------- Tool Page Layout ---------- */
.tool-page {
  flex: 1;
  padding: 2rem 0 4rem;
}

.tool-page__header {
  margin-bottom: 2rem;
}

.tool-page__breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tool-page__breadcrumb a { color: var(--text-secondary); }
.tool-page__breadcrumb a:hover { color: var(--color-primary); }
.tool-page__breadcrumb span { color: var(--text-muted); }

.tool-page__title {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 800;
  margin-bottom: .5rem;
}

.tool-page__desc {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 700px;
}

/* Tool Workspace Area */
.tool-workspace {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.tool-workspace__section {
  margin-bottom: 1.5rem;
}
.tool-workspace__section:last-child { margin-bottom: 0; }

.tool-workspace__section h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--text-primary);
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .375rem;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'Fira Code', 'Consolas', monospace;
  line-height: 1.5;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.5rem;
}

.form-range {
  width: 100%;
  accent-color: var(--color-primary);
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 1;
  min-width: 140px;
}

.form-help {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.form-check input {
  accent-color: var(--color-primary);
  width: 16px; height: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--border-color); }

.btn-success {
  background: #10b981;
  color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-danger {
  background: #ef4444;
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm {
  padding: .375rem .75rem;
  font-size: .8rem;
}

.btn-lg {
  padding: .875rem 2rem;
  font-size: 1rem;
}

.btn-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ---------- Drop Zone ---------- */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--bg-body);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.dragover {
  background: rgba(99,102,241,.08);
}

.drop-zone__icon {
  width: 48px; height: 48px;
  margin: 0 auto .75rem;
  color: var(--text-muted);
}
.drop-zone__text {
  color: var(--text-secondary);
  font-size: .95rem;
}
.drop-zone__text strong { color: var(--color-primary); }
.drop-zone__hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .375rem;
}

.drop-zone input[type="file"] {
  display: none;
}

/* ---------- Output / Preview ---------- */
.output-area {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 100px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: .85rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.preview-area {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.preview-area img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
}

.preview-area canvas {
  max-width: 100%;
}

/* ---------- Alerts / Feedback ---------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: 1rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-info {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
[data-theme="dark"] .alert-info {
  background: rgba(14,165,233,.1);
  color: #7dd3fc;
  border-color: rgba(14,165,233,.2);
}

.alert-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
[data-theme="dark"] .alert-success {
  background: rgba(16,185,129,.1);
  color: #6ee7b7;
  border-color: rgba(16,185,129,.2);
}

.alert-warning {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fef08a;
}
[data-theme="dark"] .alert-warning {
  background: rgba(245,158,11,.1);
  color: #fcd34d;
  border-color: rgba(245,158,11,.2);
}

.alert-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
[data-theme="dark"] .alert-error {
  background: rgba(239,68,68,.1);
  color: #fca5a5;
  border-color: rgba(239,68,68,.2);
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: .75rem 0;
}
.progress-bar__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width .3s ease;
  width: 0%;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .625rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Stats / Badges ---------- */
.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: .75rem 0;
}
.stat-badge {
  background: var(--bg-surface-alt);
  padding: .375rem .75rem;
  border-radius: var(--radius-full);
  font-size: .8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-badge strong {
  color: var(--text-primary);
  margin-right: .25rem;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 1.5rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .5rem;
}
.footer__brand svg {
  width: 28px; height: 28px;
  color: var(--color-primary);
}
.footer__tagline {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  max-width: 280px;
}

.footer__col h4 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  font-weight: 600;
}
.footer__col a {
  display: block;
  padding: .25rem 0;
  color: var(--text-secondary);
  font-size: .875rem;
}
.footer__col a:hover { color: var(--color-primary); }

.footer__bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .8rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .footer__grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .footer__grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Content Pages ---------- */
.content-page {
  flex: 1;
  padding: 2.5rem 0 4rem;
}

.content-page .container {
  max-width: 800px;
}

.content-page h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.content-page h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2rem 0 .75rem;
}

.content-page h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 .5rem;
}

.content-page p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.content-page ul,
.content-page ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
.content-page ul { list-style: disc; }
.content-page ol { list-style: decimal; }
.content-page li {
  margin-bottom: .375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.content-page a { text-decoration: underline; }

/* Contact Form */
.contact-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

/* FAQ */
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
  overflow: hidden;
}
.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: none;
  text-align: left;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition);
}
.faq-question:hover { background: var(--bg-surface-alt); }
.faq-question svg {
  width: 18px; height: 18px;
  transition: transform .2s;
  flex-shrink: 0;
  color: var(--text-muted);
}
.faq-item.open .faq-question svg {
  transform: rotate(180deg);
}
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.faq-answer__inner {
  padding: 0 1.25rem 1rem;
  color: var(--text-secondary);
  font-size: .9rem;
  line-height: 1.7;
}

/* ---------- 404 Page ---------- */
.page-404 {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.page-404__code {
  font-size: clamp(5rem, 15vw, 10rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.page-404 h1 {
  font-size: 1.5rem;
  margin: 1rem 0 .5rem;
}
.page-404 p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ---------- Cookie Consent Banner ---------- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  padding: 1rem 1.5rem;
  z-index: 10000;
  display: none;
}
.cookie-banner.show { display: block; }

.cookie-banner__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.cookie-banner__text {
  font-size: .875rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
}
.cookie-banner__text a { text-decoration: underline; }

/* ---------- Responsive Helpers ---------- */
@media (max-width: 640px) {
  .tool-workspace { padding: 1rem; }
  .form-row { flex-direction: column; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; }
}

/* ---------- Print Styles ---------- */
@media print {
  .navbar, .footer, .cookie-banner, .theme-toggle, .menu-toggle { display: none; }
  body { background: #fff; color: #000; }
  .tool-workspace { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn .3s ease forwards;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ---------- Copy Button ---------- */
.copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  padding: .25rem .5rem;
  font-size: .75rem;
}

.output-wrapper {
  position: relative;
}

/* ---------- Toggle Switch ---------- */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
}
.toggle-switch__slider {
  position: absolute;
  inset: 0;
  background: var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-switch__slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-switch__slider {
  background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-switch__slider::before {
  transform: translateX(20px);
}

/* ---------- Color Picker Specific ---------- */
.color-display {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

/* ---------- Markdown Preview ---------- */
.markdown-body {
  line-height: 1.7;
  color: var(--text-primary);
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.5rem 0 .75rem;
  font-weight: 700;
}
.markdown-body h1 { font-size: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: .5rem; }
.markdown-body h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: .3rem; }
.markdown-body h3 { font-size: 1.25rem; }
.markdown-body p { margin-bottom: 1rem; }
.markdown-body code {
  background: var(--bg-code);
  padding: .15rem .4rem;
  border-radius: 3px;
  font-size: .85em;
  font-family: 'Fira Code', monospace;
}
.markdown-body pre {
  background: var(--bg-code);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 1rem;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 4px solid var(--color-primary);
  padding: .5rem 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
}
.markdown-body ul, .markdown-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.markdown-body ul { list-style: disc; }
.markdown-body ol { list-style: decimal; }
.markdown-body li { margin-bottom: .25rem; }
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: .5rem .75rem;
  text-align: left;
}
.markdown-body th { background: var(--bg-surface-alt); font-weight: 600; }
.markdown-body img { border-radius: var(--radius-sm); }
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2rem 0;
}

/* ---------- Regex Tester ---------- */
.regex-match {
  background: rgba(99,102,241,.2);
  border-bottom: 2px solid var(--color-primary);
  padding: 0 1px;
}
.regex-group-1 { background: rgba(236,72,153,.2); border-bottom-color: var(--cat-images); }
.regex-group-2 { background: rgba(16,185,129,.2); border-bottom-color: var(--cat-text); }

/* ---------- Diff Viewer ---------- */
.diff-added {
  background: rgba(16,185,129,.15);
  color: #15803d;
}
[data-theme="dark"] .diff-added {
  background: rgba(16,185,129,.1);
  color: #6ee7b7;
}
.diff-removed {
  background: rgba(239,68,68,.15);
  color: #b91c1c;
}
[data-theme="dark"] .diff-removed {
  background: rgba(239,68,68,.1);
  color: #fca5a5;
}
.diff-line {
  display: block;
  padding: 0 .5rem;
  font-family: 'Fira Code', monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  min-height: 1.5em;
}

/* ---------- Loan Calculator Chart ---------- */
.chart-container {
  width: 100%;
  max-width: 400px;
  margin: 1rem auto;
}
.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Focus Styles (Accessibility) ---------- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---------- Skip Link ---------- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: .5rem 1rem;
  z-index: 10001;
  transition: top .2s;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
  color: #fff;
}

/* Split panes for text tools */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 768px) {
  .split-pane {
    grid-template-columns: 1fr;
  }
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 240px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn .25s ease forwards;
  transition: opacity .25s, transform .25s;
}

.toast--success { border-left: 4px solid #10b981; }
.toast--error { border-left: 4px solid #ef4444; }
.toast--info { border-left: 4px solid var(--color-primary); }
.toast--warning { border-left: 4px solid var(--color-accent); }

.toast.toast-hiding {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Ad Placeholder Styling ---------- */
.ad-slot-placeholder {
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}
.ad-slot-placeholder span {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .25rem;
}

/* Hero motion uses transforms and opacity; search stays in normal layout. */
.hero { position: relative; isolation: isolate; }
.hero::before, .hero::after {
  content: "";
  position: absolute;
  width: clamp(140px, 24vw, 300px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(circle, rgba(99,102,241,.16), transparent 70%);
  animation: hero-drift 8s ease-in-out 2 alternate;
}
.hero::before { top: 0; left: 2%; }
.hero::after { bottom: 0; right: 2%; background: radial-gradient(circle, rgba(14,165,233,.14), transparent 70%); animation-delay: -4s; }
.hero__title { animation: hero-enter .65s ease-out both; }
.hero__subtitle { animation: hero-enter .65s .12s ease-out both; }
.hero .search-bar { animation: hero-enter .65s .24s ease-out both; }
@keyframes hero-enter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes hero-drift {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(24px) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero::before, .hero::after, .hero__title, .hero__subtitle, .hero .search-bar { animation: none; }
}

/* Theme-safe controls and focus feedback. */
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #1e293b inset;
  -webkit-text-fill-color: #f1f5f9;
  caret-color: #f1f5f9;
}
.tool-guide { padding-top: 2rem; padding-bottom: 2rem; }
.tool-guide h2 { font-size: 1.35rem; margin-bottom: .75rem; }
.tool-guide h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.tool-guide p { color: var(--text-secondary); max-width: 80ch; }
.tool-guide ul { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; list-style: none; }

/* Native FAQ disclosure remains usable before JavaScript loads. */
details.faq-item > summary { list-style: none; }
details.faq-item > summary::-webkit-details-marker { display: none; }
details.faq-item[open] .faq-answer { max-height: none; overflow: visible; }
details.faq-item[open] .faq-question svg { transform: rotate(180deg); }
.tool-guide__support { margin-top: 1rem; }
