/* מי מקדימה? — design #1 "שמש וצבעים" (designs/1.html): a butter-yellow dotted page with a
   sun in the corner, chunky "3D" buttons that sit on a solid bottom edge, Rubik + Secular One.
   RTL, phone-first, light only (a dark-mode phone still sees the same sunny design).
   Each kid wears their own colour, set per element by app.js:
     --kid (the colour) · --kid-d (a deeper shade for edges) · --kid-soft (a pale tint) · --kid-ink (text on --kid) */

:root {
  --bg: #fff6d6;
  --dots: #f0e2b4;
  --sunball: #ffe07a;
  --card: #ffffff;
  --cream: #fffbea;
  --soft: #f3eedc;
  --ink: #2b2344;
  --muted: #685d86;   /* >= 5:1 on the page, cards and kid tints, so small grey text stays readable */
  --line: #eadfbf;
  --line-2: #dccb98;
  --shadow: #e3d6ae;
  --sun: #ffc83d;
  --sun-d: #e5a800;
  --sun-ink: #6b5300;
  --save: #ff6b57;
  --save-d: #d6452f;
  --danger: #d6452f;
  --danger-d: #a8321f;
  --danger-soft: #ffe4de;
  --danger-line: #f6c9bf;
  --ok: #15803d;
  --tab: #766b94;
  --tab-on: #c2410c;
  --tab-pill: #ffe7cf;
  --radius: 22px;
  --radius-s: 16px;
  --tab-h: 66px;
  --maxw: 520px;
  --font: "Rubik", "Assistant", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Secular One", "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: only light;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1.6px, transparent 1.7px);
  background-size: 24px 24px;
}
body {
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom));
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
b { font-weight: 700; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------------- header (with the sun) ---------------- */
.app-header {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: calc(54px + env(safe-area-inset-top));
  padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app-header::before {           /* the sun peeking in at the top corner */
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  width: 176px; height: 176px; border-radius: 50%;
  background: var(--sunball);
  top: calc(-118px + env(safe-area-inset-top)); right: -57px;
}
.app-title { font-family: var(--display); font-size: 23px; line-height: 1.2; white-space: nowrap; }
.me-chip {
  font-size: 14px; font-weight: 500; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%;
}

.offline {
  position: sticky; top: 8px; z-index: 40;
  width: calc(100% - 32px); max-width: calc(var(--maxw) - 32px);
  margin: 0 auto 12px;
  background: var(--danger-soft); color: var(--danger-d);
  border: 2.5px solid var(--danger-line); border-radius: 16px;
  box-shadow: 0 4px 0 var(--danger-line);
  text-align: center; font-weight: 700; font-size: 14.5px; line-height: 1.35; text-wrap: balance;
  padding: 8px 12px;
}

/* ---------------- layout ---------------- */
#main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.card {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--shadow);
  padding: 16px;
  margin-bottom: 18px;
}
.card.soft { background: var(--cream); }
.card-title { font-family: var(--display); font-weight: 400; font-size: 21px; line-height: 1.25; margin-bottom: 6px; }
.page-title { font-family: var(--display); font-weight: 400; font-size: 25px; line-height: 1.2; margin: 2px 2px 4px; }
.page-sub { margin: 0 2px 12px; }
.loading { padding: 40px 16px; font-size: 18px; font-weight: 500; }
.loading-car { display: inline-block; animation: drive 1.2s ease-in-out infinite alternate; }
@keyframes drive { from { transform: translateX(6px); } to { transform: translateX(-6px); } }
.big-emoji { font-size: 46px; margin-bottom: 6px; }
.empty {
  list-style: none;
  text-align: center; color: var(--muted); font-weight: 500; line-height: 1.7;
  background: rgba(255, 255, 255, 0.65);
  border: 2.5px dashed var(--line-2); border-radius: var(--radius);
  padding: 22px 16px 24px; margin-bottom: 14px;
}
.empty-emoji { font-size: 44px; line-height: 1.25; margin-bottom: 4px; }

/* ---------------- the chunky "3D" buttons ----------------
   white face, a sand border and a solid edge underneath (--sh); pressed = pushed down */
.btn, .car-btn, .len-btn, .kid-chip, .front-btn, .chip, .trip-row, .hint-link, .x, #toastAction, .res-btn, .res-x, .opt-row {
  --sh: var(--shadow);
  background: var(--card);
  border: 2.5px solid var(--line);
  box-shadow: 0 4px 0 var(--sh);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
}
:is(.btn, .car-btn, .len-btn, .kid-chip, .front-btn, .chip, .trip-row, .hint-link, .x, #toastAction, .res-btn, .res-x, .opt-row):active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--sh);
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px;
  border-radius: var(--radius-s);
  padding: 10px 16px; margin-top: 12px;
  font-weight: 700; font-size: 17px; line-height: 1.25; color: var(--ink);
}
.btn:disabled { opacity: 0.45; }
.btn.primary { --sh: var(--save-d); background: var(--save); border-color: var(--save); color: #fff; }
.btn.big { min-height: 58px; border-radius: 18px; box-shadow: 0 5px 0 var(--sh); font-family: var(--display); font-weight: 400; font-size: 23px; }
.btn.ghost { background: var(--card); }
.btn.danger { --sh: var(--danger-d); background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { --sh: var(--danger-line); background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-d); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------------- install hint ---------------- */
.hint-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--shadow);
  padding: 6px 12px 6px 6px; margin-bottom: 14px;
  font-size: 14.5px; font-weight: 500;
}
.hint-emoji { font-size: 24px; line-height: 1; }
.hint-text { flex: 1; line-height: 1.3; }
.hint-link {
  --sh: var(--sun-d); background: var(--sun); border-color: var(--sun-d);
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px;
  font-weight: 700; font-size: 15px; color: var(--ink);
}
.hint-x { flex: none; color: var(--muted); font-size: 16px; min-width: 40px; min-height: 40px; border-radius: 50%; }

