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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

header {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar {
  padding: 1rem 0;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: #4b5563;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-menu a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  transition: all 0.3s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
  background: #6b7280;
  color: white;
}

main {
  flex: 1;
  padding: 2rem 0;
}

.calculator-section {
  display: none;
  animation: fadeIn 0.5s ease;
}

.calculator-section.active {
  display: block;
}

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

h2 {
  text-align: center;
  color: white;
  margin-bottom: 2rem;
  font-size: 2rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.calculator {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  max-width: 400px;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.scientific-calc {
  max-width: 550px;
  transform: scale(0.8);
  transform-origin: center top;
  margin: 0 auto;
  margin-top: 50px;
}

.display {
  margin-bottom: 1rem;
}

#display,
#sci-display {
  width: 100%;
  padding: 1rem;
  font-size: 2rem;
  text-align: right;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: #f5f5f5;
  color: #333;
}

.history {
  text-align: right;
  color: #888;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  min-height: 1.2rem;
}

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

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

.btn {
  padding: 20px;
  font-size: 1.2rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #f0f0f0;
  color: #333;
  transition: all 0.3s ease;
  font-weight: 500;
}

.btn:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
}

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

.btn-operator {
  background: #6b7280;
  color: white;
}

.btn-operator:hover {
  background: #4b5563;
}

.btn-clear {
  background: #f56565;
  color: white;
  grid-column: span 1;
}

.btn-clear:hover {
  background: #e53e3e;
}

.btn-equals {
  background: #48bb78;
  color: white;
  grid-row: span 2;
}

.btn-equals:hover {
  background: #38a169;
}

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

.sub-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.sub-nav-btn {
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.sub-nav-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.sub-nav-btn.active {
  background: white;
  color: #4b5563;
  border-color: white;
}

.math-subsection {
  display: none;
  animation: fadeIn 0.5s ease;
}

.math-subsection.active {
  display: block;
}

.power-root-calculator,
.fraction-calculator,
.percentage-calculator {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.power-root-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.calc-section {
  padding: 1.5rem;
  background: #f7fafc;
  border-radius: 10px;
}

.calc-section h3 {
  margin-bottom: 1rem;
  color: #4b5563;
  font-size: 1.2rem;
}

.calc-section .description {
  color: #666;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.sqrt-input-group,
.nth-root-input-group,
.power-input-group,
.fraction-power-input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.power-input-group sup {
  position: relative;
  top: -25px;
  margin-left: -10px;
}

.sqrt-wrapper {
  position: relative;
  display: inline-block;
}

.sqrt-symbol {
  font-size: 2.5rem;
  color: #333;
  font-weight: bold;
  position: absolute;
  left: -5px;
  top: -8px;
  z-index: 1;
}

.sqrt-wrapper::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 28px;
  right: -5px;
  height: 2px;
  background-color: #333;
  z-index: 1;
}

.sqrt-wrapper .sqrt-number-input {
  padding-left: 35px;
  padding-top: 12px;
}

.sqrt-number-input,
.power-input {
  width: 150px;
  padding: 0.75rem;
  font-size: 1.1rem;
  border: 2px solid #e0e0e0;
  border-radius: 5px;
  text-align: center;
}

.root-degree-display {
  position: relative;
  top: -10px;
  margin-right: -5px;
}

.root-degree-input {
  width: 40px;
  padding: 0.25rem;
  font-size: 0.9rem;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  text-align: center;
}

.power-exp-input {
  width: 60px;
  padding: 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  text-align: center;
}

.fraction-exp {
  display: inline-block;
  vertical-align: super;
  position: relative;
  top: -30px;
  margin: 0 5px;
}

.fraction-display {
  display: inline-block;
  text-align: center;
}

.fraction-display hr {
  margin: 3px 0;
  border: none;
  border-top: 2px solid #333;
  width: 65px;
}

.fraction-input {
  width: 65px;
  padding: 0.35rem;
  font-size: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  text-align: center;
  display: block;
}

.equals {
  font-size: 1.5rem;
  color: #333;
  font-weight: bold;
}

.result-display {
  min-width: 100px;
  padding: 0.75rem;
  font-size: 1.2rem;
  font-weight: bold;
  color: #48bb78;
  background: #f0fff4;
  border: 2px solid #48bb78;
  border-radius: 5px;
  text-align: center;
}

.fraction-inputs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 2rem;
}

.fraction-group {
  text-align: center;
}

.fraction-group h3 {
  margin-bottom: 1rem;
  color: #4b5563;
}

.fraction-group input {
  width: 100px;
  padding: 0.5rem;
  text-align: center;
  border: 2px solid #e0e0e0;
  border-radius: 5px;
  font-size: 1.2rem;
}

.fraction-group hr {
  margin: 0.5rem 0;
  border: none;
  border-top: 2px solid #333;
}

.operation-select {
  padding: 1rem;
  font-size: 1.5rem;
  border: 2px solid #6b7280;
  border-radius: 10px;
  background: white;
  color: #4b5563;
  cursor: pointer;
}

.btn-calculate {
  padding: 1rem 2rem;
  font-size: 1.5rem;
  background: #48bb78;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-calculate:hover {
  background: #38a169;
  transform: translateY(-2px);
}

.fraction-result {
  text-align: center;
}

.fraction-result h3 {
  margin-bottom: 1rem;
  color: #4b5563;
}

#fraction-result-display {
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

#fraction-result-display hr {
  margin: 0.5rem auto;
  width: 50px;
  border: none;
  border-top: 2px solid #333;
}

#decimal-result {
  margin-top: 1rem;
  color: #888;
}

