/* ==========================================================================
   FreeOnlineTool — Design System
   ========================================================================== */

:root {
  --navy: #0B1020;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --accent: #635BFF;
  --accent-dark: #4F46E5;
  --text-primary: #111827;
  --text-secondary: #64748B;
  --border: #E2E8F0;
  --success: #16A34A;
  --warning: #F59E0B;
  --error: #DC2626;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  --header-h: 68px;
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg: #09090B;
  --card: #18181B;
  --border: #27272A;
  --text-primary: #F4F4F5;
  --text-secondary: #A1A1AA;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 56px; line-height: 1.08; }
h2 { font-size: 34px; line-height: 1.2; }
h3 { font-size: 22px; line-height: 1.3; }
p { margin: 0; color: var(--text-secondary); }

@media (max-width: 640px) {
  h1 { font-size: 36px; }
  h2 { font-size: 26px; }
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------------- */
/* Header                                                                  */
/* ---------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  flex-shrink: 0;
}

.logo-mark svg { width: 100%; height: 100%; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.main-nav a {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
  white-space: nowrap;
}

.main-nav a:hover, .main-nav a.active { color: var(--text-primary); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

.menu-toggle { display: none; }

@media (max-width: 900px) {
  .main-nav { display: none; }
  .menu-toggle { display: flex; }
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  transition: all var(--transition);
  min-height: 44px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }

.btn-secondary { background: var(--card); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-block { width: 100%; }

/* ---------------------------------------------------------------------- */
/* Hero                                                                    */
/* ---------------------------------------------------------------------- */
.hero {
  position: relative;
  padding: 88px 0 64px;
  overflow: hidden;
}

.hero-particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.hero h1 { margin-bottom: 18px; }
.hero-sub {
  font-size: 18px;
  max-width: 560px;
  margin: 0 auto 36px;
}

/* Search box */
.search-box {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  height: 58px;
  padding: 0 22px 0 52px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-primary);
  font-size: 16px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
  text-align: left;
  display: none;
}
.search-results.open { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.search-result-item .name { font-weight: 600; font-size: 14.5px; }
.search-result-item .cat { font-size: 12.5px; color: var(--text-secondary); }
.search-empty { padding: 24px; text-align: center; color: var(--text-secondary); font-size: 14px; }

/* Popular pills */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
}

.pill {
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.pill:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ---------------------------------------------------------------------- */
/* Sections                                                                */
/* ---------------------------------------------------------------------- */
.section { padding: 56px 0; }
.section-head { text-align: center; max-width: 560px; margin: 0 auto 40px; }
.section-head h2 { margin-bottom: 10px; }

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 900px) { .category-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .category-grid { grid-template-columns: 1fr; } }

.category-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all var(--transition);
}
.category-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); }

.category-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.category-icon svg { width: 22px; height: 22px; }

.category-card h3 { margin-bottom: 6px; }
.category-card p { font-size: 14px; margin-bottom: 10px; }
.category-count { font-size: 12.5px; font-weight: 600; color: var(--accent); }

/* Tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .tool-grid { grid-template-columns: 1fr; } }

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  gap: 14px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); }

.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tool-icon svg { width: 20px; height: 20px; }

.tool-card-body { min-width: 0; }
.tool-card-body h3 { font-size: 16px; margin-bottom: 4px; }
.tool-card-body p { font-size: 13.5px; margin-bottom: 8px; }

.badge-free {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  padding: 3px 8px;
  border-radius: 999px;
}

/* Why us */
.why-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  text-align: center;
}
@media (max-width: 900px) { .why-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .why-grid { grid-template-columns: 1fr; } }

.why-item .why-icon {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.why-item .why-icon svg { width: 24px; height: 24px; }
.why-item h3 { font-size: 16px; margin-bottom: 6px; }
.why-item p { font-size: 14px; }

/* ---------------------------------------------------------------------- */
/* Tool page                                                               */
/* ---------------------------------------------------------------------- */
.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 20px 0 0;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 6px; }

.tool-header { padding: 20px 0 32px; text-align: center; }
.tool-header h1 { font-size: 34px; margin-bottom: 10px; }
.tool-header p { font-size: 16px; max-width: 560px; margin: 0 auto; }

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  padding: 6px 14px;
  border-radius: 999px;
  margin-top: 14px;
}
.privacy-note svg { width: 14px; height: 14px; }

.tool-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  max-width: 760px;
  margin: 0 auto;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.dropzone svg { width: 40px; height: 40px; color: var(--accent); margin: 0 auto 14px; }
.dropzone h3 { font-size: 17px; margin-bottom: 6px; }
.dropzone p { font-size: 13.5px; margin-bottom: 18px; }
.dropzone input[type="file"] { display: none; }

