@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Inter:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-color: #f8fafc;
  --sidebar-bg: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --text-dark: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 3px 0 rgba(79, 70, 229, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(79, 70, 229, 0.1);
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.375rem;
  --font-en: "Inter", system-ui, -apple-system, sans-serif;
  --font-heading: "Outfit", var(--font-en);
  --font-ar: "Cairo", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  /* Category Colors */
  --cat-measurement: #4f46e5;
  --cat-health: #e11d48;
  --cat-finance: #d97706;
  --cat-misc: #8b5cf6; /* Purple */
}

.dark-mode {
  --bg-color: #0f172a;
  --sidebar-bg: #1e293b;
  --border-color: #334155;
  --card-bg: #1e293b;
  --text-dark: #f8fafc;
  --text-muted: #94a3b8;
  --primary-light: rgba(59, 130, 246, 0.15);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
  background-clip: content-box;
}

.dark-mode ::-webkit-scrollbar-thumb {
  background: #475569;
  background-clip: content-box;
}
.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
  background-clip: content-box;
}

.hidden {
  display: none;
}

/* Page Loader Bar */
.loader-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  width: 0%;
  opacity: 0;
  transition: width 0.4s ease-out, opacity 0.3s ease;
  pointer-events: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout restorative fixes */
.main-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1.5rem;
  box-sizing: border-box;
  flex-grow: 1;
}

.left-sidebar, .right-sidebar {
  display: none;
}

@media (max-width: 1023px) {
  .left-sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    background: var(--card-bg);
    padding: 1.5rem;
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .left-sidebar.open {
    transform: translateX(0);
  }

  body[dir="rtl"] .left-sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  
  body[dir="rtl"] .left-sidebar.open {
    transform: translateX(0);
  }

  #mobileMenuBtn {
    display: block !important;
  }
  
  .right-sidebar {
    display: none !important;
  }
}

.center-content {
  width: 100%;
  min-width: 0;
  flex-grow: 1;
}

@media (min-width: 1024px) {
  .main-container {
    display: grid !important;
    grid-template-columns: 280px minmax(0, 1fr) 300px !important;
    grid-template-areas: "left-col center-col right-col" !important;
    gap: 1.5rem !important;
    padding: 1.5rem !important;
    align-items: start !important;
    max-width: 100% !important;
  }

  .left-sidebar {
    grid-area: left-col !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1.25rem !important;
    position: sticky !important;
    top: 80px !important; /* Topbar (56px) + main padding (24px) */
    height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    padding-bottom: 2.5rem !important;
    padding-right: 12px !important;
    scrollbar-gutter: stable;
    scrollbar-width: thin !important;
    z-index: 20 !important;
  }

  .right-sidebar {
    grid-area: right-col !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1.25rem !important;
    position: sticky !important;
    top: 80px !important;
    height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    padding-bottom: 2.5rem !important;
    padding-right: 12px !important;
    scrollbar-gutter: stable;
    scrollbar-width: thin !important;
    z-index: 20 !important;
  }

  .center-content {
    grid-area: center-col;
    max-width: 100%;
  }
}

/* Sidebar Categories & Hints */
/* Sidebar Nav Hint Enhancement */
.sidebar-nav-hint {
  font-size: 0.65rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  color: var(--text-muted) !important;
  margin: 1.25rem 0 0.4rem 0 !important;
  padding-inline-start: 1rem !important;
  font-weight: 800 !important;
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.6;
}

.sidebar-nav-hint::after {
  content: "";
  flex-grow: 1;
  height: 1px;
  background: var(--border-color);
  opacity: 0.2;
}

.sidebar-nav-hint:first-of-type {
  margin-top: 0.25rem !important;
}

/* Sidebar Links refinement */
.left-sidebar-link,
.sidebar-links a {
  display: flex !important;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem !important;
  text-decoration: none !important;
  color: var(--text-dark) !important;
  border-radius: 12px;
  font-size: 0.925rem;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 4px 0 !important;
  border: 1px solid transparent;
  white-space: normal;
  word-break: break-word;
  width: 100%;
  box-sizing: border-box;
}

