:root {
  --bg: #0f0f12;
  --card: #1a1a1f;
  --text: #ffffff;
  --muted: #bbbbc2;
  --accent: #4caf50;
  --danger: #ff5252;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border-bottom: 1px solid #2a2a31;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .total { font-size: 18px; margin-left: auto; }
.goal {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
.target {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
}
.over { color: var(--muted); font-size: 16px; }

.container { max-width: 680px; margin: 0 auto; padding: 12px; padding-bottom: 280px; }

#list { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  padding: 8px;
  border-radius: 12px;
}
.name { color: var(--text); font-size: 16px; flex: 1; background: transparent; border: none; text-align: left; padding: 0; }
.amount { font-weight: 700; font-size: 18px; }
.actions { display: flex; gap: 6px; }
.btn-delete {
  border: none;
  background: var(--danger);
  color: #fff;
  width: 30px; height: 30px; border-radius: 10px;
  font-size: 18px; line-height: 18px;
}

.input-area { position: fixed; left: 0; right: 0; bottom: 0; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid #2a2a31; }
.inputs { display: flex; gap: 8px; align-items: center; }
.amount-tools { display: flex; align-items: center; gap: 8px; width: 100%; }
.tools { display: flex; gap: 8px; }
.tool-btn { 
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}
.inputs input {
  flex: 1;
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}

.amount-display {
  flex: 0 0 auto;
  min-width: 9ch;
  text-align: right;
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  font-size: 18px;
  font-weight: 700;
}

.keypad {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.keypad .key {
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 12px;
  padding: 14px 0;
  font-size: 20px;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  touch-action: manipulation;
}
.keypad .key.add {
  background: var(--accent);
  color: #fff;
  border: none;
}
.keypad .key:active,
.keypad .key.pressed { 
  transform: scale(0.96);
  background: #26262d;
  box-shadow: inset 0 0 0 2px #2a2a31;
}
.keypad .key.add:active,
.keypad .key.add.pressed { 
  transform: scale(0.98);
  filter: brightness(0.95);
}

.edit-name {
  flex: 1;
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 18px;
}

.add {
  margin-top: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
}

@media (min-width: 480px) {
  .inputs input { font-size: 18px; }
  .amount-display { font-size: 20px; }
  .add { font-size: 20px; }
}
.edit-target {
  width: 8ch; /* 4位整数 + '.' + 2位小数 ≈ 7ch，略留余量 */
  min-width: 7ch;
  text-align: right;
  background: var(--card);
  border: 1px solid #2a2a31;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 18px;
}