@font-face { font-family: 'Vazirmatn'; src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f1f6f6;
  --card: #ffffff;
  --ink: #12292b;
  --muted: #5d7578;
  --line: #dbe5e6;
  --accent: #0d9488;
  --accent-strong: #0b766d;
  --accent-soft: #d9f2ee;
  --on-accent: #ffffff;
  --warn: #b45309;
  --warn-soft: #fdf0d9;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(18, 41, 43, .06), 0 4px 14px rgba(18, 41, 43, .06);
  --tabs-h: 64px;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1f24;
    --card: #12292f;
    --ink: #e8f3f3;
    --muted: #93b3b6;
    --line: #22414a;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123c3d;
    --on-accent: #06302c;
    --warn: #fbbf24;
    --warn-soft: #3a2f12;
    --danger: #f87171;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + 90px + env(safe-area-inset-bottom)); }

/* header */
#hdr {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #hdr { background: #0f3a3c; color: #e8f3f3; } }
#hdr h1 { font-size: 19px; margin: 0; font-weight: 700; }
.hdr-end { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.18); color: inherit; border: 0; padding: 4px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.pill svg.ic { width: 16px; height: 16px; }

main { padding: 14px 14px 0; outline: none; }

/* cards & text */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card h2, .section-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; color: var(--muted); }
.section-title { margin: 18px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hero { padding: 16px; }
.hero .date-main { font-size: 22px; font-weight: 700; line-height: 1.4; }
.hero .date-sub { color: var(--muted); font-size: 14px; }
.progress { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; margin: 10px 0 4px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* quick add */
.quick { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.quick input { flex: 1; min-width: 0; }

/* inputs */
input[type=text], input[type=time], input[type=number], select, textarea {
  width: 100%; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 46px; outline: none;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 12px 2px 4px; }

/* buttons */
.btn { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 16px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; flex: none; }
.icon-btn.mic.on { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.5);} 70% { box-shadow: 0 0 0 14px rgba(220,38,38,0);} 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0);} }
.btn:active, .icon-btn:active, .fab:active { transform: scale(.97); }
button:focus-visible, [data-act]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.fab {
  position: fixed; z-index: 30; inset-inline-end: max(16px, calc((100vw - 640px) / 2 + 16px));
  bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(13,148,136,.45);
}
.fab svg.ic { width: 28px; height: 28px; stroke-width: 2.5; }
.fab[hidden] { display: none; }

/* tabs */
#tabs {
  position: fixed; z-index: 25; inset-inline: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; max-width: 640px; margin: 0 auto;
}
#tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; position: relative; }
#tabs button.on { color: var(--accent); font-weight: 700; }
#tabs button.on::before { content: ''; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent); }
#tabs .badge { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 99px; min-width: 18px; height: 18px; font-size: 11px; display: grid; place-items: center; padding: 0 4px; }

/* list rows */
ul.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.chk { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--on-accent); display: grid; place-items: center; flex: none; margin-top: 2px; padding: 0; }
.chk svg.ic { width: 16px; height: 16px; stroke-width: 3.2; }
.row.done .chk { background: var(--accent); }
.row.done .row-title { text-decoration: line-through; color: var(--muted); }
.row-main { flex: 1; min-width: 0; cursor: pointer; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; }
.tag svg.ic { width: 14px; height: 14px; }
.badge-type { background: var(--accent-soft); color: var(--accent-strong); border-radius: 8px; padding: 0 8px; font-size: 12px; }
.late { color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* segmented + chips */
.seg { display: flex; background: var(--accent-soft); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; min-height: 40px; color: var(--accent-strong); font-weight: 500; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 14px; min-height: 36px; white-space: nowrap; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* banners */
.banner { background: var(--warn-soft); color: var(--ink); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.banner .btn { margin-top: 8px; }
.banner.info { background: var(--accent-soft); }
.banner svg.ic { margin-top: 3px; }

/* reports */
.report-text { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 15px; margin: 8px 0 10px; overflow-wrap: anywhere; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
details.hist { border-bottom: 1px solid var(--line); padding: 8px 0; }
details.hist:last-child { border-bottom: 0; }
details.hist summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center; list-style: none; }
details.hist summary::-webkit-details-marker { display: none; }
.mini-bar { width: 70px; height: 6px; border-radius: 9px; background: var(--accent-soft); overflow: hidden; display: inline-block; vertical-align: middle; margin-inline-start: 8px; }
.mini-bar > i { display: block; height: 100%; background: var(--accent); }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { flex: 1; min-width: 0; }
.set-row select, .set-row input[type=time] { width: auto; min-width: 130px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { inset-inline-start: 23px; }
.switch input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }
.prof { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prof:last-child { border-bottom: 0; }
.prof .grow { flex: 1; }
.prof .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.prof.on .dot { background: var(--accent); }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 20, 22, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; -webkit-overflow-scrolling: touch; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.smart { background: var(--card); border: 1.5px dashed var(--accent); border-radius: 14px; padding: 10px; margin-bottom: 4px; }
.smart textarea { border: 0; padding: 4px 6px; min-height: 56px; box-shadow: none; background: transparent; }
.smart .btn-row { justify-content: space-between; align-items: center; }
.detected { font-size: 13px; color: var(--accent-strong); margin-top: 6px; min-height: 20px; }
.detected.guess { color: var(--warn); }

/* toast */
#toast { position: fixed; z-index: 80; inset-inline: 12px; bottom: calc(var(--tabs-h) + 84px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
#toast .t { background: #12292b; color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); display: flex; align-items: center; gap: 14px; max-width: 520px; pointer-events: auto; animation: up .2s ease-out; font-size: 15px; }
#toast button { background: transparent; border: 0; color: #5eead4; font-weight: 700; padding: 0; }

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