* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --card-2: #f8f9fb;
  --text: #111827;
  --text-soft: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 22px;
}

body.dark {
  --bg: #0f172a;
  --card: #111827;
  --card-2: #1f2937;
  --text: #f9fafb;
  --text-soft: #9ca3af;
  --line: #2b3648;
  --blue: #3b82f6;
  --blue-hover: #60a5fa;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #f87171;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #dfe5ee 100%);
  color: var(--text);
}

body.dark {
  background: linear-gradient(180deg, var(--bg) 0%, #0b1220 100%);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.bg-orb {
  display: none;
}

.welcome-card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 24px;
  text-align: center;
}

.welcome-card.hidden {
  display: none;
}

.welcome-eyebrow {
  margin: 0 0 12px;
  color: #93c5fd;
  font-weight: 700;
}

.welcome-title {
  margin: 0;
  font-size: 52px;
  line-height: 1.02;
  letter-spacing: -1.8px;
  color: white;
}

.welcome-text {
  max-width: 700px;
  margin: 18px 0 0;
  color: #d1d5db;
  font-size: 19px;
  line-height: 1.5;
}

.welcome-form {
  width: min(100%, 520px);
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.welcome-form input {
  flex: 1;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  font-size: 16px;
  outline: none;
}

.welcome-button {
  border: none;
  border-radius: 999px;
  padding: 0 22px;
  background: var(--blue);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.welcome-button:hover {
  background: var(--blue-hover);
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  padding: 24px;
}

.celebration-overlay.show {
  display: flex;
}

.celebration-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.celebration-emoji {
  font-size: 42px;
  margin-bottom: 8px;
}

.celebration-box h2 {
  margin: 0 0 8px;
  font-size: 34px;
}

.celebration-box p {
  margin: 0;
  color: var(--text-soft);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 31;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  animation: confettiFall linear forwards;
}

.app-window {
  width: 100%;
  max-width: 980px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--shadow);
}

body.dark .app-window {
  background: rgba(17, 24, 39, 0.88);
  border-color: rgba(255, 255, 255, 0.06);
}

.topbar,
.lists-bar,
.controls-row,
.top-row,
.edit-row,
.subtask-row,
.subtask-edit-row {
  display: flex;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.date-label {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
}

.time-label {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
}

.topbar-btn {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  cursor: pointer;
  font-size: 20px;
  color: var(--text);
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-size: 52px;
  line-height: 1.02;
  letter-spacing: -2px;
}

.subheadline {
  margin: 12px auto 0;
  max-width: 640px;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.45;
}

.lists-bar,
.controls-row {
  margin-bottom: 14px;
}

.list-selector-wrap {
  flex: 1;
}

#listSelect,
#taskInput,
#searchInput,
.edit-input,
.subtask-row input,
.welcome-form input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.secondary-btn,
.primary-btn,
.subtask-add-btn,
.save-btn,
.cancel-btn {
  border: none;
  border-radius: 18px;
  height: 54px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-soft {
  color: var(--red);
}

.primary-btn {
  min-width: 160px;
  background: var(--blue);
  color: white;
}

.primary-btn:hover,
.welcome-button:hover,
.subtask-add-btn:hover,
.save-btn:hover {
  filter: brightness(1.05);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box,
.progress-card,
.task-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.stat-box {
  padding: 18px;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-soft);
}

.stat-value {
  display: block;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
}

.progress-card {
  padding: 18px;
  margin-bottom: 18px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #dbe2ea;
  border-radius: 999px;
  overflow: hidden;
}

body.dark .progress-track {
  background: #263142;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
  transition: width 0.25s ease;
}

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

.filter-btn {
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.top-row {
  margin-bottom: 24px;
}

#taskList {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.task-card {
  padding: 16px;
}

.task-card.dragging {
  opacity: 0.6;
}

.task-card.drag-over {
  outline: 2px dashed var(--blue);
  outline-offset: 2px;
}

.task-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-title-btn {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card-2);
  color: var(--text);
  text-align: left;
  padding: 16px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 18px;
  cursor: pointer;
}

.edit-btn {
  background: #fff7e8;
  color: var(--orange);
}

.delete-btn {
  background: #fff1f2;
  color: var(--red);
}

body.dark .edit-btn,
body.dark .delete-btn,
body.dark .subtask-edit-btn,
body.dark .subtask-delete-btn {
  background: var(--card-2);
}

.edit-row,
.subtask-edit-row {
  margin-top: 12px;
}

.edit-input {
  flex: 1;
}

.save-btn {
  min-width: 110px;
  background: var(--green);
  color: white;
}

.cancel-btn {
  min-width: 110px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.subtask-area {
  margin-top: 16px;
  padding-top: 6px;
}

.subtask-row input {
  flex: 1;
}

.subtask-add-btn {
  width: 54px;
  padding: 0;
  background: var(--green);
  color: white;
  font-size: 26px;
}

.subtask-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card-2);
}

.subtask-item.done {
  background: rgba(34, 197, 94, 0.08);
}

.subtask-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.check-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #b8c0cc;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.check-circle.checked {
  background: var(--green);
  border-color: var(--green);
}

.check-circle.checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.subtask-text {
  word-break: break-word;
}

.checked-text {
  text-decoration: line-through;
  color: var(--text-soft);
}

.subtask-actions {
  display: flex;
  gap: 8px;
}

.subtask-small-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.subtask-edit-btn {
  color: var(--orange);
}

.subtask-delete-btn {
  color: var(--red);
}

.empty-state {
  text-align: center;
  padding: 42px 20px 16px;
}

.empty-emoji {
  font-size: 44px;
  margin-bottom: 10px;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.empty-state p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(105vh) rotate(360deg);
    opacity: 0.9;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .app-window {
    padding: 20px;
    border-radius: 24px;
  }

  .welcome-title {
    font-size: 40px;
  }

  .welcome-text {
    font-size: 17px;
  }

  .welcome-form,
  .lists-bar,
  .controls-row,
  .top-row,
  .edit-row,
  .subtask-edit-row,
  .subtask-row {
    flex-direction: column;
  }

  .hero h1 {
    font-size: 38px;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .filter-btn,
  .primary-btn,
  .secondary-btn,
  .save-btn,
  .cancel-btn,
  .welcome-button {
    width: 100%;
  }

  .task-header {
    flex-wrap: wrap;
  }

  .task-title-btn {
    font-size: 18px;
  }
}
