/* 홈 탭 — 할 일 + 구글 캘린더.
   토큰(--card, --border, --text …)은 upload.html 의 것을 그대로 쓴다. 여기선
   캘린더 고유의 것만 정의한다. */

:root {
  --cal-h: 48px;            /* 주/일 보기 1시간 높이 */
  --cal-gut: 56px;          /* 시간 눈금 폭 */
  --evt-radius: 6px;
}

/* ---------- 툴바 ---------- */
.home-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.home-bar .grow { flex: 0 1 auto; min-width: 0; }
.home-title { font-size: 1.12rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.home-title .sub { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: 7px; }

.nav-group { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 32px; height: 32px; flex: none; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--text-soft); cursor: pointer; font-size: 15px;
  line-height: 1; display: grid; place-items: center; font-family: inherit;
  transition: background .13s, border-color .13s, color .13s;
}
.icon-btn:hover { background: var(--card-inset); border-color: var(--border); }
.icon-btn.on { background: var(--accent-bg); color: var(--accent); border-color: transparent; }

.seg-view { display: flex; gap: 2px; padding: 2px; background: var(--card-inset);
  border: 1px solid var(--border); border-radius: 10px; }
.seg-view button {
  padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .79rem; font-weight: 600; color: var(--text-soft);
}
.seg-view button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* 검색은 남는 폭을 먹고 줄어드는 쪽 — 이게 없으면 기간 라벨이 길어질 때
   '+ 만들기' 가 둘째 줄로 밀린다. */
.home-search { position: relative; flex: 1 1 150px; min-width: 110px; max-width: 260px; }
.home-search input {
  width: 100%; padding: 8px 30px 8px 30px; border-radius: 9px; font-family: inherit;
  border: 1px solid var(--border-strong); background: var(--card-inset);
  color: var(--text); font-size: .8rem;
}
.home-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.home-search .mag { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .8rem; pointer-events: none; }
.home-search .clr { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; }

.btn-create {
  flex: none; padding: 9px 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font-family: inherit; font-size: .83rem; font-weight: 700;
}
.btn-create:hover { filter: brightness(1.07); }


/* ---------- 본문: 달력이 폭을 다 쓴다 ---------- */
.cal-wrap { min-width: 0; }

/* 툴바의 남은 할 일 뱃지 — 누르면 목록 보기로 간다 */
.todo-badge { display: none; }
.todo-badge.on {
  display: inline-block; flex: none; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card-inset); color: var(--text-soft);
  font-family: inherit; font-size: .74rem; font-weight: 700;
}
.todo-badge.on:hover { border-color: var(--accent); color: var(--accent); }
.todo-badge.late { background: var(--fail-bg); color: var(--fail);
  border-color: color-mix(in srgb, var(--fail) 28%, transparent); }

/* 날짜 모드 — 시간 / 종일 / 날짜 없음 (하나로 합친 항목이 어떤 모습인지 고른다) */
.seg-mode { display: inline-flex; gap: 2px; padding: 2px; background: var(--card-inset);
  border: 1px solid var(--border); border-radius: 10px; }
.seg-mode button {
  padding: 6px 13px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .79rem; font-weight: 600; color: var(--text-soft);
}
.seg-mode button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* 날짜/시간 줄 — flex 기본값이면 date 칸이 0 에 가깝게 찌그러진다. 최소 폭을 준다. */
#ed-when input[type="date"] { flex: 1 1 128px; min-width: 118px; }
#ed-when input[type="time"] { flex: 1 1 104px; min-width: 96px; }
#ed-when > span { flex: none; }

/* ---------- 월 보기 ---------- */
.mv-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0;
  background: var(--card-inset); overflow: hidden; }
.mv-dow div { text-align: center; padding: 7px 0; font-size: .7rem; font-weight: 700; color: var(--muted); }
.mv-dow div.sun { color: var(--fail); } .mv-dow div.sat { color: var(--excel); }

