/* ============================================================
   Todo app — Figma Make inspired redesign
   Centered card · pink/purple gradient · minimalist
   ============================================================ */

:root {
  /* Brand gradient: pink → purple */
  --grad-start: #ec4899;
  --grad-mid:   #d946ef;
  --grad-end:   #a855f7;

  /* Neutrals */
  --bg:          #fcfafe;
  --surface:     #ffffff;
  --text:        #1f2937;
  --text-2:      #6b7280;
  --text-3:      #9ca3af;
  --border:      #e5e7eb;
  --track:       #f3f4f6;

  /* Tag chip palette (light pastels) */
  --tag-bg:      #f3e8ff;
  --tag-fg:      #7c3aed;
  --tag-dot:     #a855f7;

  /* Due-date chip */
  --date-fg:     #3b82f6;
  --date-bg:     #eff6ff;

  /* Surfaces & elevation */
  --radius:      12px;
  --radius-lg:   16px;
  --radius-pill: 999px;
  --shadow-sm:   0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-md:   0 8px 24px rgba(168, 85, 247, 0.10), 0 2px 6px rgba(17, 24, 39, 0.04);
  --shadow-lg:   0 12px 32px rgba(168, 85, 247, 0.16);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* subtle warm wash matching figma */
  background-image:
    radial-gradient(circle at 0% 0%,   rgba(236, 72, 153, 0.04), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(168, 85, 247, 0.05), transparent 50%);
  background-attachment: fixed;
}

/* ============================================================
   App layout — single centered card
   ============================================================ */
#app {
  display: flex;
  justify-content: center;
  padding: 48px 20px 80px;
  min-height: 100vh;
}

.card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   Header
   ============================================================ */
.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 4px;
}
.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.30);
  margin-bottom: 4px;
}
.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 400;
}

/* ============================================================
   Add row
   ============================================================ */
.add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms, box-shadow 120ms;
}
.add-input::placeholder { color: var(--text-3); }
.add-input:focus {
  outline: none;
  border-color: var(--grad-end);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}
.add-icon-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms, color 120ms, background 120ms;
  text-align: center;
}
.add-icon-btn:hover {
  border-color: var(--grad-end);
  color: var(--grad-end);
}
.add-priority { min-width: 56px; }
.add-submit {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
  transition: transform 100ms, box-shadow 120ms;
  flex-shrink: 0;
}
.add-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(236, 72, 153, 0.35); }
.add-submit:active { transform: translateY(0); }

/* ============================================================
   Filter row
   ============================================================ */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.filter-label svg { color: var(--grad-end); }
.filter-select {
  height: 32px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 120ms;
}
.filter-select:hover { border-color: var(--grad-end); }
.filter-select:focus { outline: none; border-color: var(--grad-end); box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12); }

/* ============================================================
   Tab bar (segmented control)
   ============================================================ */
.tab-bar {
  display: flex;
  background: var(--track);
  border-radius: var(--radius);
  padding: 4px;
  gap: 2px;
}
.tab {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.04);
}

/* ============================================================
   Task list
   ============================================================ */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms, transform 100ms;
}
.task-item:hover {
  border-color: rgba(168, 85, 247, 0.40);
  box-shadow: var(--shadow-sm);
}
.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--text-3);
}
.task-item.done {
  background: #f9fafb;  /* slight gray tint to mark completed */
}
.task-item.done .task-check {
  background: #1f2937;  /* solid dark, not gradient — matches figma */
  border-color: transparent;
}
.task-item.done .task-check svg { opacity: 1; }
.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--text-3);
}
.task-item.done .task-tags,
.task-item.done .task-due { opacity: 0.55; }

.task-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms;
  position: relative;
  flex-shrink: 0;
}
.task-check:hover { border-color: var(--grad-end); }
.task-check svg { opacity: 0; transition: opacity 120ms; }
.task-check svg polyline { stroke: white; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; fill: none; }

.task-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.task-tag-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}
.task-due {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--date-bg);
  color: var(--date-fg);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}