.percentage-intro {
  background: rgba(255, 255, 255, 0.2);
  padding: 1.5rem;
  border-radius: 15px;
  margin-bottom: 2rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
}

.percentage-intro p {
  color: white;
  text-align: center;
  font-size: 1.1rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.percentage-options {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.percentage-calc-card {
  background: white;
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.percentage-calc-card h3 {
  margin-bottom: 1.5rem;
  color: #4b5563;
  font-size: 1.2rem;
  font-weight: 600;
}

.percentage-input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  padding: 1rem;
  background: #f7fafc;
  border-radius: 10px;
}

.percentage-input-group input[type="number"] {
  width: 120px;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.percentage-input-group input[type="number"]:focus {
  outline: none;
  border-color: #6b7280;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.percentage-input-group .result-field {
  width: 150px;
  padding: 0.75rem;
  border: 2px solid #48bb78;
  border-radius: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  background: #f0fff4;
  color: #48bb78;
}

.percentage-input-group .text-label {
  color: #666;
  font-size: 1.1rem;
}

.percentage-input-group .question-mark {
  color: #999;
  font-size: 1.3rem;
  font-weight: normal;
}

.percentage-input-group .equals-sign {
  font-size: 1.5rem;
  font-weight: bold;
  color: #4b5563;
}

.percentage-input-group .percent-sign {
  font-size: 1.2rem;
  color: #4b5563;
  font-weight: bold;
}

.percentage-input-group .dropdown-select {
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1.1rem;
  background: white;
  cursor: pointer;
  min-width: 100px;
  transition: all 0.3s ease;
}

.percentage-input-group .dropdown-select:hover {
  border-color: #6b7280;
}

.percentage-input-group .dropdown-select:focus {
  outline: none;
  border-color: #6b7280;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.percentage-calc-type {
  padding: 1.5rem;
  background: #f7fafc;
  border-radius: 10px;
}

.percentage-calc-type h3 {
  margin-bottom: 1rem;
  color: #4b5563;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.input-group input {
  padding: 0.5rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 5px;
  font-size: 1rem;
  width: 120px;
}

.input-group select {
  padding: 0.5rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 5px;
  font-size: 1rem;
  background: white;
  cursor: pointer;
}

.input-group span {
  color: #666;
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  background: #e6fffa;
  border-radius: 5px;
  color: #234e52;
  font-weight: 500;
  min-height: 3rem;
  display: flex;
  align-items: center;
}

footer {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem 0;
  text-align: center;
  color: #666;
  margin-top: auto;
}

@media (max-width: 768px) {
  .nav-menu {
    flex-direction: column;
    gap: 0.5rem;
  }

  .navbar .container {
    flex-direction: column;
  }

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

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

  .fraction-inputs {
    flex-direction: column;
  }

  .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .input-group input,
  .input-group select {
    width: 100%;
  }

  .percentage-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .percentage-input-group input[type="number"],
  .percentage-input-group .result-field,
  .percentage-input-group .dropdown-select {
    width: 100%;
  }

  .sub-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .sub-nav-btn {
    width: 100%;
  }

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