.left-sidebar-link:hover,
.sidebar-links a:hover {
  background-color: var(--primary-light);
  color: var(--primary) !important;
  transform: translateX(6px);
  border-color: var(--border-color);
}

.left-sidebar-link.active,
.sidebar-links a.active {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white !important;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
  border-color: transparent;
}

.left-sidebar-link i,
.left-sidebar-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.left-sidebar-link:hover i,
.left-sidebar-link:hover svg {
  opacity: 1;
}

.left-sidebar-link.active i, 
.left-sidebar-link.active svg {
  color: white !important;
  opacity: 1;
}

.sidebar-widget {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.sidebar-title i,
.sidebar-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.sidebar-nav-hint {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1.25rem 0.5rem 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.sidebar-nav-hint:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

/* Sidebar Widget Polishing */
/* Explicit Scrollbar Styling for Sidebars */
.left-sidebar::-webkit-scrollbar,
.right-sidebar::-webkit-scrollbar {
  width: 5px !important;
  display: block !important;
}

.left-sidebar::-webkit-scrollbar-track,
.right-sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02) !important;
  border-radius: 10px !important;
}

.left-sidebar::-webkit-scrollbar-thumb,
.right-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color) !important;
  border-radius: 10px !important;
}

.left-sidebar:hover::-webkit-scrollbar-thumb,
.right-sidebar:hover::-webkit-scrollbar-thumb {
  background: #94a3b8 !important;
}

.dark-mode .left-sidebar::-webkit-scrollbar-thumb,
.dark-mode .right-sidebar::-webkit-scrollbar-thumb {
  background: #475569 !important;
}

.dark-mode .left-sidebar:hover::-webkit-scrollbar-thumb,
.dark-mode .right-sidebar:hover::-webkit-scrollbar-thumb {
  background: #64748b !important;
}

/* Sidebar Widget Refining */
.sidebar-widget {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: 1.25rem !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  transition: all 0.2s ease;
  word-wrap: break-word !important;
}

.sidebar-widget:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.04) !important;
  border-color: var(--primary-light) !important;
}

.dark-mode .sidebar-widget {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.sidebar-widget h4,
.sidebar-title {
  display: flex !important;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.75rem !important;
  border-bottom: 1px solid var(--border-color) !important;
  margin-bottom: 1rem !important;
  font-size: 0.75rem !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
  color: var(--text-dark) !important;
  opacity: 0.8;
}

.sidebar-widget h4 i,
.sidebar-title i,
.sidebar-widget h4 svg,
.sidebar-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  opacity: 0.9;
}


.sidebar-links {
  list-style: none;
  display: flex !important;
  flex-direction: column;
  gap: 0.4rem; /* More compact links */
}

/* Redundant removal - sidebar-links a styles are managed above with .left-sidebar-link */

.sidebar-faq {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body[dir="rtl"] .sidebar-faq-item {
  text-align: right;
}


.sidebar-faq-item h5 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.15rem;
}

.sidebar-faq-item p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar-more-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.8rem;
  text-decoration: none;
  transition: opacity 0.2s;
}

.sidebar-more-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-en);
  color: var(--text-dark);
  line-height: 1.6;
  transition: background-color 0.3s;
  min-height: 100vh;
  display: block; /* Changed from flex for better top-level stability */
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

body[dir="rtl"] {
  font-family: var(--font-ar);
  text-align: right;
}

.layout-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  overflow: hidden;
}

