/* PoopMoney: light, card based layout. Bottom tab bar on phones, top menu on larger screens. */
:root {
  --bg: #F3F5F2;
  --card: #FFFFFF;
  --text: #16211B;
  --muted: #56655C;
  --line: #D5DDD7;
  --line-soft: #E6EBE7;
  --accent: #1F7A4D;
  --accent-dark: #145A38;
  --accent-soft: #E6F2EB;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --radius: 18px;
  --tabbar: 68px;
  --shadow: 0 1px 2px rgba(22, 33, 27, 0.06), 0 4px 16px rgba(22, 33, 27, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2 { margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex-shrink: 0; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.page { flex-grow: 1; padding-top: 20px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 16px; }

/* Header */
.topbar { background: var(--card); border-bottom: 1px solid var(--line-soft); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.nav-desktop { display: none; gap: 4px; }
.nav-desktop a { padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav-desktop a:hover { background: var(--bg); color: var(--text); }
.nav-desktop a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); }
.hello { margin-left: auto; color: var(--muted); font-size: 0.9rem; }

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line-soft);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--accent); }
body { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }

.footer { text-align: center; padding: 20px 16px; font-size: 0.85rem; }
.footer a { color: var(--muted); }

@media (min-width: 760px) {
  .nav-desktop { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  .page { padding-top: 32px; gap: 20px; }
  h1 { font-size: 2rem; }
}

/* Flash messages */
.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 14px; font-weight: 600; background: var(--accent-soft); color: var(--accent-dark); }
.flash-danger { background: var(--danger-soft); color: var(--danger); }
.flash-badge { background: #FFF4D6; color: #7A4E00; }

/* Cards and tiles */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-flush { padding: 6px 0; }
.narrow { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); font-size: 0.92rem; }

