:root {
  --primary: #6c63ff;
  --primary-dark: #564fd8;
  --primary-light: #eef0ff;
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #edeef5;
  --text: #23253a;
  --text-sub: #8b8fa3;
  --text-faint: #b7bacb;

  --cat-study: #4f8ef7;
  --cat-study-bg: #e6f0ff;
  --cat-exercise: #ec4899;
  --cat-exercise-bg: #ffe4f0;
  --cat-work: #f5a524;
  --cat-work-bg: #fef3dd;
  --cat-personal: #22c55e;
  --cat-personal-bg: #e3f9ea;
}

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

[hidden] { display: none !important; }

body {
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, select, input { font-family: inherit; }

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- 사이드바 ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  padding: 0 6px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__item:hover { background: var(--bg); }

.nav__item.is-active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.nav__icon { font-size: 1rem; }

.sidebar__categories {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.sidebar__categories-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-faint);
  padding: 0 12px 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: background 0.15s ease;
}

.category-list__item:hover { background: var(--bg); }

.category-list__item.is-active {
  background: var(--bg);
  color: var(--text);
}

.category-list__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-list__name { flex: 1; }

.category-list__count {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 700;
}

.sidebar__mascot {
  margin-top: auto;
  text-align: center;
  font-size: 2.4rem;
  padding-top: 20px;
  opacity: 0.85;
}

/* ---------- 메인 ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 56px;
  max-width: 780px;
}

.main__header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.main__header p {
  margin-top: 4px;
  color: var(--text-sub);
  font-size: 0.92rem;
}

/* ---------- 입력 폼 ---------- */
.todo-form {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
}

.todo-form__row {
  display: flex;
  gap: 10px;
}

#todoInput {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  padding: 6px 4px;
  background: transparent;
}

#todoInput::placeholder { color: var(--text-faint); }

.btn-add {
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-add:hover { background: var(--primary-dark); }

.todo-form__options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  position: relative;
  flex-wrap: wrap;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.option-pill:hover { background: var(--primary-light); }

.option-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.option-pill--select {
  padding: 6px 10px 6px 12px;
}

.option-pill--select select {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.option-date-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- 툴바 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.sort {
  font-size: 0.8rem;
  color: var(--text-sub);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort select {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.8rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.empty-trash {
  display: block;
  margin: 0 0 14px auto;
  border: 1px solid var(--border);
  background: var(--card);
  color: #e0554f;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.empty-trash:hover { background: #fdecea; }

/* ---------- 목록 ---------- */
.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  animation: fadeIn 0.18s ease;
}

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

.todo-item__check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid #d8dae6;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 0.75rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.todo-item.is-done .todo-item__check {
  background: var(--primary);
  border-color: var(--primary);
}

.todo-item__body {
  flex: 1;
  min-width: 0;
}

.todo-item__text {
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  word-break: break-word;
}

.todo-item.is-done .todo-item__text {
  color: var(--text-faint);
  text-decoration: line-through;
}

.todo-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.tag--공부 { background: var(--cat-study-bg); color: var(--cat-study); }
.tag--운동 { background: var(--cat-exercise-bg); color: var(--cat-exercise); }
.tag--업무 { background: var(--cat-work-bg); color: var(--cat-work); }
.tag--개인 { background: var(--cat-personal-bg); color: var(--cat-personal); }

.todo-item__date {
  font-size: 0.76rem;
  color: var(--text-faint);
  font-weight: 600;
}

.todo-item__star {
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--text-faint);
  line-height: 1;
}

.todo-item__star.is-active { color: #f5b301; }

.todo-item__delete,
.todo-item__restore {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.todo-item__delete:hover {
  background: #fdecea;
  color: #e0554f;
}

.todo-item__restore:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.empty-state {
  text-align: center;
  padding: 40px 0;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.list-footer-msg {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.84rem;
  margin: 18px 0 26px;
}

/* ---------- 통계 ---------- */
.stats {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 26px;
  flex-wrap: wrap;
}

.stats__ring {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
}

.stats__ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.stats__ring-track {
  fill: none;
  stroke: var(--bg);
  stroke-width: 9;
}

.stats__ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  transition: stroke-dashoffset 0.3s ease;
}

.stats__ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stats__ring-text strong {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.stats__ring-text span {
  font-size: 0.6rem;
  color: var(--text-faint);
  margin-top: 1px;
}

.stats__item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stats__item strong {
  font-size: 1.3rem;
  font-weight: 800;
}

.stats__item span {
  font-size: 0.78rem;
  color: var(--text-sub);
  font-weight: 600;
}

.stats__item--streak {
  margin-left: auto;
}

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    overflow-x: auto;
  }

  .brand { margin-bottom: 0; }
  .nav { flex-direction: row; }
  .nav__item span:last-child { white-space: nowrap; }
  .sidebar__categories { display: none; }
  .sidebar__mascot { display: none; }

  .main { padding: 24px 20px 40px; max-width: none; }
}

@media (max-width: 520px) {
  .todo-form__options { gap: 6px; }
  .stats { gap: 18px; }
  .stats__item--streak { margin-left: 0; }
}
