* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 360px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

/* ---------- Accent colors ---------- */
body[data-accent="violet"] { --accent: #8b5cf6; --accent-2: #a78bfa; }
body[data-accent="blue"]   { --accent: #3b82f6; --accent-2: #60a5fa; }
body[data-accent="teal"]   { --accent: #14b8a6; --accent-2: #2dd4bf; }
body[data-accent="green"]  { --accent: #22c55e; --accent-2: #4ade80; }
body[data-accent="amber"]  { --accent: #f59e0b; --accent-2: #fbbf24; }
body[data-accent="rose"]   { --accent: #f43f5e; --accent-2: #fb7185; }
body[data-accent="pink"]   { --accent: #ec4899; --accent-2: #f472b6; }
body[data-accent="slate"]  { --accent: #64748b; --accent-2: #94a3b8; }

/* ---------- Themes ---------- */
body[data-theme="dark"] {
  --bg: #16161d;
  --surface: #1f1f29;
  --surface-2: #262632;
  --text: #f1f1f4;
  --text-muted: #9797a6;
  --border: #34343f;
  --danger: #f87171;
  --accent-contrast: #0f0f14;
}

body[data-theme="light"] {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f0f0f6;
  --text: #1c1c26;
  --text-muted: #6b6b7b;
  --border: #e3e3ec;
  --danger: #dc2626;
  --accent-contrast: #ffffff;
}

.app {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}

.icon-btn.active {
  color: var(--accent);
  transform: rotate(45deg);
}

/* ---------- Settings panel ---------- */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideDown 0.15s ease;
}

.settings-panel.hidden {
  display: none;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.theme-toggle {
  display: flex;
  gap: 6px;
}

.theme-opt {
  flex: 1;
  padding: 6px 0;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-opt.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch.selected {
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--sw);
}

/* ---------- Add form ---------- */
.add-form {
  display: flex;
  gap: 8px;
}

#taskInput {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#taskInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

#taskInput::placeholder {
  color: var(--text-muted);
}

.add-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.add-btn:hover {
  filter: brightness(1.08);
}

.add-btn:active {
  transform: scale(0.94);
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 6px;
}

.filter-btn {
  flex: 1;
  padding: 6px 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn.active {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.task-list::-webkit-scrollbar {
  width: 6px;
}

.task-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.task-checkbox svg {
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.12s ease;
}

.task-item.completed .task-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.task-item.completed .task-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.task-text {
  flex: 1;
  font-size: 13px;
  word-break: break-word;
  outline: none;
  cursor: text;
}

.task-item.completed .task-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.task-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.task-item:hover .task-delete {
  opacity: 1;
}

.task-delete:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state.hidden,
.task-list.hidden {
  display: none;
}

/* ---------- Footer ---------- */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.item-count {
  font-size: 12px;
  color: var(--text-muted);
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* ---------- Support note ---------- */
.support-note {
  margin: 0;
  padding-top: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.support-note a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

.support-note a:hover {
  color: var(--accent-2);
}
