/* ---------- 라이트 모드 (샴페인 골드) ---------- */
:root {
  /* 창 전체와 사이드바는 그라데이션도 넣을 수 있게 따로 둡니다. */
  --app-bg: linear-gradient(160deg, #FBF7EC 0%, #F4ECD8 100%);
  --sidebar-bg: linear-gradient(180deg, #FFFDF5 0%, #F7EFDC 100%);

  --bg: #F8F3E6;
  --card: #FFFDF6;
  --accent: #C09520;
  --accent-dark: #A07A15;
  --accent-light: #F6EBC9;
  /* 골드 배경 위에는 흰 글자의 대비가 부족해서 어두운 글자를 씁니다. */
  --accent-text: #2B2310;
  --pastel-green: #E2C766;
  --pastel-green-dark: #C09520;
  --text: #2E2718;
  --text-light: #8A7A55;
  --border: #EADFC2;
  --shadow: 0 2px 10px rgba(160, 125, 30, 0.14);

  --danger-text: #C0392B;
  --danger-bg: #FBEFE9;
  --danger-border: #F1D8CB;
  --danger-bg-strong: #F7E3D8;

  --important-bg: #FFF6DF;
  --important-border: #F2DDA0;
  --star-color: #D9A520;

  --toast-bg: #2E2718;
  --toast-text: #FBF7EC;

  color-scheme: light;
}

/* ---------- 다크 모드 (블랙 골드) ---------- */
/* 배경은 채도 없는 블랙~차콜로 두고 명도만 조금씩 달리해 층을 나눕니다.
   메인(가장 어두움) < 입력칸·오목한 영역 < 사이드바 < 카드·상단바.
   골드는 버튼·강조 글자·별점·체크·진행률·중요 항목 테두리에만 써서 배경과 대비가 뚜렷하게 보이게 합니다. */
html[data-theme="dark"] {
  --app-bg: linear-gradient(160deg, #141414 0%, #0F0F0F 100%);
  --sidebar-bg: linear-gradient(180deg, #1A1A1A 0%, #171717 100%);

  --bg: #141414;
  --card: #1E1E1E;
  --accent: #D4AF37;
  /* 다크 모드에서는 hover 시 더 밝아지는 쪽이 자연스럽습니다. */
  --accent-dark: #EBC85F;
  /* 선택·마우스 올림 배경. 금빛을 섞으면 어두운 곳에서 카키색으로 보여, 거의 무채색으로 둡니다. */
  --accent-light: #2A2826;
  --accent-text: #1A1405;
  /* 이름은 예전 테마에서 남은 것이고, 체크박스·습관 달력·진행률에 쓰이는 골드입니다. */
  --pastel-green: #C9A227;
  --pastel-green-dark: #D4AF37;
  --text: #EFEBE2;
  --text-light: #A3A09A;
  --border: #2C2C2C;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.6);

  --danger-text: #F0A79E;
  --danger-bg: #241818;
  --danger-border: #3D2826;
  --danger-bg-strong: #2F1E1D;

  /* 중요 항목은 배경을 거의 무채색으로 두고 골드 테두리로 구분합니다. */
  --important-bg: #201E19;
  --important-border: #5E4F22;
  --star-color: #FFC94D;

  --toast-bg: #EFEBE2;
  --toast-text: #141414;

  color-scheme: dark;
}

/* ---------- 라이트 (기본, 깔끔한 흰 바탕 + 블루 포인트) ---------- */
html[data-theme="basic-light"] {
  --app-bg: linear-gradient(160deg, #FFFFFF 0%, #F2F5FA 100%);
  --sidebar-bg: linear-gradient(180deg, #FFFFFF 0%, #F6F8FC 100%);

  --bg: #F3F6FB;
  --card: #FFFFFF;
  --accent: #2F6FEB;
  --accent-dark: #1F5AD1;
  --accent-light: #E6EEFD;
  /* 진한 블루 위에서는 흰 글자가 잘 읽힙니다. */
  --accent-text: #FFFFFF;
  --pastel-green: #7EA6F5;
  --pastel-green-dark: #2F6FEB;
  --text: #1F2533;
  --text-light: #6B7486;
  --border: #E1E6EF;
  --shadow: 0 2px 10px rgba(31, 45, 80, 0.08);

  --danger-text: #D0342C;
  --danger-bg: #FDEEEC;
  --danger-border: #F6D4D0;
  --danger-bg-strong: #FADDD9;

  --important-bg: #FFF8E3;
  --important-border: #F5E0A6;
  --star-color: #F0A500;

  --toast-bg: #1F2533;
  --toast-text: #FFFFFF;

  color-scheme: light;
}

/* ---------- 블랙 (기본, 차분한 무채색 다크 + 블루 포인트) ---------- */
html[data-theme="basic-dark"] {
  --app-bg: linear-gradient(145deg, #16171B 0%, #1B1D22 50%, #131418 100%);
  --sidebar-bg: linear-gradient(180deg, #202228 0%, #18191E 100%);

  --bg: #1A1C21;
  --card: #23252C;
  --accent: #6EA0FF;
  /* 다크 모드에서는 hover 시 더 밝아지는 쪽이 자연스럽습니다. */
  --accent-dark: #93B8FF;
  --accent-light: #243351;
  --accent-text: #0D1526;
  --pastel-green: #4A7FE0;
  --pastel-green-dark: #6EA0FF;
  --text: #E7E9EE;
  --text-light: #9BA1AD;
  --border: #353841;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.5);

  --danger-text: #FF9C92;
  --danger-bg: #3A2020;
  --danger-border: #5A302D;
  --danger-bg-strong: #492725;

  --important-bg: #3A3219;
  --important-border: #5B4C22;
  --star-color: #FFC940;

  --toast-bg: #E7E9EE;
  --toast-text: #16171B;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--app-bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  user-select: none;
}

body, .sidebar, .toolbar, .month-cell, .week-col, .day-task, .week-pin-item,
.dday-item, .habit-item, .modal-box, .month-task-pill, #notesArea {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
}

.side-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px 0;
}

.habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg);
  transition: background 0.15s;
}

.habit-item:hover { background: var(--accent-light); }

.habit-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--pastel-green-dark);
  cursor: pointer;
}

.habit-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.habit-item span.habit-name {
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-item.done span.habit-name {
  text-decoration: line-through;
  color: var(--text-light);
}

.habit-stats {
  font-size: 10px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-history-btn,
.habit-del {
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.habit-item:hover .habit-history-btn,
.habit-item:hover .habit-del { opacity: 1; }

/* ---------- D-Day ---------- */
.dday-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dday-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg);
}

.dday-item:hover { background: var(--accent-light); }

.dday-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--accent-light);
  color: var(--accent-dark);
  min-width: 44px;
  text-align: center;
}

.dday-badge.is-today {
  background: var(--accent);
  color: var(--accent-text);
}

.dday-badge.is-past {
  background: var(--border);
  color: var(--text-light);
}

.dday-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dday-date {
  font-size: 10px;
  color: var(--text-light);
  flex-shrink: 0;
}

.dday-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.dday-item:hover .dday-actions { opacity: 1; }

.dday-actions button {
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 5px;
}

.dday-actions button:hover { background: var(--card); color: var(--text); }

.dday-empty {
  font-size: 12px;
  color: var(--text-light);
  padding: 6px 2px;
}

.dday-edit-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-light);
}

