/* Стиль «Цветные списки»: спокойный серый фон, белые карточки, почти чёрная
   главная кнопка. Яркие цвета есть только у списков — по ним задачи и
   отличаются. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --field: #f3f5f9;
  --ink: #1a1d24;
  --on-ink: #ffffff;
  --text: #1a1d24;
  --muted: #6b7080;
  --faint: #9aa0ad;
  --line: #e6e9f0;
  --check: #c3c8d4;
  --danger: #c43c3c;
  --overlay: rgba(19, 22, 29, 0.42);

  --tag-over-bg: #fdecec;
  --tag-over: #a52a2a;
  --tag-today-bg: #fdf3dc;
  --tag-today: #8a5a00;
  --tag-later-bg: #eef0f5;
  --tag-later: #4a5060;

  --c-green: #2f9e6e;
  --c-violet: #7a5af0;
  --c-coral: #e2683c;
  --c-blue: #3a7bf0;
  --c-pink: #d6457a;
  --c-amber: #c98a12;

  --radius: 12px;
  --font: "Onest", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", var(--font);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

body.dark {
  --bg: #121418;
  --surface: #1d2027;
  --field: #272b33;
  --ink: #eef0f5;
  --on-ink: #121418;
  --text: #eef0f5;
  --muted: #8e94a3;
  --faint: #6b7080;
  --line: #2a2e37;
  --check: #4a5060;
  --danger: #ff8a8a;
  --overlay: rgba(0, 0, 0, 0.55);

  --tag-over-bg: #3a1b1b;
  --tag-over: #ff9a9a;
  --tag-today-bg: #3a2e12;
  --tag-today: #f2c56b;
  --tag-later-bg: #2a2e37;
  --tag-later: #b8bdc9;

  --c-green: #4cc08d;
  --c-violet: #9b82ff;
  --c-coral: #ff8a5c;
  --c-blue: #6ea0ff;
  --c-pink: #ff7aa8;
  --c-amber: #f2b84b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Каркас ---------- */
.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px calc(150px + var(--safe-bottom));
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

.section-label {
  color: var(--muted);
  font-size: 13px;
  margin: 22px 4px 8px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-bottom));
}

.tabbar button {
  flex: 0 1 140px;
  border: 0;
  background: transparent;
  color: var(--faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 11px;
  border-radius: 10px;
}

.tabbar button[aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(58px + var(--safe-bottom));
  z-index: 19;
  padding: 10px 16px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.action-bar .btn {
  max-width: 528px;
  margin: 0 auto;
}

/* ---------- Кнопки и поля ---------- */
.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn.quiet {
  background: var(--field);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
}

.btn.block {
  display: flex;
  width: 100%;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.field {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--field);
  padding: 11px 12px;
  outline: none;
}

.field:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0;
}

textarea.field {
  resize: vertical;
  min-height: 72px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 14px 2px 6px;
}

.hint {
  color: var(--faint);
  font-size: 12px;
  margin: 6px 2px 0;
}

/* ---------- Чипы ---------- */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 14px;
  padding: 0 16px;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips.wrap {
  flex-wrap: wrap;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.chip {
  flex: none;
  border: 0;
  border-radius: 16px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.sheet .chip {
  background: var(--field);
}

.chip.weekday {
  width: 38px;
  justify-content: center;
  padding: 7px 0;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--on-ink);
}

.chip .count {
  color: var(--faint);
}

.chip[aria-pressed="true"] .count {
  color: inherit;
  opacity: 0.7;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--list-color, var(--faint));
}

/* ---------- Задачи ---------- */
.tasks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
}

.task-check {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--check);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-ink);
  padding: 0;
}

.task-check[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  overflow-wrap: anywhere;
}

.task.done .task-title {
  color: var(--faint);
  text-decoration: line-through;
}

.task-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  border-radius: 6px;
  padding: 2px 7px;
  background: var(--tag-later-bg);
  color: var(--tag-later);
}

.tag.over {
  background: var(--tag-over-bg);
  color: var(--tag-over);
}

.tag.today {
  background: var(--tag-today-bg);
  color: var(--tag-today);
}

/* ---------- Чеклист ---------- */
.progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.progress-track {
  flex: 1;
  max-width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--list-color, var(--ink));
}

.progress-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.check-item .task-check {
  margin-top: 0;
}

.check-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.check-item.done .check-title {
  color: var(--faint);
  text-decoration: line-through;
}

.check-item .icon-btn {
  color: var(--faint);
}

.check-add {
  margin-top: 6px;
}

.check-add .btn {
  flex: none;
}

.check-hide {
  margin-top: 6px;
}

.task > .dot {
  margin-top: 7px;
}

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

.empty h2 {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
}

.empty p {
  margin: 0 0 16px;
}

.more {
  margin-top: 12px;
}

/* ---------- Карточки и строки ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
}

.rows {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 13px 14px;
  min-height: 48px;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-main {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-sub {
  color: var(--muted);
  font-size: 13px;
}

.row .chev {
  color: var(--faint);
}

/* ---------- Профиль ---------- */
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  color: var(--avatar-fg);
  background: var(--avatar-bg);
}

.profile-name {
  font-weight: 600;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.switch {
  width: 46px;
  height: 28px;
  border-radius: 14px;
  border: 0;
  background: var(--check);
  position: relative;
  flex: none;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch[aria-checked="true"] {
  background: var(--ink);
}

.switch[aria-checked="true"]::after {
  transform: translateX(18px);
  background: var(--on-ink);
}

/* ---------- Статистика ---------- */
.segmented {
  display: flex;
  background: var(--line);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 0;
  font-size: 13px;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-grid .wide {
  grid-column: span 2;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

.stat-value small {
  font-size: 14px;
  font-weight: 400;
  color: var(--faint);
}

.bar-row + .bar-row {
  margin-top: 12px;
}

.bar-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-head .row-main {
  font-size: 14px;
}

.bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  margin-top: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--list-color);
}

/* ---------- Нижний лист ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + var(--safe-bottom));
  transform: translateY(24px);
  transition: transform 0.2s ease-out;
}

.sheet-backdrop.open .sheet {
  transform: none;
}

.sheet-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 12px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  margin: 0;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
}

.inline {
  display: flex;
  gap: 8px;
}

.inline > * {
  flex: 1;
  min-width: 0;
}

.palette {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--list-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 0;
}

.swatch[aria-pressed="true"] {
  box-shadow:
    0 0 0 3px var(--surface),
    0 0 0 5px var(--list-color);
}

/* ---------- Уведомления ---------- */
.toasts {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(126px + var(--safe-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  max-width: 420px;
}

.toast.error {
  background: var(--tag-over-bg);
  color: var(--tag-over);
}

.loader {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  margin: 60px auto;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 1.5s !important;
  }
}
