:root {
  color-scheme: light;
  --bg: #eef1f6;
  --card: #fff;
  --ink: #1f2937;
  --muted: #8a94a6;
  --line: #e6e9ef;
  --navy: #1e293b;
  --today: #e2b33c;
  --today-bg: #fff6d8;
  --accent: #2563eb;
  --danger: #c2410c;
  --radius: 14px;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

/* Person colours: background, border, ink */
.c-blue   { --c-bg: #dbe7fd; --c-bd: #9fbdf2; --c-ink: #1e3a8a; }
.c-pink   { --c-bg: #f8d9e6; --c-bd: #e09ab8; --c-ink: #7a1f45; }
.c-green  { --c-bg: #d6f0e3; --c-bd: #84c9a6; --c-ink: #14532d; }
.c-purple { --c-bg: #e6ddf7; --c-bd: #ad94dd; --c-ink: #3b2370; }
.c-orange { --c-bg: #ffe5cc; --c-bd: #f0ab6c; --c-ink: #7c3a0a; }
.c-teal   { --c-bg: #cff0f0; --c-bd: #6cc3c3; --c-ink: #134e4a; }
.c-yellow { --c-bg: #fff0b3; --c-bd: #dfc04e; --c-ink: #6b3e0f; }
.c-red    { --c-bg: #fddad6; --c-bd: #e98e84; --c-ink: #7f1d1d; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.35;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.page { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; }

/* ── Header ─────────────────────────────────────────────── */
.top { text-align: center; margin-bottom: 10px; }
.title { margin: 0 0 8px; font-size: clamp(24px, 4vw, 32px); font-weight: 800; letter-spacing: -.5px; }
.title button { background: none; border: 0; padding: 2px 8px; border-radius: 10px; font-weight: inherit; }
.title button:hover { background: #fff; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.pill {
  display: inline-block; min-width: 52px; padding: 3px 10px; border-radius: 999px;
  background: var(--c-bg); color: var(--c-ink); font-size: 13px; font-weight: 700; text-align: center;
  white-space: nowrap;
}

.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 10px; }
.weeknav .label { text-align: center; font-weight: 700; }
.weeknav .label small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.weeknav .label button { margin-top: 2px; font-size: 13px; background: none; border: 0; color: var(--accent); text-decoration: underline; }

.toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 15px;
  transition: transform .06s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.red { color: var(--danger); }
.btn.big { min-height: 52px; font-size: 17px; padding: 10px 22px; }

/* ── Week grid ──────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.day {
  display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05); overflow: hidden;
}
.day.today { border: 2px solid var(--today); }
.day.today .day-head { background: linear-gradient(to bottom, var(--today-bg), #fff); }
.day-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.day-head h2 { margin: 0; font-size: 22px; font-weight: 800; flex: 1; }
.day-head .date { font-size: 13px; color: var(--muted); font-weight: 500; }
.badge { background: #fde68a; color: #78350f; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.plus {
  width: 30px; height: 30px; border-radius: 50%; border: 1px dashed #c3cad6; background: #fff;
  font-size: 20px; line-height: 1; color: var(--muted); display: grid; place-items: center; padding: 0;
}
.plus:hover { border-style: solid; color: var(--accent); border-color: var(--accent); }

.sec { padding: 10px 12px 12px; }
.sec + .sec { border-top: 1px solid var(--line); }
.sec-label { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 10px 0; }

.pickup { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.time {
  background: var(--navy); color: #fff; border: 0; border-radius: 9px;
  font-size: 21px; font-weight: 800; letter-spacing: .5px; font-variant-numeric: tabular-nums;
  padding: 6px 10px; min-width: 78px; text-align: center; position: relative;
}
.time.off { background: #fff; color: var(--ink); border: 2px dashed #c3cad6; font-size: 16px; padding: 8px 10px; }
.after { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; position: relative;
  background: var(--c-bg); border: 1.5px solid var(--c-bd); color: var(--c-ink);
  border-radius: 9px; padding: 5px 9px; font-size: 14px; font-weight: 700; text-align: start;
}
.chip .emoji { font-size: 18px; line-height: 1; }
/* next to a pickup time: the name, and under it the activity's own hours, quieter */
.chip .stack { display: flex; flex-direction: column; line-height: 1.2; }
.chip .when { font-size: 12px; font-weight: 500; opacity: .8; font-variant-numeric: tabular-nums; }
.later { display: grid; gap: 8px; }
.chip.full { width: 100%; padding: 7px 10px; gap: 8px; }
/* title, then who it's for, on one line; the name gives way first when space runs out */
.chip.full .what { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.chip.full .name { flex: 0 1 auto; min-width: 2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.full .who { flex: 0 100 auto; min-width: 0; font-size: 12px; font-weight: 500; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.full .t { margin-inline-start: auto; flex: none; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-bd); display: inline-block; }

.chip.cancelled { opacity: .55; background: #fff; border-style: dashed; }
.chip.cancelled .name { text-decoration: line-through; }

/* a one-off change for this week only */
.changed::after {
  content: ''; position: absolute; top: -4px; inset-inline-end: -4px;
  width: 11px; height: 11px; border-radius: 50%; background: #f59e0b; border: 2px solid #fff;
}

button.time:hover, button.chip:hover { filter: brightness(.96); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }

.fab { display: none; }

/* example boards: a way out to a real one */
.demo-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 820px; margin: 0 auto 16px; padding: 10px 12px 10px 16px;
  background: #fff8db; border: 1.5px solid #f3d36b; border-radius: var(--radius);
}
.demo-cta p { margin: 0; }
.demo-cta span { color: #6b5a1e; }

/* the board's link isn't kept anywhere yet */
.keep-nudge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 820px; margin: 0 auto 16px; padding: 10px 12px 10px 16px;
  background: #eaf1ff; border: 1.5px solid #a9c3f5; border-radius: var(--radius);
}
.keep-nudge p { margin: 0; }
.keep-nudge span { color: #3b4a66; }
.keep-nudge .btn { flex: none; }

/* opened inside Instagram / Facebook…: this browser forgets */
.inapp {
  position: sticky; top: 0; z-index: 7; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  padding: 10px 14px; background: #fff1e6; border-bottom: 1.5px solid #f0ab6c; font-size: 14px;
}
.inapp p { margin: 0; flex: 1 1 260px; max-width: 640px; }
.inapp-actions { display: flex; align-items: center; gap: 8px; }
.inapp .btn { min-height: 36px; font-size: 14px; text-decoration: none; }

/* keep-the-board sheet */
.keep-lead { margin: 0 0 12px; }
.keep-options { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.keep-opt {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px;
  padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius);
}
.keep-opt .ico { font-size: 28px; }
.keep-opt p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.keep-opt p b { color: var(--ink); }
.keep-opt .btn { white-space: nowrap; }
.keep-opt.done { border-color: #84c9a6; background: #f0faf4; }
.keep-opt .rec { display: inline-block; vertical-align: 2px; margin-inline-start: 4px; padding: 1px 8px; border-radius: 99px; background: #e3f4ea; color: #1f7a4d; font-size: 12px; font-weight: 700; }
.sheet-section { margin: 18px 0 8px; font-size: 15px; color: var(--muted); font-weight: 700; }
.keep-lead + .sheet-section { margin-top: 0; }

.note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.foot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ── Sheets (dialogs) ───────────────────────────────────── */
.sheet {
  border: 0; padding: 0; border-radius: 18px; width: min(540px, 100vw - 24px); max-width: 100vw;
  max-height: min(92vh, 900px); box-shadow: 0 20px 50px rgba(15, 23, 42, .25); background: #fff;
}
.sheet::backdrop { background: rgba(15, 23, 42, .45); }
.sheet-head {
  position: sticky; top: 0; z-index: 1; background: #fff; display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.sheet-head h3 { margin: 0; font-size: 19px; flex: 1; }
.x { border: 0; background: #f1f4f8; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; }
.sheet-body { padding: 14px 18px 20px; }
.sheet.busy { pointer-events: none; opacity: .7; }

.q { font-weight: 700; margin: 14px 0 8px; }
.q:first-child { margin-top: 0; }
.q small { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.error { color: var(--danger); font-weight: 600; min-height: 1.3em; margin: 8px 0 0; }

input[type=text], input:not([type]), input[type=time] {
  width: 100%; font-size: 16px; padding: 10px 12px; border: 1.5px solid #d6dbe4; border-radius: 11px; background: #fff;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[type=time] { direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid #d6dbe4; background: #fff;
  font-weight: 700; font-size: 15px;
}
.toggle[class*=c-] { border-color: var(--c-bd); color: var(--c-ink); }
.toggle[aria-pressed=true] { background: var(--c-bg, #dbe7fd); border-color: var(--c-ink, var(--accent)); }
.toggle[aria-pressed=true]::before { content: '✓ '; }
.days .toggle { min-width: 46px; padding: 6px 0; }

.templates { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl { border: 1px solid var(--line); background: #f7f9fc; border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.tpl:hover { background: #eef3fb; }

.what { display: flex; gap: 8px; align-items: center; }
.emoji-big { font-size: 28px; width: 44px; text-align: center; flex: none; }
.emojis { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; }
.em { border: 0; background: none; font-size: 21px; width: 38px; height: 38px; border-radius: 10px; padding: 0; }
.em[aria-pressed=true] { background: #dbe7fd; box-shadow: inset 0 0 0 2px var(--accent); }
.em:hover { background: #f1f4f8; }

.times { display: flex; gap: 12px; }
.times label { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }

.seg { display: flex; gap: 0; margin-top: 14px; border: 1.5px solid #d6dbe4; border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: #fff; padding: 10px 6px; font-weight: 600; font-size: 14px; }
.seg button + button { border-inline-start: 1.5px solid #d6dbe4; }
.seg button[aria-pressed=true] { background: #dbe7fd; color: #1e3a8a; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1 1 180px; }
.actions.secondary { border-top: 1px solid var(--line); padding-top: 12px; }
.actions.secondary .btn { font-size: 14px; min-height: 38px; }

/* member editor */
.mrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--c-bd); background: var(--c-bg); flex: none; padding: 0; }
.rm { border: 0; background: none; color: var(--muted); font-size: 18px; width: 34px; height: 34px; border-radius: 50%; flex: none; }
.rm:hover { background: #fdecea; color: var(--danger); }
.add-row { border: 1.5px dashed #c3cad6; background: none; border-radius: 11px; padding: 8px 14px; color: var(--muted); font-weight: 600; width: 100%; }
.add-row:hover { color: var(--accent); border-color: var(--accent); }

/* school grid */
.school-grid { width: 100%; border-collapse: separate; border-spacing: 6px 6px; }
.school-grid th { font-weight: 700; text-align: start; font-size: 15px; white-space: nowrap; }
.school-grid thead th { text-align: center; }
.school-grid input { padding: 8px 4px; }

/* share */
.share-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.share-item:last-child { border-bottom: 0; }
.share-item h5 { margin: 0 0 2px; font-size: 16px; }
.share-item p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.copy-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-actions .btn { flex: 1 1 auto; text-align: center; text-decoration: none; }
.copy-actions .btn.ghost { flex: none; }

/* print / image sheet */
.poster-preview {
  margin: 14px 0 4px; min-height: 160px; display: grid; place-items: center;
  background: #f1f4f8; border-radius: 12px; padding: 10px;
}
.poster-preview canvas { display: block; width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 10px rgba(15, 23, 42, .15); }
.poster-preview.portrait canvas { width: auto; max-width: 100%; max-height: 52vh; }
.poster-preview.loading canvas { opacity: .5; }
#print-poster { display: none; }

.toast {
  position: fixed; inset-inline: 0; bottom: 24px; margin: 0 auto; width: max-content; max-width: calc(100vw - 32px);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

/* ── Landing & wizard ───────────────────────────────────── */
.hero { text-align: center; max-width: 720px; margin: 24px auto 0; }
.hero h1 { font-size: clamp(32px, 6vw, 48px); margin: 0 0 8px; font-weight: 800; letter-spacing: -1px; }
.hero .lead { font-size: 19px; color: #475569; margin: 0 auto 22px; max-width: 560px; }
.hero .ctas { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hero .foot { margin-top: 12px; }
.points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 900px; margin: 36px auto 0; }

/* the sample board, clearly framed as an example */
.example { max-width: 820px; margin: 56px auto 0; }
.example-head { text-align: center; margin-bottom: 14px; }
.example-head h2 { margin: 6px 0 4px; font-size: 24px; }
.example-head p { margin: 0 auto; max-width: 520px; color: #64748b; font-size: 14px; }
.example-tag {
  display: inline-block; background: #fde68a; color: #78350f; font-weight: 700; font-size: 12px;
  padding: 3px 12px; border-radius: 999px; letter-spacing: .3px;
}
.preview {
  pointer-events: none; padding: 16px; border: 2px dashed #c3cad6; border-radius: 20px;
  background: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(148, 163, 184, .06) 14px 28px);
}
.preview .legend { margin-bottom: 10px; }
.preview .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* boards opened in this browser */
.my-boards { max-width: 640px; margin: 8px auto 28px; }
.my-boards h2 { font-size: 20px; margin: 0 0 10px; }
.my-boards ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.my-boards li { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px 4px 4px; }
.my-boards li:hover { box-shadow: 0 2px 10px rgba(15, 23, 42, .07); }
.board-link { flex: 1; min-width: 0; display: grid; gap: 6px; padding: 10px 12px; color: inherit; text-decoration: none; }
.board-link b { font-size: 17px; }
.board-link .who { display: flex; flex-wrap: wrap; gap: 4px; }
.board-link .pill { min-width: 0; font-size: 12px; padding: 2px 9px; }
.view-tag { font-size: 12px; color: var(--muted); align-self: center; }
.my-boards .hint { margin-top: 8px; }
.point { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; }
.point b { display: block; font-size: 16px; margin: 6px 0 4px; }
.point span { color: #64748b; font-size: 14px; }
.point .ico { font-size: 26px; }

.wizard { max-width: 560px; margin: 24px auto; background: #fff; border-radius: 20px; border: 1px solid var(--line); padding: 22px; box-shadow: 0 6px 24px rgba(15, 23, 42, .06); }
.wizard .step { color: var(--muted); font-size: 13px; font-weight: 600; }
.wizard h2 { margin: 4px 0 4px; font-size: 26px; }
.wizard .sub { color: #64748b; margin: 0 0 16px; }

.center-msg { text-align: center; margin: 80px auto; max-width: 420px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .page { padding: 12px 12px 32px; }
  .grid, .preview .grid { grid-template-columns: minmax(0, 1fr); }
  .points { grid-template-columns: 1fr; }
  .toolbar .btn { flex: 1 1 calc(50% - 8px); }
  .toolbar .btn.primary { flex-basis: 100%; }
  .weeknav .btn { padding: 8px 10px; font-size: 14px; }
  /* on a phone the way out stays on screen */
  .demo-cta {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 6; margin: 0; border-radius: 16px 16px 0 0;
    border-width: 1.5px 0 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(15, 23, 42, .12); flex-wrap: nowrap;
  }
  .demo-cta span { display: none; }
  .keep-nudge span { display: none; }
  .keep-opt { grid-template-columns: auto 1fr; }
  .keep-opt .btn { grid-column: 1 / -1; }
  .demo-cta .btn { flex: none; }
  .is-demo { padding-bottom: 96px; }
  .is-demo .fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .fab {
    display: grid; place-items: center; position: fixed; inset-inline-end: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
    width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
    font-size: 30px; box-shadow: 0 8px 20px rgba(37, 99, 235, .4); z-index: 5;
  }
  .sheet { width: 100vw; margin: auto auto 0; border-radius: 18px 18px 0 0; max-height: 94vh; }
}

/* ── Print: one A4 page for the fridge ──────────────────── */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  /* "🖨️ הדפסה" prints only the drawn image (see printImage in app.js) */
  body.printing-poster > :not(#print-poster) { display: none !important; }
  body.printing-poster #print-poster { display: block; }
  #print-poster img { display: block; margin: 0 auto; max-width: 100%; }
  #print-poster.landscape img { max-height: 198mm; }
  #print-poster.portrait img { max-height: 285mm; }
  body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page { max-width: none; padding: 0; zoom: .74; }
  .top { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 0; }
  .weeknav { margin: 2px 0 8px; }
  .weeknav .label { display: flex; gap: 8px; align-items: baseline; }
  .weeknav .label small { display: inline; }
  /* the printout hangs all week, so no "today" */
  .day.today { border: 1px solid var(--line); }
  .day.today .day-head { background: none; }
  .badge { display: none; }
  .no-print, .demo-cta, .keep-nudge, .inapp, .fab, .toolbar, .weeknav .btn, .weeknav .label button, .foot, .plus { display: none !important; }
  .weeknav { justify-content: center; margin: 4px 0 8px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px; }
  .day { box-shadow: none; break-inside: avoid; }
  .title { font-size: 28px; margin: 0; }
  .time { font-size: 19px; }
  .note { margin-top: 8px; }
}