.dday-edit-row input {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  background: var(--card);
  color: var(--text);
}

.dday-edit-row .dday-edit-buttons {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.dday-edit-row .dday-edit-buttons button {
  border: none;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.dday-edit-row .save-btn { background: var(--accent); color: var(--accent-text); }
.dday-edit-row .cancel-btn { background: var(--card); color: var(--text-light); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-header h3 { margin: 0; }

.section-add-btn {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  width: 22px;
  height: 22px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ---------- 모달 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 46, 58, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

/* 공용 모달(백업 복원 방식 선택 등)은 설정 창 위에서 열릴 수 있습니다.
   설정 창과 z-index가 같으면 HTML에서 뒤에 있는 설정 창이 위에 그려져, 모달이 설정 창에 가려졌습니다. */
#modalOverlay { z-index: 300; }

.modal-box {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: 280px;
  box-shadow: 0 10px 30px rgba(46, 46, 58, 0.2);
}

.modal-box h4 {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 800;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body input {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

.modal-body input:focus { border-color: var(--accent); }

.modal-body select {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  font-family: inherit;
}

.modal-body select:focus { border-color: var(--accent); }

.modal-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: -6px;
}

/* ---------- 휠 날짜 피커 ---------- */
.wheel-picker {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 6px;
  height: 160px;
}

.wheel-picker-highlight {
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  height: 32px;
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  background: var(--accent-light);
  border-radius: 6px;
  pointer-events: none;
  z-index: 0;
}

.wheel-col {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 64px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  touch-action: pan-y;
}

.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col:active { cursor: grabbing; }

.wheel-item {
  height: 32px;
  line-height: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  scroll-snap-align: center;
  user-select: none;
}

.wheel-item-active {
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 14px;
}

.time-reset-btn {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 2px;
}

.time-reset-btn:hover { filter: brightness(0.96); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions button {
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.modal-save-btn { background: var(--accent); color: var(--accent-text); }
.modal-save-btn:hover { background: var(--accent-dark); }
.modal-cancel-btn { background: var(--bg); color: var(--text-light); }
.modal-cancel-btn:hover { background: var(--border); }

.settings-box { width: 340px; }

.settings-section h5 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

/* 항목이 둘 이상이 되면서 구분이 필요해졌습니다. */
.settings-section + .settings-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.settings-accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.settings-accordion-arrow {
  font-size: 11px;
  color: var(--text-light);
  transition: transform 0.15s;
}

.settings-accordion-toggle.open .settings-accordion-arrow {
  transform: rotate(-180deg);
}

.settings-accordion-body {
  margin-top: 12px;
}

.settings-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-row-between {
  justify-content: space-between;
  align-items: center;
}

.settings-row-between[hidden] { display: none; }

.settings-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  /* "복원하 / 기"처럼 단어 중간에서 끊기지 않고 어절 단위로 줄바꿈합니다. */
  word-break: keep-all;
}

.settings-btn:hover { background: var(--accent-light); border-color: var(--accent); }

.settings-hint {
  font-size: 11px;
  color: var(--text-light);
  word-break: break-all;
}

/* 설명 문장은 어절 단위로 줄바꿈해야 읽기 편합니다. */
.settings-desc {
  word-break: keep-all;
  line-height: 1.55;
  margin: 2px 0 10px;
}

.settings-loading {
  margin-top: 10px;
  font-size: 12px;
  color: var(--accent-dark);
  text-align: center;
}

.import-summary {
  font-size: 12px;
  color: var(--text-light);
  margin: 0 0 10px 0;
}

.import-choice-btn {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  margin-bottom: 8px;
}

.import-choice-btn:hover { background: var(--accent-light); border-color: var(--accent); }

/* 모드 선택을 그만두고 설정 창으로 돌아가는 버튼. 선택지와 헷갈리지 않게 오른쪽에 작게 둡니다. */
.import-cancel-btn {
  align-self: flex-end;
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.modal-box.wide-box { width: 320px; }

/* ---------- 설정 화면: 고정 반복 할 일 ---------- */
.recurring-rule-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recurring-rule-empty {
  font-size: 12px;
  color: var(--text-light);
  padding: 6px 2px;
}

.recurring-rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  background: var(--bg);
}

.recurring-rule-name {
  font-size: 12.5px;
  font-weight: 600;
}

.recurring-rule-meta {
  font-size: 10.5px;
  color: var(--text-light);
  margin-top: 2px;
}

.recurring-rule-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.recurring-rule-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.recurring-rule-btn:hover { background: var(--accent-light); color: var(--text); }

.recurring-rule-btn.danger { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.recurring-rule-btn.danger:hover { background: var(--danger-bg-strong); }
.recurring-rule-btn.confirming { background: var(--danger-text); color: var(--card); border-color: var(--danger-text); }

.habit-history-stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.habit-history-stats strong {
  color: var(--text);
  font-size: 14px;
}

.habit-history-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.habit-history-month-label {
  font-size: 13px;
  font-weight: 700;
  min-width: 90px;
  text-align: center;
}

.habit-history-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.habit-history-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  padding-bottom: 4px;
}

.habit-history-cell {
  text-align: center;
  font-size: 11px;
  padding: 6px 0;
  border-radius: 6px;
  color: var(--text);
  background: var(--bg);
}

.habit-history-cell.other-month { opacity: 0.35; }

.habit-history-cell.today { box-shadow: 0 0 0 1px var(--accent) inset; font-weight: 700; }

.habit-history-cell.checked {
  background: var(--pastel-green-dark);
  color: var(--accent-text);
  font-weight: 700;
}

.habit-history-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.notes-section { display: flex; flex-direction: column; flex: 1; }

#notesArea {
  flex: 1;
  min-height: 160px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  outline: none;
  color: var(--text);
  user-select: text;
}

#notesArea:focus { border-color: var(--accent); }

.save-indicator {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  opacity: 0.6;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
}

.tab {
  border: none;
  background: transparent;
  padding: 7px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

.tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  border: 1px solid var(--border);
  background: var(--card);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  /* 브라우저 기본 버튼 여백과 줄 높이 때문에 아이콘이 한쪽으로 밀리던 것을 없애고,
     테두리 상자 안에서 가로·세로 정중앙에 둡니다. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ‹ › 같은 문자는 글꼴 안에서 아래쪽에 그려져 상자 중앙보다 내려가 보여, 화살표는 SVG로 그립니다. */
.nav-btn svg {
  display: block;
  width: 16px;
  height: 16px;
}

.nav-btn:hover { background: var(--accent-light); }

.range-label {
  font-size: 15px;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.range-label:hover { background: var(--accent-light); color: var(--accent-dark); }

.today-btn {
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent-dark);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.today-btn:hover { background: var(--accent-light); }

/* 테마 버튼을 감싸는 상자가 글자 기준선 아래 여백을 만들어 버튼이 옆 버튼보다 내려앉지 않도록 flex로 둡니다. */
.theme-switcher { position: relative; display: flex; }

.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
  z-index: 150;
}

.theme-option {
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.theme-option.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 700;
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ---------- Month view ---------- */
.month-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.month-toolbar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.goal-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  background: var(--card);
  color: var(--text);
}

.goal-input::placeholder { color: var(--text-light); font-weight: 400; }

.goal-input:focus { border-color: var(--accent); }

.toggle-label-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 13px;
  width: 13px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(46, 46, 58, 0.25);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(15px); }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.month-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  padding-bottom: 6px;
}

.month-cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-height: 96px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.month-cell:hover { box-shadow: var(--shadow); border-color: var(--accent); }

.month-cell.other-month { opacity: 0.4; }

.month-cell.today { border-color: var(--accent); background: var(--accent-light); }

.month-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.month-cell.today .month-date {
  color: var(--accent-dark);
}

.month-weekday.weekend-red { color: var(--danger-text); }

.month-cell.weekend-red { background: var(--danger-bg); border-color: var(--danger-border); }
.month-cell.weekend-red .month-date { color: var(--danger-text); }
.month-cell.weekend-red.today { background: var(--danger-bg-strong); border-color: var(--danger-text); }
.month-cell.weekend-red.today .month-date { color: var(--danger-text); }

.holiday-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--danger-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-task-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-task-pill.done {
  text-decoration: line-through;
  color: var(--text-light);
  background: transparent;
}

.month-more {
  font-size: 10px;
  color: var(--text-light);
}

/* ---------- Week view (핀 고정 항목만 보여주는 요약 뷰) ---------- */
.week-toolbar {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
  height: 100%;
  overflow-x: auto;
}

.week-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.week-col.today { border-color: var(--accent); }

.week-col-header {
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.week-col-day { font-size: 11px; color: var(--text-light); font-weight: 700; }
.week-col-date { font-size: 15px; font-weight: 700; }
.week-col.today .week-col-date { color: var(--accent-dark); }

.week-col-tasks {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.week-pin-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}

.week-pin-text {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.week-pin-item.done .week-pin-text { text-decoration: line-through; color: var(--text-light); }

/* ---------- Day view ---------- */
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.day-title { font-size: 20px; font-weight: 800; }

.day-header-actions {
  display: flex;
  gap: 8px;
}

.carry-btn {
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent-dark);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.carry-btn:hover { background: var(--accent-light); }

.timeline-toggle-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.timeline-toggle-btn:hover { background: var(--bg); }

.timeline-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-light);
}

.day-content {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.day-main-col {
  flex: 1;
  min-width: 0;
}

.day-timeline-panel {
  width: 210px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  max-height: 640px;
  overflow-y: auto;
  padding: 6px 0;
}

.timeline-track {
  position: relative;
}

.timeline-hour-row {
  height: 40px;
  box-sizing: border-box;
  border-top: 1px solid var(--border);
  padding-left: 10px;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

.timeline-hour-row:first-child { border-top: none; }

.timeline-hour-label {
  font-size: 10px;
  color: var(--text-light);
}

.timeline-block {
  position: absolute;
  left: 54px;
  right: 8px;
  border: none;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.timeline-block.done { opacity: 0.5; text-decoration: line-through; }

.timeline-block.imp-0 { background: var(--accent-light); color: var(--accent-dark); }
.timeline-block.imp-1 { background: var(--important-bg); color: var(--text); box-shadow: 0 0 0 1px var(--important-border) inset; }
.timeline-block.imp-2 { background: var(--important-border); color: var(--text); }
.timeline-block.imp-3 { background: var(--star-color); color: var(--accent-text); }

.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.progress-top strong { color: var(--text); font-size: 15px; }

.progress-bar-bg {
  height: 9px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pastel-green), var(--pastel-green-dark));
  border-radius: 6px;
  transition: width 0.25s ease;
}

.day-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.day-add-form input[type="text"] {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
  color: var(--text);
}

.day-add-form input:focus { border-color: var(--accent); }

.day-add-form button {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0 18px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.day-add-form button:hover { background: var(--accent-dark); }

.day-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-task {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 14px;
}

.day-task input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--pastel-green-dark);
  cursor: pointer;
  flex-shrink: 0;
}

.task-time-btn {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 3px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.task-time-btn:hover { background: var(--accent); color: var(--accent-text); }

.task-time-btn.no-time {
  color: var(--text-light);
  background: var(--bg);
}

.day-task .task-text {
  flex: 1;
  outline: none;
  word-break: break-word;
}

.day-task.done .task-text {
  text-decoration: line-through;
  color: var(--text-light);
}

.day-task.done { background: var(--bg); }

.day-task.star-max {
  border-color: var(--important-border);
  background: var(--important-bg);
  box-shadow: 0 0 0 1px var(--important-border) inset;
}

.day-task.star-max.done {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: none;
}

.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.task-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  font-size: 14px;
  padding: 4px;
  border-radius: 6px;
}

.task-actions button:hover { background: var(--bg); color: var(--text); }

.star-rating {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.star-slot {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  font-size: 14px;
  line-height: 1;
  padding: 4px 1px;
  border-radius: 4px;
}

.star-slot:hover { color: var(--star-color); }

.star-slot.filled { color: var(--star-color); }

/* 고정 안 됨 = 연한 아웃라인, 고정됨 = 꽉 찬 강조색 배지로 한눈에 구분되게 합니다. */
.pin-toggle-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pin-toggle-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
  transform: scale(1.1);
}

.pin-toggle-btn.pinned-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.pin-toggle-btn.pinned-active:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: scale(1.1);
}

/* 고정된 할 일 카드 자체도 왼쪽 강조선으로 살짝 구분해줍니다. */
.day-task.pinned-item { border-left: 3px solid var(--accent); }

.empty-msg {
  text-align: center;
  color: var(--text-light);
  padding: 40px 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  /* 설정 창이나 모달이 열려 있을 때도 안내 메시지가 가려지지 않도록 모든 창보다 위에 둡니다. */
  z-index: 400;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 사이드바 아래 저장 상태 (cloud.js) ---------- */
.save-indicator[data-status="offline"] {
  color: var(--danger-text);
  opacity: 1;
  font-weight: 600;
}

/* ---------- 설정 > 계정 ---------- */
.account-email {
  color: var(--text);
  word-break: break-all;
}

/* ---------- 화면 맨 위 안내 줄 (비밀번호 변경 완료 등, cloud.js) ---------- */
.app-notice {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  white-space: pre-line;
  word-break: keep-all;
}

.app-notice[hidden] { display: none; }

/* ---------- 로그인 화면 (cloud.js) ----------
   로그인하고 데이터를 불러올 때까지 플래너 전체를 덮습니다. 뒤의 플래너 화면은 스크롤되지 않게 막습니다. */
body.is-locked { overflow: hidden; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 24px;
  overflow-y: auto;
  background: var(--app-bg);
  user-select: text;
}

.auth-gate[hidden] { display: none; }

/* 로그인 화면 안의 칸·버튼은 cloud.js가 hidden으로 보였다 숨겼다 합니다. display를 지정한 요소도 확실히 숨깁니다. */
.auth-gate [hidden] { display: none !important; }

.auth-box {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--accent-dark);
}

.auth-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

.auth-title + div .auth-label,
.auth-title + [hidden] + div .auth-label {
  margin-top: 0;
}

.auth-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: var(--text);
}

.auth-input:focus { border-color: var(--accent); }

/* 코드에서 띄우는 안내·오류 문구는 문장 사이에 줄바꿈 문자를 넣어 두었습니다. 그 줄바꿈을 화면에서도 지킵니다. */
.auth-desc,
.auth-message,
.auth-loading,
.auth-choice-message {
  white-space: pre-line;
  word-break: keep-all;
}

.auth-desc {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-light);
}

.auth-btn {
  width: 100%;
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  word-break: keep-all;
}

.auth-btn-primary { background: var(--accent); color: var(--accent-text); }
.auth-btn-primary:hover { background: var(--accent-dark); }
.auth-btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.auth-btn-secondary:hover { background: var(--accent-light); border-color: var(--accent); }
.auth-btn:disabled { opacity: 0.6; cursor: default; }
.auth-btn[hidden] { display: none; }

.auth-submit { margin-top: 20px; }
.auth-cancel { margin-top: 8px; }

.auth-message {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--accent-dark);
  background: var(--accent-light);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.auth-message.is-error {
  color: var(--danger-text);
  background: var(--danger-bg);
}

.auth-message[hidden] { display: none; }

.auth-switch-row {
  margin: 16px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--text-light);
}

