@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/fraunces.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("fonts/nunito.woff2") format("woff2");
}

/* PayDay Pig — phone-first piggy bank theme */

:root {
  --bg: #FFF3EB;
  --bg-blush: #FBE0D4;
  --ink: #3A2422;
  --ink-soft: #8A6A62;
  --ink-faint: #C4A89E;
  --card: #FFFBF8;
  --card-2: #FFEFE6;
  --line: rgba(58, 36, 34, 0.1);
  --pink: #F0A8AE;
  --pink-deep: #E07A86;
  --pink-soft: #FBE3E4;
  --gold: #E8B84A;
  --gold-deep: #C9922A;
  --gold-soft: #F8E7B8;
  --mint: #1B7D5E;
  --mint-soft: #D8F0E6;
  --coral: #C74B4B;
  --coral-soft: #F8DCDC;
  --amber: #B8761E;
  --amber-soft: #F8E6C8;
  --sage: #2F7A4E;
  --sage-soft: #D8EFDE;
  --shadow: 0 12px 32px rgba(58, 36, 34, 0.1);
  --shadow-sm: 0 4px 14px rgba(58, 36, 34, 0.07);
  --radius: 22px;
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #E8D0C4;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

input {
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }

#app {
  width: 100%;
  min-height: 100dvh;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, #FFE1D2 0%, transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 520px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
  }
  #app {
    width: 430px;
    min-height: min(900px, calc(100dvh - 48px));
    height: min(900px, calc(100dvh - 48px));
    border-radius: 36px;
    box-shadow:
      0 0 0 10px #2A1C1A,
      0 30px 80px rgba(58, 36, 34, 0.28);
  }
}

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(12px + var(--safe-top)) 18px calc(28px + var(--safe-bot));
}

/* Header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p,
.tagline {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tagline .acro b {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.12em;
  color: var(--pink-deep);
  letter-spacing: 0;
}

.pig-meaning {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.pig-meaning > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  background: #FFF8F3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 8px 11px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.25;
}

.pig-letter {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(180deg, #F0C25A, #E0A530);
  color: #3A2422;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(201, 146, 42, 0.25);
}

.icon-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 20px; height: 20px; }

/* Period picker */

.period {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0 8px;
}

.month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.month-label {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
  flex: 1;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.nav-btn:active { transform: scale(0.94); }
.nav-btn svg { width: 18px; height: 18px; }

.checks {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.check-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
}

.check-btn[aria-pressed="true"] {
  background: var(--ink);
  color: #FFF8F3;
  border-color: var(--ink);
}

.check-btn.hidden,
.checks.hidden { display: none; }

/* Pig hero */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 0 8px;
}

.pig-wrap {
  width: 250px;
  margin: 0 auto -6px;
  position: relative;
}

.pig-wrap svg.pig {
  width: 100%;
  height: auto;
  overflow: visible;
  animation: bob 3.8s ease-in-out infinite;
  transform-origin: 50% 82%;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.pig-wrap.dropping svg.pig,
.pig-wrap.mood-over svg.pig { animation: none; }

.pig-wrap.mood-over svg.pig {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

#pig-fill {
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.wave {
  animation: wave 2.8s linear infinite;
  transform-origin: center;
}

@keyframes wave {
  from { transform: translateX(0); }
  to { transform: translateX(-80px); }
}

.coin {
  opacity: 0;
  transform-origin: center;
}

.pig-wrap.dropping .coin-1 { animation: coinDrop 0.75s ease-in forwards; }
.pig-wrap.dropping .coin-2 { animation: coinDrop 0.75s ease-in 0.1s forwards; }
.pig-wrap.dropping .coin-3 { animation: coinDrop 0.75s ease-in 0.18s forwards; }

@keyframes coinDrop {
  0% { opacity: 0; transform: translate(0, -70px) rotate(-25deg) scale(0.7); }
  15% { opacity: 1; }
  75% { opacity: 1; transform: translate(0, 8px) rotate(18deg) scale(0.85); }
  100% { opacity: 0; transform: translate(0, 16px) rotate(28deg) scale(0.5); }
}

.eye-worried, .brow, .eye-happy { display: none; }
.mood-low .eye-worried, .mood-low .brow, .mood-over .eye-worried, .mood-over .brow { display: inline; }
.mood-full .eye-happy { display: inline; }
.mood-full .eye-open { display: none; }
.mood-over .blush { opacity: 0.85; }

.hero-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 800;
}

.hero-amount {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 650;
  font-size: 3rem;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--mint);
}

.hero-amount.over { color: var(--coral); }
.hero-amount.zero { color: var(--ink-soft); }

