:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #080808;
  --text: #f4f4f4;
  --muted: #7d7d7d;
  --line: #3f3f3f;
  --line-strong: #707070;
  --white: #f2f2f2;
  --black: #050505;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

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

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.brand-header {
  border-top: 1px solid var(--line-strong);
  padding-top: 12px;
  margin-bottom: 28px;
}

.eyebrow,
.tagline,
.calculator-meta,
.slot-status,
.help-note,
.pending-value,
.dialog-card label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.eyebrow,
.tagline {
  color: var(--muted);
  font-size: 11px;
  margin: 0;
}

.brand-header h1 {
  margin: 10px 0 12px;
  font-size: clamp(52px, 10vw, 112px);
  line-height: .84;
  letter-spacing: -.065em;
  font-weight: 900;
}

.calculator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.calculator {
  border-top: 1px solid var(--line-strong);
  padding-top: 10px;
  min-width: 0;
}

.calculator-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 10px;
}

.screen {
  border-bottom: 1px solid var(--line-strong);
  padding: 6px 0 14px;
  margin-bottom: 10px;
  min-height: 94px;
}

.expression {
  min-height: 19px;
  text-align: right;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.display {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  font-size: clamp(38px, 6vw, 66px);
  line-height: 1;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.keypad button,
.save-answer,
.dialog-actions button,
.placement-banner button {
  min-height: 56px;
  border: 1px solid #505050;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  border-radius: 0;
}

.keypad button:active,
.save-answer:active,
.dialog-actions button:active,
.placement-banner button:active {
  background: var(--white);
  color: var(--black);
}

.operator,
.equals,
.dialog-actions .primary {
  background: var(--white) !important;
  color: var(--black) !important;
  border-color: var(--white) !important;
}

.wide { grid-column: span 2; }
.zero { grid-column: span 2; }

.save-answer {
  width: 100%;
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .1em;
  font-size: 10px;
}

.save-answer.armed {
  background: var(--white);
  color: var(--black);
}

.slot {
  position: relative;
  min-height: 56px;
  border-style: dashed !important;
  padding: 4px 6px;
  overflow: hidden;
}

.slot.empty::after {
  content: '+';
  color: #3d3d3d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 400;
}

.slot.filled {
  border-style: solid !important;
}

.slot.selectable {
  border-color: var(--white) !important;
  animation: slotPulse .95s steps(2, end) infinite;
}

.slot.selectable::after {
  content: 'SELECT';
  color: var(--white);
  font-size: 8px;
  letter-spacing: .08em;
  font-weight: 800;
}

.slot-label {
  display: block;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.slot-value {
  display: block;
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-status {
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
  margin-top: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--white);
  border-radius: 50%;
}

.placement-banner {
  margin-top: 8px;
  border: 1px solid var(--white);
  padding: 8px 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: .08em;
}

.placement-banner button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 9px;
}

.help-note {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 11px;
  color: #626262;
  font-size: 9px;
  line-height: 1.7;
}

.help-note p { margin: 0; }

.hidden { display: none !important; }

.register-dialog,
.edit-dialog {
  width: min(440px, calc(100% - 28px));
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  padding: 0;
}

.register-dialog::backdrop,
.edit-dialog::backdrop {
  background: rgba(0, 0, 0, .78);
}

.dialog-card { padding: 18px; }
.dialog-card h2 {
  margin: 8px 0 12px;
  font-size: 32px;
  letter-spacing: -.04em;
}

.pending-value {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 10px;
}
.pending-value strong { color: var(--text); font-size: 22px; }

.dialog-card label {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.dialog-card input {
  width: 100%;
  margin-top: 8px;
  padding: 13px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  font-size: 16px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.dialog-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.dialog-actions .danger { border-color: #888; }

@keyframes slotPulse { 50% { border-color: #444; } }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 22px, 680px); padding-top: 22px; }
  .calculator-grid { grid-template-columns: 1fr; gap: 30px; }
  .brand-header h1 { font-size: clamp(48px, 17vw, 84px); }
}

@media (prefers-reduced-motion: reduce) {
  .slot.selectable { animation: none; }
}
