* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 11px;
  color: #111;
  background: #ece9d8;
}

button, input { font: inherit; }

.calculator-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ece9d8;
}

.menu-bar {
  height: 25px;
  display: flex;
  align-items: stretch;
  padding-left: 2px;
  flex-shrink: 0;
  border-bottom: 1px solid #aca899;
  background: #ece9d8;
  position: relative;
  z-index: 10;
}

.menu { position: relative; }
.menu-trigger {
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #111;
  cursor: default;
}
.menu.open > .menu-trigger,
.menu-trigger:hover {
  color: white;
  background: #316ac5;
  border-color: #316ac5;
}
.menu-popup {
  position: absolute;
  top: 24px;
  left: 0;
  display: none;
  min-width: 180px;
  padding: 2px;
  background: #ece9d8;
  border: 1px solid #777;
  box-shadow: 2px 2px 4px rgba(0,0,0,.3);
}
.menu.open .menu-popup { display: block; }
.menu-popup button {
  width: 100%;
  height: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px 0 22px;
  border: 0;
  background: transparent;
  color: #111;
  text-align: left;
  cursor: default;
}
.menu-popup button:hover { background: #316ac5; color: #fff; }
.menu-popup span { margin-left: 20px; color: #666; }
.menu-popup button:hover span { color: #fff; }

.calc-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.display-panel {
  padding: 7px;
  border: 1px solid #7f9db9;
  background: #fff;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,.12);
}
.display-topline {
  min-height: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #345;
  font-size: 9px;
}
#memory-indicator {
  min-width: 18px;
  color: #a00000;
  font-weight: bold;
}
#angle-indicator { color: #666; }
.display {
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 5px 7px;
  border: 0;
  outline: none;
  background: white;
  color: #102040;
  font-family: "Lucida Console", Consolas, monospace;
  font-size: 22px;
  text-align: right;
  user-select: text;
}
.display:focus { box-shadow: inset 0 0 0 1px #8bb7ef; }
.history-line {
  min-height: 16px;
  overflow: hidden;
  color: #777;
  font-size: 9px;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.memory-row,
.scientific-grid,
.keypad {
  display: grid;
  gap: 5px;
}
.memory-row { grid-template-columns: repeat(5, 1fr); }
.scientific-grid { grid-template-columns: repeat(5, 1fr); }
.keypad { grid-template-columns: repeat(5, 1fr); }

button {
  min-height: 34px;
  padding: 3px 6px;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  background: linear-gradient(#fff, #e8e8e8 45%, #d7d7d7);
  color: #123;
  box-shadow: inset 1px 1px rgba(255,255,255,.8);
  cursor: default;
}
button:hover { border-color: #4d83c2; background: linear-gradient(#fff, #e8f2ff 45%, #c9def8); }
button:active { background: #d5e6f7; box-shadow: inset 1px 1px 2px rgba(0,0,0,.25); }
button:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

.memory-row button { color: #a00000; min-height: 29px; }
.operator { color: #003399; font-weight: bold; }
.equals { color: #003399; font-weight: bold; border-color: #4a72a8; }
.utility { color: #8b0000; }
.red { color: #b00000; font-weight: bold; }
.wide { grid-column: span 3; }

.scientific-panel {
  padding: 7px;
  border: 1px solid #aca899;
  background: #f3f1e8;
}
.scientific-panel.hidden { display: none; }
.scientific-options {
  display: flex;
  gap: 15px;
  margin-bottom: 7px;
  padding-left: 2px;
}
.scientific-options label { display: flex; align-items: center; gap: 3px; }
.scientific-grid button { min-height: 29px; color: #303080; }

.status-bar {
  height: 22px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid #aca899;
  background: #ece9d8;
  color: #555;
}
.status-bar span {
  min-width: 0;
  height: 18px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border-right: 1px solid #aca899;
}
.status-bar span:first-child { flex: 1; }

@media (max-height: 560px) {
  .calc-body { gap: 5px; padding: 7px; }
  button { min-height: 30px; }
  .display { height: 39px; font-size: 19px; }
}