/* ---------------- "now it's X's turn" (the big card, in the kid's colour) ---------------- */
.now-card {
  position: relative; overflow: hidden;
  min-height: 178px;
  border-radius: 26px;
  background: var(--kid, #22c55e);
  border-bottom: 7px solid var(--kid-d, #15803d);
  color: var(--kid-ink, #fff);
  padding: 16px 20px 16px 128px;     /* the car stands on the left */
  margin-bottom: 12px;
  box-shadow: 0 10px 22px rgba(43, 35, 68, 0.14);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--kid) 30%, transparent);
}
.now-label { font-size: 17px; font-weight: 500; opacity: 0.95; }
.now-name-wrap {
  font-family: var(--display); font-size: 58px; line-height: 1.08;
  margin: 2px 0 10px; overflow-wrap: anywhere;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}
.now-name-wrap.sz-m { font-size: 46px; }
.now-name-wrap.sz-s { font-size: 36px; }
.now-points {
  display: inline-block; max-width: 100%;
  background: rgba(255, 255, 255, 0.2); border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px; padding: 3px 12px;
  font-size: 14px; font-weight: 700; line-height: 1.35;
}
.now-sub { font-size: 13.5px; font-weight: 500; margin-top: 7px; opacity: 0.95; }
.now-car { position: absolute; left: 16px; bottom: -8px; width: 104px; height: 170px; }
.now-card.pop .now-name-wrap { animation: pop 420ms cubic-bezier(.3, 1.6, .5, 1); }
.now-card.pop .seat-kid { animation: pop 460ms cubic-bezier(.3, 1.6, .5, 1); transform-box: fill-box; transform-origin: center; }
@keyframes pop { 0% { transform: scale(0.6) rotate(-10deg); } 100% { transform: none; } }

/* the little score cards under it */
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 16px; }
/* emoji | name + points on the first line | trips under both — so two- and three-digit
   scores still fit a third of a 360px phone */