.file-result {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 18px;
}
.file-result.show { display: flex; }
.file-result .thumb {
  width: 48px; height: 48px; border-radius: 8px;
  background: var(--bg); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.file-result .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-result .meta { flex: 1; min-width: 0; }
.file-result .meta .fname { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-result .meta .fsize { font-size: 12.5px; color: var(--text-secondary); }

.progress-bar {
  width: 100%; height: 6px; border-radius: 999px;
  background: var(--border); overflow: hidden; margin-top: 16px; display: none;
}
.progress-bar.show { display: block; }
.progress-bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 150ms; }

.tool-form-row { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.tool-form-row label { font-size: 13.5px; font-weight: 600; }
.tool-form-row input[type="text"],
.tool-form-row input[type="number"],
.tool-form-row input[type="date"],
.tool-form-row select,
.tool-form-row textarea {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
}
.tool-form-row textarea { resize: vertical; min-height: 120px; }
.tool-form-row input:focus, .tool-form-row select:focus, .tool-form-row textarea:focus {
  outline: none; border-color: var(--accent);
}

.tool-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.result-box {
  display: none;
  margin-top: 22px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}
.result-box.show { display: block; }
.result-box .result-label { font-size: 12.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.result-box .result-value { font-size: 26px; font-weight: 700; }
.result-box .result-sub { font-size: 13.5px; margin-top: 4px; }

.error-msg {
  display: none;
  color: var(--error);
  background: color-mix(in srgb, var(--error) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 25%, transparent);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-top: 16px;
}
.error-msg.show { display: block; }

/* SEO content */
.seo-content { max-width: 760px; margin: 56px auto 0; }
.seo-content h2 { font-size: 24px; margin: 36px 0 14px; }
.seo-content h2:first-child { margin-top: 0; }
.seo-content p { margin-bottom: 12px; font-size: 15.5px; }
.seo-content ol, .seo-content ul { color: var(--text-secondary); font-size: 15.5px; padding-left: 22px; }
.seo-content li { margin-bottom: 8px; }

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.faq-item:first-child { border-top: 1px solid var(--border); }
.faq-q {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 15.5px; cursor: pointer; color: var(--text-primary);
}
.faq-q svg { width: 18px; height: 18px; color: var(--text-secondary); transition: transform var(--transition); flex-shrink: 0; }
.faq-item.open .faq-q svg { transform: rotate(45deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 220ms ease; }
.faq-item.open .faq-a { max-height: 240px; }
.faq-a p { padding-top: 10px; font-size: 14.5px; }

/* Ad slot */
.ad-slot {
  max-width: 760px;
  margin: 32px auto;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-slot-label {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ad-slot.ad-slot-filled {
  border: none;
  min-height: 0;
  display: block;
  text-align: center;
}

/* Related tools */
.related-tools .tool-grid { max-width: 760px; margin: 0 auto; }

/* ---------------------------------------------------------------------- */
/* Category page                                                          */
/* ---------------------------------------------------------------------- */
.page-header { padding: 36px 0 8px; text-align: center; }
.page-header h1 { margin-bottom: 10px; }
.page-header p { max-width: 560px; margin: 0 auto; font-size: 16px; }

/* ---------------------------------------------------------------------- */
/* Footer                                                                  */
/* ---------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 56px 0 28px;
  margin-top: 40px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 32px;
}
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-brand p { font-size: 13.5px; margin-top: 10px; max-width: 240px; }
.footer-col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 14px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 14px; color: var(--text-secondary); transition: color var(--transition); }
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 10px;
}

/* Mobile drawer */
.mobile-drawer {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: none;
  flex-direction: column;
  padding: 20px 24px;
}
.mobile-drawer.open { display: flex; }
.mobile-drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.mobile-drawer nav { display: flex; flex-direction: column; gap: 4px; }
.mobile-drawer nav a { padding: 14px 4px; font-size: 17px; font-weight: 600; border-bottom: 1px solid var(--border); }

/* ---------------------------------------------------------------------- */
/* Cookie consent (GDPR / UK GDPR)                                        */
/* ---------------------------------------------------------------------- */
.consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 620px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
  z-index: 300;
  display: none;
}
.consent-banner.open { display: block; }
.consent-banner h3 { font-size: 16px; margin-bottom: 8px; }
.consent-banner p { font-size: 13.5px; margin-bottom: 16px; }
.consent-banner p a { color: var(--accent); text-decoration: underline; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.consent-actions .btn { flex: 1; min-width: 140px; padding: 11px 16px; font-size: 13.5px; }

.consent-modal-overlay {
  position: fixed; inset: 0; z-index: 310;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.consent-modal-overlay.open { display: flex; }
.consent-modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}
.consent-modal h3 { font-size: 19px; margin-bottom: 6px; }
.consent-modal > p { font-size: 13.5px; margin-bottom: 20px; }
.consent-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.consent-row:last-of-type { border-bottom: none; }
.consent-row-text h4 { font-size: 14.5px; margin-bottom: 4px; }
.consent-row-text p { font-size: 13px; margin: 0; }

.toggle-switch {
  position: relative;
  width: 44px; height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border);
  border: none;
  transition: background var(--transition);
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(18px); }
.toggle-switch.disabled { opacity: 0.6; cursor: not-allowed; }

.consent-modal-actions {
  display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap;
}
.consent-modal-actions .btn { flex: 1; min-width: 140px; }

.footer-cookie-settings {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; font-size: 14px; color: var(--text-secondary);
  cursor: pointer; text-align: left; transition: color var(--transition);
}
.footer-cookie-settings:hover { color: var(--accent); }

@media (max-width: 480px) {
  .consent-banner { left: 12px; right: 12px; bottom: 12px; padding: 18px; }
  .consent-actions .btn { min-width: 100%; }
}

/* Utility */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
