:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #17243b;
  background: #fff;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button { font: inherit; }

.page {
  width: min(100% - 48px, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 27px;
  font-size: 16px;
}

.site-name {
  color: #17243b;
  text-decoration: none;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.04em;
}

.header-divider { width: 1px; height: 22px; background: #cbd5e5; }
.site-purpose { color: #65728a; font-weight: 550; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; }
.intro { text-align: center; margin: 62px 0 31px; }
.intro h1 { margin: 0; font-size: clamp(40px, 5vw, 58px); line-height: 1.12; letter-spacing: -.055em; }
.intro p { margin: 18px 0 0; color: #66738a; font-size: clamp(17px, 2vw, 21px); font-weight: 550; }

.calculator {
  width: min(100%, 520px);
  padding: 20px;
  border: 1px solid #d9e2f0;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(28, 57, 110, .07);
}

.display {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 116px;
  padding: 16px 19px;
  border: 1px solid #d8e3f3;
  border-radius: 10px;
  background: #f8fbff;
  overflow: hidden;
}

.expression { color: #68758e; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result { text-align: right; font-size: 42px; line-height: 1; letter-spacing: -.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result.error { color: #b52b41; font-size: 22px; letter-spacing: 0; }

.keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.keys button {
  height: 57px;
  border: 1px solid #dce5f2;
  border-radius: 10px;
  background: #fff;
  color: #17243b;
  font-size: 25px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.keys button:hover { background: #f2f6fc; border-color: #b9cbe5; }
.keys button:active { transform: translateY(1px); }
.keys button:focus-visible { outline: 3px solid #82a8f8; outline-offset: 2px; }
.keys .utility { background: #f7faff; }
.keys .operator { background: #ebf3ff; }
.keys .equals { background: #2564e8; border-color: #2564e8; color: #fff; }
.keys .equals:hover { background: #1853cb; border-color: #1853cb; }

footer { border-top: 1px solid #d8e2ef; margin-top: 55px; padding: 21px 0 24px; text-align: center; color: #66738a; font-size: 15px; }

@media (max-width: 580px) {
  .page { width: min(100% - 24px, 520px); }
  .site-header { gap: 10px; padding-top: 20px; font-size: 12px; }
  .site-name { font-size: 15px; }
  .header-divider { height: 17px; }
  .intro { margin: 51px 0 26px; }
  .intro p { margin-top: 12px; }
  .calculator { padding: 12px; }
  .display { height: 105px; }
  .result { font-size: 38px; }
  .keys { gap: 7px; margin-top: 12px; }
  .keys button { height: min(15vw, 62px); min-height: 48px; font-size: 23px; }
  footer { margin-top: 55px; }
}

@media (prefers-reduced-motion: reduce) { .keys button { transition: none; } }
