@import url('variables.css');
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800&family=Inter:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--coral-deep); }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

:focus-visible { outline: 3px solid var(--sage-deep); outline-offset: 2px; border-radius: 8px; }

/* ---------- layout ---------- */
.app-shell { max-width: 1140px; margin: 0 auto; padding: 0 20px 110px; }
@media (min-width: 900px) { .app-shell { padding-bottom: 64px; } }

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,253,247,.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--beige);
}
.app-header-inner {
  max-width: 1140px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand-mark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark .logo-dot {
  width: 38px; height: 38px; border-radius: 14px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--yellow), var(--coral));
  display: grid; place-items: center; font-size: 20px;
}
.brand-mark strong { font-family: var(--font-head); font-size: 1.05rem; }
.desktop-nav { display: none; margin-left: auto; gap: 4px; }
.desktop-nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 600;
  padding: 10px 14px; border-radius: 999px;
}
.desktop-nav a.active, .desktop-nav a:hover { background: var(--beige); color: var(--ink); }
@media (min-width: 900px) { .desktop-nav { display: flex; } }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; border: 2px solid var(--beige);
  background: #fff; display: inline-grid; place-items: center; font-size: 19px;
}
.icon-btn:hover { border-color: var(--sage-deep); }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #fff; border-top: 1px solid var(--beige);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 18px rgba(38,50,56,.06);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--ink-soft); font-size: 11px; font-weight: 600;
  padding: 6px 2px; border-radius: 12px; min-height: 56px; justify-content: center;
}
.tabbar a .ticon { font-size: 21px; line-height: 1; }
.tabbar a.active { color: var(--coral-deep); background: var(--beige); }
@media (min-width: 900px) { .tabbar { display: none; } }

/* ---------- components ---------- */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 24px; margin-bottom: 20px; }
.card.soft { background: var(--beige); box-shadow: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 14px 28px; min-height: 48px;
  font-weight: 700; font-size: 1rem; text-decoration: none; border: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--coral-deep); color: #FFFDF7; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-secondary { background: #fff; color: var(--ink); border: 2px solid var(--ink); }
.btn-sage { background: var(--sage-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--coral-deep); padding: 10px 16px; min-height: 44px; }
.btn-sm { padding: 9px 18px; min-height: 44px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn[disabled] { opacity: .55; cursor: wait; }

.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--sage); margin: 0 6px 6px 0;
}
.badge.blue { background: var(--blue); }
.badge.yellow { background: var(--yellow); }
.badge.coral { background: var(--coral); }

.input, select.input, textarea.input {
  width: 100%; border: 2px solid var(--beige); border-radius: 14px;
  min-height: 48px; padding: 12px 16px; font-size: 1rem; font-family: inherit;
  background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 3px rgba(110,155,126,.2); }
label.field { display: block; font-weight: 700; margin: 16px 0 6px; }
.field-hint { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.chip {
  border: 2px solid var(--beige); background: #fff; border-radius: 999px;
  padding: 10px 18px; min-height: 48px; font-weight: 600; color: var(--ink);
}
.chip[aria-pressed="true"] { border-color: var(--coral-deep); background: #FBEFE8; color: var(--coral-dark); }

.progress-track { height: 12px; background: var(--beige); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--sage-deep), var(--sage)); border-radius: 999px; transition: width .5s ease; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: var(--cream); border-radius: 16px; padding: 14px 10px; text-align: center; }
.stat .num { font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; color: var(--coral-deep); }
.stat .lbl { font-size: .8rem; color: var(--ink-soft); font-weight: 600; }

