:root {
  color-scheme: light;
  font-family: "Avenir", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #fdf3ff, #f2faff 55%, #fffbf0);
  color: #2c3952;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(255, 255, 255, 0.6);
  --accent: #ff91a4;
  --accent-dark: #ec6c83;
  --layout-padding: clamp(12px, 3vw, 28px);
}

body {
  margin: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--layout-padding);
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
}

.card {
  width: min(520px, 100%);
  backdrop-filter: blur(16px);
  background: var(--card-bg);
  border-radius: 28px;
  border: 1px solid var(--card-border);
  box-shadow: 0 18px 40px rgba(44, 57, 82, 0.12);
  padding: clamp(20px, 4vw, 32px);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 24px);
  max-height: min(
    700px,
    calc(100dvh - (var(--layout-padding) + var(--layout-padding)))
  );
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.view {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 24px);
  min-height: 0;
  flex: 1;
}

.view[hidden] {
  display: none;
}

.view-templates {
  align-items: stretch;
  text-align: center;
  padding: clamp(12px, 3vw, 18px) clamp(16px, 4vw, 28px) clamp(20px, 5vw, 32px);
  overflow-y: auto;
}

.template-intro {
  margin: 0;
  color: rgba(44, 57, 82, 0.7);
  font-size: clamp(16px, 3.3vw, 18px);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: clamp(14px, 3vw, 22px);
  width: 100%;
}