.hero-sub {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
}

.stat {
  background: var(--card);
  border-radius: 16px;
  padding: 10px 8px 11px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat .lbl {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 800;
  margin-bottom: 2px;
}

.stat .val {
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.stat.paid .val { color: var(--sage); }
.stat.pending .val { color: var(--amber); }
.stat.unpaid .val { color: var(--coral); }

/* Cards */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 14px;
  margin-top: 14px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 800;
}

.paycheck-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.paycheck-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.money-input,
.text-input {
  width: 100%;
  border: 2px solid var(--line);
  background: #FFF8F3;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1.05rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.money-input:focus,
.text-input:focus {
  border-color: var(--pink-deep);
  box-shadow: 0 0 0 4px rgba(224, 122, 134, 0.18);
}

.money-input {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Expense list */

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

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  background: #FFF8F3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 10px 10px 14px;
  text-align: left;
}

.item .name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.item .name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item .amt {
  grid-column: 1;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.item .status {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  min-width: 88px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.status.unpaid { background: var(--coral-soft); color: var(--coral); }
.status.paid { background: var(--amber-soft); color: var(--amber); }
.status.cleared { background: var(--sage-soft); color: var(--sage); }

.tag-invest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--gold-soft);
  color: var(--gold-deep);
  border-radius: 999px;
  padding: 2px 6px;
  font-weight: 800;
  flex-shrink: 0;
}

.empty-list {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  padding: 8px 8px 4px;
  margin: 0;
}

/* Add form */

.add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr 108px auto;
  gap: 8px;
}

.add-row .text-input { min-width: 0; }
.add-row .money-input { font-size: 1.05rem; padding: 10px 10px; }

.add-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--ink);
  color: #FFF8F3;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.add-btn:active { transform: scale(0.95); }
.add-btn svg { width: 22px; height: 22px; }

.type-toggle {
  display: flex;
  gap: 8px;
}

.type-toggle button {
  flex: 1;
  min-height: 38px;
  border-radius: 12px;
  background: #FFF8F3;
  border: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 800;
}

.type-toggle button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #FFF8F3;
}

/* Actions */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  min-height: 52px;
  border-radius: 16px;
  padding: 0 18px;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(180deg, #F0C25A, #E0A530);
  color: #3A2422;
  box-shadow: 0 8px 20px rgba(201, 146, 42, 0.28);
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--coral-soft);
  color: var(--coral);
}

.btn-ghost {
  color: var(--ink-soft);
  min-height: 44px;
  font-size: 0.92rem;
}

.btn-primary.hidden,
.btn-secondary.hidden,
.hidden { display: none !important; }

.tip {
  background: var(--pink-soft);
  color: #7A3A42;
  border-radius: 16px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.tip button {
  margin-left: auto;
  color: #7A3A42;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
}

.toast {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(18px + var(--safe-bot));
  background: var(--ink);
  color: #FFF8F3;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: 0.3s ease;
  z-index: 60;
  pointer-events: none;
}

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

/* Sheets */

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58, 36, 34, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(20px + var(--safe-bot));
  transform: translateY(110%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
  max-height: 88%;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(58, 36, 34, 0.15);
}

.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet h3 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.choice-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.choice {
  text-align: left;
  background: #FFF8F3;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 56px;
}

.choice[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #FFF8F3;
}

.choice strong { display: block; font-size: 1rem; }
.choice span { display: block; font-size: 0.8rem; font-weight: 650; opacity: 0.8; }

.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFF8F3;
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  width: 100%;
  text-align: left;
}

.sheet-item .meta {
  flex: 1;
  min-width: 0;
}

.sheet-item .meta strong {
  display: block;
  font-size: 0.95rem;
}

.sheet-item .meta span {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-family: var(--display);
}

.sheet-item .go {
  color: var(--ink-faint);
  font-size: 1.2rem;
}

.settings-block {
  margin-bottom: 18px;
}

.settings-block p.help {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.4;
}

.usual-row {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.icon-del {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--coral-soft);
  color: var(--coral);
  display: grid;
  place-items: center;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 650;
  margin: 0 0 12px;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

@media (prefers-reduced-motion: reduce) {
  .pig-wrap svg.pig,
  .wave,
  .coin,
  .pig-wrap.mood-over svg.pig,
  .pig-wrap.dropping .coin-1,
  .pig-wrap.dropping .coin-2,
  .pig-wrap.dropping .coin-3 {
    animation: none !important;
  }
  #pig-fill, .sheet, .backdrop, .toast, .icon-btn, .nav-btn, .btn-primary, .add-btn {
    transition: none !important;
  }
}