body[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.sidebar .brand {
  font-family: var(--font-heading);
  background-color: transparent;
  color: var(--text-dark);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
  font-size: 1.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body[dir="rtl"] .sidebar .brand {
  text-align: right;
}

.sidebar .brand svg {
  color: var(--primary);
}

.sidebar .nav-scroller {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.75rem;
  /* Hide scrollbar visually but keep functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.sidebar .nav-scroller::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.nav-category {
  background-color: transparent;
  color: var(--text-muted);
  padding: 1rem 0.75rem 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body[dir="rtl"] .nav-category {
  text-align: right;
}

.nav-btn {
  width: 100%;
  text-align: start;
  text-decoration: none;
  border-bottom: none;
  border-radius: var(--radius-md);
  padding: 0.625rem 1rem;
  margin: 1px 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9375rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

body[dir="rtl"] .nav-btn {
  text-align: right;
}

.nav-btn:hover {
  background-color: var(--primary-light);
  color: var(--text-dark);
}

.nav-btn.active {
  background-color: var(--primary-light);
  color: var(--primary);
}

.nav-btn.cat-measurement .nav-icon {
  color: var(--cat-measurement);
}
.nav-btn.cat-health .nav-icon {
  color: var(--cat-health);
}
.nav-btn.cat-finance .nav-icon {
  color: var(--cat-finance);
}
.nav-btn.cat-misc .nav-icon {
  color: var(--cat-misc);
}

.nav-btn.active.cat-measurement {
  border-left: 3px solid var(--cat-measurement);
}
.nav-btn.active.cat-health {
  border-left: 3px solid var(--cat-health);
}
.nav-btn.active.cat-finance {
  border-left: 3px solid var(--cat-finance);
}
.nav-btn.active.cat-misc {
  border-left: 3px solid var(--cat-misc);
}

body[dir="rtl"] .nav-btn.active {
  border-left: none;
}
body[dir="rtl"] .nav-btn.active.cat-measurement {
  border-right: 3px solid var(--cat-measurement);
}
body[dir="rtl"] .nav-btn.active.cat-health {
  border-right: 3px solid var(--cat-health);
}
body[dir="rtl"] .nav-btn.active.cat-finance {
  border-right: 3px solid var(--cat-finance);
}
body[dir="rtl"] .nav-btn.active.cat-misc {
  border-right: 3px solid var(--cat-misc);
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.sidebar-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 1.5rem 1rem 0.5rem 1.25rem;
  font-weight: 700;
}

body[dir="rtl"] .sidebar-category {
  padding: 1.5rem 1.25rem 0.5rem 1rem;
  text-align: right;
}

.controls-container {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Language Switcher Base Styles */
.lang-switcher {
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--card-bg);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 0.75rem;
  padding-right: 1.75rem;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.lang-switcher:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%233b82f6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

.lang-switcher:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

body[dir="rtl"] .lang-switcher {
  background-position: left 0.625rem center;
  padding-right: 0.75rem;
  padding-left: 1.75rem;
  text-align: right;
}

/* Sidebar Specific Tweaks */
aside .lang-switcher {
  margin-top: 0.5rem;
}

.theme-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.theme-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.controls-container {
  padding: 1.25rem 0.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.controls-container select {
  flex-grow: 1;
  margin-top: 0 !important;
}

/* Topbar Specific Tweaks */
.topbar .lang-switcher {
  width: auto !important;
  min-width: 64px;
  font-size: 0.75rem;
  padding: 0.375rem 1.5rem 0.375rem 0.5rem !important;
  background-position: right 0.4rem center !important;
  height: auto;
}

body[dir="rtl"] .topbar .lang-switcher {
  padding: 0.375rem 0.5rem 0.375rem 1.5rem !important;
  background-position: left 0.4rem center !important;
}

/* Content Area */
.content-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  /* Hide scrollbar visually but keep functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.content-area::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.topbar {
  display: flex;
  padding: 0.75rem 0.25rem;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 0.5rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

.menu-toggle {
  background: var(--primary-light);
  border: none;
  cursor: pointer;
  color: var(--text-dark);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: var(--border-color);
}


.ad-placeholder {
  background: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sidebar-ad-container {
  margin: 1rem;
  padding: 1rem;
  background: var(--primary-light);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tool-footer-ad {
  margin: 2rem 0;
  width: 100%;
  min-height: 120px;
  display: flex;
  justify-content: center;
}

/* Media queries already handled above for sidebars */
@media (max-width: 1024px) {
  #main-content {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    width: 100%;
  }
}

.converter-section {
  display: none;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

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

.converter-section.active {
  display: block;
  animation: fadeInTranslate 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.header-text {
  margin-bottom: 1rem;
  text-align: center;
  width: 100%;
}

body[dir="rtl"] .header-text {
  text-align: center;
}

.header-text h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
}

.header-text p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  max-width: 100%;
  margin: 0;
}

/* Card and Grid */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  width: 100%;
  transition: box-shadow 0.3s ease;
}

@media (min-width: 600px) {
  .card {
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.05), 0 10px 15px -3px rgba(79, 70, 229, 0.05);
  }
}

.flex-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

body[dir="rtl"] .flex-row {
  direction: rtl;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--text-dark);
  text-align: start;
  margin-bottom: 0.25rem;
}

