:root {
  --bg: #fbf6fb; --card: #ffffff; --ink: #3b3552; --muted: #8a84a0; --line: #eee6f3;
  --brand: #7a67d1; --brand-ink: #ffffff; --nl: #ffa974; --de: #f0cf6b; --ok: #62c192; --warn: #e5677d;
  --soft: #f2ecfb; --pink: #fbd3e4; --sky: #d3e8fa; --mint: #d5f1e4; --peach: #ffe3d1;
  --radius: 20px; --shadow: 0 2px 4px rgba(122, 103, 209, .06), 0 10px 28px rgba(122, 103, 209, .09);
  --top: linear-gradient(120deg, #fbd3e4 0%, #e1d6f8 50%, #cfe6fa 100%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1826; --card: #262236; --ink: #efeaf7; --muted: #a29bb8; --line: #352f49;
    --brand: #a995f0; --brand-ink: #1b1826; --soft: #2f2a43; --nl: #ffa974; --de: #f0cf6b; --ok: #6fd1a0; --warn: #ff8aa0;
    --shadow: none; --top: linear-gradient(120deg, #4a2f48 0%, #3a3162 55%, #2c4560 100%);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.7 Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.4; }

/* layout */
.top { background: var(--top); color: var(--ink); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button { background: transparent; border: 0; color: inherit; opacity: .8; padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.nav button.on { background: rgba(255, 255, 255, .7); opacity: 1; font-weight: 700; }
@media (prefers-color-scheme: dark) { .nav button.on { background: rgba(255, 255, 255, .14); } }
.who { background: transparent; border: 1px solid rgba(122, 103, 209, .35); background: rgba(255, 255, 255, .45); color: inherit; border-radius: 999px; padding: 4px 12px; cursor: pointer; white-space: nowrap; }
main { max-width: 1040px; margin: 0 auto; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--warn); }
.btn:disabled { opacity: .5; cursor: wait; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

/* progress */
.bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.bar.nl > i { background: var(--nl); } .bar.de > i { background: var(--de); } .bar.ok > i { background: var(--ok); }
.big { font-size: 30px; font-weight: 800; line-height: 1.2; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* checklist */
.phase { margin-top: 16px; }
.phase h3 { font-size: 15px; display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .tt { flex: 1; cursor: pointer; min-width: 0; }
.task.done .tt .title { text-decoration: line-through; color: var(--muted); }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); cursor: pointer; flex: none; margin-top: 2px; display: grid; place-items: center; padding: 0; font-size: 14px; color: #fff; }
.check.doing { border-color: var(--brand); background: var(--soft); }
.check.doing::after { content: "◐"; color: var(--brand); }
.check.done { background: var(--ok); border-color: var(--ok); }
.check.done::after { content: "✓"; }
.prio { width: 4px; align-self: stretch; border-radius: 4px; background: var(--line); flex: none; }
.prio.p3 { background: var(--warn); } .prio.p2 { background: var(--de); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal .day { min-height: 76px; border: 1px solid var(--line); border-radius: 10px; padding: 3px 4px; cursor: pointer; background: var(--card); overflow: hidden; }
.cal .day.off { background: transparent; border-color: transparent; cursor: default; }
.cal .day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal .day .n { font-size: 12px; color: var(--muted); }
.cal .ev { display: block; width: 100%; text-align: right; border: 0; border-radius: 5px; font-size: 11px; line-height: 1.5; padding: 0 4px; margin-top: 2px; cursor: pointer; background: var(--soft); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.task { background: color-mix(in srgb, var(--warn) 15%, transparent); }
.cal .ev.nl { border-right: 3px solid var(--nl); } .cal .ev.de { border-right: 3px solid var(--de); }
@media (max-width: 560px) { .cal .day { min-height: 56px; } .cal .ev { font-size: 10px; } }
.list-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; cursor: pointer; }

/* gallery */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.photos button { padding: 0; border: 0; background: var(--soft); border-radius: 12px; overflow: hidden; aspect-ratio: 1; cursor: pointer; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox { border: 0; background: rgba(0, 0, 0, .92); color: #fff; width: 100%; max-width: 100%; height: 100%; max-height: 100%; padding: 0; }
.lightbox .in { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 14px; }
.lightbox img { max-width: 100%; max-height: 74vh; border-radius: 8px; }
.lightbox .btn { background: rgba(255, 255, 255, .12); color: #fff; border-color: transparent; }

/* forms / dialog */
dialog { border: 0; padding: 0; background: transparent; max-width: 100vw; }
dialog::backdrop { background: rgba(10, 16, 24, .55); }
#dlg > form, #dlg > div { background: var(--card); color: var(--ink); border-radius: 18px; padding: 18px; width: min(480px, 94vw); max-height: 90vh; overflow: auto; margin: auto; }
.f { display: block; margin: 10px 0; }
.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.f input, .f select, .f textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.f textarea { min-height: 80px; resize: vertical; }
.jd { display: flex; gap: 6px; }
.jd select { flex: 1; min-width: 0; }
.err { color: var(--warn); min-height: 1.4em; font-size: 14px; }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.login h1 { text-align: center; margin-bottom: 18px; }
.login .f input { background: var(--card); }

#toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
#toast.on { opacity: 1; }
.activity li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.activity { list-style: none; margin: 0; padding: 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* pastel touches */
body { background: radial-gradient(1200px 500px at 90% -10%, rgba(251, 211, 228, .55), transparent 60%), radial-gradient(900px 400px at -10% 0%, rgba(207, 230, 250, .6), transparent 60%), var(--bg); background-attachment: fixed; }
.card { backdrop-filter: blur(4px); }
.btn.primary { box-shadow: 0 4px 12px rgba(122, 103, 209, .3); }
.bar { height: 12px; }
.bar > i { background: linear-gradient(90deg, #b9a8f5, var(--brand)); }
.bar.nl > i { background: linear-gradient(90deg, #ffd0b0, var(--nl)); } .bar.de > i { background: linear-gradient(90deg, #f8e4a0, var(--de)); } .bar.ok > i { background: linear-gradient(90deg, #a8e4c6, var(--ok)); }
.stat:nth-child(1) { background: linear-gradient(160deg, var(--card), color-mix(in srgb, var(--mint) 55%, var(--card))); }
.stat:nth-child(2) { background: linear-gradient(160deg, var(--card), color-mix(in srgb, var(--peach) 60%, var(--card))); }
.stat:nth-child(3) { background: linear-gradient(160deg, var(--card), color-mix(in srgb, #fdf3c8 70%, var(--card))); }
@media (prefers-color-scheme: dark) { .stat:nth-child(n) { background: var(--card); } }
.chip.on { box-shadow: 0 3px 10px rgba(122, 103, 209, .25); }
.check { border-radius: 50%; }

/* hero */
.hero { display: flex; gap: 18px; align-items: center; padding: 14px; margin-bottom: 14px; background: linear-gradient(120deg, var(--pink), #e5dcfa 55%, var(--sky)); border: 0; overflow: hidden; position: relative; }
.hero .ph { flex: none; width: min(34%, 210px); aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; border: 4px solid rgba(255, 255, 255, .85); box-shadow: 0 8px 24px rgba(80, 60, 140, .25); background: var(--soft); transform: rotate(-2deg); }
.hero .ph img { width: 100%; height: 100%; object-fit: cover; object-position: center 38%; display: block; }
.hero .tx { flex: 1; min-width: 0; color: #3b3552; }
.hero h2 { font-size: 24px; margin-bottom: 4px; }
.hero .sub { font-size: 14px; opacity: .8; }
.hero .quote { margin: 12px 0; font-size: 16px; font-weight: 600; line-height: 1.8; }
.hero .cd { display: inline-block; background: rgba(255, 255, 255, .7); border-radius: 999px; padding: 4px 16px; font-weight: 700; }
.hero .cd small { font-weight: 400; }
.hero .fly { position: absolute; font-size: 26px; opacity: .55; pointer-events: none; }
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(120deg, #4a2f48, #3a3162 55%, #2c4560); } .hero .tx { color: #efeaf7; } .hero .cd { background: rgba(255, 255, 255, .14); } }
@media (max-width: 560px) { .hero h2 { font-size: 19px; } .hero .quote { font-size: 14px; } .hero .ph { width: 36%; } }
