:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --danger: #b91c1c;
  --tasks: #1d4ed8;
  --yalda: #be123c;
  --questions: #6d28d9;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
  --radius: 18px;
  --dock: calc(160px + env(safe-area-inset-bottom, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Vazirmatn", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 14px var(--dock);
}

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-bottom: 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(244, 245, 247, 0));
}

.header__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.progress-pill {
  min-width: 58px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ecfdf5;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card.is-done {
  opacity: 0.62;
}

.card.is-done .card__title {
  text-decoration: line-through;
  color: var(--muted);
}

.card__top {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: start;
  gap: 4px;
  min-height: 64px;
  padding-inline-end: 10px;
}

.card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.action-btn {
  height: 44px;
  border-radius: 12px;
  border: 0;
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.action-btn--add {
  background: #ecfdf5;
  color: var(--accent);
}

.action-btn--delete {
  background: #fef2f2;
  color: var(--danger);
}

.check {
  width: 44px;
  height: 44px;
  margin: 10px 6px 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.check__box {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #9ca3af;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 0.75rem;
  font-weight: 700;
  transition: 120ms ease;
}

.card.is-done .check__box,
.sub.is-done .check__box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sub .check {
  width: 40px;
  height: 40px;
  margin: 0;
}

.sub .check__box {
  width: 20px;
  height: 20px;
}

.card__body {
  padding: 14px 4px 14px 0;
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.55;
  word-break: break-word;
}

.card__meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--cat, var(--tasks));
}

.header__tools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.header__tools::-webkit-scrollbar {
  display: none;
}

.tool-btn {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.tool-btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9ca3af;
  font-size: 1.15rem;
  cursor: pointer;
}

.icon-btn:hover {
  background: #fef2f2;
  color: var(--danger);
}

.subs {
  list-style: none;
  margin: 0;
  padding: 0 12px 0 8px;
}

.subs:not(:empty) {
  border-top: 1px solid #f3f4f6;
  padding-top: 4px;
  padding-bottom: 4px;
}

.sub {
  display: grid;
  grid-template-columns: 40px 1fr 36px;
  align-items: center;
  min-height: 44px;
}

.sub.is-done .sub__text {
  color: var(--muted);
  text-decoration: line-through;
}

.sub__text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}

.sub-actions {
  padding: 0 12px 12px;
}

.sub-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.sub-form input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #f9fafb;
}

.sub-form button {
  height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.empty {
  margin-top: 48px;
  text-align: center;
  color: var(--muted);
}

.empty button {
  margin-top: 12px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  z-index: 20;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  background: rgba(244, 245, 247, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.dock__cats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.cat {
  cursor: pointer;
}

.cat input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cat span {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.cat input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.dock__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#todoInput {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: var(--surface);
}

#todoInput:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: #99f6e4;
}

.dock__add {
  height: 48px;
  min-width: 84px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
}

.install-hint {
  margin: 8px 0 0;
  text-align: center;
}

.install-hint button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 24, 39, 0.45);
  cursor: pointer;
}

.modal__panel {
  position: relative;
  width: min(360px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 20px 18px 16px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.22);
}

.modal__panel h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.modal__panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  word-break: break-word;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.modal__btn {
  height: 46px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

.modal__btn--ghost {
  background: #f3f4f6;
  color: var(--ink);
}

.modal__btn--danger {
  background: var(--danger);
  color: #fff;
}

.modal__btn--primary {
  background: var(--accent);
  color: #fff;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

#categoryName {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #f9fafb;
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock) - 24px);
  transform: translateX(-50%);
  z-index: 60;
  width: min(420px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.28);
}

.toast[hidden] {
  display: none;
}

.toast button {
  border: 0;
  background: transparent;
  color: #5eead4;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.filter:focus-visible,
.check:focus-visible,
.icon-btn:focus-visible,
.action-btn:focus-visible,
.tool-btn:focus-visible,
.dock__add:focus-visible,
.cat span:focus-visible,
#todoInput:focus-visible,
#categoryName:focus-visible,
.sub-form input:focus-visible,
.sub-form button:focus-visible,
.empty button:focus-visible,
#installBtn:focus-visible,
#undoBtn:focus-visible,
.modal__btn:focus-visible,
.modal__backdrop:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }
}
