:root {
  color-scheme: light;
  --bg-a: transparent;
  --bg-b: transparent;
  --panel: #ffffff;
  --panel-border: #d8dee9;
  --text: #1f2937;
  --muted: #6b7280;
  --key: #f3f4f6;
  --key-hover: #e5e7eb;
  --operator: #2563eb;
  --accent: #dbeafe;
  --danger: #dc2626;
  --success: #16a34a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: transparent;
  color: var(--text);
}

.calculator-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0.5rem;
  background: transparent;
}

.calculator {
  position: fixed;
  width: min(calc(100vw - 1rem), 340px);
  padding: 0.85rem;
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.10);
  touch-action: none;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
  cursor: grab;
  user-select: none;
}

.calculator.is-dragging .brand-row {
  cursor: grabbing;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.04em;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.pip-button {
  width: 2rem;
  height: 2rem;
  border: 1px solid #d1d5db;
  border-radius: 0.7rem;
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.pip-button:hover,
.pip-button:focus-visible {
  background: #f3f4f6;
  outline: none;
}

.pip-button:disabled {
  display: none;
}

.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--success);
}

.pip-mode {
  min-width: 0;
  min-height: 0;
}

.pip-mode .calculator-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0.5rem;
}

.calculator.is-pip {
  position: static;
  width: min(calc(100vw - 1rem), 340px);
}

.display {
  min-height: 4.35rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 0.25rem;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.7rem;
  border-radius: 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.history {
  min-height: 1.25rem;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen {
  max-width: 100%;
  font-size: clamp(1.9rem, 8vw, 2.7rem);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

.key {
  min-height: 2.8rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.9rem;
  background: var(--key);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.key:hover,
.key:focus-visible {
  background: var(--key-hover);
  border-color: #d1d5db;
  outline: none;
}

.key:active {
  transform: scale(0.98);
}

.utility {
  color: var(--danger);
}

.operator {
  color: var(--operator);
}

.equals {
  background: var(--operator);
  border-color: var(--operator);
  color: #ffffff;
}

.equals:hover,
.equals:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.zero {
  grid-column: span 2;
}

.hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
}

@media (max-width: 360px) {
  .calculator {
    padding: 0.75rem;
  }

  .key {
    min-height: 2.65rem;
    border-radius: 0.8rem;
  }
}
