
:root {
  color-scheme: dark;
  --background: #0b1120;
  --panel: #111c30;
  --screen: #dcebcf;
  --text: #edf4ff;
  --muted: #a4b2c7;
  --blue: #2563eb;
  --border: #293951;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.calculator-app {
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 1px;
}

.brand span {
  color: #70a5ff;
  font-size: 12px;
  letter-spacing: 2px;
}

.subtitle, .section-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.mode-button {
  border: 1px solid #456080;
  border-radius: 9px;
  background: #1b2c45;
  color: #fff;
  padding: 10px 15px;
  font-weight: 700;
}

.screen-panel {
  padding: 17px;
  border-radius: 13px;
  background: var(--screen);
  color: #172515;
  margin-bottom: 14px;
  box-shadow: inset 0 0 0 2px #a7bd98;
}

.screen-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  opacity: .7;
}

.expression {
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid #9eaf91;
  outline: none;
  background: transparent;
  color: #172515;
  font-size: 19px;
}

.result {
  min-height: 48px;
  padding-top: 8px;
  text-align: right;
  font-size: clamp(25px, 5vw, 38px);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status {
  min-height: 16px;
  text-align: right;
  font-size: 11px;
  color: #40553a;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.key {
  min-height: 54px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #1a263a;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 2px 0 #070d18;
  transition: background .15s, transform .1s;
}

.key:hover {
  background: #293c58;
}

.key:active {
  transform: translateY(2px);
  box-shadow: none;
}

.key-function {
  background: #20334c;
  color: #c6ddff;
}

.key-operator {
  background: #29374d;
  color: #8bb8ff;
  font-size: 21px;
}

.key-equals {
  background: var(--blue);
  border-color: #3977f1;
  color: white;
  font-size: 23px;
}

.key-equals:hover, .plot-button:hover {
  background: #1d4ed8;
}

.key-zero {
  grid-column: span 1;
}

.graph-panel {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  padding: 16px;
}

.section-heading h2 {
  font-size: 19px;
  margin: 0;
}

.graph-form {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 17px 0 12px;
}

.graph-form label {
  font-weight: 700;
}

.graph-form input {
  min-width: 0;
  flex: 1;
  width: 100%;
  border: 1px solid #405570;
  border-radius: 7px;
  background: #0b1425;
  color: white;
  padding: 11px;
  outline-offset: 2px;
}

.plot-button {
  padding: 11px 18px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: white;
  font-weight: 700;
}

.graph-wrap {
  width: 100%;
  height: 360px;
  overflow: hidden;
  border: 1px solid #34465d;
  border-radius: 8px;
  background: #0a1322;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.graph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.graph-controls button {
  border: 1px solid #405570;
  border-radius: 7px;
  padding: 9px 12px;
  background: #1a2940;
  color: white;
}

.graph-status {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.app-footer {
  padding: 18px 4px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .brand {
    font-size: 21px;
  }

  .brand span {
    font-size: 10px;
  }

  .keypad {
    gap: 6px;
  }

  .key {
    min-height: 48px;
    font-size: 15px;
  }

  .graph-wrap {
    height: 290px;
  }

  .graph-panel {
    padding: 11px;
  }
}
