:root {
  --bg: #000;
  --text: #fff;
  --subtext: #9a9aa0;
  --num: #27282c;
  --num-active: #3a3b40;
  --fn: #5e5f63;
  --op: #ff9f0a;
  --op-active: #f7be69;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: sans-serif;
}
body { display: grid; place-items: center; overscroll-behavior: none; }
button, input, label {
  touch-action: manipulation;
  font-family: sans-serif !important;
}

.phone {
  width: min(100vw, 430px);
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
  padding: 12px 14px 0;
  background: var(--bg);
}
@supports (height: 100dvh) {
  .phone {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.calc {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid #33353a;
  background: #15161a; color: #d6d7dc;
  display: grid; place-items: center;
}
.icon { display: inline-block; width: 21px; height: 21px; position: relative; }
.icon-list::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 1px;
  top: 3px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}
.icon-list::after {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}
.icon-svg {
  width: 22px;
  height: 22px;
  display: block;
}

.display-wrap {
  margin-top: auto;
  padding: 16px 4px 10px;
  text-align: right;
}
.expr {
  min-height: 40px;
  color: var(--subtext);
  font-size: clamp(24px, 6vw, 52px);
  line-height: 1.1;
  letter-spacing: 0.2px;
  overflow: hidden;
  white-space: nowrap;
}
.display {
  margin-top: 6px;
  font-size: clamp(48px, 16vw, 102px);
  line-height: 1.02;
  font-weight: 350;
  letter-spacing: -1px;
  white-space: nowrap;
  overflow: hidden;
}

.debug {
  display: none;
  margin: 0 4px 10px;
  min-height: 30px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #111218;
  border: 1px solid #2b2d36;
  color: #9fe89f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.keys {
  --key-size: clamp(70px, 21vw, 96px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: var(--key-size);
  gap: 10px;
  margin-top: 6px;
  padding-bottom: 32px;
  align-content: end;
  justify-items: center;
}
.key {
  width: var(--key-size);
  height: var(--key-size);
  border-radius: 50%;
  border: none;
  background: var(--num);
  color: #f5f5f7;
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 400;
}
.key:active { background: var(--num-active); }
.key-fn { background: var(--fn); }
.key-op {
  background: var(--op);
  color: #fff;
  font-size: clamp(44px, 10vw, 70px);
  font-weight: 500;
}
.key-op:active { background: var(--op-active); }

.key-sign {
  letter-spacing: 0.5px;
}

.config {
  border: none;
  padding: 0;
  margin: auto 0 0;
  width: 100%;
  max-width: none;
  background: transparent;
}
.config[open] {
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  min-height: 100vh;
}
.config::backdrop { background: rgba(0, 0, 0, 0.5); }
.config-card {
  margin: 0;
  width: 100%;
  padding: 10px 18px 18px;
  display: grid;
  gap: 12px;
  background: #15161a;
  color: #fff;
  border-radius: 18px 18px 0 0;
  border-top: 1px solid #30333d;
}
.config-card h2 { margin: 0; font-size: 20px; }
.hint { margin: 0; color: #b5b8c4; font-size: 13px; }
.config-card label { display: grid; gap: 6px; font-size: 14px; color: #d0d3dd; }
.config-card input {
  height: 40px;
  border-radius: 8px;
  border: 1px solid #3a3d45;
  background: #0d0e12;
  color: #fff;
  padding: 0 10px;
}
.sheet-grabber {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: #666b77;
  margin: 2px auto 0;
}
.switch-row {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
}
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  display: inline-flex;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
}
.switch .slider {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #3a3d45;
  transition: background .2s ease;
  position: relative;
}
.switch .slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
}
.switch input:checked + .slider {
  background: #34c759;
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 4px 0 0; }
.cfg-btn {
  border: none; border-radius: 8px; height: 38px; padding: 0 14px;
  background: #343843; color: #fff;
}
.cfg-btn-primary { background: #ff9f0a; }

@media (max-width: 390px) {
  .phone { padding-inline: 10px; }
  .keys { gap: 9px; }
  .display { font-size: clamp(44px, 14vw, 90px); }
  .expr { font-size: clamp(22px, 5.2vw, 40px); }
}
