:root {
  --brand: #1F7A4D; --brand-d: #155C39; --brand-l: #E3F2EA;
  --bg: #F4F6F3; --card: #FFFFFF; --text: #1B1F1D; --muted: #66706B; --line: #E2E6E3;
  --warn: #B25E00; --warn-l: #FFF1DE; --danger: #B3261E; --got: #9AA39E;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #4CC38A; --brand-d: #121614; --brand-l: #1C3328;
    --bg: #121614; --card: #1C211E; --text: #E8ECE9; --muted: #98A29D; --line: #2C332F;
    --warn: #F0A848; --warn-l: #3A2C17; --danger: #FF8A80; --got: #5F6964;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #4CC38A; --brand-d: #121614; --brand-l: #1C3328;
  --bg: #121614; --card: #1C211E; --text: #E8ECE9; --muted: #98A29D; --line: #2C332F;
  --warn: #F0A848; --warn-l: #3A2C17; --danger: #FF8A80; --got: #5F6964;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.55 "Rubik", "Heebo", "Assistant", "Noto Sans Hebrew", system-ui, sans-serif;
  padding-block-end: calc(72px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: currentColor; }
[hidden] { display: none !important; }

.top {
  position: sticky; inset-block-start: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand-d); color: #fff;
}
.top h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: inherit; padding: 6px; border-radius: 50%; }
.sync { width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.sync.ok { background: #7EE2A8; } .sync.busy { background: #FFD166; } .sync.err { background: #FF6B6B; }

main { max-width: 680px; margin-inline: auto; padding: 12px; }
.view > * + * { margin-block-start: 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0; }
.center { text-align: center; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }

input, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
}
input:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
button.primary, button.ghost, button.danger, .finish {
  border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer;
}
button.primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] button.primary { color: #0B1A12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { color: #0B1A12; } }
button.ghost { background: var(--brand-l); color: var(--brand); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.wide { width: 100%; }

/* --- chips (מה בקנייה הזאת) --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; display: flex; gap: 6px; align-items: center;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .chip.on { color: #0B1A12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.on { color: #0B1A12; } }
.chip small { opacity: .8; }
.chip .manual { font-size: 11px; opacity: .85; }

.progress { position: relative; height: 26px; background: var(--card); border-radius: 999px; overflow: hidden; }
#bar { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: var(--brand-l); transition: width .25s; }
#count { position: relative; display: block; text-align: center; font-size: 14px; line-height: 26px; font-weight: 600; }

.quick { display: flex; gap: 8px; }
.quick button { width: 48px; font-size: 22px; padding: 0; }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.toggle input { width: auto; }

/* --- קבוצות ופריטים --- */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.group + .group { margin-block-start: 10px; }
.gh {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-weight: 600; border-block-end: 1px solid var(--line);
}
.gh .em { font-size: 20px; }
.gh .name { flex: 1; }
.gh .meta { font-weight: 400; font-size: 13px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--brand-l); color: var(--brand); }
.badge.warn { background: var(--warn-l); color: var(--warn); }

.it {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 54px;
  border-block-end: 1px solid var(--line); user-select: none; cursor: pointer;
}
.it:last-child { border-block-end: 0; }
.box {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted);
  display: grid; place-items: center;
}
.it.got .box { background: var(--brand); border-color: var(--brand); }
.it.got .box::after { content: ""; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg); }
.it .txt { flex: 1; min-width: 0; }
.it .n { display: block; }
.it .q { color: var(--muted); font-size: 14px; }
.it .note { display: block; color: var(--warn); font-size: 13px; }
.it.got .n, .it.got .q { color: var(--got); text-decoration: line-through; }
.it.got .note { display: none; }
.it .more { flex: none; background: none; border: 0; color: var(--muted); font-size: 22px; padding: 4px 8px; line-height: 1; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--warn-l); color: var(--warn); margin-inline-start: 6px; }

.finish { width: 100%; margin-block-start: 14px; background: var(--brand); color: #fff; font-size: 18px; padding: 15px; }
:root[data-theme="dark"] .finish { color: #0B1A12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .finish { color: #0B1A12; } }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty b { display: block; font-size: 40px; }

/* --- עריכה --- */
.li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-block-end: 1px solid var(--line); cursor: pointer; }
.li:last-child { border-block-end: 0; }
.li .txt { flex: 1; min-width: 0; }
.need {
  flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 4px 10px; font-size: 13px; color: var(--muted);
}
.need.on { background: var(--warn-l); border-color: var(--warn); color: var(--warn); font-weight: 600; }
.addit { width: 100%; background: none; border: 0; color: var(--brand); padding: 10px 14px; text-align: start; font-weight: 600; }

/* --- היסטוריה --- */
.sched { display: flex; justify-content: space-between; padding: 6px 0; border-block-end: 1px solid var(--line); }
.sched:last-child { border-block-end: 0; }
.sched { gap: 12px; align-items: baseline; }
.sched .nw { white-space: nowrap; }
.sched .hint { text-align: end; }
.big { font-size: 26px; font-weight: 700; color: var(--brand); }
.hi { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-block-start: 8px; }
.hi .d { font-weight: 600; }
.hi .m { color: var(--muted); font-size: 14px; }

/* --- תפריטים --- */
.tabs {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 6;
  display: flex; background: var(--card); border-block-start: 1px solid var(--line);
  padding-block-end: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; background: none; border: 0; padding: 8px 0 10px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs button.on { color: var(--brand); font-weight: 600; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; background: none; border: 0; padding: 9px; }
.seg button.on { background: var(--brand); color: #fff; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.panel {
  width: 100%; max-width: 680px; max-height: 88vh; overflow: auto;
  background: var(--card); border-start-start-radius: 20px; border-start-end-radius: 20px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.panel h3 { margin: 0 0 12px; font-size: 19px; }
.panel label { display: block; font-size: 14px; color: var(--muted); margin-block: 10px 4px; }
.panel .acts { display: flex; gap: 8px; margin-block-start: 16px; flex-wrap: wrap; }
.panel .acts > * { flex: 1; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opts button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; }
.opts button.on { border-color: var(--brand); background: var(--brand-l); color: var(--brand); font-weight: 600; }
.check { display: flex !important; gap: 8px; align-items: center; color: var(--text) !important; }
.check input { width: auto; }

.banner { background: var(--warn-l); color: var(--warn); padding: 10px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.banner button { margin-inline-start: auto; }
.toast {
  position: fixed; inset-block-end: calc(84px + env(safe-area-inset-bottom)); inset-inline: 16px; z-index: 30;
  margin-inline: auto; max-width: 420px; background: #222; color: #fff; padding: 12px 16px; border-radius: 12px;
  display: flex; gap: 12px; align-items: center; box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
.toast button { margin-inline-start: auto; background: none; border: 0; color: #7EE2A8; font-weight: 700; }

.nudge { display: flex; gap: 12px; align-items: center; font-size: 15px; border: 1px solid var(--brand); }
.nudge button { flex: none; }
.adv summary { color: var(--muted); font-size: 14px; cursor: pointer; margin-top: 8px; }
