* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1e2f 0%, #2d2d44 100%);
  padding: 20px;
}


.app {
  display: flex;
  justify-content: center;
  flex-direction: row-reverse;
  gap: 20px;
  width: 100%;
}


.calculator {
  width: 100%;
  max-width: 360px;
  background: #1c1c28;
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.display {
  background: #12121a;
  border-radius: 16px;
  padding: 20px 18px;
  margin-bottom: 20px;
  text-align: right;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.display-history {
  color: #6b6b80;
  font-size: 16px;
  min-height: 20px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.display-current {
  color: #ffffff;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.btn {
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 500;
  padding: 18px 0;
  color: #ffffff;
  background: #2a2a3c;
  transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  box-shadow: 0 4px 0 #1a1a26;
}

.btn:hover {
  background: #33334a;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a1a26;
}

.btn-op {
  background: #ff8c42;
  color: #1c1c28;
  font-weight: 600;
  box-shadow: 0 4px 0 #b85f24;
}

.btn-op:hover {
  background: #ffa05e;
}

.btn-op:active {
  box-shadow: 0 2px 0 #b85f24;
}

.btn-func {
  background: #3a3a52;
  color: #b8b8d0;
  box-shadow: 0 4px 0 #24243a;
}

.btn-func:hover {
  background: #45455f;
}

.btn-func:active {
  box-shadow: 0 2px 0 #24243a;
}

.btn-equal {
  background: #4caf50;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 0 #2e7d32;
}

.btn-equal:hover {
  background: #5cbf60;
}

.btn-equal:active {
  box-shadow: 0 2px 0 #2e7d32;
}

.btn-zero {
  grid-column: span 2;
}


.history {
  width: 280px;
  background: #1c1c28;
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.history-title {
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.history-clear {
  background: transparent;
  border: none;
  color: #6b6b80;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.history-clear:hover {
  color: #ff8c42;
  background: rgba(255, 140, 66, 0.1);
}

.history-list {
  list-style: none;
  overflow-y: auto;
  max-height: 420px;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: #3a3a52;
  border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: #4a4a66;
}


.history-item {
  background: #12121a;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: background 0.2s;
}

.history-item:hover {
  background: #181824;
}

.history-expression {
  color: #b8b8d0;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-word;
}

.history-result {
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
}


.history-empty {
  color: #6b6b80;
  font-size: 14px;
  text-align: center;
  padding: 30px 0;
  font-style: italic;
}

@media (max-width: 700px) {
  .app {
    flex-direction: column;
    align-items: center;
  }

  .history {
    width: 100%;
    max-width: 360px;
  }

  .history-list {
    max-height: 220px;
  }
}

@media (max-width: 380px) {
  .calculator {
    padding: 16px;
    border-radius: 20px;
  }

  .display-current {
    font-size: 32px;
  }

  .btn {
    font-size: 18px;
    padding: 15px 0;
  }

  .buttons {
    gap: 8px;
  }

  .history {
    padding: 16px;
    border-radius: 20px;
  }

  .history-title {
    font-size: 16px;
  }

  .history-item {
    padding: 10px 12px;
  }

  .history-result {
    font-size: 16px;
  }
}
