:root {
  --bg: #0f1a17;
  --card: #17241f;
  --card-2: #1e2e28;
  --line: #2a3d36;
  --text: #eef5f1;
  --muted: #8aa39a;
  --mint: #5ef2b0;
  --mint-deep: #22c47f;
  --peach: #ffb38a;
  --fill: 45%;
  --radius: 22px;
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(120% 60% at 50% -10%, #1d3a30 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.top { display: flex; align-items: center; gap: 10px; padding: 4px 4px 6px; }
.logo { font-size: 26px; }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.label.light { color: rgba(15, 26, 23, .65); }

/* Bill */
.bill { display: flex; flex-direction: column; gap: 6px; }
.bill-input { display: flex; align-items: baseline; gap: 4px; }
.currency { font-size: 30px; font-weight: 700; color: var(--muted); }
#bill {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  caret-color: var(--mint);
}
#bill::placeholder { color: #3f564d; }

/* Tip */
.row { display: flex; justify-content: space-between; align-items: center; }
.tip-face { font-size: 24px; transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.tip-face.pop { transform: scale(1.3) rotate(-8deg); }

.pct {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1;
  margin: 6px 0 16px;
  font-variant-numeric: tabular-nums;
  color: var(--mint);
}
.pct small { font-size: 30px; margin-left: 2px; color: var(--mint-deep); }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mint-deep), var(--mint) var(--fill), var(--card-2) var(--fill));
}
.slider::-moz-range-track {
  height: 12px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mint-deep), var(--mint) var(--fill), var(--card-2) var(--fill));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--mint);
  box-shadow: 0 4px 14px rgba(94, 242, 176, .45);
  transition: transform .15s ease;
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--mint);
  box-shadow: 0 4px 14px rgba(94, 242, 176, .45);
}
.slider:active::-webkit-slider-thumb { transform: scale(1.15); }
.slider:focus-visible::-webkit-slider-thumb { outline: 3px solid rgba(94,242,176,.4); outline-offset: 2px; }

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px 0;
  font-variant-numeric: tabular-nums;
}

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.presets button, .stepper button, .round {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: background .2s, color .2s, transform .12s, border-color .2s;
}
.presets button { padding: 10px 0; font-weight: 700; font-size: 15px; }
.presets button:active, .stepper button:active, .round:active { transform: scale(.95); }
.presets button.on { background: var(--mint); color: var(--bg); border-color: var(--mint); }

/* Split */
.split { display: flex; justify-content: space-between; align-items: center; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 44px; height: 44px; font-size: 22px; font-weight: 600; }
.stepper button:disabled { opacity: .35; cursor: default; }
#people { min-width: 28px; text-align: center; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Result */
.result {
  background: linear-gradient(145deg, var(--mint) 0%, #b6f7d4 100%);
  color: var(--bg);
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 18px 40px -18px rgba(94, 242, 176, .6);
}
.big { display: flex; flex-direction: column; gap: 2px; }
.amount {
  font-size: 50px;
  font-weight: 900;
  letter-spacing: -.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  transition: transform .2s ease;
}
.amount.bump { transform: scale(1.03); }

.breakdown {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(15, 26, 23, .25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.breakdown div { display: flex; justify-content: space-between; font-size: 15px; }
.breakdown span { color: rgba(15, 26, 23, .7); font-weight: 600; }
.breakdown strong { font-variant-numeric: tabular-nums; font-weight: 800; }

.round {
  margin-top: 14px;
  width: 100%;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  background: var(--bg);
  color: var(--mint);
  border-color: var(--bg);
}
.round.on { background: rgba(15, 26, 23, .12); color: var(--bg); border-color: rgba(15, 26, 23, .3); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
