:root {
  --primary: #3a6ea5;
  --primary-dark: #2a527c;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #20303f;
  --muted: #8a99a8;
  --border: #e1e7ee;
  --green: #4caf78;
  --orange: #e3a33e;
  --red: #d9534f;
  --whatsapp: #25d366;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  background: var(--primary);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 1.2rem;
  margin: 0;
}

.sync-status {
  font-size: 0.75rem;
  background: rgba(255,255,255,0.18);
  padding: 4px 10px;
  border-radius: 999px;
}

#app {
  flex: 1;
  padding: 12px 14px 90px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.tab { display: none; }
.tab.active { display: block; animation: fade .15s ease-in; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 1.1rem;
  margin: 6px 0 10px;
}

.section-title {
  font-size: 0.95rem;
  margin: 18px 4px 8px;
  color: var(--text);
}

.section-title.muted { color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.form { display: flex; flex-direction: column; gap: 8px; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  width: 100%;
}

textarea { resize: vertical; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #eef1f5;
  color: var(--text);
  flex: 1;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.whatsapp {
  background: var(--whatsapp);
  color: #fff;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e9eef4;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip.active {
  background: var(--primary);
  color: #fff;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.item.done { opacity: 0.55; }

.item .check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--primary);
}

.item.done .check {
  background: var(--primary);
  color: #fff;
}

.item .body { flex: 1; min-width: 0; }

.item .title {
  font-weight: 600;
  word-break: break-word;
}

.item.done .title { text-decoration: line-through; }

.item .meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #e9eef4;
  color: var(--text);
}

/* צבעי התגיות לכל אדם נקבעים ב-app.js (PERSON_COLORS) */

.item .due.overdue { color: var(--red); font-weight: 600; }
.item .due.today { color: var(--orange); font-weight: 600; }

.del {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
}

.edit {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.6;
}

.edit:hover { opacity: 1; }

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.form-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.btn.cancel-btn {
  background: #f0e8e8;
  color: var(--red);
  font-size: 0.9rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tabbtn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
}

.tabbtn span { font-size: 0.72rem; }

.tabbtn.active { color: var(--primary); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 16px;
}