.hero { background: var(--accent); color: #FFFFFF; border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 4px; }
.hero-label { font-size: 0.85rem; font-weight: 600; opacity: 0.92; }
.hero-amount { font-size: 3rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 0.85rem; opacity: 0.92; min-height: 1.3em; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); min-width: 0; }
a.tile:hover { color: var(--text); outline: 2px solid var(--accent-soft); }
.tile-label { font-size: 0.78rem; color: var(--muted); }
.tile-value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-accent { background: var(--accent); color: #FFFFFF; }
.tile-accent .tile-label { color: #FFFFFF; opacity: 0.9; }
@media (max-width: 420px) {
  .tiles-3 .tile-value { font-size: 1.05rem; }
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.input-wrap { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; min-height: 50px; background: var(--card); }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input { flex-grow: 1; min-width: 0; width: 100%; border: none; outline: none; background: transparent; font-size: 1.1rem; font-weight: 600; padding: 12px 0; }
.suffix { color: var(--muted); font-weight: 600; white-space: nowrap; }
.unit { border: none; background: transparent; color: var(--muted); font-weight: 600; padding: 8px 0; }
.hint { font-size: 0.8rem; color: var(--muted); }
.error { font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.has-error .input-wrap { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1.5px solid transparent; font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; min-height: 54px; }
.btn-primary { background: var(--text); color: #FFFFFF; }
.btn-primary:hover { background: #000000; color: #FFFFFF; }
.btn-secondary { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }
.btn-accent { background: var(--accent); color: #FFFFFF; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--muted); }

.chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.chip { min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

/* Calculator page */
.calc-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "tiles" "form"; }
.calc-grid .hero { grid-area: hero; }
.calc-grid .tiles { grid-area: tiles; }
.calc-form { grid-area: form; display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 760px) {
  .calc-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-areas: "form hero" "form tiles" "form ."; align-items: start; gap: 20px; }
  .calc-form { padding: 24px; }
  .hero { padding: 28px; }
  .hero-amount { font-size: 3.6rem; }
}

.monthly { border: 1.5px dashed var(--line); border-radius: 14px; }
.monthly summary { cursor: pointer; padding: 12px 14px; font-weight: 700; color: var(--accent-dark); min-height: 44px; }
.monthly[open] summary { border-bottom: 1px solid var(--line-soft); }
.monthly-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.monthly-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 480px) { .monthly-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.timer { background: var(--bg); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.timer-head { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.timer-time { margin-left: auto; font-size: 1.6rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.timer.is-running .timer-time { color: var(--accent); }
.timer-buttons { display: flex; gap: 8px; }
.timer-buttons .btn { flex-grow: 1; }
.privacy { font-size: 0.8rem; color: var(--muted); text-align: center; }

/* Statistics and ranking */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #E3E9E5; border-radius: 12px; padding: 4px; }
.segmented a { padding: 8px 14px; min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: 0.88rem; white-space: nowrap; }
.segmented a[aria-current="page"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
@media (max-width: 520px) { .segmented { width: 100%; } }

.stats-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .stats-grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; gap: 20px; } }

.day + .day { margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: flex; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.entry-time { color: var(--muted); font-size: 0.9rem; }
.entry-amount { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.delete-form { margin: 0; }
.icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: none; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.badge { border-radius: 14px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--accent-soft); color: var(--accent-dark); }
.badge-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.badge-title { font-weight: 800; font-size: 0.92rem; color: var(--text); }
.badge-goal { font-size: 0.78rem; }
.badge.is-locked { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
.badge.is-locked .badge-icon { background: var(--line-soft); color: var(--muted); }
.badge.is-locked .badge-title { color: var(--muted); }

.notice { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; padding: 12px 16px; border-radius: 14px; }
.ranking { list-style: none; margin: 0; padding: 0; }
.rank-row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.rank-row:last-child { border-bottom: none; }
.rank-place { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: var(--bg); color: var(--muted); flex-shrink: 0; }
.rank-row.is-top .rank-place { background: var(--accent); color: #FFFFFF; }
.rank-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { color: var(--muted); font-weight: 500; }
.rank-amount { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-row.is-me { background: var(--accent-soft); }

.empty { text-align: center; padding: 24px 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); }

/* Start page */
.intro { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .intro { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: stretch; gap: 20px; } }
.hero-intro { justify-content: center; min-height: 180px; }
.hero-quote { font-size: 1.5rem; font-weight: 800; line-height: 1.3; letter-spacing: -0.02em; }
.intro-text { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; }

/* Imprint */
.prose { overflow-wrap: anywhere; }
.prose h1 { margin: 8px 0 12px; }
.prose h2 { margin: 20px 0 8px; font-size: 1.2rem; }
.prose h3 { margin: 16px 0 6px; font-size: 1.05rem; }
.prose h4 { margin: 12px 0 4px; font-size: 1rem; }
.prose p { margin: 0 0 10px; }

/* Sharing */
.hero-share { align-self: flex-start; margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; background: rgba(255, 255, 255, 0.16); color: #FFFFFF; text-decoration: none; font-weight: 700; font-size: 0.92rem; }
.hero-share:hover { background: rgba(255, 255, 255, 0.26); color: #FFFFFF; }
.share-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .share-grid { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; gap: 24px; } }
.share-preview-wrap { display: flex; justify-content: center; }
.share-preview { width: 100%; max-width: 300px; height: auto; aspect-ratio: 9 / 16; border-radius: 22px; background: var(--accent); box-shadow: 0 10px 30px rgba(22, 33, 27, 0.2); }
.btn-light { background: #FFFFFF; color: var(--accent-dark); }
.btn-light:hover { color: var(--accent-dark); background: var(--accent-soft); }

.recap-links { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .recap-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.recap-link { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); background: #0F3D27; color: #FFFFFF; text-decoration: none; }
.recap-link:hover { color: #FFFFFF; background: #0B2E1D; }
.recap-link .icon { color: #9BE7B8; }
.recap-link span { display: flex; flex-direction: column; }
.recap-link small { opacity: 0.85; }

.recap { display: flex; flex-direction: column; gap: 12px; }
.recap-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.slides { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 24px; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { scroll-snap-align: start; min-height: 440px; padding: 32px 26px; box-sizing: border-box; background: #0F3D27; color: #FFFFFF; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.slide:nth-child(even) { background: var(--accent); }
.slide-kicker { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #9BE7B8; }
.slide:nth-child(even) .slide-kicker { color: #DDF5E6; }
.slide-lead { font-size: 1.3rem; font-weight: 700; line-height: 1.3; }
.slide-big { font-size: 3.2rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; overflow-wrap: anywhere; }
.slide-text { font-size: 1rem; opacity: 0.92; }
.slide .btn { align-self: flex-start; margin-top: 8px; }
.slide-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; height: 110px; align-items: end; }
.slide-bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; font-size: 0.75rem; }
.slide-bar-fill { width: 100%; border-radius: 8px; background: rgba(255, 255, 255, 0.25); }
.slide-bar.is-top .slide-bar-fill { background: #9BE7B8; }
.slide-bar.is-top { font-weight: 800; }
.slide-dots { display: flex; justify-content: center; gap: 6px; }
.slide-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.slide-dots span.is-active { background: var(--accent); width: 22px; border-radius: 4px; }
@media (min-width: 760px) {
  .slides { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; gap: 16px; border-radius: 0; }
  .swipe-hint { display: none; }
  .slide { border-radius: 24px; min-height: 420px; }
  .slide-big { font-size: 2.6rem; }
  .slide-dots { display: none; }
}

.challenge-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .challenge-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; } }
.challenge-hero { gap: 10px; padding: 28px; }
.challenge-title { font-size: 2rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.card-title { padding: 12px 18px 0; }
.won { color: var(--accent-dark) !important; font-weight: 800 !important; }