.template-card {
  border: 2px solid transparent;
  border-radius: 24px;
  padding: clamp(18px, 3.5vw, 24px);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 26px rgba(44, 57, 82, 0.1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 220ms ease, border-color 180ms ease,
    background 180ms ease;
  color: inherit;
  font: inherit;
  width: 100%;
  border-style: solid;
}

.template-card .template-icon {
  font-size: clamp(32px, 6vw, 48px);
}

.template-card .template-title {
  font-size: clamp(18px, 3.6vw, 22px);
  font-weight: 700;
  color: rgba(44, 57, 82, 0.88);
}

.template-card .template-description {
  font-size: clamp(14px, 3.1vw, 16px);
  color: rgba(44, 57, 82, 0.66);
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-tag {
  background: rgba(255, 145, 164, 0.14);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 32px rgba(44, 57, 82, 0.14);
  border-color: rgba(255, 145, 164, 0.4);
  background: rgba(255, 255, 255, 0.92);
}

.template-card:focus-visible {
  outline: none;
  border-color: rgba(255, 145, 164, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 145, 164, 0.25);
  transform: translateY(-2px);
}

.title {
  font-size: clamp(24px, 4vw, 32px);
  margin: 0;
  letter-spacing: 0.03em;
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(12px, 2.5vw, 20px);
  flex: 1;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: clamp(16px, 4vw, 28px);
  padding-bottom: clamp(16px, 4vw, 28px);
}

.check-card {
  position: relative;
  border: 2px solid transparent;
  border-radius: 24px;
  padding: clamp(18px, 3.5vw, 24px) clamp(14px, 3vw, 18px);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 24px rgba(44, 57, 82, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: transform 180ms ease, box-shadow 240ms ease, border-color 180ms ease,
    background 180ms ease;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  outline: none;
  will-change: transform;
}

.check-card:focus-visible {
  border-color: rgba(236, 108, 131, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 145, 164, 0.25);
}

.check-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(44, 57, 82, 0.12);
}

.check-card.completed {
  background: linear-gradient(160deg, rgba(255, 226, 235, 0.9), rgba(255, 255, 255, 0.88));
  border-color: rgba(255, 145, 164, 0.65);
  box-shadow: 0 18px 40px rgba(255, 145, 164, 0.22);
}

.check-card.celebrate {
  animation: bounce-pop 520ms ease-out;
}

.icon {
  font-size: clamp(36px, 7vw, 52px);
  transition: transform 180ms ease;
}

.check-card.completed .icon {
  transform: scale(1.08) rotate(-3deg);
}

.check-card.celebrate .icon {
  animation: icon-pop 520ms ease-out;
}

.label {
  font-size: clamp(16px, 3.5vw, 20px);
  font-weight: 600;
  text-align: center;
  color: rgba(44, 57, 82, 0.85);
}

.sparkles {
  position: absolute;
  inset: -12px;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.sparkles span {
  font-size: clamp(24px, 7vw, 36px);
  line-height: 1;
  opacity: 0;
  transform: scale(0.2) translate(0, 0);
  animation: sparkle 960ms ease-out forwards;
  filter: drop-shadow(0 4px 6px rgba(44, 57, 82, 0.18));
}

@keyframes sparkle {
  0% {
    transform: scale(0.2) translate(0, 0) rotate(-20deg);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  55% {
    transform: scale(1.6) translate(var(--dx), var(--dy)) rotate(12deg);
    opacity: 1;
  }
  100% {
    transform: scale(0.7)
      translate(calc(var(--dx) * 1.4), calc(var(--dy) * 1.4))
      rotate(-30deg);
    opacity: 0;
  }
}

@keyframes bounce-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.08);
  }
  65% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes icon-pop {
  0% {
    transform: scale(1) rotate(0deg);
  }
  35% {
    transform: scale(1.25) rotate(-8deg);
  }
  70% {
    transform: scale(0.92) rotate(6deg);
  }
  100% {
    transform: scale(1.05) rotate(-3deg);
  }
}

.progress {
  margin-top: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "label track help config reset"
    "message message message message message";
  align-items: center;
  gap: 8px 12px;
  font-weight: 600;
  font-size: clamp(16px, 3vw, 18px);
  color: rgba(44, 57, 82, 0.75);
  padding: 9px clamp(14px, 3vw, 18px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  bottom: clamp(8px, 3vw, 20px);
  box-shadow: 0 12px 28px rgba(44, 57, 82, 0.14);
  backdrop-filter: blur(18px);
  z-index: 1;
  width: 100%;
  box-sizing: border-box;
  transition: box-shadow 280ms ease, transform 320ms ease;
}

.progress.complete {
  box-shadow: 0 18px 42px rgba(255, 145, 164, 0.28);
  transform: translateY(-2px);
}

#progress-label {
  grid-area: label;
  white-space: nowrap;
}

.config-button {
  grid-area: config;
}

.help-button {
  grid-area: help;
  color: rgba(44, 57, 82, 0.75);
  font-weight: 700;
}

.help-button:hover {
  transform: none;
}

.help-button:focus-visible {
  transform: none;
}

.celebration-message {
  grid-area: message;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: translateY(6px);
  color: var(--accent-dark);
  font-size: clamp(14px, 3vw, 16px);
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: normal;
  text-align: center;
  margin: 0;
  padding-top: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 320ms ease, transform 320ms ease, max-height 320ms ease;
}

.progress.complete .celebration-message {
  opacity: 1;
  transform: translateY(0);
  max-height: 64px;
  padding-top: 2px;
}

.progress.complete .celebration-message::before,
.progress.complete .celebration-message::after {
  content: "✨";
  font-size: 16px;
  display: inline-block;
  transform: translateY(-1px);
}

.progress.complete .celebration-message::before {
  margin-right: 8px;
}

.progress.complete .celebration-message::after {
  margin-left: 8px;
}

.progress-track {
  grid-area: track;
  width: 100%;
  min-width: 0;
}

#progress-label.complete {
  color: var(--accent-dark);
  text-shadow: 0 0 10px rgba(255, 145, 164, 0.45);
}

.progress-track {
  flex: 1;
  height: 10px;
  background: rgba(44, 57, 82, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd86f, #ff91a4);
  border-radius: 999px;
  transition: width 320ms ease, box-shadow 240ms ease;
  background-size: 100% 100%;
}

.progress-bar.complete {
  box-shadow: 0 0 12px rgba(255, 145, 164, 0.45);
}

.icon-button {
  border: none;
  background: rgba(44, 57, 82, 0.08);
  color: rgba(44, 57, 82, 0.7);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
  flex-shrink: 0;
}

.icon-button:hover {
  background: rgba(255, 145, 164, 0.18);
  color: var(--accent-dark);
  transform: rotate(6deg);
}

.icon-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.35);
}

