:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --cream: #fff7ed;
  --yellow: #fef3c7;
  --green: #dcfce7;
  --red: #fee2e2;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #e5e7eb;
  --white: #ffffff;
  --shadow: 0 14px 30px rgba(15, 23, 42, 0.10);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f8fafc; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(254, 243, 199, 0.75), transparent 34%),
    radial-gradient(circle at bottom right, rgba(220, 252, 231, 0.75), transparent 34%),
    #f8fafc;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }
img { max-width: 100%; display: block; }
.app-shell { width: min(1120px, 100%); margin: 0 auto; padding: 14px; }

.login-wrap { max-width: 560px; margin: 0 auto; padding-bottom: 24px; }
.family-hero {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: linear-gradient(135deg, #dbeafe, #fef3c7);
}
.family-hero img {
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #fff;
}
.login-title { text-align: center; margin: 18px 0 12px; }
.login-title h1 { margin: 0; font-size: clamp(2rem, 8vw, 3rem); line-height: 1; color: #1e3a8a; }
.login-title p { margin: 9px 0 0; color: var(--muted); font-weight: 700; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-card {
  background: var(--white); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 150px;
}
.profile-card img { width: 82px; height: 82px; object-fit: cover; border-radius: 999px; background: #dbeafe; }
.profile-card strong { font-size: 1.05rem; }
.install-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.primary-btn, .soft-btn, .danger-btn, .small-btn, .nav-btn, .tab-btn {
  border-radius: 999px; padding: 12px 16px; font-weight: 800; min-height: 44px;
}
.primary-btn { background: var(--blue); color: white; }
.primary-btn:hover { background: var(--blue-dark); }
.soft-btn { background: #e0f2fe; color: #075985; }
.danger-btn { background: var(--red); color: #991b1b; }
.small-btn { padding: 8px 12px; min-height: 38px; background: #eef2ff; color: #3730a3; }
.ghost-btn { background: transparent; color: var(--blue); font-weight: 800; padding: 8px 10px; }
.pin-card { margin-top: 14px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.pin-card label { display: block; font-weight: 800; margin-bottom: 8px; }
.pin-card input { width: 100%; padding: 15px; border: 2px solid var(--line); border-radius: 16px; font-size: 1.25rem; text-align: center; }
.error { color: #b91c1c; font-weight: 800; min-height: 22px; }

.app-header {
  position: sticky; top: 0; z-index: 5; margin: -14px -14px 14px; padding: 12px 14px;
  background: rgba(248, 250, 252, 0.9); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.user-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 999px; background: #dbeafe; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.page-title { margin: 12px 0 4px; font-size: clamp(1.7rem, 7vw, 2.6rem); color: #1e3a8a; }
.date-line { color: var(--muted); font-weight: 700; margin: 0 0 14px; }

.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2, .card h3 { margin-top: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-card .num { font-size: 1.8rem; font-weight: 950; color: #1e3a8a; }
.stat-card .label { color: var(--muted); font-weight: 800; }
.progress-wrap { background: #e5e7eb; height: 16px; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #22c55e, #2563eb); border-radius: 999px; transition: width .2s ease; }
.mission-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 10px; }
.mission-section-title h2 { margin: 0; font-size: 1.25rem; }
.task-list { display: grid; gap: 12px; }
.task-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; box-shadow: 0 8px 20px rgba(15,23,42,.06); }
.task-card.done { background: var(--green); border-color: #86efac; }
.task-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-title { font-weight: 950; font-size: 1.08rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: .75rem; font-weight: 900; border-radius: 999px; padding: 5px 8px; background: #eff6ff; color: #1d4ed8; white-space: nowrap; }
.badge.warn { background: var(--yellow); color: #92400e; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.task-actions button { flex: 1; min-width: 92px; }

.bottom-nav {
  position: sticky; bottom: 0; z-index: 4; margin: 18px -14px -14px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.nav-btn { background: #f1f5f9; color: #334155; padding: 10px 8px; font-size: .92rem; }
.nav-btn.active { background: var(--blue); color: #fff; }
.parent-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.tab-btn { background: #f1f5f9; color: #334155; white-space: nowrap; }
.tab-btn.active { background: var(--blue); color: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field label { display: block; font-weight: 900; margin-bottom: 7px; }
.field input, .field textarea, .field select {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px; background: white;
}
.field textarea { min-height: 92px; resize: vertical; }
.item-list { display: grid; gap: 10px; }
.list-item { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: #fff; }
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.muted { color: var(--muted); font-weight: 700; }
.chat-box { display: grid; gap: 10px; max-height: 48vh; overflow: auto; padding-right: 4px; }
.chat-message { background: #eef2ff; border-radius: 18px; padding: 12px; }
.chat-message.mine { background: var(--green); }
.chat-meta { font-size: .8rem; color: var(--muted); font-weight: 800; margin-bottom: 4px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(520px, 100%); background: #fff; border-radius: 24px; box-shadow: var(--shadow); padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.quiz-option { display: block; width: 100%; text-align: left; border: 2px solid var(--line); border-radius: 16px; padding: 12px; margin-top: 8px; background: #fff; }
.quiz-option.selected { border-color: var(--blue); background: #eff6ff; }
.hr { border: 0; height: 1px; background: var(--line); margin: 14px 0; }
.empty { text-align: center; color: var(--muted); font-weight: 800; padding: 24px 10px; }

@media (max-width: 520px) {
  .app-shell { padding: 10px; }
  .app-header { margin: -10px -10px 12px; padding: 10px; }
  .family-hero img {
    max-height: 300px;
  }
  .profile-grid { gap: 10px; }
  .profile-card { min-height: 138px; padding: 12px; }
  .profile-card img { width: 72px; height: 72px; }
  .header-actions .soft-btn, .header-actions .primary-btn { padding: 9px 11px; min-height: 38px; }
  .task-actions { flex-direction: column; }
  .bottom-nav { margin-left: -10px; margin-right: -10px; margin-bottom: -10px; }
}


/* v1.6 AI attraction layer */
.ai-card {
  border: 2px solid #bfdbfe;
  background:
    radial-gradient(circle at top right, rgba(219, 234, 254, .95), transparent 38%),
    #ffffff;
}
.ai-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.ai-message {
  font-weight: 900;
  color: #1e3a8a;
  line-height: 1.45;
}
.ai-status {
  margin-top: 12px;
  font-weight: 900;
  color: #075985;
}
.ai-modal-card {
  background:
    radial-gradient(circle at top right, rgba(254, 243, 199, .85), transparent 45%),
    #ffffff;
}
@media (max-width: 520px) {
  .ai-card-top {
    flex-direction: column;
  }
  .ai-card-top .soft-btn {
    width: 100%;
  }
}