.day-card { border: 2px solid var(--beige); border-radius: 18px; margin-bottom: 14px; overflow: hidden; background: #fff; }
.day-head {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: none; padding: 16px 18px; font-size: 1rem;
}
.day-head .day-name { font-family: var(--font-head); font-weight: 800; flex: 1; }
.day-head .caret { transition: transform .2s; color: var(--ink-soft); }
.day-card.open .day-head .caret { transform: rotate(180deg); }
.day-body { display: none; padding: 0 18px 18px; border-top: 1px dashed var(--beige); padding-top: 14px; }
.day-card.open .day-body { display: block; }

.act-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--beige);
}
.act-row:last-child { border-bottom: none; }
.act-info { flex: 1; min-width: 0; }
.act-info .t { font-weight: 700; }
.act-info .m { font-size: .85rem; color: var(--ink-soft); }
.act-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mini-btn {
  border: 2px solid var(--beige); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: .82rem; font-weight: 700; min-height: 38px;
}
.mini-btn.done { border-color: var(--sage-deep); background: var(--sage); color: var(--ink); }
.mini-btn:hover { border-color: var(--coral-deep); }
.act-check {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 999px; margin-top: 2px;
  border: 2px solid var(--sage-deep); background: #fff; display: grid; place-items: center; font-size: 16px;
}
.act-row.is-done .act-check { background: var(--sage-deep); color: #fff; }
.act-row.is-done .act-info .t { text-decoration: line-through; color: var(--ink-soft); }
.act-row.is-skipped { opacity: .55; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.tile { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.tile h3 { margin: 0; font-size: 1.05rem; }
.tile .meta { font-size: .85rem; color: var(--ink-soft); }
.tile .spacer { flex: 1; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.filters .input, .filters select.input { width: auto; flex: 1 1 140px; }

.rail { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x mandatory; }
.rail .tile { min-width: 250px; scroll-snap-align: start; }

/* ---------- onboarding ---------- */
.ob-wrap { max-width: 640px; margin: 0 auto; padding-top: 24px; }
.ob-progress { margin-bottom: 24px; }
.ob-steps { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 8px; }
.ob-dots { display: flex; gap: 6px; margin-top: 10px; }
.ob-dots span { flex: 1; height: 6px; border-radius: 999px; background: var(--beige); }
.ob-dots span.on { background: var(--coral-deep); }
.ob-card { background: #fff; border-radius: 24px; box-shadow: var(--card-shadow); padding: 32px 28px; }
.ob-nav { display: flex; gap: 10px; margin-top: 24px; }
.ob-nav .btn { flex: 1; }
.ob-emoji { font-size: 3rem; margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(38,50,56,.5);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--cream); border-radius: 24px; max-width: 640px; width: 100%;
  max-height: 88vh; overflow: auto; padding: 28px; position: relative;
}
.modal-close { position: absolute; top: 12px; right: 12px; }

/* ---------- search overlay ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(255,253,247,.98);
  padding: 24px 20px; overflow: auto; display: none;
}
.search-overlay.open { display: block; }
.search-inner { max-width: 640px; margin: 0 auto; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 16px; right: 16px; bottom: 84px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
@media (min-width: 900px) { #toasts { bottom: 32px; } }
.toast {
  background: var(--ink); color: #FFFDF7; border-radius: 999px; padding: 12px 22px;
  font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: toast-in .25s ease; max-width: 520px; text-align: center;
}
.toast.good { background: var(--sage-deep); }
.toast.bad { background: #B5462F; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

/* ---------- skeletons / states ---------- */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--beige) 25%, #fbf5ea 50%, var(--beige) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .big { font-size: 3rem; margin-bottom: 12px; }
.error-state { text-align: center; padding: 40px 20px; background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); }

/* ---------- forms misc ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--beige); }
.switch-row:last-child { border-bottom: none; }
.toggle { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.toggle input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; background: var(--beige); border-radius: 999px; transition: .2s; }
.toggle .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.toggle input:checked + .track { background: var(--sage-deep); }
.toggle input:checked + .track::after { left: 25px; }

.child-pill {
  display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--beige);
  background: #fff; border-radius: 999px; padding: 8px 8px 8px 16px; font-weight: 700; min-height: 48px;
}
.child-pill select { border: none; background: transparent; font: inherit; font-weight: 700; color: var(--coral-deep); }

.mode-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mode-chip { border-radius: 999px; padding: 10px 18px; min-height: 44px; font-weight: 700; border: 2px solid transparent; }
.mode-chip.noprep { background: var(--sage); }
.mode-chip.rainy { background: var(--blue); }
.mode-chip.outside { background: var(--yellow); }
.mode-chip.busy { background: var(--coral); }

.note-box { background: var(--cream); border: 2px dashed var(--beige); border-radius: 14px; padding: 12px 14px; font-size: .92rem; margin-top: 8px; }

.invite-code {
  font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; letter-spacing: 2px;
  background: var(--yellow); border-radius: 14px; padding: 12px 20px; display: inline-block;
}

.install-banner {
  display: none; align-items: center; gap: 12px; background: var(--ink); color: #FFFDF7;
  border-radius: 18px; padding: 14px 18px; margin-bottom: 16px;
}
.install-banner.show { display: flex; }

/* ---------- printable preview (HTML) ---------- */
.pv-page { background: #fff; border: 1px solid var(--beige); border-radius: 8px; padding: 32px; margin: 0 auto; max-width: 560px; color: #263238; }
.pv-page h2 { text-align: center; }
.pv-trace { font-size: 3rem; letter-spacing: .5rem; border-bottom: 3px dashed #999; margin: 18px 0; text-align: center; font-family: var(--font-head); }
.pv-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pv-box { border: 2px solid #555; border-radius: 10px; padding: 12px; text-align: center; min-height: 70px; }
.pv-check { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dotted #999; }
.pv-check .box { width: 22px; height: 22px; border: 2px solid #555; border-radius: 6px; flex: 0 0 auto; }
.pv-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pv-card { border: 2px dashed #555; border-radius: 10px; padding: 18px; text-align: center; font-size: 1.6rem; font-weight: 800; font-family: var(--font-head); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- print ---------- */
@media print {
  .app-header, .tabbar, #toasts, .search-overlay, .no-print, .btn-row, .act-actions, .filters { display: none !important; }
  body { background: #fff; }
  .app-shell { max-width: none; padding: 0; }
  .card, .day-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .day-body { display: block !important; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- free-tier paywall ---------- */
.paywall-plans {
  display: grid; gap: 10px; margin-top: 16px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 520px) { .paywall-plans { grid-template-columns: 1fr; } }
.pw-plan {
  position: relative;
  background: #fff; border: 2px solid var(--beige); border-radius: 18px;
  padding: 16px 8px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.pw-plan > span:last-child { font-size: .82rem; color: var(--ink-soft); }
.pw-plan.pw-pop { border-color: var(--coral-deep); box-shadow: var(--card-shadow); }
.pw-tag {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--coral-deep); color: #fff; font-size: .68rem; font-weight: 800;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.pw-price { font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; }
.pw-price small { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }

/* ---------- free plays pill (app header) ---------- */
.free-plays-pill {
  display: inline-block;
  font-size: .82rem; font-weight: 700;
  background: var(--yellow, #F6E7A8); color: var(--ink);
  border-radius: 999px; padding: 6px 12px;
  margin-left: 8px; white-space: nowrap;
}

/* ---------- offline mode ---------- */
#offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
  background: #3E4A54; color: #fff; text-align: center;
  font-size: .88rem; padding: 8px 12px;
  transform: translateY(-110%); transition: transform .25s ease;
}
#offline-bar.show { transform: translateY(0); }
.offline-note {
  background: #FFF8E7; border: 1.5px dashed #D9A441; border-radius: 12px;
  padding: 10px 14px; margin: 12px 0; font-size: .92rem; color: var(--ink);
}
.dl-progress { min-width: 180px; max-width: 240px; }
.dl-bar {
  height: 10px; border-radius: 999px; background: #EFE7D8; overflow: hidden;
}
.dl-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sage, #9DBE9D), var(--sage-deep, #6F9A6F));
  transition: width .2s ease;
}
.dl-label { font-size: .78rem; color: var(--ink-soft); margin-top: 4px; white-space: nowrap; }
