:root {
  --bg: #fdf8f3;
  --card: #ffffff;
  --text: #3a2e2a;
  --muted: #8a7a72;
  --primary: #e8735a;
  --primary-dark: #cf5d45;
  --soft: #fbe6dd;
  --line: #eadfd7;
  --danger: #c0392b;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Heebo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.screen { display: none; padding: 34px 16px 48px; max-width: 640px; margin: 0 auto; min-height: 100vh; }
.screen.active { display: block; }
.screen.center.active { display: flex; align-items: center; justify-content: center; }

.card { background: var(--card); border-radius: var(--radius); padding: 28px 22px; box-shadow: 0 4px 24px rgba(120, 70, 40, .08); text-align: center; }
.narrow { width: 100%; max-width: 420px; }
.logo { font-size: 56px; }
h1 { margin: 4px 0; font-size: 28px; font-weight: 800; }
h2 { margin: 0; font-size: 22px; }
.sub { color: var(--muted); margin: 4px 0 18px; }
.section-title { margin: 28px 0 12px; }

label { display: block; text-align: right; font-weight: 500; margin: 16px 0 6px; }
input, textarea {
  width: 100%; font: inherit; padding: 14px; border: 2px solid var(--line);
  border-radius: 14px; background: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
.code-input { text-align: center; font-size: 28px; letter-spacing: 6px; direction: ltr; }

.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 14px; cursor: pointer;
  padding: 12px 18px; background: var(--soft); color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.soft { background: var(--soft); }
.btn.outline { background: transparent; border: 2px dashed var(--primary); color: var(--primary-dark); }
.btn.danger { background: #fde8e6; color: var(--danger); }
.btn.link { background: none; color: var(--muted); text-decoration: underline; font-weight: 400; }
.btn.big { width: 100%; padding: 16px; margin-top: 14px; font-size: 19px; }
.btn.huge { width: 100%; padding: 26px 16px; font-size: 22px; border-radius: 20px; box-shadow: 0 6px 18px rgba(232, 115, 90, .35); }
.btn.small { padding: 8px 14px; font-size: 16px; white-space: nowrap; }

.icon-btn { background: none; border: 0; font-size: 26px; padding: 8px; cursor: pointer; color: var(--text); min-width: 44px; }
.icon-btn.light { color: #fff; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.actions { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.hint {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: #fff7e6; border: 1px solid #f3dfb5; border-radius: 14px; padding: 12px 14px; margin-top: 14px; font-size: 16px;
}

.children { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.child-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 12px; text-align: center; cursor: pointer;
  box-shadow: 0 2px 12px rgba(120, 70, 40, .07); border: 0; font: inherit; color: inherit;
}
.child-card .face { font-size: 40px; }
.child-card .name { font-weight: 700; font-size: 20px; }
.child-card .age { color: var(--muted); font-size: 15px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

/* דף ילד */
.month { margin: 22px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.month b { font-size: 19px; }
.month span { color: var(--muted); font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; background: var(--soft); border-radius: 8px; overflow: hidden; cursor: pointer; border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.55); color: #fff; border-radius: 8px; font-size: 13px; padding: 1px 6px; }
.tile .star { position: absolute; top: 4px; right: 4px; font-size: 16px; }
.tile.video-tile { display: flex; align-items: center; justify-content: center; font-size: 34px; }
.note-card {
  grid-column: 1 / -1; background: #fff; border-radius: 12px; padding: 12px 14px; text-align: right; cursor: pointer;
  border: 0; font: inherit; color: inherit; border-right: 4px solid var(--primary);
}

/* חלונות */
.sheet { position: fixed; inset: 0; background: rgba(40, 25, 20, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet-body {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.previews { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 12px 0 8px; }
.previews .p { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 22px; position: relative; }
.previews .p img { width: 100%; height: 100%; object-fit: cover; }
.previews .p .x { position: absolute; top: 2px; left: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 24px; height: 24px; font-size: 14px; cursor: pointer; }
.previews .more { font-weight: 700; font-size: 18px; color: var(--primary-dark); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; cursor: pointer; color: var(--text); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.all { border-style: dashed; }

.progress { margin-top: 16px; }
.progress .bar { height: 12px; background: var(--soft); border-radius: 8px; overflow: hidden; }
.progress #upload-bar { height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.progress span { display: block; text-align: center; margin-top: 6px; color: var(--muted); }

/* צפייה */
.viewer { position: fixed; inset: 0; background: #1b1513; z-index: 30; display: flex; flex-direction: column; overflow-y: auto; }
.viewer-top { display: flex; justify-content: space-between; padding: 8px; }
.viewer-media { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 40vh; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 60vh; }
.viewer-media .note-big { color: #fff; font-size: 22px; padding: 24px; white-space: pre-wrap; }
.viewer-panel { background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; padding: 14px; }

.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #3a2e2a; color: #fff; padding: 12px 20px; border-radius: 14px; z-index: 50; max-width: 90vw; text-align: center;
}

/* מיון תמונות לפי ילד */
.muted-small { color: var(--muted); font-size: 15px; margin: 14px 0 8px; text-align: right; }
.sub-tight { color: var(--muted); margin: 6px 0 12px; }
.chip .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-inline-end: 6px; vertical-align: -1px; }
.sort-status { font-weight: 700; margin: 8px 0; }
.sort-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 3px solid transparent; padding: 0; background: var(--soft); cursor: pointer; }
.stile.none { border-color: #e0a030; }
.stile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stile .vid { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 30px; }
.sbs { position: absolute; bottom: 4px; right: 4px; display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.sb { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-style: normal; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.sticky-bottom { position: sticky; bottom: 0; background: var(--bg); padding-bottom: 4px; }

/* חיפוש ובחירה בדף ילד */
.search { margin-bottom: 8px; }
.legal { color: var(--muted); font-size: 14px; text-align: center; margin: 14px 0 0; }
.legal a { color: var(--muted); }
.tile.sel { outline: 4px solid var(--primary); outline-offset: -4px; }
.tile .tick { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.sel-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); z-index: 15; box-shadow: 0 -4px 12px rgba(0,0,0,.1); }
.sel-bar .chips { margin-top: 6px; align-items: center; }
.sel-bar .lbl { color: var(--muted); font-size: 15px; }
body.selecting .screen { padding-bottom: 200px; }

/* כפתור צף "הוספת תמונות" בדף של ילד */
#scr-child { padding-bottom: 110px; }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 14;
  font: inherit; font-weight: 700; font-size: 19px; color: #fff;
  background: var(--primary); border: 0; border-radius: 999px;
  padding: 16px 28px; white-space: nowrap; cursor: pointer;
  box-shadow: 0 6px 18px rgba(232, 115, 90, .45);
}
.fab:active { transform: translateX(-50%) scale(.97); background: var(--primary-dark); }
#scr-child:not(.active) .fab, body.selecting .fab { display: none; }

/* אירועים, טיולים ומדידות */
select { width: 100%; font: inherit; padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--text); }
.tools { margin: 4px 0 12px; }
.form-card { text-align: start; padding: 8px 18px 20px; }
.charts h3 { margin: 18px 0 4px; }
.chart-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.mrow { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 12px; padding: 10px 14px; margin-top: 8px; }
#scr-albums .row, #scr-album .row { margin: 4px 0 14px; }

/* סרט השנה וספר */
.viewer-inline video { width: 100%; border-radius: 14px; background: #000; }
.chk { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 12px 0 0; }
.chk input { width: auto; }
.bk-page { background: #fff; border-radius: 14px; padding: 16px; margin-top: 14px; box-shadow: 0 2px 12px rgba(120, 70, 40, .07); }
.bk-cover { text-align: center; padding: 60px 16px; }
.bk-cover h2 { font-size: 40px; margin: 0; }
.bk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.bk-grid figure { margin: 0; }
.bk-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.bk-grid figcaption { color: var(--muted); font-size: 14px; margin-top: 4px; }
@media print {
  body { background: #fff; }
  .no-print, .toast, .icon-btn, .sel-bar { display: none !important; }
  .screen { padding: 0; min-height: 0; }
  .bk-page { box-shadow: none; border-radius: 0; margin: 0; padding: 12mm; page-break-after: always; break-after: page; break-inside: avoid; }
  .bk-cover { padding-top: 90mm; }
}

/* החודש החינם */
.hint.trial { background: #eef8f1; border-color: #cfe8d6; }
.hint.trial.ending { background: #fff7e6; border-color: #f3dfb5; }

.viewer-age { margin: 6px 0 0; color: var(--primary-dark); font-weight: 700; }

/* כרטיסי ילדים: תמונה, מונה ועריכה */
.child-wrap { position: relative; }
.child-wrap .child-card { width: 100%; }
.edit-child { position: absolute; top: 6px; left: 6px; background: #fff; border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; font-size: 16px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.child-card .face { display: flex; justify-content: center; }
.child-card .face img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.child-card .count { color: var(--primary-dark); font-size: 15px; font-weight: 700; margin-top: 2px; }
.avatar-edit { display: flex; align-items: center; gap: 14px; margin: 10px 0 0; }
.avatar-big { width: 84px; height: 84px; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 42px; overflow: hidden; flex: none; }
.avatar-big img { width: 100%; height: 100%; object-fit: cover; }

.otd { background: var(--soft, #ffe3ea); border-radius: 16px; padding: 12px; margin: 14px 0 6px; }
.otd > b { font-size: 18px; }
.otd-row { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; }
.otd-item { flex: 0 0 96px; text-align: center; font-size: 13px; color: var(--muted); }
.otd-item .tile { width: 96px; height: 96px; }

/* צופה בלבד (ילד ששיתפו איתי) */
body.readonly #btn-child-add, body.readonly #btn-edit-child, body.readonly #btn-share, body.readonly #btn-select, body.readonly #btn-albums, body.readonly #btn-measure, body.readonly #btn-special, body.readonly #viewer-actions, body.readonly #viewer-kids-wrap, body.readonly #viewer-album-row { display: none !important; }
.shared-tag { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--primary-dark); font-weight: 700; }
.home-sub-title { margin: 22px 0 8px; font-size: 18px; }
#share-link { direction: ltr; text-align: left; margin: 12px 0; }
.children .home-sub-title, .children .empty { grid-column: 1 / -1; }

/* דף הילד: צפוף יותר, כפתור הוספה מתחת לחיפוש */
#scr-child .top { margin-bottom: 6px; }
#scr-child .tools { gap: 6px; margin: 2px 0 8px; }
#scr-child .tools .chip { padding: 6px 12px; font-size: 15px; }
#scr-child .month { margin: 14px 0 6px; }
.child-add { margin: 4px 0 8px; padding: 14px; }
body.selecting #btn-child-add { display: none; }
.vm-h { font-size: 1.15rem; margin: 0 0 4px; }
.vm-badge { background: #fff3d9; border-radius: 10px; padding: 1px 8px; font-size: .8rem; font-weight: 700; vertical-align: 2px; }
#vmenu-albums .btn { margin: 6px 0; text-align: right; }

/* המילה "אין" בשאלת התאריך: אדום, מהבהב וגדול יותר */
.blink-no { color: #e0192b; font-weight: 800; font-size: 1.3em; animation: blinkno 1s ease-in-out infinite; }
@keyframes blinkno { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .blink-no { animation: none; } }

/* סרטון עם הערה: ההערה מופיעה בתוך הריבוע, כדי שיידעו איזה סרטון זה */
.tile.video-tile { flex-direction: column; gap: 2px; padding: 6px; text-align: center; }
.tile.video-tile .vicon { font-size: 34px; line-height: 1; }
.tile.video-tile.has-note .vicon { font-size: 24px; }
.tile.video-tile .vnote { font-size: 12px; line-height: 1.25; font-weight: 600; color: var(--text); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

/* שם האתר בדף הבית: גדול ובאמצע */
#scr-home .top { position: relative; justify-content: center; }
#scr-home .top h1 { font-size: 31px; text-align: center; margin: 6px 0; padding: 0 44px; white-space: nowrap; }
#scr-home .top .icon-btn { position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%); }

/* כפתור קטן בפינה: חזרה לדף הנחיתה */
.to-landing { position: fixed; top: 6px; left: 8px; z-index: 40; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--card); color: var(--primary); border: 1px solid var(--primary); text-decoration: none; opacity: .9; }
body.selecting .to-landing { display: none; }

/* חץ החזרה: גדול, מודגש וצבעוני */
.icon-btn[aria-label="חזרה"] { font-size: 34px; font-weight: 900; line-height: 1; color: #fff; background: var(--primary); border-radius: 50%; width: 46px; height: 46px; min-width: 46px; padding: 0; display: inline-flex; align-items: center; justify-content: center; -webkit-text-stroke: 1.5px #fff; }

.btn.danger-link { color: var(--danger); font-size: 14px; opacity: .85; }

/* תמונה בלי תאריך צילום: מסגרת ותווית אדומות */
.previews .p.nodate { outline: 3px solid #e0192b; outline-offset: -3px; }
.previews .p .nd-badge { position: absolute; bottom: 0; inset-inline: 0; background: #e0192b; color: #fff; font-size: 10px; font-weight: 800; line-height: 1.5; text-align: center; padding: 1px 0; }
.previews .p.dated { outline: 3px solid #2e9e5b; outline-offset: -3px; }
.previews .p.dated .nd-badge { background: #2e9e5b; }

/* כפתורי עזרה בפינה: לדף הנחיתה וסימן שאלה */
.top-actions { position: fixed; top: 6px; left: 8px; z-index: 15; display: flex; gap: 6px; align-items: center; direction: ltr; }
.top-actions .to-landing { position: static; }
.to-ask { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--primary); background: var(--primary); color: #fff; font-weight: 900; font-size: 18px; line-height: 1; cursor: pointer; padding: 0; box-shadow: 0 3px 8px rgba(0,0,0,.18); }
body.selecting .top-actions { display: none; }

a.btn { display: block; text-align: center; text-decoration: none; }
.btn .btn-sub { display: block; font-size: 14px; font-weight: 600; opacity: .85; margin-top: 4px; direction: rtl; }

/* כפתור "למעלה": קבוע בצד, מופיע אחרי גלילה */
.to-top { position: fixed; left: 14px; bottom: 90px; z-index: 15; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 24px; font-weight: 900; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.28); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; padding: 0; }
.to-top span { font-size: 10px; font-weight: 700; margin-top: -2px; }
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
body.selecting .to-top { bottom: 230px; }
@media print { .to-top { display: none !important; } }
.chip.danger-chip { background: #fde8e6; color: var(--danger); border-color: #f3bdb8; font-weight: 800; }

/* עיגול קטן בכל תמונה לסימון */
.tile .selcircle { position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid #fff; background: rgba(0,0,0,.22); box-shadow: 0 1px 5px rgba(0,0,0,.35); color: #fff; font-weight: 900; font-size: 16px; display: flex; align-items: center; justify-content: center; z-index: 2; }
.tile .selcircle.on { background: var(--primary); }
body.readonly .selcircle { display: none; }

.film-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.film-row:first-child { border-top: 0; }
.film-info { flex: 1 1 140px; display: flex; flex-direction: column; line-height: 1.3; }
.film-info span { color: var(--muted); font-size: 13px; }

/* ===== English (left-to-right) ===== */
html[dir="ltr"] label, html[dir="ltr"] .muted-small, html[dir="ltr"] #vmenu-albums .btn { text-align: left; }
html[dir="ltr"] .note-card { text-align: left; border-right: 0; border-left: 4px solid var(--primary); }
html[dir="ltr"] .btn .btn-sub { direction: ltr; }


/* כרטיס "הוספת אדם" / "הוספת טיול": באותו גודל של שאר הכרטיסים */
.child-card.add-card { background: transparent; border: 2px dashed var(--primary); box-shadow: none; color: var(--primary-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 190px; width: 100%; }
.child-card.add-card .face { font-size: 64px; line-height: 1; font-weight: 300; }

#upload-video-names .vname-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
#upload-video-names .vname-row input { flex: 1; }
html[dir="ltr"] #upload-video-names label { text-align: left; }
