html, body, main, header, footer {
  padding: 0px;
  margin: 0px;
}

body {
  background: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 16px 0 8px;
}

#header-title {
  color: #e0e0e0;
  font-size: 22px;
  font-weight: 600;
  margin: 12px 0 4px;
  letter-spacing: 1px;
}

#app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
}

#calculator {
  background: #16213e;
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(100, 100, 255, 0.08);
}

#display {
  background: #0f0f23;
  border-radius: 12px;
  padding: 20px 16px;
  margin-bottom: 16px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  overflow: hidden;
}

#expression {
  color: #8888aa;
  font-size: 16px;
  min-height: 22px;
  word-break: break-all;
  text-align: right;
  width: 100%;
  transition: color 0.2s;
}

#result {
  color: #ffffff;
  font-size: 40px;
  font-weight: 300;
  word-break: break-all;
  text-align: right;
  width: 100%;
  line-height: 1.2;
  transition: font-size 0.15s;
}

#result.small {
  font-size: 28px;
}

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

.btn {
  border: none;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 500;
  padding: 18px 0;
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.94);
}

.btn-num {
  background: #1e2a4a;
  color: #e8e8f0;
}

.btn-num:hover {
  background: #28355a;
}

.btn-num:active {
  background: #32406a;
}

.btn-op {
  background: #f0a030;
  color: #ffffff;
  font-size: 24px;
}

.btn-op:hover {
  background: #f5b550;
}

.btn-op:active {
  background: #e09020;
}

.btn-func {
  background: #2a2a4a;
  color: #c0c0d0;
  font-size: 18px;
}

.btn-func:hover {
  background: #34345a;
}

.btn-func:active {
  background: #3e3e6a;
}

.btn-eq {
  background: #4a7cf7;
  color: #ffffff;
  font-size: 26px;
}

.btn-eq:hover {
  background: #5c8af8;
}

.btn-eq:active {
  background: #3a6ce0;
}

#history-panel {
  margin-top: 16px;
  background: #0f0f23;
  border-radius: 12px;
  overflow: hidden;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: #8888aa;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.history-header:hover {
  background: #1a1a35;
}

.history-btn {
  background: none;
  border: 1px solid #444466;
  color: #8888aa;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.history-btn:hover {
  background: #2a2a4a;
  color: #c0c0d0;
}

#history-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 16px 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1a1a35;
  color: #aaaac0;
  font-size: 14px;
  cursor: pointer;
}

.history-item:hover {
  color: #ffffff;
}

.history-item .expr {
  color: #8888aa;
  font-size: 13px;
}

.history-item .val {
  color: #e0e0f0;
  font-size: 16px;
  font-weight: 500;
}

footer {
  text-align: center;
  padding: 20px 0;
}

.page-info {
  color: #555;
  font-size: 12px;
}

.page-info a {
  color: #777;
  text-decoration: none;
}

.page-info a:hover {
  color: #aaa;
  text-decoration: underline;
}

@media (max-width: 480px) {
  #calculator {
    border-radius: 16px;
    padding: 16px;
    max-width: 100%;
  }

  #display {
    padding: 16px 12px;
    min-height: 70px;
  }

  #result {
    font-size: 32px;
  }

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

  .btn {
    font-size: 20px;
    padding: 16px 0;
    border-radius: 10px;
  }

  #buttons {
    gap: 8px;
  }
}