/* ---- view toggle ---- */
.view-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.toggle-btn {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #eef1f5;
  color: var(--muted);
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---- calendar ---- */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title {
  font-size: 1rem;
  font-weight: 600;
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 14px;
}

.cal-day-header {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 0;
  font-weight: 600;
}

.cal-cell {
  background: var(--card);
  border-radius: 8px;
  padding: 5px 3px 4px;
  min-height: 46px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.1s;
}

.cal-cell:hover { border-color: var(--primary); }

.cal-cell.cal-today { background: #eef4ff; }

.cal-cell.cal-selected {
  border-color: var(--primary);
  background: #ddeaff;
}

.cal-num {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.cal-today .cal-num {
  color: var(--primary);
}

.cal-dots {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.cal-detail-header {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--primary);
}

/* ---------- login screen ---------- */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-logo { font-size: 3rem; }

.auth-error {
  color: var(--red);
  font-size: 0.9rem;
  margin: 0;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-row .hint { flex: 1; margin: 0; }
.account-row .btn { flex: 0 0 auto; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  max-width: 520px;
  margin: 0 auto;
  z-index: 70;
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

/* ---------- classes ---------- */

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tab-header h2 { margin: 0; }
.tab-header .btn { flex: 0 0 auto; }

.kid-card { padding: 4px 14px; }

.kid-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.kid-tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.kid-tag.small {
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.kid-card-head .hint { margin: 0; }

.class-row {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.class-when { flex: 0 0 auto; min-width: 84px; }
.class-what { flex: 1; min-width: 0; }

.class-days { font-weight: 700; }

.class-time,
.class-loc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.class-name {
  font-weight: 600;
  word-break: break-word;
}

.day-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.day-btn {
  border: none;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  padding: 8px 2px 6px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.day-btn.active {
  background: var(--primary);
  color: #fff;
}

.day-btn .cal-dots { margin-top: 0; min-height: 7px; }
/* ביום הנבחר הנקודות לבנות, כמו בעיצוב (הצבע של כל ילד נקבע inline) */
.day-btn.active .cal-dot { background: #fff !important; }

.day-class {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.day-class-time {
  flex: 0 0 auto;
  width: 48px;
  font-weight: 700;
  padding-top: 12px;
}

.day-class .item { flex: 1; cursor: pointer; }

.day-class .item .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.day-chips {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.day-chips .chip {
  text-align: center;
  font-size: 0.9rem;
  padding: 8px 0;
}

/* full-screen form */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sheet-close {
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}

.sheet-body {
  padding: 12px 14px calc(env(safe-area-inset-bottom) + 24px);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.version-line {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 4px 0 16px;
}

.version-line.usage-note { margin-bottom: 2px; }

/* ---------- home: members, invite, delete ---------- */

.auth-screen { overflow-y: auto; }
.auth-card { margin: auto 0; }
#homeScreen .auth-card { text-align: start; }
#homeScreen .auth-logo, #homeScreen h2, #homeScreen #homeScreenEmail { text-align: center; }

.home-members {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.home-members li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.home-members li:last-child { border-bottom: none; }
.home-members .email { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.home-members .role { color: var(--muted); font-size: 0.85rem; }
.home-members .btn { flex: 0 0 auto; padding: 6px 10px; font-size: 0.85rem; }

#inviteBox { margin-bottom: 12px; }
#inviteLink { direction: ltr; font-size: 0.85rem; margin-bottom: 8px; }

.danger-zone {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.btn:disabled { opacity: 0.5; cursor: default; }

#inviteBox > .btn,
#homeCard > .btn,
.danger-zone > .btn { width: 100%; margin-top: 8px; }

/* ---------- סנכרון ליומן ---------- */

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.card-head h3 { margin: 0; flex: 1; }

.badge-new {
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.house-help {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.house-help svg { width: 100%; height: 100%; display: block; }
.house-help .hh-house { fill: #e8eff7; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.house-help text { fill: var(--primary); font-size: 14px; font-weight: 700; font-family: inherit; }

#calendarWhoChips { margin-bottom: 8px; }
button.chip { font-family: inherit; color: var(--text); }
button.chip.active { color: #fff; }

.calendar-who-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}

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

.hint.warn { color: var(--orange); }

#calendarLinkBox .btn,
#calendarWhoBox .btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.calendar-google-hint { margin: 6px 0 4px; text-align: center; }
#calendarLinkInput { direction: ltr; font-size: 0.85rem; margin-top: 8px; }

.calendar-reset-line {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.calendar-reset-line .link-btn { font-size: 0.8rem; }
.calendar-reset-line .link-btn[data-armed] { color: var(--red); font-weight: 600; }

/* פופאפ בצורת בית: גג עם ארובה ויומן, קירות, ודלת שהיא הכפתור */
.intro-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(20, 32, 48, 0.6);
}

.intro-house {
  width: 100%;
  max-width: 350px;
  margin: auto;
  animation: intro-pop 0.22s ease-out;
}

@keyframes intro-pop {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.intro-roof { display: block; width: 100%; height: auto; margin-bottom: -1px; }
.intro-roof .roof { fill: var(--primary); stroke: var(--primary); stroke-width: 8; stroke-linejoin: round; }
.intro-roof .chimney { fill: var(--primary-dark); }
.intro-roof .chimney-cap { fill: var(--primary-dark); }
.intro-roof .cal-body { fill: #fff; }
.intro-roof .cal-head { fill: var(--orange); }
.intro-roof .cal-ring { fill: #fff; }
.intro-roof .cal-dot { fill: var(--primary); opacity: 0.55; }
.intro-roof .cal-dot.today { fill: var(--orange); opacity: 1; }

.intro-walls {
  position: relative;
  margin: 0 6%;
  padding: 18px 18px 0;
  background: var(--card);
  border: 4px solid var(--primary);
  border-top: none;
  border-radius: 0 0 8px 8px;
  text-align: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25);
}

.intro-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.intro-walls h2 {
  margin: 4px 26px 10px;
  color: var(--primary-dark);
  font-size: 1.2rem;
  line-height: 1.35;
  text-wrap: balance;
}

.intro-walls p { margin: 0 0 12px; line-height: 1.55; }

.intro-checks {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  text-align: start;
  display: inline-block;
}

.intro-checks li {
  position: relative;
  padding-inline-start: 26px;
  margin-bottom: 8px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.intro-checks li::before {
  content: '✓';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  color: var(--green);
  font-weight: 800;
}

/* הדלת: קשת למעלה, יושבת על רצפת הבית, עם ידית */
.intro-door {
  position: relative;
  display: block;
  width: 128px;
  min-height: 74px;
  margin: 14px auto 0;
  padding: 22px 10px 12px;
  border: none;
  border-radius: 64px 64px 0 0;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.intro-door::after {
  content: '';
  position: absolute;
  left: 14px;
  top: 58%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
}

.intro-door:hover, .intro-door:focus-visible { background: var(--primary-dark); }

/* ---------- shopping: קטגוריות ---------- */

.cat-title {
  margin: 14px 2px 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

#openShopping .cat-title:first-child { margin-top: 4px; }

.tag.cat-tag {
  border: none;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 32, 48, 0.5);
}

.picker-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
}

.picker-card h3 { margin: 0 0 4px; padding-inline-end: 40px; font-size: 1rem; }
.picker-card .hint { margin: 0 0 12px; }

.picker-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #e9eef4;
  font-size: 1rem;
  cursor: pointer;
}

.cat-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cat-choices .chip {
  font: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  text-align: start;
  white-space: normal;
}

/* ---------- מי גר בבית? ---------- */

.household-add { margin-bottom: 8px; }
.household-add input { flex: 1; min-width: 0; margin: 0; }
.household-add .btn { flex: 0 0 auto; }

.household-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.household-list .person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.person-name {
  flex: 1 1 100%;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.me-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.seg button, .phone-toggle, .person-del {
  font: inherit;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  background: #e9eef4;
  color: var(--text);
}

.seg button.on { background: var(--primary); color: #fff; }
.phone-toggle { border-radius: 999px; }
.phone-toggle.on { background: #d8f5d0; color: #2f6b2a; }

.person-del {
  margin-inline-start: auto;
  background: none;
  color: var(--muted);
  padding: 6px 8px;
}

.invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.invite-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.invite-list li:last-child { border-bottom: none; }

.invite-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.invite-name { font-weight: 600; }
.invite-status { margin: 0; }
.invite-actions { margin-top: 8px; align-items: center; }
.invite-actions .btn { flex: 0 0 auto; text-decoration: none; }

#householdDoneBtn { width: 100%; }
#householdSaveBtn { width: 100%; }
.person-lock { font-size: 0.8rem; }