body[dir="rtl"] .input-group label {
  text-align: right;
}

.input-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-dark);
  background-color: var(--bg-color);
  transition: all 0.2s ease;
  text-align: start;
}

body[dir="rtl"] input[type="number"],
body[dir="rtl"] input[type="date"],
body[dir="rtl"] select {
  text-align: right;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  background-color: var(--card-bg);
  transform: translateY(-1px);
}

input:hover,
select:hover {
  border-color: #cbd5e1;
}

select[size] {
  height: 160px !important;
  margin-top: 0.5rem;
  border-radius: var(--radius-md) !important;
  overflow-y: auto;
  appearance: auto !important;
  background-image: none !important;
  padding-right: 0.5rem !important;
}

.swap-btn {
  background-color: #f1f5f9;
  color: var(--text-muted);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
}

.swap-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  transform: scale(1.1) rotate(180deg);
}

body[dir="rtl"] .swap-btn svg {
  transform: scaleX(-1);
}

/* Results */
.result-display {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
  cursor: pointer;
}

.result-display:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.5);
}

.result-display::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 100C0 44.771 44.771 0 100 0h100v100H0z' fill='%23fff' fill-opacity='.03'/%3E%3C/svg%3E") no-repeat top right;
  pointer-events: none;
}

.result-display.update-anim {
  animation: slideUpResult 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpResult {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.result-value {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  color: #ffffff;
  word-break: break-word;
  letter-spacing: -0.02em;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-details {
  color: rgba(255, 255, 255, 0.65);
  margin-top: 0.5rem;
  font-size: 1.125rem;
  font-weight: 500;
}

.formula-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}

.swap-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
}

.swap-units-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.swap-units-btn:hover {
  background: var(--primary);
  color: white;
  transform: rotate(180deg);
}

.swap-units-btn svg {
  width: 18px;
  height: 18px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 1rem;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.copy-btn.copied {
  background: rgba(255, 255, 255, 0.35);
}

/* SEO Content */
/* SEO Content Formatting */
.seo-content {
  margin-top: 2rem;
  padding: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  color: var(--text-dark);
  font-family: inherit;
  transition: all 0.3s ease;
}

body[dir="rtl"] .seo-content {
  text-align: right;
  border-left: 1px solid var(--border-color);
  border-right: 4px solid var(--primary);
}

.seo-content h2, 
.seo-content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.seo-content h2:first-child,
.seo-content h3:first-child {
  margin-top: 0;
}

.seo-content p {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.seo-content p strong {
  color: var(--text-dark);
  font-weight: 600;
  background: var(--primary-light);
  padding: 0 0.25rem;
  border-radius: 4px;
}

.seo-content ul {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

body[dir="rtl"] .seo-content ul {
  padding-left: 0;
  padding-right: 1.5rem;
}

.seo-content ul li {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.75rem;
  position: relative;
}

.seo-content ul li::marker {
  color: var(--primary);
  font-weight: bold;
}

/* Ad Placeholders */
.ad-leaderboard,
.ad-rectangle,
.ad-container {
  width: 100%;
  margin: 2rem 0;
  display: block;
  min-height: 100px;
  overflow: hidden;
}

/* Quick Reference Table */
.quick-ref-section {
  margin-top: 1.5rem;
  width: 100%;
}

.quick-ref-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 0;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

@media (min-width: 768px) {
  .ref-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9375rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
  background-color: var(--card-bg);
  gap: 1rem;
}

.ref-item:nth-child(odd) {
  background-color: var(--bg-color);
}

.ref-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  z-index: 1;
}

@media (min-width: 768px) {
  .ref-item:nth-child(even) {
    border-left: 1px solid var(--border-color);
  }
  /* Remove border bottom on last rows in 2-column mode */
  .ref-item:nth-last-child(-n+2) {
    border-bottom: none;
  }
  /* Correct zebra for 2 columns: 1 (odd), 2 (even), 3 (odd), 4 (even) */
  /* If we want rows to match color, we need sophisticated selection or just simple zebra */
  .ref-item:nth-child(4n+1), .ref-item:nth-child(4n+2) {
    background-color: var(--card-bg);
  }
  .ref-item:nth-child(4n+3), .ref-item:nth-child(4n+4) {
    background-color: var(--bg-color);
  }
}

.ref-item span:first-child {
  font-weight: 500;
  color: var(--text-dark);
  flex: 1;
}

.ref-item span:last-child {
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: rgba(79, 70, 229, 0.05);
}

@media (max-width: 480px) {
  .ref-item {
    padding: 0.75rem 1rem;
  }
  .ref-item span:first-child {
    font-size: 0.875rem;
  }
  .ref-item span:last-child {
    font-size: 0.8125rem;
  }
}

.ref-item:last-child {
  border-bottom: none;
}

.reference-container {
  margin-top: 3rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px -2px rgb(0 0 0 / 0.05);
}

.reference-header {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, transparent), color-mix(in srgb, var(--primary) 3%, transparent));
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 640px) {
  .reference-header {
    padding: 1rem;
  }
  
  .reference-header h3 {
    font-size: 0.9375rem;
  }
  
  .ref-item {
    padding: 1rem;
    font-size: 0.8125rem;
  }
}

.reference-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-spacer {
  margin-top: 4rem;
}

.related-tools-section {
  padding-top: 2rem !important;
  border-top: 1px solid var(--border-color) !important;
  margin-top: 4rem !important;
}

.related-tools-section h2 {
  font-size: 1.5rem !important;
  margin-bottom: 2rem !important;
  font-weight: 800 !important;
  color: var(--text-dark) !important;
  letter-spacing: -0.025em !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
}

.related-tools-section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border-color), transparent);
}