.auth-switch-row[hidden] { display: none; }

.auth-link {
  border: none;
  background: transparent;
  padding: 0;
  margin-left: 4px;
  font-size: inherit;
  font-family: inherit;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
  flex-shrink: 0;
}

.auth-loading {
  margin: 0;
  font-size: 14px;
  text-align: center;
  color: var(--text-light);
}

.auth-loading.is-error { color: var(--danger-text); }

.auth-choice-message {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
}

.auth-choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* ================================================================
   휴대폰(좁은 화면) 전용 스타일
   boot.js가 화면 폭이 좁을 때(900px 미만) <html>에 붙이는 platform-mobile 클래스
   아래에서만 적용됩니다. 넓은 화면에서는 이 클래스가 없으므로 아래 규칙이 적용되지 않습니다.
   휴대폰용 HTML 요소(햄버거 버튼, 사이드바 닫기 버튼, 오버레이)는 아래 첫 규칙으로
   항상 기본 숨김이고, platform-mobile 아래에서만 보이게 합니다.
   ================================================================ */

.mobile-menu-btn,
.sidebar-close-btn,
.sidebar-overlay {
  display: none;
}

/* ---------- 1. 사이드바 → 왼쪽에서 밀려 나오는 드로어 ---------- */
.platform-mobile .mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: 8px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.platform-mobile .sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 60;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.28);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding-top: calc(56px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
}

