* {
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  margin: 0;
  background-color: #f4f4f4;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  transition: background-color 0.3s ease;
}

body.dark {
  background-color: #1e1e1e;
}

.calculator {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 10px 4px 11px -6px rgba(0, 0, 0, 0.73);
  -webkit-box-shadow: 10px 4px 11px -6px rgba(0, 0, 0, 0.73);
  -moz-box-shadow: 10px 4px 11px -6px rgba(0, 0, 0, 0.73);
  padding: 20px;
  width: 320px;
  transition: background 0.3s ease;
}

body.dark .calculator {
  background: #2c2c2c;
  box-shadow: 10px 4px 11px -6px rgba(255, 255, 255, 0.73);
  -webkit-box-shadow: 10px 4px 11px -6px rgba(255, 255, 255, 0.73);
  -moz-box-shadow: 10px 4px 11px -6px rgba(255, 255, 255, 0.73);
}

.display {
  background: #eee;
  padding: 20px;
  border-radius: 10px;
  text-align: right;
  font-size: 2rem;
  min-height: 60px;
  overflow-x: auto;
}

body.dark .display {
  background: #444;
  color: #fff;
}

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

button {
  padding: 20px;
  font-size: 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background-color: #dedede;
  transition: background 0.2s ease;
  box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.6);
  -webkit-box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.6);
  -moz-box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.6);
}

button:hover {
  background-color: #ccc;
  box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.7);
  -webkit-box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.7);
  -moz-box-shadow: 5px 4px 8px -4px rgba(0, 0, 0, 0.7);
}

body.dark button {
  background-color: #555;
  color: #fff;
 box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.6);
-webkit-box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.6);
-moz-box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.6);
}

body.dark button:hover {
  background-color: #666;
  box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.7);
  -webkit-box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.7);
  -moz-box-shadow: 5px 4px 8px -4px rgba(255,255,255,0.7);
}

body.dark button:not(.operator):not(.remove):not(.c):not(.equals):hover {
  background-color: #666;
}

.operator {
  background-color: #fca311;
  color: white;
}

body.dark .operator {
  background-color: #f77f00;
}
.operator:hover {
  background-color: #e08500;
}

body.dark .operator:hover {
  background-color: #d26900;
}
.remove {
  background-color: #ff6b6b;
  color: white;
}

.remove:hover {
  background-color: #ff4c4c;
}

body.dark .remove {
  background-color: #ff4c4c;
}
body.dark .remove:hover {
  background-color: #d43d3d;
}
body.dark button {
  background-color: #555;
  color: #fff;
}

.c {
  background-color: #4dabf7;
  color: white;
}

body.dark .c {
  background-color: #4dabf7;
}

.c:hover {
  background-color: #339af0;
}

body.dark .c:hover {
  background-color: #339af0;
}
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.top-bar strong {
  color: #222;
}

body.dark .top-bar strong {
  color: #fff;
}

.theme-toggle {
  cursor: pointer;
  font-size: 1.2rem;
}

.history {
  margin-top: 10px;
  font-size: 0.9rem;
  color: #888;
  max-height: 60px;
  overflow-y: auto;
}

body.dark .history {
  color: #bbb;
}

.expression {
  font-size: 2rem;
  text-align: right;
  color: #3a3a3a;
  padding: 0.5rem;
  transition: font-size 0.2s ease;
}

body.dark .expression {
  color: #fff;
}

body.dark .result {
  color: #fff;
}

.result {
  font-size: 2rem;
  font-weight: bold;
  text-align: right;
  padding: 0.5rem;
  color: #3a3a3a;
  transition: font-size 0.2s ease;
}

.expression.small {
  font-size: 1rem;
  color: #888;
}

@media (min-width: 1025px) {
  .calculator {
    max-width: 800px;
    width: 100%;
    height: 100vh;
  }

  .expression {
    font-size: 2.2rem;
  }

  .expression.small {
    font-size: 1.2rem;
  }

  .result {
    font-size: 3.2rem;
  }

  button {
    font-size: 1.6rem;
    padding: 16px;
  }
  .screen {
    height: 100px;
  }
}
@media (min-width: 600px) and (max-width: 1024px) {
  .calculator {
    width: 90%;
    max-width: 600px;
    height: 90vh;
    margin: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
  }

  .screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 2rem;
    padding: 1rem;
    overflow-wrap: break-word;
  }

  .buttons {
    flex: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .buttons button {
    font-size: 1.2rem;
    padding: 1rem;
    min-height: 120px;
  }

  #exp {
    font-size: 3rem;
    text-align: right;
    transition: font-size 0.3s ease;
  }

  #exp.small {
    font-size: 1.5rem;
  }

  #res {
    font-size: 4rem;
    font-weight: bold;
    text-align: right;
    margin-top: 0.5rem;
  }
}

@media (max-width: 600px) {
  .calculator {
    width: 90%;
    max-width: 400px;
    height: auto;
    padding: 1rem;
  }

  .screen {
    font-size: 1.5rem;
    padding: 0.5rem;
  }

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

  .buttons button {
    font-size: 1rem;
    padding: 0.5rem;
    min-height: 80px;
  }
}