.related-tools-section .home-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 1rem !important;
}

.related-tools-section .home-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.related-tools-section .home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  border-color: var(--primary);
  background: var(--primary-light);
}

.related-tools-section .home-card-icon {
  background: var(--primary-light);
  color: var(--primary);
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.related-tools-section .home-card:hover .home-card-icon {
  background: var(--primary);
  color: white;
  transform: scale(1.1) rotate(-5deg);
}

.related-tools-section .home-card-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.related-tools-section .home-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.related-tools-section .home-card p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .related-tools-section .home-grid {
    grid-template-columns: 1fr;
  }
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--card-bg);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.faq-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.faq-item h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
}

.faq-item p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background-color: var(--card-bg);
  color: var(--text-muted);
  padding: 4rem 0 0;
  width: 100%;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

.footer-col h4 {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  margin-bottom: 1.5rem;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-nav a {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: inherit;
}

.footer-nav a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.footer-brand-desc {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 380px;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding: 3rem 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
}

.footer-copyright {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Sitemap Specific Styling in Footer */
.footer-sitemap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1rem;
}

@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 640px) {
  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer-brand-desc {
    margin: 0 auto;
  }
  .footer-nav a {
    justify-content: center;
  }
  .footer-nav a:hover {
    transform: none;
  }
  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

/* Responsive */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.1);
  }
  body[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  body[dir="rtl"] .sidebar.open,
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 95;
    display: none;
    backdrop-filter: blur(2px);
    cursor: pointer;
  }
  .overlay.active {
    display: block;
  }
  .main-content {
    padding: 1.5rem 1rem;
  }
  .flex-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .header-text h2 {
    font-size: 1.5rem;
  }
  .result-value {
    font-size: 2.5rem;
  }
  .input-group label {
    font-size: 0.875rem;
  }
  input[type="number"],
  input[type="date"],
  select {
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    height: 2.25rem;
    line-height: normal;
  }
}