.platform-mobile .sidebar.mobile-open {
  transform: translateX(0);
}

.platform-mobile .sidebar-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 18px;
  cursor: pointer;
}

.platform-mobile .sidebar-overlay.mobile-open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.45);
}

/* 사이드바가 화면 밖으로 고정되어 떠 있으므로(position:fixed), 남은 유일한 flex
   항목인 .main이 자동으로 화면 전체 너비를 씁니다 - 별도 width 지정이 필요 없습니다. */

.platform-mobile .toolbar {
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
  gap: 8px;
  flex-wrap: wrap;
}

.platform-mobile .tabs { font-size: 13px; }
.platform-mobile .range-label { font-size: 12px; }

.platform-mobile .view {
  padding-top: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

/* ---------- 2. 주간뷰 → 7열 그리드 대신 요일별 세로 카드 목록 ---------- */
.platform-mobile .week-grid {
  grid-template-columns: 1fr;
  height: auto;
  overflow-x: visible;
  overflow-y: visible;
  gap: 12px;
}

.platform-mobile .week-col-tasks {
  max-height: 40vh;
}

.platform-mobile .week-col.today {
  border-width: 2px;
  background: var(--accent-light);
}

.platform-mobile .week-col.today .week-col-header::after {
  content: "오늘";
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}

/* 월간/일간뷰 - 좁은 화면에서 글자 축소로 넘침 방지 (요약 카드는 이미 개수 표시로 넘침을 막고 있음) */
.platform-mobile .month-grid { gap: 4px; }

.platform-mobile .month-cell {
  min-height: 60px;
  padding: 4px;
  gap: 2px;
  border-radius: 8px;
}

.platform-mobile .month-weekday { font-size: 11px; padding-bottom: 4px; }
.platform-mobile .month-date { font-size: 11px; }
.platform-mobile .holiday-name { font-size: 8px; }
.platform-mobile .month-task-pill { font-size: 9px; padding: 1px 4px; }
.platform-mobile .month-more { font-size: 9px; }

.platform-mobile .day-title { font-size: 17px; }

/* 일간뷰 타임라인 패널(고정폭 210px)을 옆이 아니라 아래로 내려, 본문이 짓눌리지 않게 함 */
.platform-mobile .day-content {
  flex-direction: column;
}

.platform-mobile .day-timeline-panel {
  width: 100%;
  max-height: 320px;
}

/* ---------- 3. hover로만 보이던 버튼 → 모바일에서는 항상 보이고 터치 영역 44px 이상 ---------- */
.platform-mobile .habit-history-btn,
.platform-mobile .habit-del {
  opacity: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  font-size: 16px;
}

.platform-mobile .dday-actions {
  opacity: 1;
}

.platform-mobile .dday-actions button {
  min-width: 44px;
  min-height: 44px;
  font-size: 14px;
}

/* ---------- 4. 모달 → 화면 폭을 넘지 않고, 넘치면 내부 스크롤 ---------- */
.platform-mobile .modal-box {
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

/* ---------- 5. 전역 user-select:none은 유지하되, 입력 가능 영역은 선택·편집 가능하게 ---------- */
.platform-mobile #notesArea,
.platform-mobile input,
.platform-mobile textarea,
.platform-mobile [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
