* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --green: #22c55e;
  --text: #1f2430;
  --text-dim: #8a8f9e;
  --line: #e6e8ef;
  --bg: #f3f5f8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 48px 16px;
  touch-action: manipulation; /* без зума по двойному тапу */
  overscroll-behavior: none;
}

.app {
  width: 100%;
  max-width: 480px;
}

/* ---------- Header ---------- */

.header {
  margin-bottom: 24px;
}

.header h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header .date {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 15px;
  text-transform: capitalize;
}

/* ---------- Add form ---------- */

.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.add-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.add-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.add-btn {
  flex: 0 0 auto;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.add-btn:hover { background: var(--accent-dark); }
.add-btn:active { transform: scale(0.97); }

.form-hint {
  margin: -10px 0 14px 4px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Task list ---------- */

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  transition: opacity 0.4s ease, height 0.4s ease,
              transform 0.4s ease;
}

/* подложка, проявляется при свайпе вправо */
.swipe-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  background: #e7f9ee;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}

.swipe-hint.left {
  justify-content: flex-end;
  color: #ef9f44;
  background: #fdf3e4;
}

.task.swiping .swipe-hint {
  opacity: 1;
}

.task-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  touch-action: pan-y; /* вертикальный скролл остаётся, горизонталь — наш */
}

.task.dragging .task-inner {
  transition: none;
}

@keyframes task-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task.enter { animation: task-in 0.35s ease; }

/* уход задачи: затухание + схлопывание высоты (соседи подъезжают вверх) */
.task.leaving {
  opacity: 0;
  height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  transform: translateX(24px);
  pointer-events: none;
}

/* круглый чекбокс */
.check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #cfd3de;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.25s, background 0.25s, transform 0.15s;
}

.check:hover {
  border-color: var(--green);
  transform: scale(1.08);
}

.check svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.3s ease 0.05s;
}

.task.completing .check {
  background: var(--green);
  border-color: var(--green);
}

.task.completing .check svg {
  stroke-dashoffset: 0;
}

/* текст задачи + анимация зачёркивания */
.task-text {
  position: relative;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
  transition: color 0.5s ease;
}

.task-text::after {
  content: "";
  position: absolute;
  left: 0;
  top: 55%;
  width: 100%;
  height: 2px;
  background: var(--text-dim);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s ease;
}

.task.completing .task-text {
  color: var(--text-dim);
}

.task.completing .task-text::after {
  transform: scaleX(1);
}

/* кнопка редактирования */
.edit-btn {
  margin-left: auto;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #c3c7d4;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.2s, background 0.2s;
}

.edit-btn:hover {
  color: var(--accent);
  background: #f0f0fb;
}

.edit-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* кнопка удаления */
.del-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #c3c7d4;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.2s, background 0.2s;
}

.del-btn:hover {
  color: #ef4444;
  background: #fdf0f0;
}

.del-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* плавающая вкладка «Следующий день» */
.nav-btn {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 50;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.nav-btn:hover { background: var(--accent-dark); }
.nav-btn:active { transform: scale(0.95); }

/* инлайн-редактирование */
.edit-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ---------- Пустое состояние ---------- */

.empty-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 24px 0;
}

/* ---------- Карточка успеха ---------- */

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.success-card {
  background: linear-gradient(160deg, #ffffff 0%, #f0fdf4 100%);
  border: 1px solid #d7f0e0;
  border-radius: 18px;
  padding: 32px 24px 20px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(34, 197, 94, 0.10);
  animation: card-in 0.5s ease;
}

.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
}

.success-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-icon circle {
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: draw 0.6s ease forwards;
}

.success-icon path {
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
  animation: draw 0.4s ease 0.45s forwards;
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.success-card h2 {
  font-size: 22px;
  font-weight: 800;
}

.success-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 15px;
}

/* разворачивающийся список выполненных */
.done-toggle {
  margin-top: 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.done-toggle:hover { background: #fafafc; }

.done-toggle .chevron {
  width: 14px;
  height: 14px;
  stroke: var(--text-dim);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s ease;
}

.done-toggle.open .chevron {
  transform: rotate(180deg);
}

.done-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.done-wrap.open {
  grid-template-rows: 1fr;
}

.done-list {
  list-style: none;
  overflow: hidden;
  min-height: 0;
  text-align: left;
}

.done-list li {
  padding: 10px 4px;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: line-through;
  border-bottom: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.done-list li:last-child { border-bottom: none; }

.done-list li::before {
  content: "";
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l3 3 5-6' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
}

/* ---------- Переключатель тем ---------- */

.settings-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(31, 36, 48, 0.10);
  transition: transform 0.35s ease, box-shadow 0.2s;
}

.settings-btn:hover { transform: rotate(35deg); }
.settings-btn:active { transform: rotate(35deg) scale(0.92); }

.settings-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--text-dim);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.theme-panel {
  position: fixed;
  top: 66px;
  right: 14px;
  z-index: 50;
  width: 235px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(31, 36, 48, 0.16);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: panel-in 0.2s ease;
}

.theme-panel[hidden] { display: none; }

.theme-panel button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  color: var(--text);
}

.theme-panel button span {
  font-size: 12px;
  color: var(--text-dim);
}