/* FAQ Styles */
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.faq-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.faq-question {
  background: var(--card-bg);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-dark);
  transition: background 0.2s;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 1rem;
  gap: 1rem;
}

body[dir="rtl"] .faq-question {
  text-align: right;
}

.faq-question:hover {
  background: color-mix(in srgb, var(--primary) 3%, var(--card-bg));
}

.faq-answer {
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
  background: color-mix(in srgb, var(--bg-color) 40%, var(--card-bg));
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  padding: 1.25rem 1.5rem;
  max-height: 500px;
  border-top: 1px solid var(--border-color);
}

.faq-icon {
  transition: transform 0.3s ease;
  color: var(--primary);
}

.faq-item.open .faq-icon {
  transform: rotate(180deg);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.625rem;
}
.calc-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.875rem 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.calc-btn:hover {
  background: var(--bg-color);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.calc-btn:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}
.calc-btn.fn-btn {
  background: #f8fafc;
  color: var(--primary);
  font-size: 0.875rem;
  font-family: var(--font-mono);
}
.calc-btn.op-btn {
  background: #eff6ff;
  color: #2563eb;
}
.calc-btn.num-btn {
  background: #ffffff;
}
.calc-btn.clear-btn {
  color: #ef4444;
  background: #fef2f2;
}
.calc-btn.primary-btn {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  grid-column: span 2;
}
.calc-btn.primary-btn:hover {
  opacity: 0.95;
  background: #2563eb;
}
.calc-display-section {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  text-align: right;
  font-family: var(--font-mono);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}
.calc-input {
  color: #94a3b8;
  font-size: 1rem;
  min-height: 1.5rem;
  margin-bottom: 0.5rem;
}
.calc-result {
  color: #ffffff;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.calc-input::-webkit-scrollbar,
.calc-result::-webkit-scrollbar {
  display: none;
}
.calc-input {
  font-size: 1.25rem;
  color: var(--text-muted);
  min-height: 28px;
}
.calc-result {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* iOS fixes for selects and inputs */
@media screen and (max-width: 768px) {
  input[type="number"],
  input[type="text"],
  input[type="date"],
  select,
  .lang-switcher,
  .topbar .lang-switcher {
    font-size: 16px !important;
  }

  select {
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Custom Currency Select Styles */
.cc-wrapper {
  position: relative;
  width: 100%;
}
.cc-trigger {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  background-color: var(--card-bg);
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: border-color var(--transition-speed);
}
.cc-trigger:hover,
.cc-trigger:focus {
  border-color: var(--primary);
}
.cc-trigger:after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
}
.cc-trigger.open:after {
  border-top: none;
  border-bottom: 5px solid var(--text-muted);
}
.cc-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.cc-options.show {
  display: block;
}
.cc-option {
  padding: 0.625rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 1.125rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--bg-color);
}
.cc-option:last-child {
  border-bottom: none;
}
.cc-option:hover {
  background-color: var(--bg-hover);
}
.cc-option.selected {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.cc-flag {
  display: inline-block;
  width: 1.33333333em;
  line-height: 1em;
  margin-right: 0.5rem;
  border-radius: 2px;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
body[dir="rtl"] .cc-flag {
  margin-right: 0;
  margin-left: 0.5rem;
}

/* Home Grid Specifics */
.category-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0;
}

@media (min-width: 860px) {
  .category-title {
    font-size: 1.1rem;
  }
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding-top: 1rem;
  justify-content: center;
}
@media (min-width: 1200px) {
  .home-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
  }
}
.search-container {
  max-width: 600px;
  margin: 1.5rem auto 2.5rem;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 1rem 1.5rem 1rem 3.5rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 1.1rem;
  background: var(--card-bg);
  color: var(--text-dark);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}
.search-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 4px var(--primary-light);
  transform: translateY(-2px);
}
.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.3s;
}
.search-input:focus + .search-icon {
  color: var(--primary);
}

.search-highlight {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 600;
  border-radius: 2px;
  padding: 0 2px;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.1);
}

