:root {
  --bg: #f6f7fb; --surface: #fff; --surface-2: #f0f2f8; --text: #1f2430; --muted: #7a8194;
  --line: #e6e9f2; --primary: #4f6ef7; --primary-soft: #e8ecff; --star: #f5a623;
  --orange: #f08c00; --orange-soft: #fff1da; --red: #e03131; --red-soft: #ffe3e3; --green: #2f9e66;
  --shadow: 0 1px 2px rgba(25, 35, 70, .05), 0 4px 14px rgba(25, 35, 70, .05);
  --radius: 14px; --nav-h: 64px;
}
:root[data-theme="dark"] {
  --bg: #12141b; --surface: #1b1e28; --surface-2: #232733; --text: #e8eaf2; --muted: #98a0b6;
  --line: #2b3040; --primary: #7b93ff; --primary-soft: #262d52; --star: #ffc247;
  --orange: #ffa94d; --orange-soft: #3a2c15; --red: #ff6b6b; --red-soft: #3d1f22; --green: #4cc38a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141b; --surface: #1b1e28; --surface-2: #232733; --text: #e8eaf2; --muted: #98a0b6;
    --line: #2b3040; --primary: #7b93ff; --primary-soft: #262d52; --star: #ffc247;
    --orange: #ffa94d; --orange-soft: #3a2c15; --red: #ff6b6b; --red-soft: #3d1f22; --green: #4cc38a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Heebo', system-ui, sans-serif; font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ----- פריסה ----- */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 260px; flex: none; background: var(--surface); border-inline-end: 1px solid var(--line);
  padding: 20px 14px; display: none; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 4px 10px 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.brand .logo svg { stroke-width: 3; width: 20px; height: 20px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border-radius: 11px;
  color: var(--text); font-weight: 500; text-align: start; transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .label { flex: 1; }
.count { min-width: 24px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; }
.nav-item.active .count { background: var(--primary); color: #fff; }
.side-foot { margin-top: auto; display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; padding: 0 16px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.content { max-width: 760px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 0 10px; display: flex; flex-direction: column; gap: 10px; }
.top-row { display: flex; align-items: center; gap: 10px; }
.search { flex: 1; position: relative; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; padding: 11px 14px 11px 14px; padding-inline-start: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--primary); }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.top-actions { display: flex; }
.title-row h1 { margin: 6px 0 0; font-size: 26px; line-height: 1.2; }
.subtitle { color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ----- רשימת משימות ----- */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.task {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 12px 12px 8px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: start;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.task.sortable-ghost { opacity: .35; }
.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center;
  color: transparent; margin-top: 1px; transition: all .15s; flex: none;
}
.check svg { width: 16px; height: 16px; stroke-width: 3; }
.check:hover { border-color: var(--green); color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.task-main { min-width: 0; padding-top: 2px; }
.task-title { font-size: 17px; font-weight: 500; word-break: break-word; cursor: pointer; }
.task-notes { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.chip.business { background: var(--primary-soft); color: var(--primary); }
.chip.home { background: #e3f6ec; color: var(--green); }
:root[data-theme="dark"] .chip.home { background: #1d3a2d; }
.chip.recurring { background: #f1e7ff; color: #8a4fe0; }
:root[data-theme="dark"] .chip.recurring { background: #35264f; color: #b99cff; }
.chip.warn { background: var(--orange-soft); color: var(--orange); font-weight: 500; }
.chip.late { background: var(--red-soft); color: var(--red); font-weight: 500; }
.chip svg { width: 13px; height: 13px; }
.task.w-warn { border-inline-start: 4px solid var(--orange); }
.task.w-late { border-inline-start: 4px solid var(--red); }
.task-tools { display: flex; align-items: center; }
.star { color: var(--muted); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; }
.star.on { color: var(--star); }
.star.on svg { fill: currentColor; }
.grip { color: var(--muted); width: 28px; height: 36px; display: grid; place-items: center; cursor: grab; touch-action: none; opacity: .6; }
.actions { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; background: var(--surface-2);
  color: var(--text); font-size: 14px; border: 1px solid transparent; transition: all .15s;
}
.pill svg { width: 16px; height: 16px; color: var(--muted); }
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill:hover svg { color: var(--primary); }
.pill.danger:hover { border-color: var(--red); color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }
.empty svg { width: 44px; height: 44px; opacity: .5; margin-bottom: 8px; }

/* ----- ניווט תחתון (נייד) ----- */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex;
}
.bottom-nav .nav-item { flex-direction: column; gap: 2px; justify-content: center; padding: 6px 2px; border-radius: 0; font-size: 11.5px; position: relative; }
.bottom-nav .nav-item .label { flex: none; }
.bottom-nav .nav-item.active { background: none; }
.bottom-nav .count { position: absolute; top: 4px; inset-inline-start: 50%; margin-inline-start: 6px; min-width: 18px; padding: 0 5px; font-size: 11px; background: var(--surface-2); }
.bottom-nav .nav-item.active .count { background: var(--primary); }

.fab {
  position: fixed; inset-inline-end: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(79, 110, 247, .45); transition: transform .15s;
}
.fab:hover { transform: scale(1.06); }
.fab svg { width: 28px; height: 28px; stroke-width: 2.5; }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .main { padding: 0 32px 120px; }
  .fab { bottom: 28px; inset-inline-end: 32px; }
  .task { padding: 14px 14px 14px 10px; }
}
@media (min-width: 900px) and (max-width: 1100px) { .sidebar { width: 220px; } }

/* ----- חלונות ----- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 40, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { .overlay { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { margin: 0 0 14px; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-size: 14px; color: var(--muted); }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { min-height: 76px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); font-weight: 500; }
.day.on { background: var(--primary); color: #fff; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.toggle.on { color: var(--star); }
.toggle.on svg { fill: currentColor; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; padding: 12px 16px; border-radius: 12px; font-weight: 500; background: var(--surface-2); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { opacity: .6; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

/* ----- משימות קבועות ----- */
.rec-card { opacity: 1; }
.rec-card.paused { opacity: .6; }
.rec-card .task-title { cursor: default; }

/* ----- התחברות ----- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 22px; text-align: center; }
.login-card .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--primary); color: #fff; display: grid; place-items: center; margin: 0 auto 12px; }
.login-card .logo svg { width: 30px; height: 30px; stroke-width: 3; }
.login-card h1 { margin: 0 0 18px; font-size: 24px; }
.login-card .field { text-align: start; }

/* ----- הודעות ----- */
#toasts { position: fixed; inset-inline: 0; bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { #toasts { bottom: 28px; } }
.toast {
  pointer-events: auto; background: #272b38; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); animation: up .2s ease; position: relative; overflow: hidden; max-width: 460px;
}
.toast .undo { color: #9db1ff; font-weight: 700; }
.toast .bar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: #9db1ff; transform-origin: right; animation: shrink 5s linear forwards; }
@keyframes shrink { to { transform: scaleX(0); } }
.toast.err { background: var(--red); }

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

[hidden] { display: none !important; }
.rec-ic { width: 28px; height: 28px; color: var(--primary); display: grid; place-items: center; margin-top: 1px; }
@media (min-width: 900px) { .top-actions { display: none; } }

.login-card .btn { width: 100%; }