.sc {
  min-width: 0; min-height: 58px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "e n p" "e t t";
  align-content: center; column-gap: 4px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 16px;
  padding: 5px 6px;
}
.sc-e { grid-area: e; align-self: center; font-size: 20px; line-height: 1; }
.sc-t { display: contents; }
.sc-t b, .sc-t small { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-t b { grid-area: n; align-self: end; font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.sc-t small { grid-area: t; font-size: 11.5px; font-weight: 500; color: var(--muted); line-height: 1.35; }
.sc-pts { grid-area: p; align-self: end; font-family: var(--display); font-size: 22px; line-height: 1; }
.sc-pts.long { font-size: 17px; }
.sc-pts .frac { font-size: 0.62em; letter-spacing: -0.02em; }
.sc.now { border-color: var(--kid); background: var(--kid-soft); }
/* not in the car this time: a dashed, see-through card and a faded emoji, but the text is not
   faded (no opacity on the card), so the name and the numbers stay easy to read */
.sc.off { border-style: dashed; border-color: var(--line-2); background: rgba(255, 255, 255, 0.55); }
.sc.off .sc-e { opacity: 0.45; filter: grayscale(1); }
.sc.off .sc-t b, .sc.off .sc-pts { color: var(--muted); }

/* ---------------- the quick trip form (and the edit sheet) ---------------- */
.sec { margin-bottom: 16px; }
.q {
  display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px;
  font-size: 16px; font-weight: 700; line-height: 1.3;
  margin: 0 2px 8px;
}
.q-hint { font-size: 12.5px; font-weight: 500; color: var(--muted); }

.cars { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.car-btn {
  min-height: 52px; padding: 6px 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 16px; font-size: 17px; font-weight: 700;
}
.car-emoji { font-size: 22px; line-height: 1; }
.car-btn.on, .len-btn.on { --sh: var(--sun-d); background: var(--sun); border-color: var(--sun-d); }

.lengths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.len-btn {
  min-width: 0; min-height: 70px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 16px; text-align: center; line-height: 1.15;
}
.len-name { font-size: 16.5px; font-weight: 700; }
.len-hint { font-size: 11.5px; font-weight: 500; color: var(--muted); text-wrap: balance; }
.len-pts { font-size: 12px; font-weight: 700; background: var(--soft); border-radius: 999px; padding: 1px 9px; margin-top: 3px; }
.len-btn.on .len-hint { color: var(--sun-ink); }
.len-btn.on .len-pts { background: #fff; }

.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.kid-chip {
  min-width: 0; min-height: 46px; padding: 4px 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 999px; font-size: 16.5px; font-weight: 700;
}
.kid-chip .tick {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; line-height: 1;
}
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kid-chip.on { --sh: var(--kid); border-color: var(--kid); }
.kid-chip.on .tick { background: var(--kid); color: var(--kid-ink); }
.kid-chip:not(.on) {
  background: rgba(255, 255, 255, 0.55); border-style: dashed; border-color: var(--line-2);
  box-shadow: none; transform: translateY(3px); color: var(--muted);
}
.kid-chip:not(.on) .tick { border: 2px solid var(--line-2); }

.fronts { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; }
.front-btn {
  position: relative; min-width: 0;
  min-height: 52px; padding: 6px 8px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 6px;
  border-radius: 16px; font-size: 16.5px; font-weight: 700;
}
.front-emoji { font-size: 21px; line-height: 1.1; }
.front-name { overflow-wrap: anywhere; }
.front-btn.on { --sh: var(--kid-d); background: var(--kid); border-color: var(--kid-d); color: var(--kid-ink); }
.turn-badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  background: var(--sun); color: var(--ink); border: 2px solid var(--sun-d);
  font-size: 11.5px; font-weight: 700; line-height: 1.45; border-radius: 999px; padding: 0 8px;
}
.turn-badge.inline { position: static; transform: none; display: inline-block; vertical-align: middle; }
.front-note { margin: 12px 2px 0; font-size: 14px; font-weight: 500; color: var(--muted); line-height: 1.45; }
.front-note b { color: var(--ink); white-space: nowrap; }   /* never split a kid's name across lines */

.sum {
  margin: 20px 4px 10px; text-align: center;
  font-size: 14px; font-weight: 500; color: var(--muted); line-height: 1.9;
}
.sum b {
  color: var(--ink); font-weight: 700; white-space: nowrap;
  background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 1px 9px;
}
.save-btn { margin-top: 0; min-height: 60px; font-size: 25px; gap: 10px; }
.save-emoji { font-size: 22px; line-height: 1; }
.save-btn.soft { opacity: 0.72; }

.nudge { animation: nudge 420ms ease; }
@keyframes nudge {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------------- score table ---------------- */
.board { margin-bottom: 18px; }
.score-list { list-style: none; display: grid; gap: 12px; }
.score-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 20px;
  box-shadow: 0 4px 0 var(--shadow);
  padding: 12px 12px 12px 14px;
}
.score-row.first { border-color: var(--kid); background: var(--kid-soft); box-shadow: 0 4px 0 var(--kid); }
.rank {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 16px; color: var(--muted);
  background: var(--soft); border: 2px solid var(--line);
}
.score-row.first .rank { background: var(--sun); color: var(--ink); border-color: var(--sun-d); }
.avatar {
  width: 46px; height: 46px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 25px; line-height: 1;
  background: var(--kid-soft, var(--soft));
  border: 2.5px solid var(--kid, var(--line));
}
.score-row.first .avatar { background: #fff; }
.score-main { flex: 1; min-width: 0; }
.score-top { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.score-name { font-size: 18px; font-weight: 700; }
.score-pts { margin-inline-start: auto; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.score-pts b { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1; color: var(--ink); }
.bar { height: 14px; border-radius: 999px; background: var(--soft); overflow: hidden; margin: 6px 0 5px; }
.bar span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--kid); box-shadow: inset 0 -4px 0 var(--kid-d);
  transition: width 0.4s ease;
}
.score-meta { display: flex; flex-wrap: wrap; column-gap: 12px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.rules { margin-top: 4px; }
.rules ul { padding-inline-start: 20px; line-height: 1.45; font-size: 15.5px; }
.rules li { margin: 6px 0; }
.rules li::marker { color: var(--sun-d); }

/* ---------------- history ---------------- */
.filters { margin-bottom: 4px; }
/* an even grid of chips: app.js sets --cols (phone, at most 3 across) and --cols-w (wider,
   at most 4) so the rows come out balanced — 4 chips are 2+2 on a phone, never 3+1 */
.filter-row {
  display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 8px; padding: 2px 0 10px;
}
@media (min-width: 480px) {
  .filter-row { grid-template-columns: repeat(var(--cols-w, 4), minmax(0, 1fr)); }
}
.chip {
  min-width: 0; min-height: 42px;
  border-radius: 999px; padding: 4px 8px;
  font-size: 15px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.on { --sh: var(--sun-d); background: var(--sun); border-color: var(--sun-d); }
.chip.kid.on { --sh: var(--kid-d); background: var(--kid); border-color: var(--kid-d); color: var(--kid-ink); }
.summary { margin: 2px 4px 4px; font-weight: 500; }

.day-head {
  display: inline-block;
  font-family: var(--display); font-size: 15px; line-height: 1.5;
  background: var(--sunball); border-radius: 999px; padding: 1px 12px;
  margin: 12px 2px 8px;
}
.trip-list { display: flex; flex-direction: column; align-items: stretch; }
.trip-list .day-head { align-self: flex-start; }
.trip-row {
  width: 100%; text-align: start;
  display: flex; align-items: center; gap: 12px;
  border-radius: 18px;
  padding: 10px 12px; margin-bottom: 10px; min-height: 68px;
}
.trip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trip-title { font-weight: 700; font-size: 16.5px; line-height: 1.35; }
.riders { white-space: nowrap; }
.trip-meta, .trip-by { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.trip-pts {
  flex: none; font-family: var(--display); font-size: 17px; line-height: 1.4;
  background: var(--kid-soft, var(--soft)); color: var(--kid-d, var(--ink));
  border: 2px solid var(--kid, var(--line)); border-radius: 999px; padding: 0 10px;
}
.tag {
  display: inline-block; text-decoration: none;
  font-size: 11.5px; font-weight: 700; line-height: 1.5; border-radius: 999px; padding: 0 8px; vertical-align: middle;
  background: var(--soft); color: var(--ink);
}
.trip-list .btn { margin-top: 4px; }

/* ---------------- more ---------------- */
.me-card { background: var(--sun); border-color: var(--sun-d); box-shadow: 0 5px 0 var(--sun-d); }
.me-card .muted { color: var(--sun-ink); }
.me-hello { font-family: var(--display); font-size: 27px; line-height: 1.2; margin-bottom: 4px; }
.ok-line { color: var(--ok); font-weight: 700; }
.install-block { margin-top: 14px; background: var(--cream); border: 2px solid var(--line); border-radius: 18px; padding: 12px; }
.install-head { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.steps { list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 4px 38px 6px 0; line-height: 1.45; }
.steps li::before {
  content: counter(s);
  position: absolute; right: 0; top: 3px;
  width: 27px; height: 27px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--sun); border: 2px solid var(--sun-d); color: var(--ink);
  font-family: var(--display); font-size: 14px;
}
.share-ico { display: inline-block; border: 1.5px solid currentColor; border-radius: 5px; padding: 0 4px; font-size: 13px; line-height: 1.3; }
.logout-wrap { margin: -2px 0 16px; }
.version { margin-top: 6px; }

/* ---------------- sheet, question, toast ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(43, 35, 68, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.center { align-items: center; padding: 24px; z-index: 80; }
.sheet {
  width: 100%; max-width: var(--maxw); max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1.6px, transparent 1.7px);
  background-size: 24px 24px;
  border-radius: 28px 28px 0 0;
  border-top: 2.5px solid var(--line);
  padding: 8px 16px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(43, 35, 68, 0.22);
  animation: up 220ms ease-out;
}
@media (min-width: 700px) {
  .overlay:not(.center) { align-items: center; padding: 24px; }
  .sheet { border-radius: 28px; border: 2.5px solid var(--line); padding-bottom: 22px; }
}
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.grabber { width: 48px; height: 6px; border-radius: 3px; background: var(--line-2); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sheet-title { font-family: var(--display); font-size: 25px; line-height: 1.2; }
.x {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: var(--muted);
}
.sheet .q { margin-top: 16px; }
.sheet .btn.big { margin-top: 22px; }

.ask-card {
  width: 100%; max-width: 380px; margin: 0;
  border-radius: 24px; padding: 20px 18px 18px;
  box-shadow: 0 6px 0 var(--shadow), 0 22px 44px rgba(43, 35, 68, 0.25);
  animation: up 200ms ease-out;
}
.ask-text { white-space: pre-wrap; font-size: 18px; font-weight: 500; line-height: 1.5; }
.ask-card .btn-row { margin-top: 6px; }
#askYes.danger { --sh: var(--danger-d); background: var(--danger); border-color: var(--danger); color: #fff; }

.toast {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom));
  width: min(calc(100vw - 24px), 480px);
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff;
  border-radius: 18px; padding: 8px 8px 8px 14px; min-height: 56px;
  box-shadow: 0 5px 0 #17122b, 0 14px 30px rgba(43, 35, 68, 0.3);
  font-weight: 700; font-size: 15.5px; line-height: 1.35;
}
.toast #toastText { flex: 1; padding-inline-start: 6px; white-space: pre-line; }   /* a "\n" starts a 2nd line */
.toast.show { animation: toast-in 240ms ease-out; }
@keyframes toast-in { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
#toastAction {
  --sh: var(--sun-d); background: var(--sun); border-color: var(--sun-d);
  flex: none; min-height: 42px; padding: 4px 16px; border-radius: 12px;
  color: var(--ink); font-weight: 700;
}
body.pairing .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }

/* ---------------- tab bar ---------------- */
.tabbar {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 30;
  display: flex; justify-content: center;
  background: #fff;
  border-top: 2.5px solid var(--line);
  padding: 0 max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--tab); font-size: 12.5px; font-weight: 700;
}
.tab svg { width: 24px; height: 24px; transition: transform 0.15s ease; }
.tab span { border-radius: 999px; padding: 1px 10px; line-height: 1.35; transition: background 0.15s ease; }
.tab.selected { color: var(--tab-on); }
.tab.selected span { background: var(--tab-pill); }
.tab:active svg { transform: translateY(2px); }
body.pairing .tabbar { display: none; }

/* ---------------- pairing ---------------- */
.pair {
  position: fixed; inset: 0; z-index: 70;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at calc(100% - 31px) -30px, var(--sunball) 0 88px, rgba(255, 224, 122, 0) 89px),
    radial-gradient(var(--dots) 1.6px, transparent 1.7px);
  background-size: auto, 24px 24px;
  background-repeat: no-repeat, repeat;
  display: flex;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.pair-card { width: 100%; max-width: 380px; margin: auto; text-align: center; }
.pair-badge {
  position: relative; overflow: hidden;
  width: 124px; height: 124px; margin: 0 auto;
  border-radius: 32px;
  background: #22c55e; border-bottom: 7px solid #15803d;
  box-shadow: 0 10px 22px rgba(34, 197, 94, 0.28);
}
.pair-badge svg { position: absolute; left: 50%; bottom: -44px; transform: translateX(-50%) rotate(-12deg); }
.pair-title { font-family: var(--display); font-weight: 400; font-size: 40px; line-height: 1.15; margin-top: 16px; }
.pair-sub { color: var(--muted); font-size: 17px; font-weight: 500; margin: 4px 0 24px; }
.pair-label { display: block; font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.pair-input {
  width: 100%; min-height: 58px;
  font: inherit; font-size: 22px; font-weight: 700; text-align: center;
  color: var(--ink); background: #fff;
  border: 2.5px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--shadow);
  padding: 10px 14px;
  outline: none;
}
.pair-input::placeholder { color: #b3a9c7; font-weight: 500; }
.pair-input:focus { border-color: var(--sun-d); box-shadow: 0 4px 0 var(--sun-d); }
.pair-input.bad, .pair-input.bad:focus { border-color: var(--danger); box-shadow: 0 4px 0 var(--danger-d); background: var(--danger-soft); }
.pair-card .btn.big { margin-top: 16px; }
.pair-error { min-height: 1.5em; margin-top: 12px; color: var(--danger-d); font-weight: 700; text-wrap: balance; }
.pair-help { color: var(--muted); font-size: 14px; font-weight: 500; margin-top: 4px; text-wrap: balance; }

/* ================= version 2 (SPEC "גרסה 2") =================
   same language as above: white faces on a solid edge, kid colours, sun-yellow "on" */

/* each car keeps its own little colour tag: the seat chips, the per-car sections, the two-car card */
.car-tag {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 13px; font-weight: 700; line-height: 1.5;
  border-radius: 999px; padding: 0 9px;
  background: var(--soft); border: 2px solid var(--line-2); color: var(--ink);
}
.car-tag.c0 { background: #fff1c2; border-color: #f0c44c; color: #5c4700; }
.car-tag.c1 { background: #dcefff; border-color: #8cc4f5; color: #1e4f7a; }
.car-tag.home { background: transparent; border-style: dashed; color: var(--muted); font-weight: 500; }
.q .car-tag { font-size: 14.5px; margin-inline-start: 2px; vertical-align: 1px; }

/* 📌 reservations at the top of the trip tab */
.res-list { display: grid; gap: 10px; margin-bottom: 14px; }
.res-card {
  background: var(--card); border: 2.5px solid var(--line); border-inline-start: 7px solid var(--kid);
  border-radius: 18px; box-shadow: 0 4px 0 var(--shadow);
  padding: 9px 11px 10px;
}
.res-card.on { background: var(--kid-soft); border-color: var(--kid); box-shadow: 0 4px 0 var(--kid-d); }
.res-top { display: flex; align-items: flex-start; gap: 7px; font-size: 15px; font-weight: 500; line-height: 1.4; }
.res-pin { font-size: 18px; line-height: 1.2; }
.res-text b { font-weight: 700; }
.res-when { color: var(--muted); white-space: nowrap; }
.res-btns { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.res-btn {
  min-height: 42px; border-radius: 13px; padding: 4px 12px;
  font-size: 15px; font-weight: 700; line-height: 1.2;
}
.res-btn.use { flex: 1; --sh: var(--kid-d); background: var(--kid); border-color: var(--kid-d); color: var(--kid-ink); }
.res-btn.del { flex: none; color: var(--muted); font-weight: 500; }
.res-ready { flex: 1; font-size: 14.5px; font-weight: 700; color: var(--ok); padding: 0 4px; }

/* the reservation, inside the form (✕ = not this reservation after all) */
.res-strip {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 0; padding: 5px 5px 5px 5px; padding-inline-start: 12px;
  background: var(--cream); border: 2.5px solid var(--sun-d); border-radius: 16px;
  font-size: 15px; font-weight: 500; line-height: 1.35;
}
.res-strip-text { flex: 1; min-width: 0; }
.res-x {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--muted);
}

/* "אחר כך: מרדכי, ואז אהרון" under the big name */
.now-after { font-size: 15px; font-weight: 500; line-height: 1.35; margin: -4px 0 9px; opacity: 0.97; }
.now-after b { font-weight: 700; }

/* two cars: a card per car, in the colour of the kid whose turn it is there */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.duo-card {
  min-width: 0; min-height: 150px;
  border-radius: 22px;
  background: var(--kid); border-bottom: 6px solid var(--kid-d); color: var(--kid-ink);
  padding: 10px 12px 12px;
  box-shadow: 0 8px 18px rgba(43, 35, 68, 0.12);
}
.duo-card.none {
  background: rgba(255, 255, 255, 0.55); border: 2.5px dashed var(--line-2); box-shadow: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: flex-start;
}
.duo-car .car-tag { background: rgba(255, 255, 255, 0.92); }
.duo-label { font-size: 14px; font-weight: 500; margin-top: 8px; opacity: 0.95; }
.duo-name { display: flex; align-items: center; gap: 6px; font-family: var(--display); font-size: 31px; line-height: 1.1; overflow-wrap: anywhere; }
.duo-emoji { font-size: 25px; line-height: 1; flex: none; }
.duo-kid { min-width: 0; }
.duo-after { font-size: 13px; font-weight: 500; line-height: 1.35; margin-top: 6px; }
.duo-after b { font-weight: 700; }
.duo-none { margin: auto 0; font-weight: 500; font-size: 14.5px; }

/* "רכב אחד / שני רכבים" */
.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--soft); border: 2.5px solid var(--line); border-radius: 999px;
  padding: 4px; margin: 0 0 16px;
}
.mode-btn {
  min-height: 40px; border-radius: 999px; padding: 2px 8px;
  font-size: 15px; font-weight: 700; color: var(--muted); white-space: nowrap;
  border: 2px solid transparent;
}
.mode-btn.on { background: var(--card); color: var(--ink); border-color: var(--line-2); box-shadow: 0 3px 0 var(--shadow); }

/* two cars: the kid chips carry their car */
.kid-chip.seat-chip { flex-direction: column; gap: 3px; min-height: 64px; padding: 6px 6px; border-radius: 18px; }
.seat-chip .car-tag { font-size: 12.5px; padding: 0 8px; }
.two-note { margin: 0 4px 2px; text-align: center; font-size: 13.5px; font-weight: 500; color: var(--muted); line-height: 1.45; }

/* why was the suggestion skipped (optional chips) */
.why { margin-top: 12px; }
.why-q { font-size: 14.5px; font-weight: 700; margin: 0 2px 8px; line-height: 1.35; }
.why-q .q-hint { margin-inline-start: 4px; }
.why-chips { display: flex; flex-wrap: wrap; gap: 8px 6px; }
.chip.why-chip { flex: none; min-height: 40px; padding: 3px 12px; font-size: 14.5px; }
.chip.why-chip.heart.on { --sh: #e0759a; background: #ffd9e5; border-color: #f08db0; }

/* "עוד אפשרויות": 🎂 gift and 🔄 half-half */
.opts { margin: 0 0 8px; }
.opts-toggle {
  width: 100%; min-height: 46px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.6); border: 2.5px dashed var(--line-2);
  font-size: 15.5px; font-weight: 700; color: var(--ink); text-align: start;
}
.opts.open .opts-toggle { background: var(--card); border-style: solid; }
.opts-marks { margin-inline-start: auto; font-size: 15px; letter-spacing: 2px; opacity: 0.75; }
.opts-marks.on {
  opacity: 1; letter-spacing: 0; font-size: 14px; line-height: 1.5;
  background: var(--sun); border: 2px solid var(--sun-d); border-radius: 999px; padding: 0 8px;
}
.chev { color: var(--muted); font-size: 14px; }
.opt-row {
  width: 100%; min-height: 62px; margin-top: 10px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 16px; text-align: start;
}
.opt-row.on { --sh: var(--sun-d); background: var(--cream); border-color: var(--sun-d); }
.opt-row:disabled { opacity: 0.55; box-shadow: none; transform: translateY(3px); }
.opt-emoji { font-size: 25px; line-height: 1; flex: none; }
.opt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.opt-text b { font-size: 15.5px; }
.opt-text small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.opt-row.on .opt-text small { color: var(--sun-ink); }
.switch {
  position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px;
  background: var(--line-2); transition: background-color 0.15s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 0 rgba(43, 35, 68, 0.18); transition: inset-inline-start 0.15s ease;
}
.opt-row.on .switch { background: #22a45a; }
.opt-row.on .switch::after { inset-inline-start: 21px; }
.half-pick { margin-top: 14px; }
.sheet .opts { margin-top: -2px; }
.sheet .opt-row:first-child { margin-top: 0; }

.sum-line { display: block; }
.sum-line .car-tag { font-size: 12.5px; margin-inline-end: 2px; }
.res-new { margin-top: 16px; min-height: 48px; font-size: 16px; }

/* history: the new facts of a trip, and a two-car outing kept together */
.trip-facts { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.fact {
  display: inline-block; font-size: 12.5px; font-weight: 700; line-height: 1.55;
  background: var(--soft); color: var(--ink); border-radius: 999px; padding: 0 8px;
}
.fact.heart { background: #ffe1ea; color: #9d174d; }
.fact.gift { background: #fff1c2; color: #5c4700; }
.fact.pin { background: #dcefff; color: #1e4f7a; }
.fact.group { background: #ece8ff; color: #4c3a8f; }
.trip-group {
  border: 2.5px dashed #c9bdf2; border-radius: 22px; background: rgba(236, 232, 255, 0.45);
  padding: 8px 8px 0; margin-bottom: 10px;
}
.group-head {
  display: inline-block; font-size: 13px; font-weight: 700; line-height: 1.6;
  background: #ece8ff; color: #4c3a8f; border-radius: 999px; padding: 0 10px; margin: 0 2px 8px;
}
.trip-group .trip-row { margin-bottom: 8px; }
.sheet-info { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }

/* table: ❤️ gave the seat up · 🎂 birthday gifts */
.mini-badge {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 12.5px; font-weight: 700; line-height: 1.55;
  background: #ffe1ea; color: #9d174d; border-radius: 999px; padding: 0 7px;
}
.mini-badge.gift { background: #fff1c2; color: #5c4700; }

/* the reservation sheet's text boxes */
.field {
  width: 100%; min-height: 52px;
  font: inherit; font-size: 17px; font-weight: 500; color: var(--ink);
  background: #fff; border: 2.5px solid var(--line); border-radius: 16px;
  box-shadow: 0 4px 0 var(--shadow); padding: 10px 14px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.field::placeholder { color: #b3a9c7; }
.field:focus { border-color: var(--sun-d); box-shadow: 0 4px 0 var(--sun-d); }
.date-row { display: flex; align-items: center; gap: 8px; }
.date-row .field { flex: 1; min-width: 0; }
label.q { display: flex; }

/* ---------------- narrow & wider screens ---------------- */
@media (max-width: 380px) {
  .card { padding: 14px 12px; }
  .now-card { padding: 14px 16px 14px 112px; }
  .now-car { left: 10px; width: 94px; height: 154px; bottom: -6px; }
  .now-name-wrap { font-size: 54px; }
  .now-name-wrap.sz-m { font-size: 42px; }
  .now-name-wrap.sz-s { font-size: 33px; }
  .now-points { font-size: 13px; padding: 3px 10px; }
  .sc { padding: 5px 5px; column-gap: 3px; }
  .sc-e { font-size: 19px; }
  .sc-t b { font-size: 14px; }
  .sc-pts { font-size: 21px; }
  .sc-pts.long { font-size: 15px; }
  .len-hint { font-size: 11px; }
  .kid-chip, .front-btn { font-size: 16px; }
  .chips, .fronts, .lengths { gap: 7px; }
  .now-after { font-size: 14px; }
  .duo { gap: 8px; }
  .duo-card { padding: 9px 10px 11px; }
  .duo-name { font-size: 27px; }
  .duo-emoji { font-size: 22px; }
  .chip.why-chip { font-size: 14px; padding: 3px 10px; }
  .mode-btn { font-size: 14.5px; }
}
@media (min-width: 700px) {
  .app-header { padding-top: calc(22px + env(safe-area-inset-top)); }
  .app-header::before { top: calc(-110px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
