@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&display=swap');

:root {
  --cream: #FFF6EC;
  --cream-2: #FFE8D6;
  --coral: #FF8C69;
  --coral-dark: #E8734F;
  --sunny: #FFD166;
  --mint: #8FD9A8;
  --sky: #7EC8E3;
  --plum: #B892C9;
  --ink: #3A2E2E;
  --muted: #8A7A72;
  --white: #FFFFFF;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: calc(76px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

button, input, textarea {
  font-family: inherit;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: 18px 16px 6px;
}
.app-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--coral-dark);
  letter-spacing: 0.5px;
}
.app-header .tagline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Install tip ---------- */
.install-tip {
  background: var(--sunny);
  color: var(--ink);
  font-size: 13px;
  padding: 10px 40px 10px 14px;
  position: relative;
  text-align: center;
}
.install-tip button {
  position: absolute;
  right: 8px;
  top: 4px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  color: var(--ink);
}

/* ---------- Layout ---------- */
main#views {
  flex: 1;
  display: flex;
  padding: 0 16px 16px;
}
.view {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--white);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 6px 20px rgba(180, 120, 90, 0.12);
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--coral-dark);
  margin: 8px 0 -4px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 16px;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--coral);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(255, 140, 105, 0.45);
}
.btn-primary:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--cream-2);
  color: var(--coral-dark);
}
.btn-huge {
  width: 100%;
  font-size: 19px;
  padding: 18px;
  border-radius: 20px;
}
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ---------- Capture view ---------- */
.capture-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.field-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-top: 4px;
}
#quote-input {
  width: 100%;
  border: 2px solid var(--cream-2);
  border-radius: 18px;
  padding: 16px;
  font-size: 19px;
  resize: vertical;
  min-height: 120px;
  background: var(--white);
  color: var(--ink);
}
#quote-input:focus {
  outline: none;
  border-color: var(--coral);
}

.kid-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.kid-chip {
  border: 2px solid var(--cream-2);
  background: var(--white);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.kid-chip.selected {
  background: var(--chip-color, var(--coral));
  border-color: var(--chip-color, var(--coral));
  color: var(--white);
}
.kid-chip.all-chip.selected {
  background: var(--ink);
  border-color: var(--ink);
}

.timestamp-preview {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  animation: toast-pop 1.8s ease forwards;
  z-index: 50;
}
@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ---------- Onboarding ---------- */
.onboarding-card { margin-top: 12px; }
.onboarding-card h2 { margin-top: 0; }
.onboarding-form {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.onboarding-form input, .add-kid-form input {
  flex: 1;
  border: 2px solid var(--cream-2);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  min-height: 44px;
}
.onboarding-form input:focus, .add-kid-form input:focus {
  outline: none;
  border-color: var(--coral);
}

/* ---------- Collection view ---------- */
.filter-chips {
  padding-top: 12px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.collection-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.memory-card {
  background: var(--white);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(180, 120, 90, 0.12);
  border-left: 8px solid var(--card-color, var(--coral));
}
.memory-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.memory-card-kid {
  font-weight: 800;
  color: var(--card-color, var(--coral-dark));
  font-size: 15px;
}
.memory-card-date {
  font-size: 12px;
  color: var(--muted);
}
.memory-card-text {
  font-size: 18px;
  line-height: 1.4;
  margin: 0 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.memory-card-actions {
  display: flex;
  gap: 10px;
}
.icon-btn {
  border: none;
  background: var(--cream);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  min-height: 40px;
}
.icon-btn.danger { color: #C0392B; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .btn { margin-top: 12px; }

/* ---------- Settings view ---------- */
.settings-kid-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-kid-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 3px 10px rgba(180, 120, 90, 0.10);
}
.settings-kid-row .swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  cursor: pointer;
}
.settings-kid-row input[type="text"] {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
}
.settings-kid-row input[type="text"]:focus { outline: none; }
.settings-kid-row .icon-btn { flex-shrink: 0; }

.add-kid-form {
  display: flex;
  gap: 8px;
}
.settings-hint { color: var(--muted); font-size: 14px; margin: 0; }
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-footnote {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.swatch-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.swatch-picker .swatch { width: 24px; height: 24px; }
.swatch-picker .swatch.active { box-shadow: 0 0 0 3px var(--ink); }

/* ---------- Tab bar ---------- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--cream-2);
  padding-bottom: var(--safe-bottom);
  z-index: 40;
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-height: 56px;
  cursor: pointer;
}
.tab-btn.active { color: var(--coral-dark); }
.tab-icon { font-size: 22px; }

/* ---------- Card export modal ---------- */
.card-modal {
  position: fixed;
  inset: 0;
  background: rgba(58, 46, 46, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.card-modal-inner {
  background: var(--white);
  border-radius: 20px;
  padding: 16px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#card-canvas {
  width: 100%;
  border-radius: 14px;
  aspect-ratio: 1 / 1;
}
.card-modal-actions {
  display: flex;
  gap: 10px;
}
.card-modal-actions .btn { flex: 1; }

@media (min-width: 560px) {
  body { max-width: 480px; margin: 0 auto; }
  .tab-bar { max-width: 480px; margin: 0 auto; left: 0; right: 0; }
}