.theme-panel button:hover { background: #f3f4f8; }

.theme-panel button.active {
  background: #eef0fe;
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- Тема: Минимализм ---------- */

body[data-theme="minimal"] { --bg: #ffffff; }

body[data-theme="minimal"] .header h1 {
  font-size: 40px;
  font-weight: 900;
}

body[data-theme="minimal"] .task-list { gap: 0; }

body[data-theme="minimal"] .task-inner {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 16px 4px;
}

body[data-theme="minimal"] .swipe-hint { border-radius: 0; }

body[data-theme="minimal"] .check {
  border-color: #1f2430;
  background: transparent;
}

body[data-theme="minimal"] .add-form input {
  border: none;
  border-bottom: 2px solid #1f2430;
  border-radius: 0;
  background: transparent;
}

body[data-theme="minimal"] .add-form input:focus {
  box-shadow: none;
  border-color: var(--accent);
}

body[data-theme="minimal"] .add-btn {
  background: #1f2430;
  border-radius: 8px;
}

body[data-theme="minimal"] .success-card {
  background: none;
  border: none;
  box-shadow: none;
}

body[data-theme="minimal"] .done-toggle {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

body[data-theme="minimal"] .theme-panel,
body[data-theme="minimal"] .settings-btn {
  border: 1px solid #1f2430;
}

/* ---------- Тема: Soft UI (неоморфизм) ---------- */

body[data-theme="soft"] {
  --bg: #e3e7ee;
  --text: #3a4454;
  --text-dim: #7a8397;
}

body[data-theme="soft"] .task-list { gap: 14px; }

body[data-theme="soft"] .task-inner {
  background: #e3e7ee;
  border: none;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 7px 7px 14px #c3c9d4, -7px -7px 14px #ffffff;
}

body[data-theme="soft"] .swipe-hint {
  border-radius: 18px;
  background: #d5efdf;
}

body[data-theme="soft"] .check {
  background: #e3e7ee;
  border: none;
  box-shadow: inset 3px 3px 6px #c3c9d4, inset -3px -3px 6px #ffffff;
}

body[data-theme="soft"] .check:hover {
  transform: none;
  box-shadow: 3px 3px 8px #c3c9d4, -3px -3px 8px #ffffff;
}

body[data-theme="soft"] .task.completing .check {
  background: var(--green);
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.25);
}

body[data-theme="soft"] .add-form input {
  background: #e3e7ee;
  border: none;
  border-radius: 16px;
  box-shadow: inset 4px 4px 10px #c3c9d4, inset -4px -4px 10px #ffffff;
}

body[data-theme="soft"] .add-form input:focus { box-shadow: inset 4px 4px 10px #c3c9d4, inset -4px -4px 10px #ffffff, 0 0 0 3px rgba(99, 102, 241, 0.2); }

body[data-theme="soft"] .add-btn {
  border-radius: 16px;
  box-shadow: 5px 5px 12px #c3c9d4, -5px -5px 12px #ffffff;
}

body[data-theme="soft"] .success-card {
  background: #e3e7ee;
  border: none;
  border-radius: 22px;
  box-shadow: 8px 8px 18px #c3c9d4, -8px -8px 18px #ffffff;
}

body[data-theme="soft"] .done-toggle {
  background: #e3e7ee;
  border: none;
  border-radius: 14px;
  box-shadow: inset 3px 3px 8px #c3c9d4, inset -3px -3px 8px #ffffff;
}

body[data-theme="soft"] .settings-btn,
body[data-theme="soft"] .theme-panel {
  background: #e3e7ee;
  border: none;
  box-shadow: 5px 5px 12px #c3c9d4, -5px -5px 12px #ffffff;
}

body[data-theme="soft"] .theme-panel button:hover { background: #dde2ec; }
body[data-theme="soft"] .theme-panel button.active { background: #d8ddf7; box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Тема: Карточки ---------- */

body[data-theme="cards"] { --bg: #eceff4; }

body[data-theme="cards"] .task-list { gap: 14px; }

body[data-theme="cards"] .task-inner {
  border: none;
  border-left: 5px solid var(--accent);
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: 0 6px 18px rgba(31, 36, 48, 0.09);
}

/* цветные акценты по кругу — разные «типы» дел */
body[data-theme="cards"] .task:nth-child(4n + 2) .task-inner { border-left-color: #f59e0b; }
body[data-theme="cards"] .task:nth-child(4n + 3) .task-inner { border-left-color: #22c55e; }
body[data-theme="cards"] .task:nth-child(4n + 4) .task-inner { border-left-color: #ec4899; }

body[data-theme="cards"] .swipe-hint { border-radius: 18px; }

body[data-theme="cards"] .add-form input {
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(31, 36, 48, 0.07);
}

body[data-theme="cards"] .add-btn { border-radius: 14px; }

body[data-theme="cards"] .success-card {
  border: none;
  border-radius: 22px;
  box-shadow: 0 14px 36px rgba(34, 197, 94, 0.16);
}

body[data-theme="cards"] .done-toggle {
  border: none;
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(31, 36, 48, 0.07);
}

/* ---------- Мобильная адаптация ---------- */

@media (max-width: 520px) {
  body {
    padding: 20px 12px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .header h1 { font-size: 28px; }

  /* font-size >= 16px, чтобы iOS не зумил при фокусе */
  .add-form input,
  .task-text { font-size: 16px; }

  .add-form { gap: 6px; }
  .add-form input { padding: 14px 12px; }
  .add-btn { padding: 14px 14px; }

  .task-inner { padding: 16px; }
  .check { width: 28px; height: 28px; }
}
