/* ---------- 기본 / 테마 변수 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
}
body {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  background: transparent;
  user-select: none;
  overflow: hidden;
}

/* 미니멀 (C) */
body[data-theme="minimal"] {
  --app-bg: #FBF8F3;
  --text: #59554E;
  --muted: #B0AAA0;
  --accent: #4FB99A;
  --accent-strong: #2E9E7E;
  --mascot-bg: #FAEEDA;
  --mascot-fg: #C98A2E;
  --track: #ECE4D7;
  --border: #ECE4D5;
  --card: #FFFFFF;
  --card-line: #F1EBE0;
}

/* 파스텔 (A) */
body[data-theme="pastel"] {
  --app-bg: #FBEAF0;
  --text: #7A3B54;
  --muted: #CFA0B4;
  --accent: #E76A99;
  --accent-strong: #D4537E;
  --mascot-bg: #F6C9DB;
  --mascot-fg: #C24C7E;
  --track: #F6D6E2;
  --border: #F3D3E0;
  --card: #FFFFFF;
  --card-line: #FCE4EC;
}

/* 라벤더 */
body[data-theme="lavender"] {
  --app-bg: #F0ECFA;
  --text: #5B4B7A;
  --muted: #B4A7D0;
  --accent: #9B87E0;
  --accent-strong: #7A63C9;
  --mascot-bg: #DED3F5;
  --mascot-fg: #7A5FC0;
  --track: #E4DBF5;
  --border: #E1D7F2;
  --card: #FFFFFF;
  --card-line: #EFE9FB;
}

/* 민트 */
body[data-theme="mint"] {
  --app-bg: #E6F5EF;
  --text: #3E6B5C;
  --muted: #9CC7B7;
  --accent: #43C39A;
  --accent-strong: #2E9E7E;
  --mascot-bg: #CDEEE1;
  --mascot-fg: #2E9E7E;
  --track: #D6EFE7;
  --border: #D2ECE2;
  --card: #FFFFFF;
  --card-line: #E4F4EE;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--app-bg);
  border-radius: 18px;
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  color: var(--text);
  overflow: hidden;
  transition: background-color .45s ease, color .45s ease;
}

