:root {
  --bg: #f6f7fb; --card: #fff; --text: #1b1d2a; --muted: #6b7084; --line: #e6e8f0;
  --accent: #6366f1; --accent-text: #fff; --danger: #e5484d; --ok: #22a06b; --warn: #f59e0b;
  --radius: 16px; --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1117; --card: #181b25; --text: #eceef6; --muted: #9096ad; --line: #272b3a; --accent: #818cf8; --accent-text: #0f1117; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Vazirmatn', system-ui, -apple-system, Tahoma, sans-serif; line-height: 1.6;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: .85rem; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: .25rem 0 0; }
.grow { flex: 1; }

#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top)) 0 12px; }
.top h1 { font-size: 1.6rem; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.section-title { margin: 18px 4px 8px; font-size: .95rem; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.section-title.late { color: var(--danger); }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 16px; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 500; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }

/* quick add */
.quick { display: flex; gap: 8px; }
.quick input { flex: 1; min-width: 0; }
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.quick-hint { margin: 6px 4px 0; }

/* task row */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; }
.task + .task { margin-top: 8px; }
.tick {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; cursor: pointer; display: grid; place-items: center; color: transparent; font-size: .9rem; padding: 0;
  margin-top: 1px; position: relative;
}
.tick::after { content: ''; position: absolute; inset: -9px; } /* area لمس بزرگ‌تر */
.task.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.t-body { flex: 1; min-width: 0; }
.t-title { font-weight: 500; overflow-wrap: anywhere; }
.t-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { font-size: .78rem; padding: 1px 9px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.proj { border-color: transparent; color: #fff; }
.chip.time { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-feature-settings: 'tnum'; }
.chip.late { color: var(--danger); border-color: var(--danger); }
.prio { color: var(--warn); }

.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* week */
.week { display: grid; gap: 12px; }
.day-card h3 { font-size: 1rem; display: flex; justify-content: space-between; margin-bottom: 8px; }
.day-card.today { border-color: var(--accent); }
.day-card .task { padding: 8px 4px; }
.day-card .task + .task { margin: 0; border-top: 1px solid var(--line); }
.weeknav { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { cursor: pointer; padding: 6px 14px; font-size: .88rem; flex: none; }
.filters .chip.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* projects */
.proj-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.proj-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.bar { height: 6px; background: var(--bg); border-radius: 9px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); }

/* settings */
.form-grid { display: grid; gap: 12px; }
.form-grid label, dialog label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.code { font-size: 2rem; letter-spacing: .3em; text-align: center; font-weight: 700; direction: ltr; margin: 8px 0; }

/* FAB / nav */
.fab {
  position: fixed; z-index: 5; inset-inline-start: 20px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text);
  font-size: 2rem; line-height: 1; cursor: pointer; box-shadow: 0 6px 20px rgba(99, 102, 241, .45);
}
.tabs {
  position: fixed; z-index: 4; bottom: 0; inset-inline: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { flex: 1; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: .75rem; color: var(--muted); }
.tabs button span { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--accent); font-weight: 700; }
.tabs button.on span { filter: none; opacity: 1; }

/* dialogs as bottom-sheets on mobile */
dialog { border: 0; border-radius: 20px; padding: 18px; width: min(520px, calc(100vw - 24px)); max-height: 92dvh; background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.check input { width: 20px; min-height: 20px; height: 20px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
@media (max-width: 600px) {
  dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* جلوگیری از زوم iOS */
}
@media (min-width: 900px) {
  #app { max-width: 1100px; }
  .week { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 24px; }

.toast { position: fixed; z-index: 20; bottom: calc(var(--nav-h) + 90px); inset-inline: 16px; margin: auto; width: fit-content; max-width: 90vw; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: .9rem; }