#noResults {
  display: none;
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--bg-color);
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  margin-top: 2rem;
  animation: fadeIn 0.3s ease;
}

.no-results-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.25rem;
  color: var(--text-muted);
  opacity: 0.3;
}

.no-results-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.hero-box {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.home-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--text-dark);
  transition: all 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}
.home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: rgb(var(--icon-color, 37, 99, 235));
}
.home-card[data-tab="numwords"] {
  --icon-color: 2, 132, 199;
}
.home-card[data-tab="time"] {
  --icon-color: 202, 138, 4;
}
.home-card[data-tab="length"] {
  --icon-color: 22, 163, 74;
}
.home-card[data-tab="weight"] {
  --icon-color: 234, 88, 12;
}
.home-card[data-tab="temperature"] {
  --icon-color: 220, 38, 38;
}
.home-card[data-tab="scientific"] {
  --icon-color: 147, 51, 234;
}
.home-card[data-tab="area"] {
  --icon-color: 5, 150, 105;
}
.home-card[data-tab="speed"] {
  --icon-color: 219, 39, 119;
}
.home-card[data-tab="volume"] {
  --icon-color: 79, 70, 229;
}
.home-card[data-tab="pressure"] {
  --icon-color: 192, 38, 211;
}
.home-card[data-tab="energy"] {
  --icon-color: 234, 179, 8;
}
.home-card[data-tab="power"] {
  --icon-color: 239, 68, 68;
}
.home-card[data-tab="currency"] {
  --icon-color: 16, 185, 129;
}
.home-card[data-tab="bmi"] {
  --icon-color: 14, 165, 233;
}
.home-card[data-tab="age"] {
  --icon-color: 225, 29, 72;
}

.home-card-icon {
  color: rgb(var(--icon-color, 37, 99, 235));
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(var(--icon-color, 37, 99, 235), 0.15);
  border-radius: var(--radius-md);
}
.home-card-icon svg {
  width: 32px;
  height: 32px;
}
.home-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}


.tool-card:hover {
  border-color: var(--primary) !important;
  transform: translateY(-1px) !important;
}
.footer-links a:hover {
  color: var(--primary) !important;
}
.affiliate-banner-btn:hover {
  opacity: 0.9;
}

@media (max-width: 860px) {
  .desktop-nav-links {
    display: flex !important;
    gap: 1rem !important;
    overflow-x: auto;
    padding-bottom: 2px;
  }
}
@media (max-width: 600px) {
  .desktop-nav-links {
    display: none !important;
  }
}

.hero-section {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.hero-section::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.3;
  z-index: -1;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
  -webkit-mask-image: radial-gradient(circle at center, black, transparent 80%);
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

@media (max-width: 600px) {
  .hero-title {
    font-size: 1.75rem;
  }
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .hero-subtitle {
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
  }
}
.tool-cards-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .tool-cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
}

@media (min-width: 601px) {
  .tool-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
  }
}

/* Tool card base */
.tool-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.tool-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Base icon sizing */
.tool-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: transform 0.2s;
}

@media (max-width: 600px) {
  .tool-card {
    flex-direction: column;
    text-align: center;
    padding: 1rem 0.5rem;
    gap: 0.5rem;
  }
  .tool-card-icon {
    width: 48px;
    height: 48px;
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
  }
}

@media (min-width: 601px) {
  .tool-card-icon {
    width: 52px;
    height: 52px;
    font-size: 1.85rem;
  }
}

.tool-card:hover .tool-card-icon {
  transform: scale(1.1);
}

.tool-card-body {
  flex: 1;
}

.tool-card-body h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 0.25rem;
}

.tool-card-body p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

/* Category individual colors */
.tool-category:nth-child(1) .tool-card-icon {
  background: var(--primary-light);
  color: var(--primary);
}
.tool-category:nth-child(2) .tool-card-icon {
  background: #ffe4e6;
  color: var(--cat-health);
}
.tool-category:nth-child(3) .tool-card-icon {
  background: #fef3c7;
  color: var(--cat-finance);
}
.tool-category:nth-child(4) .tool-card-icon {
  background: #f3e8ff;
  color: var(--cat-misc);
}
