:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --fg: #1f2933;
  --panel: #ffffff;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --border: #d9dce3;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --fg: #e2e8f0;
    --panel: #121b33;
    --accent-soft: rgba(99, 102, 241, 0.22);
    --border: rgba(148, 163, 184, 0.24);
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.45);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, rgba(99, 102, 241, 0.12), transparent 55%), var(--bg);
  color: var(--fg);
  display: flex;
  justify-content: center;
  padding: clamp(24px, 5vw, 60px) 16px;
}

.app {
  width: min(680px, 100%);
  background: var(--panel);
  border-radius: 28px;
  padding: clamp(24px, 5vw, 48px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 32px;
}

header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 42px);
  letter-spacing: -0.04em;
}

header p {
  margin: 0;
  color: rgba(99, 102, 241, 0.9);
  font-weight: 500;
}

form {
  display: grid;
  gap: 12px;
}

.new-task {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.new-task input[type="text"] {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 16px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  background: transparent;
  color: inherit;
}

.new-task input[type="text"]:focus {
  border-color: rgba(99, 102, 241, 0.6);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.details-field textarea {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 15px;
  min-height: 120px;
  resize: vertical;
  background: transparent;
  color: inherit;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.details-field textarea:focus {
  border-color: rgba(99, 102, 241, 0.6);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.new-task button {
  border: none;
  border-radius: 14px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.new-task button:active {
  transform: translateY(1px);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background 0.2s ease, border 0.2s ease;
}

.chip.active {
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.6);
  color: var(--accent);
}

.chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(18px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.checkbox {
  position: relative;
  width: 22px;
  height: 22px;
}

.checkbox input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.checkbox span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.4);
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.checkbox input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox svg {
  width: 12px;
  height: 12px;
  stroke: white;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.checkbox input:checked + span svg {
  opacity: 1;
}

.item label {
  display: grid;
  gap: 6px;
  cursor: text;
}

.item label span {
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
}

.item.completed label span {
  text-decoration: line-through;
  color: rgba(100, 116, 139, 0.7);
}

.meta {
  font-size: 13px;
  color: rgba(100, 116, 139, 0.8);
}

.details {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(71, 85, 105, 0.95);
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 12px;
  padding: 6px 10px;
  background: rgba(99, 102, 241, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.details:hover {
  background: rgba(99, 102, 241, 0.14);
}

.details:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.details.empty {
  background: transparent;
  color: rgba(99, 102, 241, 0.8);
  border: 1px dashed rgba(99, 102, 241, 0.3);
}

.details.empty:hover {
  background: rgba(99, 102, 241, 0.1);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: rgba(100, 116, 139, 0.9);
}

.actions button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.actions button:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 32px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  color: rgba(100, 116, 139, 0.75);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.edit-input {
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 16px;
  background: rgba(99, 102, 241, 0.08);
  color: inherit;
}

.edit-textarea {
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  min-height: 120px;
  resize: vertical;
  background: rgba(99, 102, 241, 0.08);
  color: inherit;
}

@media (max-width: 640px) {
  .app {
    padding: 24px;
    border-radius: 18px;
  }

  .item {
    grid-template-columns: auto 1fr;
    grid-auto-flow: dense;
  }

  .actions {
    justify-self: start;
    grid-column: 1 / -1;
    margin-top: 4px;
  }
}
