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

body {
  background-color: #F5F0E8;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

main {
  width: 100%;
  display: flex;
  justify-content: center;
}

.todo-card {
  background: #FFFFFF;
  border: 1px solid #E2DDD6;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  border-top: 4px solid #4F46E5;
}

/* ── HEADER ── */
.todo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}

.todo-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2D2B55;
  line-height: 1.4;
}

.todo-title.completed {
  text-decoration: line-through;
  color: #6B6880;
}

.todo-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.todo-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #4F46E5;
  cursor: pointer;
}

.todo-toggle label {
  font-size: 11px;
  color: #6B6880;
  cursor: pointer;
}

/* ── DETAILS ── */
.todo-details {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #E2DDD6;
  padding-bottom: 1rem;
}

/* ── EXPAND TOGGLE ── */
.todo-details button#expandToggle {
  align-self: flex-start;
  background: none;
  border: 1px solid #E2DDD6;
  border-radius: 99px;
  font-size: 0.75rem;
  color: #4F46E5;
  padding: 3px 10px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
}

.todo-details button#expandToggle:hover {
  background: #EDE9FE;
}

.todo-details button#expandToggle:focus {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
}

/* ── COLLAPSIBLE SECTION ── */
.collapsible-section {
  overflow: hidden;
  max-height: 3.2em;
  transition: max-height 0.3s ease;
}

.collapsible-section.expanded {
  max-height: 500px;
}

.todo-description {
  font-size: 0.875rem;
  color: #6B6880;
  line-height: 1.6;
}

/* ── DUE DATE ── */
.todo-due-date {
  display: inline-block;
  font-size: 0.8rem;
  color: #2D2B55;
  font-weight: 500;
}

.todo-due-date::before {
  content: "📅 ";
}

/* ── TIME REMAINING ── */
.todo-time-remaining {
  font-size: 0.8rem;
  font-weight: 500;
  color: #4F46E5;
}

.todo-time-remaining::before {
  content: "⏱ ";
}

.todo-time-remaining.overdue {
  color: #B91C1C;
}

/* ── OVERDUE INDICATOR ── */
.overdue-indicator {
  display: inline-block;
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  align-self: flex-start;
}
.overdue-indicator[hidden] {
  display: none;
}

/* ── META (PRIORITY + STATUS) ── */
.todo-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid #E2DDD6;
  padding-bottom: 1rem;
}

.todo-priority {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 99px;
}

.todo-priority.high {
  background: #FEE2E2;
  color: #B91C1C;
}

.todo-priority.medium {
  background: #FEF9C3;
  color: #A16207;
}

.todo-priority.low {
  background: #DCFCE7;
  color: #15803D;
}

/* ── PRIORITY INDICATOR DOT ── */
.todo-priority-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.todo-priority-indicator.high {
  background: #B91C1C;
}

.todo-priority-indicator.medium {
  background: #A16207;
}

.todo-priority-indicator.low {
  background: #15803D;
}

/* ── STATUS SELECT ── */
.todo-status {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 99px;
  border: none;
  cursor: pointer;
  background: #EDE9FE;
  color: #6D28D9;
  appearance: none;
}

.todo-status:focus {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
}

.todo-status.done {
  background: #DCFCE7;
  color: #15803D;
}

.todo-status.in-progress {
  background: #EDE9FE;
  color: #6D28D9;
}

.todo-status.pending {
  background: #F1F5F9;
  color: #475569;
}

/* ── TAGS ── */
.todo-tags-section {
  margin-bottom: 1rem;
  border-bottom: 1px solid #E2DDD6;
  padding-bottom: 1rem;
}

.todo-tags-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B6880;
  margin-bottom: 8px;
  font-weight: 500;
}

.todo-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 99px;
  background: #EDE9FE;
  color: #4F46E5;
  font-weight: 500;
}

/* ── ACTIONS ── */
.todo-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 1rem;
}

.edit-btn,
.delete-btn {
  flex: 1;
  padding: 9px 0;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.edit-btn {
  background: #4F46E5;
  color: #FFFFFF;
}

.delete-btn {
  background: #FEE2E2;
  color: #B91C1C;
}

.edit-btn:hover,
.delete-btn:hover {
  opacity: 0.85;
}

.edit-btn:focus,
.delete-btn:focus,
.todo-toggle input:focus {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
}

/* ── EDIT FORM ── */
.edit-section {
  border-top: 1px solid #E2DDD6;
  padding-top: 1rem;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #2D2B55;
}

.form-input,
.form-textarea,
.form-select {
  padding: 8px 12px;
  border: 1px solid #E2DDD6;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #2D2B55;
  font-family: inherit;
  background: #FAFAFA;
  transition: border-color 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
  border-color: #4F46E5;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.cancel-btn,
.save-btn {
  flex: 1;
  padding: 9px 0;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.cancel-btn {
  background: #F1F5F9;
  color: #475569;
}

.save-btn {
  background: #4F46E5;
  color: #FFFFFF;
}

.cancel-btn:hover,
.save-btn:hover {
  opacity: 0.85;
}

.cancel-btn:focus,
.save-btn:focus {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .todo-card {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .todo-title {
    font-size: 1rem;
  }

  .form-row {
    flex-direction: column;
  }
}