.hidden { display: none !important; }
.main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; }

.header { height: var(--height); }
.logo-mark { background-image: url("favicon.png"); }
.header-tools { height: 100%; }

.work { min-height: 0; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: var(--gap-large); overflow-y: auto; }
.calc { --columns: 4; align-self: start; justify-self: center; width: min(100vw, calc(var(--height) * 1.7 * var(--columns) + var(--gap-small) * (var(--columns) - 1))); display: flex; flex-direction: column; gap: var(--gap-medium); }

.display { display: flex; flex-direction: column; gap: var(--gap-small); padding: var(--padding-medium); border: var(--border-width) solid var(--border); border-radius: var(--border-radius-large); background: var(--bg-1); }
.display-bar { display: flex; align-items: center; gap: var(--gap-small); height: var(--height); }
.previous { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-1); font-family: var(--font-mono); font-size: var(--font-size-small); }
.mark { padding: 0 var(--padding-small); border: var(--border-width) solid var(--border); border-radius: var(--border-radius-small); color: var(--fg-1); font-size: var(--font-size-extra-small); font-weight: 700; }
#angle-button { font-size: var(--font-size-extra-small); }
.expression { width: 100%; padding: 0; border: 0; background: transparent; text-align: end; font-family: var(--font-mono); font-size: var(--font-size-large); }
.expression:focus { border: 0; outline: 0; }
.result { display: block; min-height: calc(var(--font-size-extra-large) * 2); overflow-x: auto; text-align: end; white-space: nowrap; font-family: var(--font-mono); font-size: calc(var(--font-size-extra-large) * 1.5); font-weight: 700; scrollbar-width: none; }

.keypad { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: var(--gap-small); }
.key { height: calc(var(--height) * 1.4); padding: 0; font-size: var(--font-size-medium); text-transform: none; }
.key.digit { background: var(--bg-1); }
.key.function, .key.memory { font-size: var(--font-size-small); color: var(--fg-1); }
.key.memory { height: var(--height); font-size: var(--font-size-extra-small); }

.history { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; border: var(--border-width) solid var(--border); border-radius: var(--border-radius-large); overflow: hidden; }
.history-bar { flex: none; display: flex; align-items: center; gap: var(--gap-small); height: var(--height); padding-inline: var(--padding-medium) var(--padding-small); border-bottom: var(--border-width) solid var(--border); }
.pane-title { flex: 1; min-width: 0; font-size: var(--font-size-extra-small); font-weight: 700; text-transform: uppercase; color: var(--fg-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap-small); padding: var(--padding-small); overflow-y: auto; }
.history-empty { padding: var(--padding-small); color: var(--fg-1); font-size: var(--font-size-small); }
.history-item { height: auto; min-height: calc(var(--height) * 1.4); padding: var(--padding-small) var(--padding-medium); flex-direction: column; align-items: flex-end; justify-content: center; gap: 0; text-transform: none; font-weight: 400; }
.history-expression { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-1); font-family: var(--font-mono); font-size: var(--font-size-small); }
.history-result { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--font-size-large); font-weight: 700; }

@media (max-width: 48rem) {
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .calc { width: 100%; }
  .history { order: 1; height: auto; }
  .history-list { overflow-y: visible; }
  .key { height: var(--height); }
}
