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

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 0.6s ease-out forwards;
}

:root {
  --background: hsl(210 20% 98%);
  --foreground: hsl(215 25% 15%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(215 25% 15%);
  --primary: hsl(242 85% 55%);
  --primary-foreground: hsl(0 0% 100%);
  --secondary: hsl(210 40% 96%);
  --secondary-foreground: hsl(215 25% 15%);
  --muted: hsl(210 40% 96%);
  --muted-foreground: hsl(215 20% 45%);
  --accent: hsl(43 96% 56%);
  --accent-foreground: hsl(0 0% 100%);
  --success: hsl(142 76% 36%);
  --border: hsl(214 32% 91%);
  --input: hsl(214 32% 91%);
  --ring: hsl(242 85% 55%);
  --radius: 0.75rem;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.dark {
  --background: hsl(215 25% 11%);
  --foreground: hsl(210 20% 98%);
  --card: hsl(215 25% 15%);
  --card-foreground: hsl(210 20% 98%);
  --primary: hsl(242 85% 65%);
  --secondary: hsl(215 25% 15%);
  --secondary-foreground: hsl(210 20% 98%);
  --muted: hsl(215 25% 15%);
  --muted-foreground: hsl(215 20% 65%);
  --accent: hsl(43 96% 56%);
  --border: hsl(215 25% 20%);
  --input: hsl(215 25% 20%);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  background: linear-gradient(180deg, hsl(210 20% 95%) 0%, hsl(210 20% 92%) 100%);
  position: relative;
  z-index: 1;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.content-image {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.content-image .image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--muted);
  border-radius: var(--radius);
  min-height: 120px;
}

.dark .content-image .image-placeholder {
  background: hsl(215 25% 15%);
}

.content-image .image-placeholder span {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-align: center;
}

@media (max-width: 768px) {
  .content-image {
    gap: 0.75rem;
  }
  
  .content-image .image-placeholder {
    min-height: 100px;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.5rem;
  }
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.dark .header {
  background-color: rgba(23, 25, 35, 0.8);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: transform 0.2s;
}

.logo:hover {
  transform: scale(1.02);
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, hsl(242 85% 55%), hsl(262 85% 55%));
  color: white;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, hsl(242 85% 55%), hsl(262 85% 55%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  opacity: 0.8;
  text-decoration: none;
  transition: opacity 0.2s, color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  opacity: 1;
  color: var(--primary);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  cursor: pointer;
  color: var(--foreground);
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--muted);
}

.theme-toggle .sun-icon {
  display: block;
}

.theme-toggle .moon-icon {
  display: none;
}

.dark .theme-toggle .sun-icon {
  display: none;
}

.dark .theme-toggle .moon-icon {
  display: block;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 60;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--foreground);
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: 4rem;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    z-index: 55;
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links .nav-link {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    width: 100%;
  }

  .nav-links .nav-link:hover {
    background: var(--muted);
  }
}

.main::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 400px;
  background: radial-gradient(ellipse at top, hsl(242 85% 55%, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.calculator-page > .container {
  position: relative;
  z-index: 1;
}

.dark .main {
  background: linear-gradient(180deg, hsl(215 25% 11%) 0%, hsl(215 25% 9%) 100%);
}

.dark .main::before {
  background: radial-gradient(ellipse at top, hsl(242 85% 55%, 0.1) 0%, transparent 70%);
}

.breadcrumbs {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.breadcrumbs a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.hero {
  padding: 3rem 0;
  position: relative;
}

@media (min-width: 768px) {
  .hero {
    padding: 5rem 0;
  }
}

.hero-text {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 3rem;
  }
}

@media (min-width: 1024px) {
  .hero-title {
    font-size: 3.75rem;
  }
}

.gradient-text {
  background: linear-gradient(135deg, hsl(242 85% 55%), hsl(262 85% 55%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1rem;
  color: var(--muted-foreground);
  max-width: 42rem;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .hero-description {
    font-size: 1.125rem;
  }
}

.calculator-widget {
  max-width: 32rem;
  margin: 2rem auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  overflow: hidden;
}

.calc-display {
  padding: 1rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

.calc-mode {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  text-align: left;
  margin-bottom: 0.25rem;
}

.calc-equation {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  min-height: 1.25rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-result {
  font-size: 2rem;
  font-weight: 700;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.375rem;
  padding: 0.5rem;
}

.calc-btn {
  padding: 0.625rem 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s;
}

.calc-btn:hover {
  background: var(--secondary);
}

.calc-btn:active {
  transform: scale(0.95);
}

.calc-btn.function {
  font-size: 0.6875rem;
  background: var(--secondary);
}

.calc-btn.memory {
  font-size: 0.75rem;
  background: hsl(43 96% 56%, 0.1);
  color: var(--accent);
  font-weight: 600;
}

.calc-btn.toggle {
  background: hsl(142 76% 36%, 0.1);
  color: var(--success);
  font-weight: 600;
}

.calc-btn.operator {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.calc-btn.operator:hover {
  background: hsl(242 85% 45%);
}

.calc-btn.clear {
  background: hsl(0 84% 60%);
  color: white;
  border-color: hsl(0 84% 60%);
}

.calc-btn.clear:hover {
  background: hsl(0 84% 50%);
}

.calc-btn.equals {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.calc-btn.equals:hover {
  background: hsl(242 85% 45%);
}

.search-container {
  max-width: 36rem;
  margin: 2rem auto;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
}

.search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.quick-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.quick-link {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--card);
  transition: all 0.2s;
}

.quick-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.categories {
  padding: 3rem 0;
}

.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.section-description {
  color: var(--muted-foreground);
}

.categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

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

@media (min-width: 1024px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.category-card {
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

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

.category-card:hover::before {
  transform: scaleX(1);
}

.category-card {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, hsl(242 85% 55%), hsl(262 85% 55%));
  color: white;
}

.category-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.category-info {
  flex: 1;
}

.category-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.category-name a {
  color: var(--foreground);
  text-decoration: none;
  transition: color 0.2s;
}

.category-name a:hover {
  color: var(--primary);
}

.category-count {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.category-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 0.75rem;
}

.category-calculators {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.calc-tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-radius: 0.25rem;
  text-decoration: none;
  transition: background 0.2s;
}

a.calc-tag:hover {
  background: var(--primary);
  color: white;
}

/* Calculator Info Section (homepage) */
.calculator-info {
  padding: 3rem 0;
}

.calculator-info article {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.calculator-info article:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.calculator-info h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 1rem;
}

.calculator-info h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 1rem;
}

.calculator-info p {
  color: var(--muted-foreground);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.calculator-info p:last-child {
  margin-bottom: 0;
}

.calculator-info a {
  color: var(--primary);
  text-decoration: none;
}

.calculator-info a:hover {
  text-decoration: underline;
}

.features {
  padding: 3rem 0;
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

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

.feature-card {
  text-align: center;
  padding: 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  background: hsl(242 85% 55%, 0.1);
  color: var(--primary);
  margin-bottom: 1rem;
}

.feature-icon.accent {
  background: hsl(43 96% 56%, 0.1);
  color: var(--accent);
}

.feature-icon.success {
  background: hsl(142 76% 36%, 0.1);
  color: var(--success);
}

.feature-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.feature-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.footer {
  padding: 3rem 0 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--background);
  margin-top: auto;
  position: relative;
  z-index: 10;
  min-height: 200px;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

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

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-tagline {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem;
}

.footer-heading {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 1rem;
}

.footer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-list a {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-list a:hover {
  color: var(--primary);
}

.footer-bottom {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-bottom p {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .calc-buttons {
    gap: 0.375rem;
    padding: 0.5rem;
  }
  
  .calc-btn {
    padding: 0.625rem 0.5rem;
    font-size: 0.875rem;
  }
  
  .calc-btn.function {
    font-size: 0.625rem;
  }
}
