/* Family Board — parent app. MadeForMyKids look:
   coral #ff7d26, slate #1e293b, cream #fffbf7,
   Fredoka headings + Inter body (system fallback if Google Fonts is unreachable). */

:root {
  --coral: #ff7d26;
  --coral-dark: #e8660f;
  --slate: #1e293b;
  --slate-soft: #475569;
  --cream: #fffbf7;
  --card: #ffffff;
  --line: #f1e6da;
  --danger: #dc2626;
  --success: #15803d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--slate);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  margin: 0 0 0.5em;
  color: var(--slate);
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 0.75em; }
.muted { color: var(--slate-soft); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.loading-text { color: var(--slate-soft); padding: 1.5rem 0; }

.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}
.success {
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}

/* ---------- layout ---------- */
.topbar {
  background: var(--slate);
  color: #fff;
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-emoji { font-size: 2rem; }
.topbar h1 { color: #fff; margin: 0; }
.tagline { color: #cbd5e1; margin: 0; font-size: 0.9rem; }

.main-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.nav-btn {
  background: transparent;
  border: 2px solid transparent;
  color: #e2e8f0;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}
.nav-btn:hover { background: #334155; }
.nav-btn.active { background: var(--coral); color: #fff; }
.nav-logout { color: #fca5a5; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.view[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.05);
}

.auth-card { max-width: 480px; margin: 2rem auto; }
.sub-form { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.setup-actions { margin-top: 1rem; }

/* ---------- buttons & forms ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  min-height: 48px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--coral-dark); }
.btn-secondary { background: #fff7ed; color: var(--coral-dark); border: 2px solid var(--coral); }
.btn-ghost { background: transparent; color: var(--slate-soft); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-danger-text { color: var(--danger); }
.btn-small { padding: 0.35rem 0.7rem; min-height: 36px; font-size: 0.9rem; }
.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: none;
  color: var(--coral-dark);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.field { display: block; margin-bottom: 1rem; }
.field > span, fieldset.field > legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
fieldset.field { border: none; padding: 0; }
.field input, .field select {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: var(--slate);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 125, 38, 0.2);
}
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }

.auth-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.toggle-btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: var(--slate-soft);
  cursor: pointer;
}
.toggle-btn.active { border-color: var(--coral); background: #fff7ed; color: var(--coral-dark); }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input {
  flex: 1;
  min-width: 200px;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
}

/* ---------- dashboard ---------- */
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dash-head h2 { margin: 0; }

.cal-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cal-head h3 { margin: 0; flex: 1; text-align: center; }
.cal-nav { font-size: 1.25rem; padding: 0.4rem 0.8rem; min-height: 44px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--slate-soft);
  padding: 0.3rem 0;
}
.cal-cell {
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 64px;
  padding: 0.3rem 0.2rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cal-cell:hover { border-color: var(--coral); }
.cal-blank { background: transparent; border: none; cursor: default; }
.cal-today { border: 2px solid var(--coral); }
.cal-selected { background: #fff7ed; box-shadow: inset 0 0 0 2px var(--coral); }
.cal-daynum { font-weight: 700; font-size: 0.95rem; }
.cal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; min-height: 10px; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-dot[data-done="1"] { opacity: 0.35; }
.cal-more { font-size: 0.7rem; color: var(--slate-soft); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.9rem;
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- task list ---------- */
.task-list { display: flex; flex-direction: column; gap: 0.6rem; }
.task-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  cursor: pointer;
}
.task-row:hover { border-color: var(--coral); }
.task-color { width: 8px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.task-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.task-title { font-weight: 600; }
.task-meta { color: var(--slate-soft); font-size: 0.9rem; }
.task-stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.task-done .task-title { text-decoration: line-through; color: var(--slate-soft); }

/* ---------- kids & tablets ---------- */
.kid-list, .tablet-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.kid-row, .tablet-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.kid-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.kid-emoji { font-size: 1.4rem; }
.kid-name { flex: 1; font-weight: 600; }
.tablet-icon { font-size: 1.4rem; }
.tablet-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tablet-name { font-weight: 600; }
.tablet-meta { color: var(--slate-soft); font-size: 0.9rem; }

.code-box {
  margin-top: 1.25rem;
  background: #fff7ed;
  border: 2px dashed var(--coral);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.pairing-code {
  font-family: 'Fredoka', 'Inter', system-ui, sans-serif;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin: 0.25rem 0 0.5rem;
  color: var(--slate);
}

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 59, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(30, 41, 59, 0.25);
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.modal-actions .spacer { flex: 1; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.selected { border-color: var(--slate); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--coral); }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.emoji-btn {
  font-size: 1.6rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
}
.emoji-btn.selected { border-color: var(--coral); background: #fff7ed; }

.weekday-checks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.weekday-checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}
.weekday-checks input { accent-color: var(--coral); width: 18px; height: 18px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .cal-cell { min-height: 52px; }
  .pairing-code { font-size: 2.4rem; letter-spacing: 0.25em; }
  .modal { padding: 1rem 0.5rem; }
}
