@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500;1,600&family=Quicksand:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap");

:root {
  --void: #150e20; /* page background — midnight ink */
  --plum: #241733; /* panel background — amethyst-plum */
  --plum-light: #32213f; /* input / field background */
  --amethyst: #b08ce0; /* primary gem accent */
  --amethyst-deep: #8a64c4;
  --emerald: #55bf8f; /* secondary gem accent — tip highlight */
  --emerald-deep: #3c9a70;
  --gold: #d9b36c; /* metallic accent — borders, shimmer */
  --moonlight: #f4ecff; /* primary text on dark */
  --mist: #ae9cc4; /* muted / secondary text */
  --line: rgba(217, 179, 108, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--moonlight);
  font-family: "Quicksand", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 32px 16px 60px;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(
      ellipse 500px 300px at 20% 0%,
      rgba(176, 140, 224, 0.16),
      transparent 60%
    ),
    radial-gradient(
      ellipse 500px 300px at 85% 15%,
      rgba(85, 191, 143, 0.1),
      transparent 60%
    ),
    var(--void);
}

.app {
  width: 100%;
  max-width: 460px;
}

.logo {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto 18px;
  filter: drop-shadow(0 0 18px rgba(217, 179, 108, 0.25));
}

h1 {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 600;
  font-size: 42px;
  line-height: 1.05;
  margin: 0 0 8px;
  background: linear-gradient(
    120deg,
    var(--moonlight) 0%,
    var(--amethyst) 55%,
    var(--gold) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subhead {
  font-size: 13.5px;
  text-align: center;
  color: var(--mist);
  margin: 0 0 28px;
  line-height: 1.55;
}

.subhead em {
  font-style: italic;
  color: var(--amethyst);
}

section {
  margin-bottom: 24px;
}

.section-label {
  font-family: "Space Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 108px 44px;
  gap: 8px;
  align-items: center;
}

.item-row input[type="text"] {
  font-family: "Quicksand", sans-serif;
  font-weight: 500;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--plum-light);
  color: var(--moonlight);
  width: 100%;
  outline: none;
}

.item-row input[type="text"]::placeholder {
  color: var(--mist);
  opacity: 0.7;
}

.amount-wrap {
  position: relative;
}
.amount-wrap span {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Space Mono", monospace;
  font-size: 14px;
  color: var(--mist);
  pointer-events: none;
}

.item-row input[type="number"] {
  font-family: "Space Mono", monospace;
  font-size: 16px;
  padding: 10px 10px 10px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--plum-light);
  color: var(--moonlight);
  width: 100%;
  outline: none;
  text-align: right;
}

.item-row input::placeholder {
  color: var(--mist);
  opacity: 0.55;
}

.item-row input:focus {
  border-color: var(--amethyst);
  box-shadow: 0 0 0 3px rgba(176, 140, 224, 0.18);
}

.remove-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--mist);
  font-size: 18px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.15s,
    background 0.15s;
}
.remove-btn:hover:not(:disabled) {
  color: #e48fa8;
  background: rgba(228, 143, 168, 0.12);
}
.remove-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.add-btn {
  margin-top: 4px;
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: 1.5px dashed var(--gold);
  background: transparent;
  color: var(--gold);
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s,
    background 0.15s;
}
.add-btn:hover:not(:disabled) {
  border-color: var(--amethyst);
  color: var(--amethyst);
  background: rgba(176, 140, 224, 0.08);
}
.add-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.tip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tip-btn {
  padding: 12px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--plum-light);
  color: var(--moonlight);
  font-family: "Space Mono", monospace;
  font-size: 15px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s;
}
.tip-btn:hover {
  border-color: var(--amethyst);
}
.tip-btn.active {
  background: linear-gradient(135deg, var(--emerald), var(--emerald-deep));
  border-color: var(--emerald);
  color: #0e241a;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(85, 191, 143, 0.35);
}

.custom-tip-wrap {
  margin-top: 8px;
  display: none;
  align-items: center;
  gap: 8px;
}
.custom-tip-wrap.visible {
  display: flex;
}
.custom-tip-wrap input {
  flex: 1;
  font-family: "Space Mono", monospace;
  font-size: 16px;
  padding: 10px 12px;
  border: 1.5px solid var(--emerald);
  border-radius: 10px;
  background: var(--plum-light);
  color: var(--moonlight);
  outline: none;
}
.custom-tip-wrap label {
  font-size: 12.5px;
  color: var(--mist);
  font-family: "Quicksand", sans-serif;
}

/* Receipt / spell-ledger */
.receipt-wrap {
  position: relative;
  filter: drop-shadow(0 10px 24px rgba(85, 50, 140, 0.28));
}

.receipt {
  background:
    radial-gradient(
      circle at 12% 8%,
      rgba(176, 140, 224, 0.1),
      transparent 40%
    ),
    radial-gradient(
      circle at 90% 85%,
      rgba(85, 191, 143, 0.08),
      transparent 45%
    ),
    var(--plum);
  padding: 26px 22px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  position: relative;
}

.receipt::before {
  content: "✦";
  position: absolute;
  top: 10px;
  left: 14px;
  color: var(--gold);
  font-size: 11px;
  opacity: 0.8;
}
.receipt::after {
  content: "✦";
  position: absolute;
  top: 10px;
  right: 14px;
  color: var(--gold);
  font-size: 11px;
  opacity: 0.8;
}

.receipt-title {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 600;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--gold);
  margin-bottom: 16px;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  font-family: "Space Mono", monospace;
  font-size: 13.5px;
  color: var(--moonlight);
  padding: 3px 0;
}
.receipt-line .label {
  color: var(--mist);
}
.receipt-line .val {
  font-variant-numeric: tabular-nums;
}

.receipt-line.tip-line {
  margin: 10px -12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(85, 191, 143, 0.14);
  border: 1px solid rgba(85, 191, 143, 0.4);
  font-size: 15px;
}
.receipt-line.tip-line .label {
  color: var(--emerald);
  font-weight: 700;
}
.receipt-line.tip-line .val {
  color: var(--emerald);
  font-weight: 700;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 12px 0;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 30px;
  font-weight: 600;
  color: var(--gold);
  padding-top: 4px;
  text-shadow: 0 0 18px rgba(217, 179, 108, 0.35);
}
.receipt-total .val {
  font-variant-numeric: tabular-nums;
}

.receipt-note {
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 10.5px;
  color: var(--mist);
  margin-top: 16px;
  letter-spacing: 0.08em;
}

@media (max-width: 380px) {
  h1 {
    font-size: 34px;
  }
  .item-row {
    grid-template-columns: 1fr 80px 44px;
  }
}

.app-footer {
  text-align: center;
  margin-top: 26px;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: var(--mist);
  letter-spacing: 0.04em;
}

.app-footer a {
  color: var(--amethyst);
  text-decoration: none;
  border-bottom: 1px dotted var(--amethyst);
  transition:
    color 0.15s,
    border-color 0.15s;
}

.app-footer a:hover {
  color: var(--gold);
  border-color: var(--gold);
}
