/* ========== CSS Variables ========== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: #131a2e;
  --bg-card-hover: #1a2340;
  --bg-sidebar: #0c1022;
  --bg-input: #131a2e;
  --border-color: rgba(99, 102, 241, 0.15);
  --border-hover: rgba(99, 102, 241, 0.35);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --gradient-start: #6366f1;
  --gradient-end: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-input: #f1f5f9;
  --border-color: rgba(99, 102, 241, 0.12);
  --border-hover: rgba(99, 102, 241, 0.3);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

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

ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ========== Sidebar ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--accent-light), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 4px;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.nav-arrow {
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--transition);
}

.nav-item.active .nav-arrow { opacity: 1; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
  font-family: inherit;
}

.sidebar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.toggle-switch {
  margin-left: auto;
  width: 40px;
  height: 22px;
  background: var(--text-muted);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition);
}

[data-theme="dark"] .toggle-switch,
body:not([data-theme]) .toggle-switch {
  background: var(--accent);
}

.toggle-knob {
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
}

[data-theme="dark"] .toggle-knob,
body:not([data-theme]) .toggle-knob {
  transform: translateX(18px);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.status-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.05em;
}

.status-sub {
  font-size: 0.7rem;
  color: var(--accent-light);
  margin-top: 1px;
}

/* ========== Mobile Header ========== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  z-index: 90;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.hamburger {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all var(--transition);
}

.mobile-logo {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mobile-history-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 95;
  backdrop-filter: blur(4px);
}

/* ========== Main Content ========== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ========== Hero ========== */
.hero {
  position: relative;
  padding: 60px 40px 50px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-color);
}

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

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-light);
  margin-bottom: 24px;
  animation: fadeInDown 0.6s ease;
}

.badge-icon { font-size: 1rem; }

.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 32px;
  animation: fadeInUp 0.6s ease 0.1s both;
}

.gradient-text {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease 0.2s both;
}

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

.search-input {
  width: 100%;
  padding: 18px 24px 18px 52px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

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

.search-results.active { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.search-result-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.search-result-item .result-category {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ========== Categories ========== */
.categories {
  padding: 40px;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
  animation: fadeInUp 0.5s ease both;
}

.category-card:nth-child(1) { animation-delay: 0.05s; }
.category-card:nth-child(2) { animation-delay: 0.1s; }
.category-card:nth-child(3) { animation-delay: 0.15s; }
.category-card:nth-child(4) { animation-delay: 0.2s; }
.category-card:nth-child(5) { animation-delay: 0.25s; }
.category-card:nth-child(6) { animation-delay: 0.3s; }
.category-card:nth-child(7) { animation-delay: 0.35s; }
.category-card:nth-child(8) { animation-delay: 0.4s; }
.category-card:nth-child(9) { animation-delay: 0.45s; }

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

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.category-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.category-count {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.calc-list li {
  margin-bottom: 2px;
}

.calc-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.calc-list a:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateX(4px);
}

.calc-icon {
  font-size: 1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* ========== Popular Tools ========== */
.popular-tools {
  padding: 20px 40px 40px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 32px;
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
}

.popular-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  cursor: pointer;
}

.popular-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.popular-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

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

.popular-icon-green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.popular-icon-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}

.popular-icon-blue {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue);
}

.popular-icon-orange {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
}

.popular-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========== Why Section ========== */
.why-section {
  padding: 40px;
  max-width: 960px;
  margin: 0 auto;
}

.why-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.8;
  max-width: 700px;
  margin: 0 auto 40px;
}

.why-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  transition: all var(--transition);
}

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

.feature-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
}

.feature-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.why-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.why-link {
  color: var(--accent-light);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color var(--transition);
}

.why-link:hover { color: var(--accent); }

.why-link.accent {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.link-dot {
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
}

/* ========== Footer ========== */
.footer {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding: 40px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.footer-brand h3 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 300px;
  line-height: 1.6;
}

.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--accent-light); }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
}

.heart { color: var(--red); }

/* ========== Ad Containers ========== */
.ad-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  text-align: center;
  min-height: 90px;
  overflow: hidden;
}

.ad-container-calc {
  max-width: 640px;
  margin: 24px auto;
  text-align: center;
  min-height: 90px;
  overflow: hidden;
}