/* ---------- 타이틀바 / 창 버튼 ---------- */
.titlebar {
  -webkit-app-region: drag;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.win-btns { -webkit-app-region: no-drag; display: flex; gap: 6px; }
.win-btn {
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.win-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }
.win-btn:active { transform: scale(.9); }
.win-close:hover { background: #E24B4A; color: #fff; }
.win-btn.on { color: var(--accent-strong); }
.win-btn svg { width: 15px; height: 15px; }

/* ---------- 마스코트 / 헤더 ---------- */
.head {
  -webkit-app-region: drag;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.mascot {
  -webkit-app-region: no-drag;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--mascot-bg);
  color: var(--mascot-fg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .45s ease, transform .16s ease;
}
.mascot svg { width: 29px; height: 29px; }
.mascot:hover { transform: scale(1.08); }
.mascot.jump { animation: jump .6s ease; }
.mascot.pop svg { animation: moodPop .28s cubic-bezier(.22,1,.36,1); }
@keyframes moodPop {
  0% { opacity: 0; transform: scale(.6); }
  60% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}

.head-mid { flex: 1; display: flex; justify-content: center; }
.head-btn {
  -webkit-app-region: no-drag;
  width: 26px; height: 26px; flex-shrink: 0;
  border: none; border-radius: 8px; background: transparent;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.head-btn:hover:not(:disabled) { background: rgba(0,0,0,.06); color: var(--text); }
.head-btn:active:not(:disabled) { transform: scale(.9); }
.head-btn:disabled { opacity: .28; cursor: default; }
.head-btn svg { width: 16px; height: 16px; }
.datenav {
  -webkit-app-region: no-drag;
  display: flex; align-items: center; gap: 6px;
}
.nav-btn {
  width: 24px; height: 24px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: background .15s ease, color .15s ease, opacity .15s ease;
}
.nav-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }
.nav-btn:disabled { opacity: .25; cursor: default; }
.daylabel {
  -webkit-app-region: no-drag;
  text-align: center; min-width: 96px;
  border: none; background: transparent; cursor: pointer;
  padding: 3px 8px; border-radius: 10px; color: inherit;
  font-family: inherit;
  transition: background .15s ease;
}
.daylabel:hover { background: rgba(0,0,0,.05); }
.day-title { display: block; font-size: 15px; font-weight: 700; }
.day-date { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* ---------- 말풍선 (떠서 나타남 — 평소엔 공간 안 차지) ---------- */
.bubble {
  position: absolute;
  top: 40px; left: 52px;
  max-width: 200px;
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 12px 12px 12px 3px;
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
  z-index: 18;
  opacity: 0;
  transform: translateY(-4px) scale(.94);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.bubble.error { background: #E24B4A; color: #fff; }

/* ---------- 진행도 ---------- */
.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-shrink: 0; }
.progress {
  flex: 1; height: 9px; border-radius: 6px;
  background: var(--track); overflow: hidden;
}
.progress-fill {
  width: 0%; height: 100%; border-radius: 6px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.22,1,.36,1), background .45s ease;
}
.count { font-size: 12px; color: var(--muted); min-width: 40px; text-align: right; }
.streak {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 700; color: #E8863C;
  flex-shrink: 0;
}
.streak[hidden] { display: none; }
.streak svg { width: 14px; height: 14px; }

/* 어제 못한 일 이월 버튼 */
.carry {
  display: block; width: 100%;
  margin: 0 0 8px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--accent-strong);
  font-family: inherit; font-size: 12.5px;
  padding: 8px 10px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.carry[hidden] { display: none; }
.carry:hover { border-color: var(--accent); background: rgba(0,0,0,.03); }

/* ---------- 할 일 목록 ---------- */
.todos {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -4px;
  padding: 2px 4px;
}
.todos::-webkit-scrollbar { width: 6px; }
.todos::-webkit-scrollbar-thumb { background: var(--track); border-radius: 6px; }

.todo {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 9px 11px;
  margin-bottom: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  animation: slideIn .28s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
  cursor: pointer;
}
.todo:active { transform: scale(.99); }
.todo.removing {
  animation: slideOut .13s ease forwards;
  pointer-events: none;
}
.check {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: background .18s ease, border-color .18s ease;
}
.check svg { width: 13px; height: 13px; opacity: 0; transform: scale(.4); transition: opacity .15s ease, transform .2s ease; }
.todo.done .check { background: var(--accent); border-color: var(--accent); }
.todo.done .check svg { opacity: 1; transform: scale(1); }
.check.pop { animation: pop .35s ease; }

.todo-text {
  flex: 1; font-size: 14px; line-height: 1.35;
  word-break: break-word; cursor: default;
}
.todo.done .todo-text { color: var(--muted); text-decoration: line-through; }

.del {
  opacity: 0; flex-shrink: 0;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.del svg { width: 14px; height: 14px; }
.todo:hover .del { opacity: 1; }
.del:hover { background: rgba(0,0,0,.06); color: var(--accent-strong); }

.empty {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 24px 10px; line-height: 1.6;
}

/* ---------- 추가 바 ---------- */
.addbar {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; flex-shrink: 0;
}
.add-input {
  flex: 1;
  outline: none;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px; color: var(--text);
  font-family: inherit;
  transition: border-color .15s ease;
}
.add-input:focus { border-color: var(--accent); }
.add-input::placeholder { color: var(--muted); }
.add-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  border: none; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: transform .12s ease, background .3s ease, filter .15s ease;
}
.add-btn:hover { filter: brightness(1.05); }
.add-btn:active { transform: scale(.9); }

/* ---------- 메모 ---------- */
.memo {
  margin-top: 10px; flex-shrink: 0;
  border: none; outline: none;
  background: transparent;
  border-top: 1.5px dashed var(--card-line);
  padding: 10px 4px 2px;
  font-size: 13px; color: var(--text);
  font-family: inherit; line-height: 1.5;
  resize: none;
  max-height: 120px; overflow-y: auto;
  user-select: text;
}

/* ---------- 미니 모드 (할 일만 보기) ---------- */
body.compact .head,
body.compact .bubble,
body.compact .carry,
body.compact .addbar,
body.compact .memo { display: none; }
body.compact .progress-row { margin-top: 2px; }
.memo::placeholder { color: var(--muted); }

/* ---------- 달력 ---------- */
.calendar {
  position: absolute;
  top: 62px; left: 50%; margin-left: -123px; /* width 246의 절반 — transform 안 쓰고 가운데 정렬 */
  width: 246px;
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  z-index: 25;
  animation: pickerIn .2s cubic-bezier(.22,1,.36,1);
}
.calendar[hidden] { display: none; }
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title { font-size: 14px; font-weight: 700; color: var(--text); }
.cal-nav {
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 18px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.cal-nav:hover { background: rgba(0,0,0,.05); color: var(--text); }
.cal-week, .cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-week span {
  text-align: center; font-size: 10px; color: var(--muted); padding: 2px 0;
}
.cal-day {
  position: relative;
  min-height: 30px;
  border: none; background: transparent;
  border-radius: 8px; cursor: pointer;
  color: var(--text); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 2px 0;
  transition: background .12s ease;
}
.cal-num { font-size: 11px; line-height: 1; }
.cal-mark { height: 14px; display: flex; align-items: center; justify-content: center; }
.cal-mark.dot::after {
  content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.cal-day:hover:not(:disabled) { background: rgba(0,0,0,.06); }
.cal-day.blank { visibility: hidden; }
.cal-day:disabled { color: var(--muted); opacity: .4; cursor: default; }
.cal-day.today .cal-num { font-weight: 700; color: var(--accent-strong); }
.cal-day.sel { background: var(--accent); }
.cal-day.sel .cal-num { color: #fff; }
.cal-day.sel .cal-mark.dot::after { background: #fff; }

.cal-copy {
  width: 100%; margin-top: 10px;
  border: none; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  padding: 8px; cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}
.cal-copy:hover { filter: brightness(1.05); }
.cal-copy:active { transform: scale(.98); }

/* ---------- 컨페티 ---------- */
.confetti {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 30;
}

/* ---------- 애니메이션 ---------- */
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-9deg); }
  75% { transform: rotate(9deg); }
}
@keyframes jump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-14px) scale(1.08); }
  55% { transform: translateY(0) scale(.96); }
  75% { transform: translateY(-6px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  70% { transform: scale(.85); }
  100% { transform: scale(1); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideOut {
  to { opacity: 0; transform: translateX(18px) scale(.97); }
}
@keyframes pickerIn {
  from { opacity: 0; transform: translateY(-6px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
