@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #1c2130;
  --ink-soft: #3a4152;
  --muted: #6b7280;
  --gold: #a8863d;
  --gold-soft: rgba(168, 134, 61, 0.14);
  --earn: #3f9a68;
  --spend: #c05621;
  --page: #f6f4ef;
  --card-bg: #ffffff;
  --hairline: rgba(28, 33, 48, 0.09);
  --shadow: 0 1px 2px rgba(28, 33, 48, 0.04), 0 12px 32px rgba(28, 33, 48, 0.07);
  --radius: 16px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15.5px;
  color: var(--ink);
  background: linear-gradient(180deg, #f8f6f2 0%, var(--page) 40%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-soft); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- Header / nav ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 32px;
  background: rgba(248, 246, 242, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.logo span { color: var(--gold); font-style: italic; }

.nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.nav > a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: color 0.15s ease;
}
.nav > a:hover { color: var(--ink); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 14px 4px 5px;
}
.user-chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 20px 72px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

h1 { font-size: 2.1rem; margin: 0 0 14px; line-height: 1.15; }
h2 { margin: 0 0 12px; }
p  { line-height: 1.65; }
.muted { color: var(--muted); }

.page-title { margin-bottom: 22px; }
.back-link {
  display: inline-block;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: 12px;
  padding: 11px 22px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
  background: #2a3145;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(28, 33, 48, 0.18);
}
.btn-small { font-size: 0.83rem; padding: 7px 16px; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(28, 33, 48, 0.22);
}
.btn-ghost:hover { background: rgba(28, 33, 48, 0.04); box-shadow: none; }

.btn-earn  { background: var(--earn);  border-color: var(--earn); }
.btn-earn:hover  { background: #358457; }
.btn-spend { background: var(--spend); border-color: var(--spend); }
.btn-spend:hover { background: #a84a1c; }

/* ---------- Flash messages ---------- */
.flash {
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 500;
  font-size: 0.93rem;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.flash-success {
  background: rgba(63, 154, 104, 0.12);
  border-color: rgba(63, 154, 104, 0.3);
  color: #2c6b48;
}
.flash-error {
  background: rgba(192, 86, 33, 0.10);
  border-color: rgba(192, 86, 33, 0.3);
  color: #93411a;
}

/* ---------- Guest hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 48px 44px;
}
.hero-text { flex: 1; }
.hero h1 { font-size: 2.5rem; }
.hero em { font-style: italic; color: var(--gold); }
.hero-emoji {
  font-size: 4.2rem;
  line-height: 1;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-soft);
  border-radius: 50%;
  flex-shrink: 0;
}
.hero-points { list-style: none; padding: 0; margin: 18px 0; }
.hero-points li { margin: 8px 0; color: var(--ink-soft); font-size: 0.95rem; }
.hero-note { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 640px) {
  .hero { flex-direction: column-reverse; text-align: center; padding: 32px 24px; }
  .hero h1 { font-size: 2rem; }
  .hero-emoji { width: 110px; height: 110px; font-size: 3rem; }
}

/* ---------- Jar grid (dashboard) ---------- */
.jar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.jar-card { text-align: center; margin-bottom: 0; }
.jar-card h2 { font-size: 1.3rem; margin: 12px 0 4px; }
.jar-avatar {
  font-size: 2rem;
  line-height: 1;
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-soft);
  border-radius: 18px;
}
.jar-balance {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 4px 0 16px;
}
.jar-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.jar-add h2 { font-size: 1.15rem; }
.add-child-form { text-align: left; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: #fbfaf8;
  border: 1px solid rgba(28, 33, 48, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.chips { display: flex; gap: 8px; margin-top: 8px; }
.chips button {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(28, 33, 48, 0.05);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.chips button:hover { background: var(--gold-soft); border-color: var(--gold); }

/* ---------- Balance hero (child page) ---------- */
.balance-hero {
  display: flex;
  align-items: center;
  gap: 24px;
}
.balance-hero h1 { margin: 0 0 4px; }
.jar-avatar-big { width: 84px; height: 84px; font-size: 2.6rem; border-radius: 22px; flex-shrink: 0; }
.balance-line {
  margin: 0;
  font-size: 1.15rem;
  color: var(--ink-soft);
}
.balance-line strong {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink);
}

/* ---------- Give / spend forms ---------- */
.tx-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-card { margin-bottom: 24px; border-top: 4px solid var(--hairline); }
.form-earn  { border-top-color: var(--earn); }
.form-spend { border-top-color: var(--spend); }
.form-card h2 { font-size: 1.2rem; }
@media (max-width: 640px) {
  .tx-forms { grid-template-columns: 1fr; }
  .form-card { margin-bottom: 0; }
  .tx-forms .form-spend { margin-bottom: 24px; }
}

/* ---------- History ---------- */
.tx-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tx-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
}
.tx-list li:last-child { border-bottom: none; }
.tx-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}
.tx-delta.pos { color: var(--earn); }
.tx-delta.neg { color: var(--spend); }
.tx-reason { flex: 1; }
.tx-date { color: var(--muted); font-size: 0.83rem; white-space: nowrap; }
.tx-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.tx-del:hover { background: rgba(192, 86, 33, 0.1); color: var(--spend); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 0.85rem;
}