.task-due.overdue { background: #fef2f2; color: #dc2626; }
.task-due svg { width: 10px; height: 10px; }

.task-star {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: all 120ms;
  flex-shrink: 0;
}
.task-star:hover { background: rgba(168, 85, 247, 0.08); color: var(--grad-end); }
.task-star.active { color: #f59e0b; }
.task-star.active svg polygon { fill: currentColor; }

.empty-state {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 32px 0;
}

/* ============================================================
   Detail panel (modal-style, slides in from right)
   ============================================================ */
.task-detail {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -16px 0 40px rgba(17, 24, 39, 0.10);
  z-index: 100;
  padding: 28px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: slideIn 200ms ease-out;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.task-detail.hidden { display: none; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.detail-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}
.detail-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 120ms;
}
.detail-close:hover { background: var(--track); color: var(--text); }

.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.detail-label {
  min-width: 60px;
  color: var(--text-2);
  font-weight: 500;
}
.detail-value {
  color: var(--text);
}
.detail-value.editable { cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.detail-value.editable:hover { background: var(--track); color: var(--grad-end); }

.detail-select {
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.detail-select:hover { border-color: var(--grad-end); }
.detail-select:focus {
  outline: none;
  border-color: var(--grad-end);
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.15);
}

.detail-btn-group {
  display: flex;
  background: var(--track);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.detail-btn-item {
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms;
}
.detail-btn-item:hover { color: var(--text); }
.detail-btn-item.active {
  background: var(--surface);
  color: var(--grad-end);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
}

.detail-btn-star {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms;
}
.detail-btn-star:hover { border-color: var(--grad-end); color: var(--grad-end); }
.detail-btn-star.active {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #f59e0b;
}
.detail-btn-star.active:hover { background: #fef3c7; }

.detail-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.detail-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms;
}
.detail-tag:hover { background: var(--grad-end); color: white; }
.detail-tag-add {
  background: transparent;
  color: var(--text-3);
  border: 1px dashed var(--text-3);
  font-weight: 600;
  padding: 2px 7px;
}
.detail-tag-add:hover {
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-color: var(--grad-end);
  border-style: solid;
}

.tag-input {
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--grad-end);
  border-radius: var(--radius-pill);
  outline: none;
  width: 80px;
  background: var(--surface);
}

.detail-notes-input {
  width: 100%;
  min-height: 60px;
  border-radius: var(--radius);
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.add-modal-field textarea {
  height: auto;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 120ms, box-shadow 120ms;
}
.add-modal-field textarea::placeholder { color: var(--text-3); }
.add-modal-field textarea:focus {
  outline: none;
  border-color: var(--grad-end);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.detail-btn {
  flex: 1;
  min-width: 80px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms;
}
.detail-btn:hover { background: var(--track); }
.detail-btn.primary {
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.20);
}
.detail-btn.primary:hover { box-shadow: 0 4px 12px rgba(236, 72, 153, 0.30); }
.detail-btn.danger { color: #dc2626; }
.detail-btn.danger:hover { background: #fef2f2; }

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
}
.subtask-item.done span { text-decoration: line-through; color: var(--text-3); }
.subtask-item input[type=checkbox] { accent-color: var(--grad-end); }
.subtask-item button {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.subtask-item button:hover { color: #dc2626; background: #fef2f2; }

.subtask-add {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.subtask-add input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}
.subtask-add input:focus { border-color: var(--grad-end); }
.subtask-add button {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.add-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-modal.hidden { display: none; }
.add-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.40);
}
.add-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 200ms ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.add-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.add-modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.add-modal-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 120ms;
}
.add-modal-close:hover { background: var(--track); color: var(--text); }
.add-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.add-modal-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.add-modal-field input {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms, box-shadow 120ms;
}
.add-modal-field input::placeholder { color: var(--text-3); }
.add-modal-field input:focus {
  outline: none;
  border-color: var(--grad-end);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12);
}
.add-modal-btn-group {
  display: flex;
  background: var(--track);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.add-modal-btn-item {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms;
}
.add-modal-btn-item:hover { color: var(--text); }
.add-modal-btn-item.active {
  background: var(--surface);
  color: var(--grad-end);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
}
.add-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.add-modal-cancel {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms;
}
.add-modal-cancel:hover { background: var(--track); }
.add-modal-submit {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.25);
  transition: transform 100ms, box-shadow 120ms;
}
.add-modal-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35); }
.add-modal-submit:active { transform: translateY(0); }
body.modal-open .card { opacity: 0.5; pointer-events: none; }

.hidden { display: none !important; }

/* ============================================================
   Login overlay
   ============================================================ */
.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: #fcfafe;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 8px 48px rgba(168,85,247,0.10);
  text-align: center;
}

/* ============================================================
   Backdrop for detail panel
   ============================================================ */
body.detail-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.30);
  z-index: 99;
  animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   Responsive — narrow screens
   ============================================================ */
@media (max-width: 600px) {
  #app { padding: 16px 12px 60px; }
  .card { padding: 20px 16px 16px; gap: 16px; }
  .title { font-size: 22px; }
  .add-row { flex-wrap: wrap; }
  .add-input { min-width: 100%; }
  .filter-row { font-size: 12px; }
  .task-detail { width: 100vw; }
}
