:root {
  color-scheme: light;
  --navy: #101d3d;
  --navy-soft: #1b2c54;
  --ink: #111831;
  --muted: #687087;
  --paper: #f5f7fb;
  --white: #ffffff;
  --line: #dfe4ef;
  --yellow: #ffcf58;
  --yellow-deep: #f0b92d;
  --mint: #5ed5ac;
  --shadow: 0 18px 50px rgba(16, 29, 61, 0.12);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.goal-card {
  margin: 0 12px;
  overflow: hidden;
  border-radius: 28px;
  color: var(--white);
  background: var(--navy);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 16px;
  color: var(--white);
  background: transparent;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #acb7d0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 7vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.34rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.edit-goal-button {
  display: flex;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 13px;
  color: #dce3f2;
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.8rem;
  font-weight: 750;
  cursor: pointer;
}

.edit-goal-button span:first-child {
  color: var(--yellow);
  font-size: 1rem;
}

.progress-card {
  margin: 0;
  padding: 22px 22px 26px;
  color: var(--white);
  background: transparent;
}

.amount-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.amount-row > div {
  min-width: 0;
}

.saved-label {
  margin-bottom: 4px;
  color: #acb7d0;
  font-size: 0.86rem;
  font-weight: 650;
}

.saved-amount {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0;
  color: var(--yellow);
  font-size: clamp(2.85rem, 12.5vw, 4.1rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.06em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.saved-amount .amount-symbol {
  margin: 0.12em 0.08em 0 0;
  font-size: 0.42em;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -0.02em;
}

.target-amount {
  margin-bottom: 6px;
  color: #acb7d0;
  font-size: 0.9rem;
  white-space: nowrap;
}

.target-amount strong {
  color: var(--white);
}

.progress-wrap {
  padding-top: 30px;
}

.progress-track {
  position: relative;
  height: 10px;
  margin-right: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
  box-shadow: 0 0 18px rgba(255, 207, 88, 0.45);
  transition: width 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.milestone-dot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 3px solid #4d5a78;
  border-radius: 50%;
  background: var(--navy);
  transform: translate(-50%, -50%);
  transition: background 280ms ease, border-color 280ms ease, transform 280ms ease;
}

.milestone-dot[data-percent="25"] { left: 25%; }
.milestone-dot[data-percent="50"] { left: 50%; }
.milestone-dot[data-percent="75"] { left: 75%; }
.milestone-dot[data-percent="100"] { left: 100%; }

.milestone-dot span {
  position: absolute;
  top: 14px;
  left: 50%;
  color: #8f9bb6;
  font-size: 0.69rem;
  font-weight: 700;
  transform: translateX(-50%);
}

.milestone-dot.reached {
  border-color: var(--yellow);
  background: var(--yellow);
  transform: translate(-50%, -50%) scale(1.15);
}

.milestone-dot.reached span {
  color: var(--yellow);
}

.next-milestone {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 35px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.055);
}

.next-milestone p {
  margin-bottom: 0;
  color: #d2d8e7;
  font-size: 0.89rem;
  line-height: 1.35;
}

.next-milestone strong {
  color: var(--white);
}

.milestone-icon {
  color: var(--mint);
  font-size: 0.75rem;
}

.actions {
  padding: 28px 18px 0;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 18px;
}

.today {
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.shortcut-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 9px;
}

.shortcut-heading p {
  margin: 0;
  color: #505971;
  font-size: 0.84rem;
  font-weight: 780;
}

.shortcut-heading span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  text-align: right;
}

.empty-shortcuts {
  grid-column: 1 / -1;
  margin: 0;
  padding: 20px 18px;
  border: 1px dashed #cbd2e0;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: center;
}

.item-button {
  position: relative;
  display: grid;
  min-height: 112px;
  grid-template-columns: minmax(58px, 0.9fr) minmax(0, 1.1fr);
  gap: 6px;
  align-items: stretch;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  text-align: left;
  background: var(--white);
  box-shadow: 0 7px 22px rgba(26, 39, 71, 0.06);
  cursor: pointer;
  transition: border-color 160ms ease, transform 140ms ease, box-shadow 160ms ease;
}

.item-button:active,
.item-button.pressed {
  border-color: var(--yellow-deep);
  transform: scale(0.965);
  box-shadow: 0 3px 10px rgba(26, 39, 71, 0.06);
}

.item-button:focus-visible,
.one-time-button:focus-visible,
.add-button:focus-visible,
.edit-goal-button:focus-visible,
.data-button:focus-visible,
.save-button:focus-visible,
.icon-button:focus-visible,
.remove-item-button:focus-visible {
  outline: 3px solid rgba(63, 108, 255, 0.5);
  outline-offset: 3px;
}

.reset-button:focus-visible,
.secondary-text-button:focus-visible {
  outline: 3px solid rgba(63, 108, 255, 0.5);
  outline-offset: 3px;
}

.item-emoji {
  font-size: 1.55rem;
  line-height: 1;
}

.item-meta {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
}

.item-name {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  color: #4f5870;
  font-size: 0.88rem;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-amount {
  display: flex;
  max-width: 100%;
  align-self: center;
  grid-column: 2;
  align-items: flex-start;
  justify-self: end;
  color: #245c4c;
  font-size: clamp(2.2rem, 9.6vw, 2.9rem);
  font-weight: 840;
  line-height: 0.95;
  letter-spacing: -0.045em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.item-amount[data-size="compact"] {
  font-size: clamp(1.95rem, 8.3vw, 2.5rem);
}

.item-amount .amount-symbol {
  margin: 0.1em 0.09em 0 0;
  font-size: 0.54em;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
}

.add-button {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
  border: 2px dashed #cbd2e0;
  border-radius: 19px;
  color: var(--navy-soft);
  background: transparent;
  font-weight: 760;
  cursor: pointer;
}

.one-time-button {
  display: flex;
  width: 100%;
  min-height: 68px;
  align-items: center;
  gap: 13px;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid #cbd9d4;
  border-radius: 18px;
  color: var(--ink);
  text-align: left;
  background: #edf8f4;
  cursor: pointer;
}

.one-time-button:active {
  background: #e2f2ec;
  transform: scale(0.985);
}

.one-time-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  color: #174f40;
  background: var(--mint);
  font-size: 0.92rem;
  font-weight: 850;
}

.one-time-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.one-time-copy strong {
  color: #34403d;
  font-size: 0.9rem;
}

.one-time-copy small {
  color: #66746f;
  font-size: 0.75rem;
  line-height: 1.3;
}

.data-tools {
  display: flex;
  min-height: 60px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 9px 4px 0;
  border-top: 1px solid var(--line);
}

.data-copy {
  min-width: 0;
}

.data-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-note {
  max-width: 260px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.data-note strong {
  color: #414a61;
}

.data-actions {
  display: flex;
  align-items: center;
}

.data-button {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: #586178;
  background: transparent;
  font-size: 0.83rem;
  font-weight: 730;
  cursor: pointer;
}

.data-button:active {
  color: var(--navy);
  background: #e9edf5;
}

.data-divider {
  width: 1px;
  height: 18px;
  background: #cfd5e1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.plus {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  color: var(--navy);
  background: var(--yellow);
  font-size: 1.2rem;
  line-height: 1;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 18px;
  display: flex;
  max-width: 484px;
  min-height: 58px;
  align-items: center;
  gap: 11px;
  margin: 0 auto;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  color: var(--white);
  background: #17264a;
  box-shadow: 0 18px 45px rgba(10, 19, 42, 0.26);
  font-size: 0.94rem;
  font-weight: 680;
  opacity: 0;
  pointer-events: none;
  transform: translateY(22px);
  transition: opacity 220ms ease, transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-check {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--navy);
  background: var(--mint);
  font-weight: 900;
}

dialog {
  width: min(calc(100% - 20px), 500px);
  max-height: calc(100dvh - 22px);
  margin: auto auto 10px;
  padding: 0;
  border: 0;
  border-radius: 28px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 28px 80px rgba(7, 15, 35, 0.3);
}

dialog::backdrop {
  background: rgba(6, 14, 33, 0.6);
  backdrop-filter: blur(5px);
}

dialog[open] {
  animation: dialog-in 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

dialog form {
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
}

.dialog-handle {
  width: 38px;
  height: 5px;
  margin: 0 auto 15px;
  border-radius: 999px;
  background: #d8dce6;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.icon-button {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: #eff2f7;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.83rem;
  font-weight: 760;
}

label span {
  color: var(--muted);
  font-weight: 550;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid #ced4e0;
  border-radius: 14px;
  color: var(--ink);
  background: #fafbfc;
  font-size: 1rem;
}

input:focus {
  border-color: #5276c7;
  outline: 3px solid rgba(82, 118, 199, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 12px;
  margin-top: 18px;
}

.input-with-prefix {
  position: relative;
}

.input-with-prefix span {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  transform: translateY(-50%);
}

.input-with-prefix input {
  padding-left: 29px;
}

.emoji-field input {
  text-align: center;
  font-size: 1.35rem;
}

.goal-target-field {
  margin-top: 18px;
}

.log-amount-field {
  margin-top: 2px;
}

.large-amount-input input {
  min-height: 64px;
  padding-left: 38px;
  font-size: 1.45rem;
  font-weight: 780;
}

.large-amount-input span {
  left: 16px;
  font-size: 1.05rem;
  font-weight: 720;
}

.field-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.form-error {
  min-height: 20px;
  margin: 8px 2px 4px;
  color: #a92e37;
  font-size: 0.83rem;
  font-weight: 650;
}

.save-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  color: var(--navy);
  background: var(--yellow);
  font-weight: 820;
  box-shadow: 0 8px 20px rgba(240, 185, 45, 0.25);
  cursor: pointer;
}

.remove-item-button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 0;
  border-radius: 14px;
  color: #9b2f3b;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 740;
  cursor: pointer;
}

.remove-item-button:active {
  background: #fff1f3;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.danger-zone p {
  margin: 0 0 3px;
  font-size: 0.86rem;
  font-weight: 760;
}

.danger-zone span {
  display: block;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.reset-button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid #f0c9ce;
  border-radius: 12px;
  color: #9b2f3b;
  background: #fff4f5;
  font-size: 0.8rem;
  font-weight: 760;
  cursor: pointer;
}

.reset-button:disabled {
  border-color: var(--line);
  color: #9aa1b0;
  background: #f5f6f8;
  cursor: default;
}

#welcomeDialog form {
  text-align: center;
}

.welcome-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 3px auto 18px;
  place-items: center;
  border-radius: 16px;
  color: var(--navy);
  background: var(--yellow);
  font-size: 1rem;
}

#welcomeDialog .eyebrow {
  margin-bottom: 8px;
}

