@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400..800&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  --paper: #FAF6F0;
  --paper-alt: #F3ECE1;
  --ink: #2A241C;
  --ink-soft: #6B6155;
  --rust: #B14A2E;
  --rust-dark: #8C3A22;
  --line: #E5DDD0;
  --white: #FFFFFF;
  --gold: #D9A85A;
  --success: #6FA36F;

  /* routine type colors */
  --morning-bg: #FBE6D8; --morning-ink: #A34E1C;
  --bedtime-bg: #D6DEF5; --bedtime-ink: #2C4670;
  --chores-bg: #F2DFA0;  --chores-ink: #5C4413;
  --custom-bg: #E4CBEF;  --custom-ink: #6B3F82;

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow: 0 20px 45px rgba(42,36,28,0.12);
  --shadow-soft: 0 8px 20px rgba(42,36,28,0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Public Sans', -apple-system, sans-serif;
  min-height: 100vh;
}
h1, h2, h3 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; margin: 0; }
button { font-family: inherit; cursor: pointer; }
p { margin: 0; }

/* ---------- Top bar ---------- */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 640px; margin: 0 auto; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.brand-mini { display: flex; align-items: center; gap: 10px; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 17px; }
.brand-logo { height: 36px; width: auto; display: block; }

/* ---------- Welcome screen ---------- */
.welcome-screen { text-align: center; padding: 20px 10px 40px; }
.welcome-logo { height: 100px; margin: 10px auto 24px; display: block; }
.welcome-screen h1 { font-size: 28px; margin-bottom: 12px; line-height: 1.2; }
.welcome-screen .welcome-sub { color: var(--ink-soft); font-size: 16px; max-width: 380px; margin: 0 auto 28px; line-height: 1.5; }
.welcome-features { display: flex; flex-direction: column; gap: 12px; max-width: 340px; margin: 0 auto 32px; text-align: left; }
.welcome-feature { display: flex; align-items: center; gap: 12px; background: white; padding: 14px 16px; border-radius: 14px; box-shadow: var(--shadow-soft); }
.welcome-feature .wf-icon { font-size: 22px; }
.welcome-feature .wf-text { font-size: 14px; font-weight: 600; }
.welcome-badge { display: inline-block; background: var(--paper-alt); color: var(--ink-soft); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 6px 16px; border-radius: 999px; margin-bottom: 18px; }
.btn-icon { background: var(--paper-alt); border: none; width: 42px; height: 42px; border-radius: 12px; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.btn-icon:active { transform: scale(0.94); }

/* ---------- Kid tabs ---------- */
.kid-tabs { max-width: 640px; margin: 0 auto; padding: 16px 20px 0; display: flex; gap: 10px; overflow-x: auto; }
.kid-tab {
  flex-shrink: 0; padding: 10px 20px; border-radius: 999px; font-weight: 700; font-size: 14.5px;
  border: 2px solid var(--line); background: var(--white); color: var(--ink-soft); display: flex; align-items: center; gap: 8px;
}
.kid-tab.active { border-color: transparent; color: white; }
.kid-tab .streak { font-size: 12px; opacity: 0.85; }
.kid-tab-add { flex-shrink: 0; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14.5px; border: 2px dashed var(--line); background: transparent; color: var(--ink-soft); }

/* ---------- Main content ---------- */
.main-content { max-width: 640px; margin: 0 auto; padding: 24px 20px 80px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state h2 { margin-bottom: 10px; color: var(--ink); }
.empty-state .btn { margin-top: 20px; }

.date-line { font-size: 14px; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }
.greeting { font-size: 28px; margin-bottom: 20px; }

.progress-wrap { background: var(--white); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow-soft); }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.progress-label { font-weight: 700; font-size: 14px; }
.progress-count { font-size: 13px; color: var(--ink-soft); }
.progress-bar-track { height: 12px; background: var(--paper-alt); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--rust)); border-radius: 999px; transition: width 0.35s ease; }

.routine-section { margin-bottom: 28px; }
.routine-section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.routine-badge { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 5px 12px; border-radius: 999px; }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  display: flex; align-items: center; gap: 14px; background: var(--white); border-radius: var(--radius-sm);
  padding: 14px 16px; box-shadow: var(--shadow-soft); border: 2px solid transparent; transition: all 0.15s ease;
}
.task-item.done { background: var(--paper-alt); border-color: var(--success); opacity: 0.75; }
.task-check {
  width: 30px; height: 30px; border-radius: 999px; border: 2.5px solid var(--line); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: white; transition: all 0.15s ease;
}
.task-item.done .task-check { background: var(--success); border-color: var(--success); }
.task-icon { font-size: 22px; flex-shrink: 0; }
.task-label { font-weight: 600; font-size: 15.5px; flex: 1; }
.task-item.done .task-label { text-decoration: line-through; color: var(--ink-soft); }

/* ---------- Celebration ---------- */
.celebration { position: fixed; inset: 0; background: rgba(42,36,28,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.celebration.hidden { display: none; }
.celebration-card { background: white; border-radius: var(--radius-lg); padding: 44px 32px; text-align: center; max-width: 340px; box-shadow: var(--shadow); }
.celebration-emoji { font-size: 64px; margin-bottom: 10px; }
.celebration-title { font-size: 26px; margin-bottom: 8px; }
.celebration-sub { color: var(--ink-soft); margin-bottom: 24px; font-size: 15px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 26px; border-radius: 999px; font-weight: 700; font-size: 15px; border: none; }
.btn-primary { background: var(--rust); color: white; }
.btn-primary:active { background: var(--rust-dark); }
.btn-ghost { background: var(--paper-alt); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 18px; font-size: 13.5px; }
.btn-danger { background: #F3E0DC; color: #A34E1C; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(42,36,28,0.5); display: flex; align-items: flex-end; justify-content: center; z-index: 90; }
.modal.hidden { display: none; }
.modal-card { background: white; border-radius: 24px 24px 0 0; padding: 28px 22px 32px; width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto; }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-card { border-radius: var(--radius-lg); max-width: 480px; }
}

.field-group { margin-bottom: 18px; }
.field-label { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: block; }
.field-input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 2px solid var(--line);
  font-size: 15px; font-family: inherit; background: var(--paper);
}
.field-input:focus { outline: none; border-color: var(--rust); }

.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.color-swatch.selected { border-color: var(--ink); }

.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.template-card { border: 2px solid var(--line); border-radius: 14px; padding: 16px; text-align: left; background: white; }
.template-card:active { transform: scale(0.97); }
.template-card .t-icon { font-size: 26px; margin-bottom: 6px; }
.template-card .t-name { font-weight: 700; font-size: 14.5px; }
.template-card .t-desc { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.task-editor-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.task-editor-row input { flex: 1; }
.remove-task { background: none; border: none; color: var(--ink-soft); font-size: 20px; padding: 4px 8px; }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-close-x { position: absolute; top: 18px; right: 18px; background: var(--paper-alt); border: none; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; }
.modal-card { position: relative; }

.kid-manage-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kid-manage-row:last-child { border-bottom: none; }
.kid-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-right: 10px; }
