/* Taschengeld-Tracker — eigenes Design: Münz-Gold + frisches Grün, kindgerecht */
:root {
  --gold: #eab308;
  --gold-dark: #ca8a04;
  --gold-deep: #92400e;
  --gold-soft: #fef9c3;
  --green: #16a34a;
  --green-dark: #15803d;
  --green-soft: #dcfce7;
  --red: #e11d48;
  --red-dark: #be123c;

  --bg: #fffdf5;
  --bg-grad-1: #fef3c7;
  --bg-grad-2: #fffbeb;
  --surface: #ffffff;
  --surface-2: #fff8e1;
  --text: #3b2f12;
  --text-soft: #7c6f4a;
  --border: #f1e3b8;
  --shadow: 0 6px 18px rgba(180, 130, 10, 0.14);
  --shadow-lg: 0 14px 40px rgba(120, 90, 10, 0.22);
  --focus: #1d4ed8;
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --gold: #facc15;
  --gold-dark: #eab308;
  --gold-deep: #fde68a;
  --gold-soft: #3a3209;
  --green: #34d399;
  --green-dark: #10b981;
  --green-soft: #0c3a2a;
  --red: #fb7185;
  --red-dark: #f43f5e;

  --bg: #1c1809;
  --bg-grad-1: #2a2310;
  --bg-grad-2: #14110a;
  --surface: #2a230f;
  --surface-2: #34290f;
  --text: #fdf6e3;
  --text-soft: #c9bd92;
  --border: #4a3d18;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.55);
  --focus: #93c5fd;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 55%, var(--bg));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  line-height: 1.45;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: var(--gold-deep);
  padding: 10px 16px;
  border-radius: 0 0 12px 0;
  font-weight: 800;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  max-width: 720px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-coin {
  display: inline-flex;
  filter: drop-shadow(0 2px 3px rgba(180,130,10,0.35));
}
.app-header h1 {
  font-size: clamp(1.15rem, 5vw, 1.5rem);
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--gold-deep);
  word-break: break-word;
}

.icon-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex: 0 0 auto;
  transition: transform .15s ease, box-shadow .15s ease;
}
.icon-btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 16px 28px;
  display: grid;
  gap: 18px;
}

/* Kontostand-Karte */
.balance-card {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  border-radius: var(--radius);
  padding: 26px 20px 22px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.balance-card::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%);
  pointer-events: none;
}
.balance-label {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.95;
}
.balance-amount {
  margin: 0 0 18px;
  font-size: clamp(2.4rem, 12vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
  word-break: break-word;
}
.balance-card.is-negative .balance-amount { color: #fee2e2; }

.balance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.big-btn {
  flex: 1 1 130px;
  min-width: 120px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, filter .12s ease;
}
.big-btn .bb-sign { font-size: 1.5rem; line-height: 1; }
.big-btn:active { transform: scale(0.97); }
.big-btn.deposit { background: var(--green); }
.big-btn.deposit:hover { filter: brightness(1.07); }
.big-btn.withdraw { background: var(--red); }
.big-btn.withdraw:hover { filter: brightness(1.07); }

/* Blöcke */
.block {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.block-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold-deep);
}

.add-btn {
  background: var(--gold);
  color: var(--gold-deep);
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.add-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }

.ghost-btn {
  background: transparent;
  color: var(--text-soft);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--gold-dark); color: var(--text); }

/* Sparziele */
.goals-list { display: grid; gap: 14px; }
.goal-card {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.goal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.goal-name {
  font-size: 1.15rem;
  font-weight: 900;
  margin: 0;
  word-break: break-word;
  min-width: 0;
}
.goal-name.done::after { content: " 🎉"; }
.goal-del {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.goal-del:hover { background: rgba(225,29,72,0.12); }

.goal-amounts {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 6px 0 8px;
  color: var(--gold-deep);
}
.goal-amounts .sep { color: var(--text-soft); font-weight: 700; }

.progress-track {
  height: 18px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
  border-radius: 999px;
  width: 0%;
  transition: width .4s ease;
  min-width: 0;
}
.goal-card.done .progress-fill {
  background: linear-gradient(90deg, var(--gold), var(--gold-dark));
}
.goal-remaining {
  margin: 8px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green-dark);
}
.goal-remaining.reached { color: var(--gold-dark); }

/* Verlauf */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.hi-badge {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
}
.hi-badge.in { background: var(--green); }
.hi-badge.out { background: var(--red); }
.hi-main { flex: 1 1 auto; min-width: 0; }
.hi-note {
  font-weight: 700;
  word-break: break-word;
}
.hi-date { font-size: 0.82rem; color: var(--text-soft); }
.hi-amount {
  font-weight: 900;
  font-size: 1.05rem;
  flex: 0 0 auto;
  white-space: nowrap;
}
.hi-amount.in { color: var(--green-dark); }
.hi-amount.out { color: var(--red-dark); }
.hi-del {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 1.1rem;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 4px 6px;
  border-radius: 8px;
}
.hi-del:hover { background: rgba(225,29,72,0.12); color: var(--red); }

.empty-hint {
  text-align: center;
  color: var(--text-soft);
  font-weight: 600;
  padding: 8px 4px;
  margin: 4px 0 0;
}

.app-footer {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.82rem;
  padding: 8px 16px 24px;
  max-width: 720px;
  margin: 0 auto;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 5, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  animation: fadeIn .18s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: popIn .2s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold-deep);
}
.modal-close { width: 38px; height: 38px; font-size: 1rem; }

form label {
  display: block;
  font-weight: 700;
  margin: 10px 0 6px;
  font-size: 0.95rem;
}
form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  background: var(--bg);
  color: var(--text);
}
form input:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--gold-dark);
}

.form-error {
  color: var(--red-dark);
  font-weight: 700;
  font-size: 0.9rem;
  margin: 10px 0 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.primary-btn, .danger-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  color: #fff;
  flex: 1 1 auto;
}
.primary-btn { background: var(--green); }
.primary-btn:hover { filter: brightness(1.06); }
.danger-btn { background: var(--red); }
.danger-btn:hover { filter: brightness(1.06); }
.modal-actions .ghost-btn { flex: 1 1 auto; }

.confirm-text { font-weight: 600; margin: 0; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--gold-deep);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-width: 90vw;
  text-align: center;
  animation: toastIn .25s ease;
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--red-dark); }

/* Fokus sichtbar überall */
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

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

@media (min-width: 560px) {
  .balance-amount { font-size: 3.4rem; }
}