@media (max-width: 768px) {
  .ad-container {
    padding: 0 12px;
    margin: 16px auto;
    min-height: 50px;
  }
  .ad-container-calc {
    margin: 16px auto;
    min-height: 50px;
  }
}

/* ========== Calculator Pages ========== */
.calc-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px;
  animation: fadeInUp 0.4s ease;
}

.calc-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.calc-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
  line-height: 1.6;
}

.calc-form {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.calc-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

.calc-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.calc-input option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.calc-input-inline {
  display: inline-block;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  margin: 0 4px;
}

.calc-input-inline:focus {
  border-color: var(--accent);
}

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 0;
}

.radio-label input[type="radio"],
.radio-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.calc-btn {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.calc-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.calc-btn-sm {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity var(--transition);
}

.calc-btn-sm:hover { opacity: 0.8; }

.calc-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.calc-inline-result {
  margin-top: 8px;
  font-size: 1.1rem;
  color: var(--text-primary);
  min-height: 24px;
}

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

/* Result Cards */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}

.result-big {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.result-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.result-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.result-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.result-category {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 12px 0;
}

.result-advice {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 12px 0;
  line-height: 1.5;
}

.result-table {
  margin-top: 16px;
  text-align: left;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}

.stat-item {
  background: var(--bg-input);
  padding: 12px 16px;
  border-radius: 8px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 700;
}

/* Scientific Calculator */
.sci-calc {
  max-width: 400px;
  margin: 0 auto;
}

.sci-display {
  width: 100%;
  padding: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1.5rem;
  font-family: 'Courier New', monospace;
  text-align: right;
  margin-bottom: 12px;
  outline: none;
}

.sci-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sci-btn {
  padding: 14px 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
  color: var(--text-primary);
}

.sci-btn:hover { background: var(--bg-card-hover); }
.sci-fn { color: var(--accent-light); font-size: 0.8rem; }
.sci-op { background: rgba(99, 102, 241, 0.15); color: var(--accent-light); }
.sci-eq { background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); color: white; }
.sci-num { font-size: 1.1rem; }

/* Password Display */
.password-display {
  padding: 16px 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  word-break: break-all;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-primary);
}

.password-display:hover { background: var(--bg-card-hover); }

/* Fraction Input */
.frac-input {
  text-align: center;
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all var(--transition);
  margin-bottom: 16px;
  cursor: pointer;
}