.icon-button:active {
  transform: scale(0.95);
}

.reset-button {
  grid-area: reset;
}

.reset-button:hover {
  background: rgba(255, 145, 164, 0.18);
  color: var(--accent-dark);
  transform: rotate(10deg);
}

.reset-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.35);
}

.reset-button:active {
  transform: scale(0.95);
}

.reset-button:disabled {
  opacity: 0.45;
  cursor: default;
  background: rgba(44, 57, 82, 0.08);
  color: rgba(44, 57, 82, 0.5);
  transform: none !important;
}

.reset-button:disabled:hover {
  background: rgba(44, 57, 82, 0.08);
  color: rgba(44, 57, 82, 0.5);
}

.config-button:hover {
  transform: rotate(12deg);
}

.view-config {
  padding: clamp(4px, 1.5vw, 12px) clamp(12px, 3vw, 18px) clamp(16px, 4vw, 24px);
  gap: clamp(18px, 4vw, 28px);
  overflow-y: auto;
}

.config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.config-title {
  margin: 0;
  font-size: clamp(20px, 3.5vw, 26px);
  letter-spacing: 0.02em;
}

.close-config-button {
  font-size: 20px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: rgba(44, 57, 82, 0.75);
}

.config-field input {
  font: inherit;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(44, 57, 82, 0.18);
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.config-field input:focus {
  outline: none;
  border-color: rgba(255, 145, 164, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.2);
}

.config-tasks {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.add-task-button {
  border: none;
  background: rgba(255, 145, 164, 0.14);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.add-task-button:hover {
  background: rgba(255, 145, 164, 0.24);
  transform: translateY(-1px);
}

.config-task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-task {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(44, 57, 82, 0.12);
}

.config-task input {
  font: inherit;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(44, 57, 82, 0.18);
  background: rgba(255, 255, 255, 0.95);
}

.config-task input:focus {
  outline: none;
  border-color: rgba(255, 145, 164, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.2);
}

.input-error {
  border-color: #ff6b6b !important;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2) !important;
}

.config-task .task-icon-input {
  text-align: center;
  font-size: 20px;
}

.remove-task-button {
  border: none;
  background: rgba(44, 57, 82, 0.08);
  color: rgba(44, 57, 82, 0.7);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.remove-task-button:hover {
  background: rgba(255, 145, 164, 0.18);
  color: var(--accent-dark);
  transform: rotate(8deg);
}

.config-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(18px, 4vw, 28px);
}

.primary-button,
.secondary-button,
.danger-outline {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.danger-outline {
  background: transparent;
  border: 1px solid rgba(255, 107, 107, 0.7);
  color: rgba(220, 44, 44, 0.85);
}

.danger-outline:hover {
  background: rgba(255, 107, 107, 0.1);
  color: rgba(220, 44, 44, 0.95);
  box-shadow: 0 6px 14px rgba(220, 44, 44, 0.12);
}

.danger-outline:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.25);
}

.primary-button {
  background: linear-gradient(90deg, #ffd86f, #ff91a4);
  color: #2c3952;
}

.secondary-button {
  background: rgba(44, 57, 82, 0.08);
  color: rgba(44, 57, 82, 0.75);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(44, 57, 82, 0.12);
}

.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.25);
}

.card.config-open .view-main {
  display: none;
}

.card.config-open .view-config {
  display: flex;
}

.card.templates-open .view-main,
.card.templates-open .view-config {
  display: none;
}

.card.templates-open .view-templates {
  display: flex;
}

.card.templates-open {
  max-height: calc(100dvh - (var(--layout-padding) + var(--layout-padding)));
  height: calc(100dvh - (var(--layout-padding) + var(--layout-padding)));
  overflow: auto;
}

.card.help-open .view-main,
.card.help-open .view-config {
  display: none;
}

.card.help-open .view-help {
  display: flex;
}

.view-help {
  gap: clamp(18px, 4vw, 28px);
  padding: clamp(12px, 3vw, 20px);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.help-title {
  margin: 0;
  font-size: clamp(20px, 3.8vw, 26px);
  letter-spacing: 0.02em;
}

.help-title:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 145, 164, 0.3);
  border-radius: 12px;
  padding: 2px 6px;
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  color: rgba(44, 57, 82, 0.78);
  font-size: clamp(15px, 3.2vw, 17px);
}

