* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #1e1e1e;
  --bg-display: #1a1a1a;
  --text: #ffffff;
  --text-secondary: #888;
  --btn-number: #2d2d2d;
  --btn-number-hover: #3d3d3d;
  --btn-operator: #004578;
  --btn-operator-hover: #005a9e;
  --btn-equals: #0067c0;
  --btn-equals-hover: #0078d4;
  --btn-clear: #3a1a1a;
  --btn-clear-hover: #4a2222;
  --btn-memory: #252525;
  --btn-memory-hover: #353535;
  --btn-sci: #252525;
  --btn-sci-hover: #353535;
  --btn-prog: #252525;
  --btn-prog-hover: #353535;
  --btn-prog-letter: #2a3a2a;
  --btn-prog-letter-hover: #3a4a3a;
  --accent: #0078d4;
  --border: #333;
  --history-bg: #252525;
  --radius: 0;
}

html,
body {
  height: 100%;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

#app {
  width: 360px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* Header */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.mode-tabs {
  display: flex;
}

.mode-tab {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.mode-tab:hover {
  color: var(--text);
}
.mode-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Display */
.display {
  background: var(--bg-display);
  padding: 16px 20px;
  text-align: right;
  min-height: 100px;
  position: relative;
}

.expression {
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 20px;
  word-break: break-all;
  overflow-wrap: break-word;
}

.result {
  font-size: 40px;
  font-weight: 300;
  color: var(--text);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-indicator {
  position: absolute;
  top: 8px;
  left: 16px;
  font-size: 11px;
  color: var(--accent);
}

/* Buttons */
.buttons {
  padding: 4px;
}

.hidden {
  display: none !important;
}

.btn-row {
  display: flex;
  gap: 1px;
  margin-bottom: 1px;
}

.btn {
  flex: 1;
  height: 52px;
  border: none;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: var(--text);
}

.btn-number {
  background: var(--btn-number);
}
.btn-number:hover {
  background: var(--btn-number-hover);
}

.btn-operator {
  background: var(--btn-operator);
}
.btn-operator:hover {
  background: var(--btn-operator-hover);
}

.btn-equals {
  background: var(--btn-equals);
  font-size: 22px;
  font-weight: 600;
}
.btn-equals:hover {
  background: var(--btn-equals-hover);
}

.btn-clear {
  background: var(--btn-clear);
}
.btn-clear:hover {
  background: var(--btn-clear-hover);
}

.btn-memory {
  background: var(--btn-memory);
  font-size: 12px;
  font-weight: 600;
}
.btn-memory:hover {
  background: var(--btn-memory-hover);
}

.btn-sci {
  background: var(--btn-sci);
  font-size: 13px;
}
.btn-sci:hover {
  background: var(--btn-sci-hover);
}

.btn-sci-empty {
  background: transparent;
  pointer-events: none;
}

.btn-prog {
  background: var(--btn-prog);
  font-size: 13px;
}
.btn-prog:hover {
  background: var(--btn-prog-hover);
}

.btn-prog-letter {
  background: var(--btn-prog-letter);
  font-size: 16px;
  font-weight: 600;
}
.btn-prog-letter:hover {
  background: var(--btn-prog-letter-hover);
}

/* Programmer */
.programmer-display {
  background: var(--bg-display);
  padding: 8px 12px;
  margin: 0 4px 4px;
  border-radius: 4px;
}

.prog-base-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
}

.prog-base {
  padding: 4px 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.prog-base:hover {
  color: var(--text);
}
.prog-base.active {
  color: var(--accent);
}

.prog-bits {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: "Consolas", "Courier New", monospace;
  letter-spacing: 1px;
  word-break: break-all;
  line-height: 1.4;
}

/* Footer / History */
.footer {
  position: relative;
  border-top: 1px solid var(--border);
}

.history-toggle {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
}

.history-toggle:hover {
  color: var(--text);
}

.history-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--history-bg);
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-bottom: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.history-header button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.history-item {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: right;
}

.history-item:hover {
  background: #333;
}
.history-item .h-expr {
  font-size: 12px;
  color: var(--text-secondary);
}
.history-item .h-result {
  font-size: 16px;
  color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}
