:root {
  color-scheme: light;
  --ink: #20272c;
  --quiet: #555c5b;
  --paper: #f2ede3;
  --panel: #20282d;
  --panel-text: #f7f1e7;
  --amber: #ffb875;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-family: "Geist", "Avenir Next", system-ui, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #9a4917; outline-offset: 3px; }

.workspace {
  width: min(100% - clamp(28px, 8vw, 96px), 880px);
  margin-inline: auto;
  padding-block: clamp(38px, 11vh, 108px) 42px;
  display: grid;
  grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr);
  column-gap: clamp(22px, 5vw, 64px);
}

.page-heading { grid-column: 1 / -1; border-bottom: 1px solid #bcb4a6; margin-bottom: 25px; }
h1 {
  margin: 0 0 13px;
  font-size: clamp(2.25rem, 6.8vw, 4.15rem);
  line-height: 1.03;
  letter-spacing: -.058em;
  font-weight: 700;
}

.calculator {
  border: 1px solid #364349;
  border-radius: 19px;
  padding: clamp(12px, 3vw, 22px);
  min-width: 0;
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: 0 2px 0 #131b20, 0 15px 28px #292d2825;
}

.readout {
  min-width: 0;
  min-height: 132px;
  margin-bottom: 16px;
  padding: 13px 15px 10px;
  border-radius: 9px;
  border: 1px solid #51604f;
  background: #d9dfbf;
  color: #253228;
}
.readout-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  min-height: 21px;
  font-size: .78rem;
}
.readout-top label { color: #3b4937; font-weight: 650; }
#calc-context {
  min-width: 0;
  color: #3b4937;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
#calc-display {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: 620 clamp(1.8rem, 6vw, 2.7rem)/1.25 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 4px 0;
}
.readout-status { margin: 0; color: #784218; font-size: .8rem; line-height: 1.3; }
.readout-status:not(.shows-message) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.keypad button {
  min-height: clamp(48px, 8vw, 57px);
  border: 1px solid #566269;
  border-bottom-color: #171e21;
  border-radius: 7px;
  background: #343f44;
  color: var(--panel-text);
  font: 550 1.22rem/1 var(--mono);
  transition: background-color .15s ease;
}
.keypad button:hover { background: #46545a; }
.keypad button:active { background: #526169; }
.keypad button:focus-visible { outline-color: var(--amber); }
.keypad .utility { background: #2b3337; color: #e7ded0; font-size: 1.02rem; }
.keypad .operator { background: #414036; color: #ffd1a0; }
.keypad .equals { color: #372114; background: var(--amber); border-color: var(--amber); }
.keypad .equals:hover { background: #ffcc9a; }
.shortcuts {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 15px 0 0;
  color: #ded6c7;
  font-size: .74rem;
}
.shortcuts kbd {
  padding: 1px 4px;
  border: 1px solid #646c65;
  border-radius: 3px;
  font: .7rem/1.3 var(--mono);
}
.shortcuts kbd + kbd { margin-left: 6px; }

.history { min-width: 0; }
.history h2 { margin: 4px 0 13px; font-size: 1.35rem; letter-spacing: -.025em; }
.history p { color: var(--quiet); font-size: .96rem; line-height: 1.55; margin: 0; }
.history ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid #cfc6b6;
  max-height: 446px;
  overflow: auto;
}
.history ol:empty { border-top: 0; }
.history li { border-bottom: 1px solid #cfc6b6; }
.history button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
  gap: 14px;
  align-items: baseline;
  width: 100%;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: start;
  padding: 12px 8px;
  font: .94rem/1.38 var(--mono);
}
.history button:hover { background: #e8e1d3; }
.history button:focus-visible { outline-offset: -2px; }
.history button span { overflow-wrap: anywhere; }
.history button span:first-child { color: var(--quiet); }
.history button span:last-child { text-align: end; }
[hidden] { display: none !important; }

@media (max-width: 680px) {
  .workspace { grid-template-columns: minmax(0, 1fr); max-width: 460px; padding-block-start: 34px; }
  .page-heading { margin-bottom: 18px; }
  .history { margin-top: 27px; }
  .history ol { max-height: none; }
}

@media (pointer: coarse) {
  .shortcuts { display: none; }
}

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