.help-content ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.help-content li {
  line-height: 1.4;
}

.help-content .info-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 226, 235, 0.9), rgba(242, 249, 255, 0.9));
  border: 1px solid rgba(255, 145, 164, 0.22);
  box-shadow: 0 12px 24px rgba(44, 57, 82, 0.08);
  color: inherit;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 220ms ease, border-color 180ms ease,
    background 220ms ease;
}

.help-content .info-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(44, 57, 82, 0.12);
  border-color: rgba(255, 145, 164, 0.35);
  background: linear-gradient(135deg, rgba(255, 223, 236, 0.95), rgba(238, 247, 255, 0.95));
}

.help-content .info-link:focus-visible {
  outline: none;
  border-color: rgba(255, 145, 164, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 145, 164, 0.25), 0 18px 32px rgba(44, 57, 82, 0.12);
  transform: translateY(-1px);
}

.app-version {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(44, 57, 82, 0.42);
  letter-spacing: 0.02em;
}

.info-link-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 26px;
}

.info-link-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-link-title {
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(44, 57, 82, 0.9);
}

.info-link-subtitle {
  font-size: 14px;
  color: rgba(44, 57, 82, 0.6);
}

.info-link-arrow {
  margin-left: auto;
  font-size: 20px;
  color: rgba(236, 108, 131, 0.9);
}

.help-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.card.all-complete {
  background: linear-gradient(
    130deg,
    rgba(255, 216, 243, 0.88),
    rgba(255, 247, 208, 0.78),
    rgba(213, 245, 255, 0.85),
    rgba(255, 216, 243, 0.88)
  );
  background-size: 220% 220%;
  animation: celebrate-gradient 6.8s ease-in-out infinite;
  border-color: rgba(255, 145, 164, 0.8);
  box-shadow: 0 24px 56px rgba(255, 145, 164, 0.25);
}

.card.all-complete::before {
  content: "";
  position: absolute;
  inset: -12%;
  background-image: radial-gradient(circle at 20% 20%, rgba(255, 177, 200, 0.32), transparent 52%),
    radial-gradient(circle at 80% 30%, rgba(255, 208, 149, 0.28), transparent 48%),
    radial-gradient(circle at 40% 75%, rgba(178, 235, 242, 0.3), transparent 50%),
    radial-gradient(circle at 70% 85%, rgba(255, 177, 200, 0.25), transparent 45%);
  background-repeat: repeat;
  background-size: 220px 240px;
  opacity: 0.2;
  animation: float-soft 14s linear infinite;
  transition: opacity 400ms ease;
  pointer-events: none;
  mix-blend-mode: screen;
}

.card.all-complete::after {
  content: "";
  position: absolute;
  inset: -10%;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.35), transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.4), transparent 50%);
  animation: celebrate-shimmer 3.6s ease-in-out infinite;
  opacity: 0.3;
  mix-blend-mode: screen;
  pointer-events: none;
}

@keyframes celebrate-gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes celebrate-shimmer {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.35;
  }
  45% {
    transform: scale(1.02);
    opacity: 0.5;
  }
  65% {
    transform: scale(0.99);
    opacity: 0.4;
  }
}

@keyframes float-soft {
  0% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-16px, -12px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 1024px) {
  .card {
    height: calc(100dvh - (var(--layout-padding) + var(--layout-padding)));
    max-height: none;
  }
}

@media (max-width: 440px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .config-task {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }

  .config-task .task-icon-input {
    grid-column: 1 / 2;
  }

  .config-task .task-label-input {
    grid-column: 1 / -1;
  }

  .config-task .remove-task-button {
    grid-column: 2 / 3;
    justify-self: end;
  }
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .check-card.celebrate,
  .template-card {
    animation: none !important;
  }

  .sparkles {
    display: none !important;
  }

  .card.all-complete::before,
  .card.all-complete::after {
    animation: none !important;
    opacity: 0.3 !important;
  }
}
