  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', system-ui, sans-serif;
    padding: 16px;
  }

  .calculator {
    background: #1e293b;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 1px solid #334155;
    width: 100%;
    max-width: 360px;
  }

  .display {
    background: #0f172a;
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    text-align: right;
    border: 1px solid #334155;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
  }

  .display .expression {
    color: #64748b;
    font-size: 16px;
    min-height: 22px;
    word-break: break-all;
    font-family: 'SF Mono', monospace;
  }

  .display .result {
    color: #f1f5f9;
    font-size: 40px;
    font-weight: 700;
    margin-top: 6px;
    word-break: break-all;
    font-family: 'SF Mono', monospace;
    transition: color 0.2s;
  }

  .display .result.error { color: #f87171; }

  .buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  button {
    border: none;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 600;
    padding: 18px 0;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    user-select: none;
  }

  button:active { transform: scale(0.95); }

  .btn-num {
    background: #334155;
    color: #f1f5f9;
  }
  .btn-num:hover { background: #475569; }

  .btn-op {
    background: #1e40af;
    color: #dbeafe;
  }
  .btn-op:hover { background: #2563eb; }

  .btn-fn {
    background: #475569;
    color: #f1f5f9;
  }
  .btn-fn:hover { background: #64748b; }

  .btn-eq {
    background: #f59e0b;
    color: #0f172a;
    grid-column: span 2;
  }
  .btn-eq:hover { background: #fbbf24; }

  .btn-zero { grid-column: span 2; }

  .history {
    margin-top: 16px;
    padding: 12px 16px;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid #334155;
    min-height: 44px;
    font-size: 13px;
    color: #64748b;
    font-family: 'SF Mono', monospace;
    max-height: 100px;
    overflow-y: auto;
  }

  .history .hist-item {
    padding: 3px 0;
    color: #94a3b8;
  }

  .history .hist-item .hist-val { color: #f59e0b; }

  @media (max-width: 400px) {
    .calculator { padding: 18px; }
    .display .result { font-size: 32px; }
    button { padding: 14px 0; font-size: 18px; }
  }

.status {
  min-height: 20px;
  margin: -10px 0 10px;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
}

.status:empty {
  visibility: hidden;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

button:disabled:hover {
  filter: none;
}