* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: #172033;
  background-color: #add8e6;
}

button {
  font-family: inherit;
}

.app {
  width: 980px;
  max-width: 94%;
  margin: 0 auto;
  padding: 36px 0;
}

.app h1 {
  margin: 0 0 26px;
  text-align: center;
  font-size: 30px;
}

.workspace {
  display: grid;
  grid-template-columns: 430px minmax(320px, 1fr);
  gap: 28px;
  align-items: start;
}

.calculator {
  padding: 22px;
  background-color: #1f2937;
  border-radius: 22px;
  box-shadow: 0 14px 30px rgba(31, 41, 55, 0.25);
}

.display {
  min-height: 122px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: right;
  color: #f9fafb;
  background-color: #111827;
  border-radius: 14px;
  overflow: hidden;
}

.expression {
  min-height: 24px;
  margin: 0 0 8px;
  color: #aeb8c8;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.result {
  margin: 0;
  font-size: 38px;
  font-weight: bold;
  overflow-wrap: anywhere;
}

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

.button {
  min-height: 68px;
  border: none;
  border-radius: 14px;
  color: #ffffff;
  background-color: #3b4658;
  font-size: 23px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}

.button:hover {
  filter: brightness(1.15);
}

.button:active {
  transform: scale(0.95);
}

.button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.function {
  color: #172033;
  background-color: #d5dae2;
}

.operator {
  background-color: #f59e0b;
}

.equals {
  background-color: #10b981;
}

.calculator-message {
  min-height: 22px;
  margin: 14px 2px 0;
  color: #fca5a5;
  font-size: 14px;
}

.history-panel {
  min-height: 590px;
  padding: 24px;
  background-color: #ffffff;
  border-radius: 22px;
  box-shadow: 0 14px 30px rgba(31, 41, 55, 0.16);
}

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

.history-header h2 {
  margin: 0;
  font-size: 25px;
}

.clear-history {
  padding: 9px 16px;
  border: none;
  border-radius: 9px;
  color: #ffffff;
  background-color: #ef4444;
  font-size: 15px;
  cursor: pointer;
}

.clear-history:hover {
  filter: brightness(1.08);
}

.clear-history:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.history-status {
  margin: 14px 0;
  color: #6b7280;
  font-size: 15px;
}

.history-list {
  max-height: 500px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid #e5e7eb;
}

.history-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-expression {
  color: #4b5563;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.history-result {
  color: #111827;
  font-size: 20px;
}

.history-time {
  color: #9ca3af;
  font-size: 12px;
}

.delete-history {
  flex-shrink: 0;
  padding: 7px 11px;
  border: none;
  border-radius: 8px;
  color: #b91c1c;
  background-color: #fee2e2;
  cursor: pointer;
}

.delete-history:hover {
  background-color: #fecaca;
}

.empty-history {
  padding: 40px 0;
  text-align: center;
  color: #9ca3af;
}

@media (max-width: 820px) {
  .app {
    width: 520px;
    padding: 24px 0;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .history-panel {
    min-height: auto;
  }
}

@media (max-width: 480px) {
  .app h1 {
    font-size: 23px;
  }

  .calculator {
    padding: 15px;
  }

  .buttons {
    gap: 8px;
  }

  .button {
    min-height: 58px;
    font-size: 20px;
  }

  .result {
    font-size: 32px;
  }
}
.result-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.result-row .result {
  min-width: 0;
  flex: 1;
}

.copy-result {
  flex-shrink: 0;
  margin-bottom: 5px;
  padding: 7px 10px;
  border: 1px solid #4b5563;
  border-radius: 8px;
  color: #d1d5db;
  background-color: #1f2937;
  font-size: 13px;
  cursor: pointer;
}

.copy-result:hover {
  color: #ffffff;
  background-color: #374151;
}

.history-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.use-history {
  padding: 7px 11px;
  border: none;
  border-radius: 8px;
  color: #065f46;
  background-color: #d1fae5;
  cursor: pointer;
}

.use-history:hover {
  background-color: #a7f3d0;
}

@media (max-width: 480px) {
  .copy-result {
    padding: 6px 8px;
    font-size: 12px;
  }
}