.back-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Calculator responsive */
@media (max-width: 600px) {
  .calc-container { padding: 20px 16px; }
  .calc-form { padding: 20px 16px; }
  .calc-title { font-size: 1.3rem; }
  .result-big { font-size: 2rem; }
  .result-stats { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .sci-grid { gap: 5px; }
  .sci-btn { padding: 12px 6px; font-size: 0.85rem; }
  .sci-display { font-size: 1.2rem; padding: 14px; }
}

@media (max-width: 400px) {
  .result-big { font-size: 1.6rem; }
  .calc-form { padding: 16px 12px; }
}

/* ========== Animations ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   RESPONSIVE DESIGN - Mobile, Tablet, Desktop/Windows
   Breakpoints:
     - Desktop XL: 1440px+
     - Desktop: 1025px - 1439px
     - Tablet Landscape: 769px - 1024px
     - Tablet Portrait: 601px - 768px
     - Mobile Large: 481px - 600px
     - Mobile Small: <= 480px
   ========================================================== */

/* ---- Desktop XL (1440px+) ---- */
@media (min-width: 1440px) {
  .hero-title {
    font-size: 3.2rem;
  }

  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 1100px;
  }

  .why-section {
    max-width: 1100px;
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero {
    padding: 72px 60px 56px;
  }

  .categories {
    padding: 48px 60px;
  }

  .popular-tools {
    padding: 24px 60px 48px;
  }

  .footer {
    padding: 48px 60px;
  }
}

/* ---- Desktop Standard (1025px - 1439px) ---- */
@media (min-width: 1025px) and (max-width: 1439px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---- Tablet Landscape (769px - 1024px) ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }

  .sidebar-header {
    padding: 20px 16px 12px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
  }

  .logo-text {
    font-size: 1.1rem;
  }

  .nav-item {
    padding: 10px 14px;
    font-size: 0.85rem;
    gap: 10px;
  }

  .sidebar-btn {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  .hero {
    padding: 48px 32px 40px;
  }

  .hero-title {
    font-size: 2.2rem;
  }

  .categories {
    padding: 32px 28px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .popular-tools {
    padding: 20px 28px 36px;
  }

  .popular-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .popular-card {
    padding: 24px 14px;
  }

  .popular-icon {
    width: 48px;
    height: 48px;
  }

  .popular-label {
    font-size: 0.85rem;
  }

  .why-section {
    padding: 32px 28px;
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .feature-card {
    padding: 24px 18px;
  }

  .footer {
    padding: 32px 28px;
  }
}

/* ---- Tablet Portrait (601px - 768px) ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-top: var(--header-height);
  }

  .hero {
    padding: 36px 24px 32px;
  }

  .hero-title {
    font-size: 2rem;
    margin-bottom: 24px;
  }

  .hero-badge {
    font-size: 0.8rem;
    padding: 6px 16px;
    margin-bottom: 20px;
  }

  .search-input {
    padding: 16px 20px 16px 48px;
    font-size: 0.9rem;
    border-radius: var(--radius);
  }

  .categories {
    padding: 24px 20px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .category-card {
    padding: 20px;
  }

  .category-header h3 {
    font-size: 0.95rem;
  }

  .calc-list a {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .popular-tools {
    padding: 20px 20px 32px;
  }

  .popular-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 100%;
  }

  .popular-card {
    padding: 28px 16px;
  }

  .popular-icon {
    width: 52px;
    height: 52px;
  }

  .section-title {
    font-size: 1.35rem;
    margin-bottom: 24px;
  }

  .why-section {
    padding: 24px 20px;
  }

  .why-text {
    font-size: 0.9rem;
    margin-bottom: 28px;
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .feature-card {
    padding: 22px 16px;
  }

  .feature-card h4 {
    font-size: 0.9rem;
  }

  .feature-card p {
    font-size: 0.8rem;
  }

  .feature-icon {
    width: 42px;
    height: 42px;
    margin-bottom: 12px;
  }

  .footer {
    padding: 28px 20px;
  }

  .footer-content {
    flex-direction: column;
    gap: 20px;
  }

  .footer-links {
    gap: 16px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
}

/* ---- Small Tablet / Large Mobile (481px - 600px) ---- */
@media (max-width: 600px) {
  .hero {
    padding: 32px 16px 28px;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .search-container {
    max-width: 100%;
  }

  .search-input {
    padding: 14px 16px 14px 44px;
    font-size: 0.85rem;
  }

  .search-icon {
    left: 16px;
  }

  .categories {
    padding: 20px 16px;
  }

  .categories-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .category-card {
    padding: 18px;
  }

  .popular-tools {
    padding: 16px;
  }

  .popular-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .popular-card {
    padding: 22px 12px;
    gap: 12px;
  }

  .popular-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .popular-icon svg {
    width: 26px;
    height: 26px;
  }

  .popular-label {
    font-size: 0.82rem;
  }

  .section-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
  }

  .why-section {
    padding: 20px 16px;
  }

  .why-text {
    font-size: 0.85rem;
    line-height: 1.7;
    margin-bottom: 24px;
  }

  .why-features {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .feature-card {
    padding: 20px 18px;
    display: flex;
    flex-direction: row;
    text-align: left;
    gap: 16px;
    align-items: center;
  }

  .feature-icon {
    margin: 0;
    flex-shrink: 0;
  }

  .feature-card h4 {
    margin-bottom: 4px;
  }

  .why-links {
    gap: 12px;
  }

  .why-link {
    font-size: 0.85rem;
  }

  .footer {
    padding: 24px 16px;
  }

  .footer-brand p {
    font-size: 0.82rem;
  }

  .footer-links {
    gap: 12px;
    flex-wrap: wrap;
  }

  .footer-links a {
    font-size: 0.82rem;
  }

  .footer-bottom {
    font-size: 0.75rem;
  }
}

/* ---- Mobile Small (<= 480px) ---- */
@media (max-width: 480px) {
  :root {
    --header-height: 54px;
  }

  .mobile-header {
    padding: 0 12px;
  }

  .mobile-logo {
    font-size: 1rem;
  }

  .hero {
    padding: 28px 14px 24px;
  }

  .hero-badge {
    font-size: 0.72rem;
    padding: 5px 14px;
    margin-bottom: 16px;
    gap: 6px;
  }

  .badge-icon {
    font-size: 0.85rem;
  }

  .hero-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
  }

  .search-input {
    padding: 13px 14px 13px 40px;
    font-size: 0.82rem;
  }

  .search-icon {
    left: 14px;
    width: 16px;
    height: 16px;
  }

  .search-results {
    max-height: 240px;
  }

  .search-result-item {
    padding: 10px 14px;
    font-size: 0.82rem;
  }

  .categories {
    padding: 16px 12px;
  }

  .categories-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .category-card {
    padding: 16px 14px;
    border-radius: var(--radius);
  }

  .category-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .category-header h3 {
    font-size: 0.9rem;
  }

  .category-count {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
    border-radius: 6px;
  }

  .calc-list a {
    padding: 7px 8px;
    font-size: 0.82rem;
    gap: 8px;
  }

  .calc-icon {
    font-size: 0.9rem;
    width: 20px;
  }

  .popular-tools {
    padding: 16px 12px;
  }

  .popular-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .popular-card {
    padding: 18px 10px;
    gap: 10px;
    border-radius: var(--radius);
  }

  .popular-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  .popular-icon svg {
    width: 22px;
    height: 22px;
  }

  .popular-label {
    font-size: 0.78rem;
  }

  .section-title {
    font-size: 1.1rem;
    margin-bottom: 18px;
  }

  .why-section {
    padding: 16px 12px;
  }

  .why-text {
    font-size: 0.82rem;
    line-height: 1.65;
    margin-bottom: 20px;
  }

  .feature-card {
    padding: 16px 14px;
    border-radius: var(--radius);
  }

  .feature-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .feature-icon svg {
    width: 20px;
    height: 20px;
  }

  .feature-card h4 {
    font-size: 0.85rem;
  }

  .feature-card p {
    font-size: 0.75rem;
  }

  .why-links {
    gap: 10px;
  }

  .why-link {
    font-size: 0.8rem;
  }

  .link-dot {
    width: 3px;
    height: 3px;
  }

  .footer {
    padding: 20px 12px;
  }

  .footer-brand h3 {
    font-size: 1.05rem;
  }

  .footer-brand p {
    font-size: 0.78rem;
  }

  .footer-links {
    gap: 10px;
  }

  .footer-links a {
    font-size: 0.78rem;
  }

  .footer-bottom {
    padding-top: 16px;
    font-size: 0.7rem;
    gap: 6px;
  }
}

/* ---- Extra Small Mobile (<= 360px) ---- */
@media (max-width: 360px) {
  .hero-title {
    font-size: 1.3rem;
  }

  .hero-badge {
    font-size: 0.68rem;
    padding: 4px 12px;
  }

  .search-input {
    padding: 12px 12px 12px 38px;
    font-size: 0.78rem;
  }

  .popular-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .popular-card {
    padding: 14px 8px;
    gap: 8px;
  }

  .popular-icon {
    width: 36px;
    height: 36px;
  }

  .popular-icon svg {
    width: 18px;
    height: 18px;
  }

  .popular-label {
    font-size: 0.72rem;
  }

  .category-card {
    padding: 14px 12px;
  }

  .calc-list a {
    padding: 6px 6px;
    font-size: 0.78rem;
  }

  .section-title {
    font-size: 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 8px;
  }
}

/* ========== Touch Device Optimizations ========== */
@media (hover: none) and (pointer: coarse) {
  .nav-item {
    padding: 14px 16px;
    min-height: 44px;
  }

  .calc-list a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .sidebar-btn {
    min-height: 44px;
  }

  .search-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .popular-card {
    min-height: 100px;
  }

  .footer-links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Disable hover transforms on touch */
  .category-card:hover,
  .popular-card:hover,
  .feature-card:hover {
    transform: none;
  }

  .popular-card:hover .popular-icon {
    transform: none;
  }

  /* Active states for touch feedback */
  .category-card:active {
    transform: scale(0.99);
  }

  .popular-card:active {
    transform: scale(0.97);
  }

  .calc-list a:active {
    background: var(--bg-card-hover);
  }
}

/* ========== Landscape Mobile ========== */
@media (max-width: 900px) and (orientation: landscape) {
  .hero {
    padding: 24px 32px 20px;
  }

  .hero-title {
    font-size: 1.6rem;
    margin-bottom: 16px;
  }

  .hero-badge {
    margin-bottom: 12px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========== Print Styles ========== */
@media print {
  .sidebar,
  .mobile-header,
  .sidebar-overlay,
  .search-container,
  .hero-badge {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }

  .hero-bg {
    background: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .category-card,
  .popular-card,
  .feature-card {
    break-inside: avoid;
    border: 1px solid #ddd !important;
  }
}

/* ========== ESSENTIAL PAGES STYLES ========== */
.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 40px 60px;
}

.page-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 20px 0 30px;
  letter-spacing: -0.5px;
}

.page-content {
  color: var(--text-secondary);
  line-height: 1.8;
}

.page-date {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.page-section {
  margin-bottom: 35px;
}

.page-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.page-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 18px 0 10px;
}

.page-section p {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.page-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 15px;
}

.page-list li {
  position: relative;
  padding: 8px 0 8px 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.page-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.legal-content .page-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 20px;
}

.legal-content .page-section h2 {
  border-bottom: none;
  padding-bottom: 0;
  display: block;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

/* About page grid */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.about-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.about-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.about-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.about-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Contact form */
.contact-form-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}

.contact-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* Cookie table */
.cookie-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 0.9rem;
}

.cookie-table th,
.cookie-table td {
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--border);
}

.cookie-table th {
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cookie-table td {
  color: var(--text-secondary);
  background: var(--card-bg);
}

.cookie-table tr:nth-child(even) td {
  background: rgba(99, 102, 241, 0.05);
}

/* ========== COOKIE CONSENT BANNER ========== */
.cookie-banner {
  position: fixed;
  bottom: -200px;
  left: 0;
  right: 0;
  z-index: 10000;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
  padding: 20px 30px;
  transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-banner.show {
  bottom: 0;
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.cookie-content p {
  flex: 1;
  min-width: 300px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

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

.cookie-link {
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: underline;
  white-space: nowrap;
}

.cookie-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.cookie-btn-accept {
  background: var(--accent);
  color: white;
}

.cookie-btn-accept:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.cookie-btn-decline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.cookie-btn-decline:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ========== PAGE RESPONSIVE STYLES ========== */
@media (max-width: 768px) {
  .page-container {
    padding: 20px 20px 50px;
  }

  .page-title {
    font-size: 1.6rem;
  }

  .page-section h2 {
    font-size: 1.2rem;
  }

  .legal-content .page-section {
    padding: 18px 16px;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .contact-form-container {
    padding: 20px;
  }

  .cookie-table {
    font-size: 0.8rem;
  }

  .cookie-table th,
  .cookie-table td {
    padding: 8px 10px;
  }

  .cookie-content {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .cookie-content p {
    min-width: auto;
    font-size: 0.85rem;
  }

  .cookie-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .cookie-banner {
    padding: 16px 20px;
  }
}

@media (max-width: 480px) {
  .page-container {
    padding: 15px 15px 40px;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .cookie-table th,
  .cookie-table td {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .cookie-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
}

/* ========== HTML SITEMAP PAGE ========== */
.sitemap-page {
  max-width: 1100px;
}

.sitemap-intro {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 32px;
  line-height: 1.6;
}

.sitemap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.sitemap-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.sitemap-section:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.sitemap-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.sitemap-heading svg {
  color: var(--accent);
  flex-shrink: 0;
}

.sitemap-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sitemap-list li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sitemap-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sitemap-list li:first-child {
  padding-top: 0;
}

.sitemap-list a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sitemap-list a:hover {
  color: var(--accent);
}

.sitemap-list a::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0.6;
}

.sitemap-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding-left: 12px;
  line-height: 1.4;
}

[data-theme="light"] .sitemap-list li {
  border-bottom-color: rgba(0,0,0,0.08);
}

/* Sitemap responsive */
@media (max-width: 768px) {
  .sitemap-grid {
    grid-template-columns: 1fr;
  }

  .sitemap-section {
    padding: 20px 20px;
  }

  .sitemap-heading {
    font-size: 1.05rem;
  }
}

@media (max-width: 480px) {
  .sitemap-intro {
    font-size: 0.95rem;
  }

  .sitemap-section {
    padding: 16px;
    border-radius: 12px;
  }

  .sitemap-list a {
    font-size: 0.9rem;
  }

  .sitemap-desc {
    font-size: 0.75rem;
  }
}

/* ========== CATEGORY PAGE LAYOUT ========== */
.category-page {
  display: flex;
  min-height: calc(100vh - 60px);
}

.cat-subnav {
  width: 280px;
  min-width: 280px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 0;
}

.cat-subnav-group {
  margin-bottom: 8px;
}

.cat-subnav-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.cat-subnav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.cat-subnav-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.cat-subnav-item.active {
  background: var(--accent);
  color: white;
  border-left-color: var(--accent);
  border-radius: 0 8px 8px 0;
  margin-right: 12px;
}

.cat-subnav-item .subnav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.cat-subnav-item.active .subnav-icon {
  opacity: 1;
}

.cat-subnav-item .nav-arrow {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s;
}

.cat-subnav-item.active .nav-arrow,
.cat-subnav-item:hover .nav-arrow {
  opacity: 0.6;
}

.cat-main {
  flex: 1;
  padding: 30px 40px 60px;
  overflow-y: auto;
  min-width: 0;
}

.cat-calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.cat-calc-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cat-calc-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cat-share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.cat-share-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.cat-calc-area {
  margin-bottom: 40px;
}

/* SEO Content Section */
.cat-seo-content {
  border-top: 1px solid var(--border);
  padding-top: 40px;
  margin-top: 40px;
}

.cat-seo-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.cat-seo-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 10px;
}

.cat-seo-content p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.cat-seo-content ul {
  list-style: disc;
  padding-left: 24px;
  margin-bottom: 16px;
}

.cat-seo-content li {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.cat-seo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 20px 0;
}

.cat-seo-grid h3 {
  margin-top: 0;
}

/* Category page responsive */
@media (max-width: 1024px) {
  .cat-subnav {
    width: 240px;
    min-width: 240px;
  }
}

@media (max-width: 768px) {
  .category-page {
    flex-direction: column;
  }

  .cat-subnav {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    display: flex;
    overflow-x: auto;
    gap: 0;
    flex-wrap: wrap;
  }

  .cat-subnav-group {
    margin-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }

  .cat-subnav-label {
    width: 100%;
    padding: 8px 16px 4px;
  }

  .cat-subnav-item {
    padding: 8px 14px;
    font-size: 0.82rem;
    border-left: none;
    border-radius: 8px;
    margin: 2px 4px;
  }

  .cat-subnav-item.active {
    margin-right: 4px;
    border-radius: 8px;
  }

  .cat-main {
    padding: 20px 16px 40px;
  }

  .cat-calc-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .cat-seo-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .cat-subnav-item {
    font-size: 0.78rem;
    padding: 6px 10px;
  }

  .cat-calc-title {
    font-size: 1.3rem;
  }

  .cat-main {
    padding: 16px 12px 30px;
  }
}

/* ==========================================================
   ENHANCED RESPONSIVE FIXES - All Devices
   ========================================================== */

/* Back Button Wrapper - responsive padding */
.back-btn-wrap {
  padding: 0 40px;
}

/* Form inputs prevent iOS zoom */
input[type="number"],
input[type="text"],
input[type="email"],
input[type="tel"],
select,
textarea {
  font-size: 16px;
}

/* Calc container overflow protection */
.calc-container,
.calc-form {
  overflow-x: hidden;
  word-wrap: break-word;
}

/* Result value text overflow */
.result-big {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Category page sub-nav horizontal scroll on mobile */
@media (max-width: 768px) {
  .cat-subnav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cat-subnav::-webkit-scrollbar {
    display: none;
  }
}

/* ---- Tablet Portrait (768px) specific fixes ---- */
@media (min-width: 601px) and (max-width: 768px) {
  .why-features {
    grid-template-columns: 1fr 1fr;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ---- Mobile (<=600px) back button & calc fix ---- */
@media (max-width: 600px) {
  .back-btn-wrap {
    padding: 0 16px;
  }

  .calc-form .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Fraction calculator inputs */
  .frac-input {
    min-width: 0;
    width: 100%;
  }

  /* Password generator slider */
  input[type="range"] {
    width: 100%;
  }

  /* GPA table responsive */
  .gpa-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Result stats single column */
  .result-stats {
    grid-template-columns: 1fr;
  }

  /* SEO content in category pages */
  .cat-seo-content h2 {
    font-size: 1.2rem;
  }

  .cat-seo-content h3 {
    font-size: 1rem;
  }

  .cat-seo-content p {
    font-size: 0.88rem;
  }

  .cat-seo-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Small Mobile (<=480px) ---- */
@media (max-width: 480px) {
  .back-btn-wrap {
    padding: 0 12px;
  }

  .calc-container {
    padding: 16px 12px;
  }

  .calc-form {
    padding: 16px 12px;
  }

  .calc-title {
    font-size: 1.2rem;
  }

  .calc-desc {
    font-size: 0.82rem;
  }

  /* Scientific calculator tighter */
  .sci-calc {
    max-width: 100%;
  }

  .sci-grid {
    gap: 4px;
  }

  .sci-btn {
    padding: 10px 4px;
    font-size: 0.8rem;
  }

  .sci-fn {
    font-size: 0.72rem;
  }

  .sci-num {
    font-size: 0.95rem;
  }

  .sci-display {
    font-size: 1.1rem;
    padding: 12px;
  }

  /* Password display */
  .password-display {
    font-size: 0.9rem;
    padding: 12px 14px;
  }

  /* Percentage calculator buttons */
  .calc-form button,
  .calc-btn {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  /* Unit converter selects */
  .calc-form select {
    padding: 10px 12px;
  }

  /* Category page header stacking */
  .cat-calc-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .cat-calc-title {
    font-size: 1.25rem;
  }

  .cat-share-btn {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  /* Essential pages tighter padding */
  .page-container {
    padding: 12px 12px 30px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .page-section h2 {
    font-size: 1.05rem;
  }

  .legal-content .page-section {
    padding: 14px 12px;
  }

  /* Contact form */
  .contact-form-container {
    padding: 16px;
  }

  /* Sitemap page */
  .sitemap-categories {
    grid-template-columns: 1fr;
  }
}

/* ---- Extra Small (<=360px) ---- */
@media (max-width: 360px) {
  .back-btn-wrap {
    padding: 0 8px;
  }

  .calc-container {
    padding: 12px 8px;
  }

  .calc-form {
    padding: 14px 10px;
    border-radius: 10px;
  }

  .calc-title {
    font-size: 1.1rem;
  }

  .sci-btn {
    padding: 9px 3px;
    font-size: 0.72rem;
    border-radius: 6px;
  }

  .sci-fn {
    font-size: 0.65rem;
  }

  .sci-display {
    font-size: 1rem;
    padding: 10px;
  }

  .result-big {
    font-size: 1.4rem;
  }

  .popular-card {
    padding: 12px 6px;
  }

  .popular-label {
    font-size: 0.68rem;
  }

  /* Category sub-nav items smaller */
  .cat-subnav-item {
    font-size: 0.72rem;
    padding: 5px 8px;
  }

  .cat-calc-title {
    font-size: 1.1rem;
  }

  .cat-seo-content h2 {
    font-size: 1.05rem;
  }

  .cat-seo-content p {
    font-size: 0.82rem;
    line-height: 1.6;
  }

  /* Footer ultra compact */
  .footer-brand h3 {
    font-size: 0.95rem;
  }

  .footer-brand p {
    font-size: 0.72rem;
  }

  .footer-links a {
    font-size: 0.72rem;
  }

  .footer-bottom {
    font-size: 0.65rem;
  }
}

/* ---- Tablet Landscape (769px - 1024px) improvements ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .calc-container {
    max-width: 560px;
    padding: 30px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .why-features {
    grid-template-columns: repeat(3, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .cat-subnav {
    width: 220px;
    min-width: 220px;
  }

  .cat-subnav-item {
    font-size: 0.82rem;
    padding: 8px 14px;
  }
}

/* ---- Large Desktop (1440px+) category page ---- */
@media (min-width: 1440px) {
  .cat-subnav {
    width: 300px;
    min-width: 300px;
  }

  .cat-main {
    padding: 40px 60px 80px;
  }

  .calc-container {
    max-width: 700px;
  }
}

/* ---- Safe area insets for notched phones ---- */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .cookie-banner {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ---- Smooth transitions for resize ---- */
.calc-container,
.cat-subnav,
.cat-main {
  transition: padding 0.2s ease;
}