.mv-body { border: 1px solid var(--border); border-radius: 0 0 12px 12px; overflow: hidden;
  background: var(--card); }
.mv-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  position: relative; border-top: 1px solid var(--border); min-height: 104px; }
.mv-week:first-child { border-top: 0; }
.mv-cell { border-left: 1px solid var(--border); padding: 3px 4px 4px; min-width: 0; cursor: pointer; }
.mv-cell:first-child { border-left: 0; }
.mv-cell:hover { background: var(--card-inset); }
.mv-cell.other { background: color-mix(in srgb, var(--card-inset) 60%, transparent); }
.mv-cell.other .mv-num { color: var(--muted); }
.mv-num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px; font-size: .74rem; font-weight: 700; color: var(--text-soft); }
.mv-cell.today .mv-num { background: var(--accent); color: #fff; }
.mv-cell.sun .mv-num { color: var(--fail); } .mv-cell.sat .mv-num { color: var(--excel); }
.mv-cell.today.sun .mv-num, .mv-cell.today.sat .mv-num { color: #fff; }
.mv-lanes { position: absolute; left: 0; right: 0; top: 27px; pointer-events: none; }
.mv-stack { margin-top: 2px; display: grid; gap: 2px; }
.mv-more { font-size: .68rem; color: var(--muted); font-weight: 600; padding: 1px 4px; cursor: pointer; }
.mv-more:hover { color: var(--accent); }

/* 종일/여러 날 일정 = 주를 가로지르는 막대 */
.bar {
  position: absolute; height: 19px; border-radius: var(--evt-radius); pointer-events: auto;
  font-size: .7rem; font-weight: 600; line-height: 19px; padding: 0 7px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff;
}
.bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* 시각 있는 일정 = 점 + 시각 + 제목 */
.chip {
  display: flex; align-items: center; gap: 4px; padding: 1px 3px; border-radius: 5px;
  font-size: .7rem; cursor: pointer; min-width: 0;
}
.chip:hover { background: var(--card-inset); }
/* 완료한 항목의 점은 속이 빈 동그라미 — 체크 표시와 같은 뜻으로 읽힌다 */
.chip .cdot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.chip .cdot.checked { border: 1.5px solid currentColor; background: transparent !important; }
.chip .pri { color: var(--fail); }
/* 월 칸이 좁아 시각이 제목을 다 잡아먹는다 — 시각은 작게, 제목에 남은 폭을 준다 */
.chip .ct { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: .65rem; }
.chip .cn { flex: 1; }
.chip .cn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.done .cn { text-decoration: line-through; color: var(--muted); }
.chip.done .ct { opacity: .6; }

/* ---------- 주 / 일 보기 ---------- */
.wv { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.wv-head { display: grid; border-bottom: 1px solid var(--border); background: var(--card-inset); }
.wv-head .corner { border-right: 1px solid var(--border); }
.wv-hcell { text-align: center; padding: 6px 2px 7px; border-left: 1px solid var(--border); }
.wv-hcell .dw { font-size: .68rem; color: var(--muted); font-weight: 700; }
.wv-hcell .dn { display: inline-grid; place-items: center; width: 27px; height: 27px; margin-top: 2px;
  border-radius: 50%; font-size: .85rem; font-weight: 700; }
.wv-hcell.today .dn { background: var(--accent); color: #fff; }
.wv-hcell.sun .dw, .wv-hcell.sun .dn { color: var(--fail); }
.wv-hcell.sat .dw, .wv-hcell.sat .dn { color: var(--excel); }
.wv-hcell.today.sun .dn, .wv-hcell.today.sat .dn { color: #fff; }

.wv-allday { display: grid; border-bottom: 1px solid var(--border); position: relative;
  min-height: 26px; background: var(--card); }
.wv-allday .lab { border-right: 1px solid var(--border); font-size: .62rem; color: var(--muted);
  padding: 4px 6px; text-align: right; }
.wv-allday .col { border-left: 1px solid var(--border); }
.wv-allday .lanes { position: absolute; top: 3px; pointer-events: none; }

.wv-scroll { max-height: 560px; overflow-y: auto; position: relative; }
.wv-grid { display: grid; position: relative; }
.wv-gut { border-right: 1px solid var(--border); }
.wv-gut .hr { height: var(--cal-h); position: relative; }
.wv-gut .hr span { position: absolute; right: 6px; top: -7px; font-size: .64rem; color: var(--muted);
  background: var(--card); padding: 0 2px; font-variant-numeric: tabular-nums; }
.wv-col { border-left: 1px solid var(--border); position: relative; }
.wv-col .hr { height: var(--cal-h); border-top: 1px solid var(--border); }
.wv-col .hr:first-child { border-top: 0; }
.wv-col .hr.half { border-top-style: dotted; }
.wv-col.today { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.evt {
  position: absolute; border-radius: var(--evt-radius); padding: 2px 6px; overflow: hidden;
  color: #fff; font-size: .7rem; line-height: 1.25; cursor: pointer; z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.evt .et { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt .eh { opacity: .85; font-size: .65rem; }
.evt.free { background: var(--card) !important; color: var(--text) !important;
  border: 1px solid currentColor; box-shadow: none; }
.evt .rz { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.evt.drag { opacity: .72; z-index: 20; }
.evt.ghost { opacity: .5; border: 1px dashed #fff; }

.nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--fail);
  z-index: 5; pointer-events: none; }
.nowline::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--fail); }

/* ---------- 일정 목록 보기 ---------- */
.ag-day { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px;
  padding: 11px 4px; border-top: 1px solid var(--border); }
.ag-day:first-child { border-top: 0; }
.ag-date { font-size: .78rem; font-weight: 700; color: var(--text-soft); }
.ag-date .dw { display: block; font-size: .68rem; font-weight: 500; color: var(--muted); }
.ag-date.today { color: var(--accent); }
.ag-row { display: flex; align-items: center; gap: 9px; padding: 5px 7px; border-radius: 8px;
  cursor: pointer; font-size: .82rem; }
.ag-row:hover { background: var(--card-inset); }
.ag-row .tm { flex: none; width: 92px; color: var(--muted); font-size: .74rem;
  font-variant-numeric: tabular-nums; }
.ag-row .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.ag-empty { padding: 34px 0; text-align: center; color: var(--muted); font-size: .82rem; }
.ag-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-row.done .nm { text-decoration: line-through; color: var(--muted); }
.ag-row.done .sw { opacity: .45; }

/* 기한 없는 할 일 — 달력엔 못 뜨니 목록 맨 위에서만 보인다 */
.ag-undated { border: 1px dashed var(--border-strong); border-radius: 12px;
  padding: 9px 11px 11px; margin-bottom: 14px; background: var(--card-inset); }
.ag-undated-h { font-size: .74rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.ag-undated .ag-row:hover { background: var(--card); }

.todo-cb { flex: none; width: 17px; height: 17px; border-radius: 50%; padding: 0;
  border: 1.6px solid var(--border-strong); background: transparent; cursor: pointer;
  display: grid; place-items: center; font-size: 11px; color: #fff; }
.todo-cb.on { background: var(--ok); border-color: var(--ok); }
.todo-pri { font-weight: 700; font-size: .72rem; }
.todo-pri.high { color: var(--fail); }
.todo-due { font-size: .68rem; padding: 1px 7px; border-radius: 999px; background: var(--card-inset); }
.todo-due.late { background: var(--fail-bg); color: var(--fail); font-weight: 700; }


/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; background: rgba(12,14,22,.45); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal.on { display: flex; }
.sheet { background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28); width: 100%; max-width: 560px;
  max-height: calc(100vh - 44px); overflow-y: auto; }
.sheet.narrow { max-width: 400px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px 0; }
.sheet-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.sheet-body { padding: 14px 18px 4px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 14px 18px 17px; }
.sheet-foot .sp { flex: 1; }

.f { margin-bottom: 12px; }
.f > label { display: block; font-size: .74rem; font-weight: 700; color: var(--text-soft);
  margin-bottom: 5px; }
.f input[type=text], .f input[type=date], .f input[type=time], .f textarea, .f select {
  width: 100%; padding: 9px 11px; border-radius: 9px; font-family: inherit; font-size: .84rem;
  border: 1px solid var(--border-strong); background: var(--card-inset); color: var(--text);
}
.f textarea { resize: vertical; min-height: 66px; }
.f input:focus, .f textarea:focus, .f select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.f-row { display: flex; gap: 8px; align-items: center; }
.f-row > * { min-width: 0; }
.f-title input { font-size: 1.02rem !important; font-weight: 700; padding: 11px 12px !important; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem;
  color: var(--text-soft); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 19px; border-radius: 999px; margin: 0;
  background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(15px); }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  padding: 0; display: grid; place-items: center; color: #fff; font-size: 12px; }
.swatch.on { border-color: var(--text); }

.rem-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.rem-row select { flex: 0 0 96px; }
.rem-row input[type=number] { flex: 0 0 76px; padding: 8px 9px; border-radius: 9px; font-family: inherit;
  font-size: .82rem; border: 1px solid var(--border-strong); background: var(--card-inset); color: var(--text); }
.rem-row .x { flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.link-btn { border: 0; background: transparent; color: var(--accent); cursor: pointer;
  font-family: inherit; font-size: .77rem; font-weight: 700; padding: 2px 0; }

.att { display: flex; flex-wrap: wrap; gap: 5px; }
.att span { font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: var(--card-inset);
  border: 1px solid var(--border); color: var(--text-soft); }
.ro-note { font-size: .7rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }

.btn-sm { padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--card-inset); color: var(--text-soft); font-family: inherit; font-size: .82rem;
  font-weight: 600; cursor: pointer; white-space: nowrap; flex: none; }
.btn-sm:hover { border-color: var(--border-strong); color: var(--text); }
.btn-sm.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-sm.danger { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 30%, transparent); }
.btn-sm:disabled { opacity: .5; cursor: default; }

.scope-opt { display: block; width: 100%; text-align: left; padding: 11px 13px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card-inset);
  color: var(--text); font-family: inherit; font-size: .84rem; cursor: pointer; }
.scope-opt:hover { border-color: var(--accent); color: var(--accent); }

/* 일정 미리보기 팝오버 */
.pop { position: absolute; z-index: 40; width: 292px; background: var(--card);
  border: 1px solid var(--border); border-radius: 13px; box-shadow: 0 18px 44px rgba(0,0,0,.22);
  padding: 14px; display: none; }
.pop.on { display: block; }
.pop h4 { margin: 0 0 3px; font-size: .95rem; padding-right: 22px; }
.pop .when { font-size: .78rem; color: var(--text-soft); }
.pop .meta { font-size: .75rem; color: var(--muted); margin-top: 7px; line-height: 1.5; word-break: break-word; }
.pop .acts { display: flex; gap: 6px; margin-top: 11px; }
.pop .x { position: absolute; top: 9px; right: 9px; }
.pop .cal-name { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; font-size: .72rem;
  color: var(--muted); }
.pop .cal-name i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }


@media (max-width: 900px) {
  .home-bar { gap: 7px; }
  .home-search { flex: 1 1 100%; order: 9; }
  .wv-scroll { max-height: 440px; }
  .mv-week { min-height: 78px; }
}

/* 팝오버 좌표 기준 + 드래그 대상 표시 */
#tab-home { position: relative; }
.mv-cell.drop { background: var(--accent-bg); box-shadow: inset 0 0 0 2px var(--accent); }