#welcomeDialog h2 {
  font-size: 1.65rem;
}

.welcome-copy {
  max-width: 360px;
  margin: 12px auto 24px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.secondary-text-button {
  width: 100%;
  min-height: 48px;
  margin-top: 5px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 720;
  cursor: pointer;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 521px) {
  body {
    padding: 24px 0;
    background: #dfe4ef;
  }

  .app-shell {
    min-height: calc(100dvh - 48px);
    overflow: hidden;
    border-radius: 34px;
    box-shadow: 0 30px 90px rgba(23, 37, 73, 0.18);
  }

  .topbar {
    padding-top: 24px;
  }
}

@media (max-width: 350px) {
  .topbar,
  .progress-card {
    padding-right: 16px;
    padding-left: 16px;
  }

  .goal-card {
    margin-right: 10px;
    margin-left: 10px;
  }

  .actions {
    padding-right: 12px;
    padding-left: 12px;
  }

  .item-button {
    min-height: 108px;
    grid-template-columns: minmax(54px, 0.95fr) minmax(0, 1.05fr);
    gap: 5px;
    padding: 14px;
  }

  .item-amount {
    font-size: clamp(2rem, 9.5vw, 2.3rem);
  }

  .item-amount[data-size="compact"] {
    font-size: clamp(1.75rem, 8vw, 2rem);
  }

  .shortcut-heading span {
    max-width: 132px;
  }

  .saved-amount {
    font-size: clamp(2.55rem, 12vw, 3rem);
  }

  .danger-zone {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-tools {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .data-actions {
    align-self: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
