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

:root {
  --navy-dark: #1a2332;
  --navy-medium: #2d3e50;
  --navy-light: #3d5266;
  --white: #ffffff;
  --gray-light: #f5f7fa;
  --gray-medium: #e1e8ed;
  --gray-dark: #6c757d;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --text-primary: #1a2332;
  --text-secondary: #6c757d;
  --border-color: #e1e8ed;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--white);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background-color: var(--navy-dark);
  color: var(--white);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
}

.nav {
  display: flex;
  gap: 30px;
}

.nav a {
  color: var(--white);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.3s ease;
}

.nav a:hover {
  opacity: 0.8;
}

/* Hero Section */
.hero {
  background-color: var(--navy-medium);
  color: var(--white);
  padding: 60px 0;
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.2;
}

.hero-description {
  font-size: 20px;
  opacity: 0.9;
  line-height: 1.6;
}

/* Calculator Section */
.calculator-section {
  padding: 60px 0;
  background-color: var(--gray-light);
}

.ad-space {
  background-color: var(--white);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin: 30px 0;
  text-align: center;
}

.ad-placeholder {
  color: var(--gray-dark);
  font-size: 14px;
  padding: 40px 20px;
}

.calculator-wrapper {
  background-color: var(--white);
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 500px;
  margin: 0 auto;
}

.calculator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.calculator-header h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-toggle {
  display: flex;
  gap: 10px;
  background-color: var(--gray-light);
  padding: 4px;
  border-radius: 8px;
}

.mode-btn {
  padding: 8px 16px;
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mode-btn.active {
  background-color: var(--white);
  color: var(--accent-blue);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Calculator Display */
.calculator {
  width: 100%;
}

.display {
  background-color: var(--gray-light);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
}

/* Added history styling */
.history {
  font-size: 14px;
  color: var(--gray-dark);
  min-height: 20px;
  margin-bottom: 4px;
  word-break: break-all;
  opacity: 0.7;
  max-height: 60px;
  overflow-y: auto;
  width: 100%;
  text-align: right;
}

.expression {
  font-size: 16px;
  color: var(--text-secondary);
  min-height: 24px;
  margin-bottom: 8px;
  word-break: break-all;
}

.result {
  width: 100%;
  background: none;
  border: none;
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  outline: none;
}

/* Calculator Buttons */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

.btn {
  padding: 20px;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--white);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

.btn.number {
  background-color: var(--white);
  color: var(--text-primary);
}

.btn.operator {
  background-color: var(--gray-medium);
  color: var(--text-primary);
  border-color: var(--gray-medium);
}

.btn.operator:hover {
  background-color: var(--gray-dark);
  color: var(--white);
}

.btn.function {
  background-color: var(--gray-light);
  color: var(--text-secondary);
  border-color: var(--gray-light);
}

.btn.function:hover {
  background-color: var(--gray-medium);
  color: var(--text-primary);
}

.btn.scientific {
  background-color: var(--navy-light);
  color: var(--white);
  border-color: var(--navy-light);
  font-size: 16px;
}

.btn.scientific:hover {
  background-color: var(--navy-dark);
}

.btn.equals {
  background-color: var(--accent-blue);
  color: var(--white);
  border-color: var(--accent-blue);
  grid-column: span 2;
  font-size: 24px;
}

.btn.equals:hover {
  background-color: var(--accent-blue-hover);
}

.btn.zero {
  grid-column: span 2;
}

/* Content Sections */
.content-section {
  padding: 80px 0;
}

.content-section.alt {
  background-color: var(--gray-light);
}

.content-section h2 {
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 50px;
  color: var(--text-primary);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-top: 40px;
}

.content-card {
  background-color: var(--white);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.content-card h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--text-primary);
}

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

/* Guide Section */
.guide-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 40px;
  margin-top: 40px;
}

.guide-item {
  background-color: var(--white);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.guide-item h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--accent-blue);
}

.guide-item ul {
  list-style: none;
  padding-left: 0;
}

.guide-item li {
  padding: 10px 0;
  color: var(--text-secondary);
  line-height: 1.8;
}

.guide-item li strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* FAQ Section */
.faq-list {
  max-width: 800px;
  margin: 40px auto 0;
}

.faq-item {
  background-color: var(--white);
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.faq-item h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.faq-item p {
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Footer */
.footer {
  background-color: var(--navy-dark);
  color: var(--white);
  padding: 60px 0 30px;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section h4 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.footer-section p {
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.8;
}

.footer-section a {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  margin-bottom: 10px;
  transition: color 0.3s ease;
}

.footer-section a:hover {
  color: var(--white);
}

.footer-bottom {
  text-align: center;
  padding-top: 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav {
    gap: 15px;
  }

  .nav a {
    font-size: 14px;
  }

  .hero-title {
    font-size: 32px;
  }

  .hero-description {
    font-size: 16px;
  }

  .calculator-wrapper {
    padding: 20px;
  }

  .result {
    font-size: 28px;
  }

  .btn {
    padding: 16px;
    font-size: 16px;
  }

  .content-section h2 {
    font-size: 28px;
  }

  .guide-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    gap: 15px;
  }

  .nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero-title {
    font-size: 24px;
  }

  .calculator-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .btn {
    padding: 14px;
    font-size: 14px;
  }

  .result {
    font-size: 24px;
  }
}
