/* ===== 기본 ===== */
:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #1d2128;
  --text-sub: #6b7280;
  --line: #e5e7eb;
  --accent: #5b6ef5;
  --accent-soft: #eef0fe;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --shadow: 0 1px 3px rgba(20, 24, 40, .07), 0 4px 14px rgba(20, 24, 40, .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --card: #1e2128;
    --text: #e8eaf0;
    --text-sub: #9aa1ad;
    --line: #2e323b;
    --accent: #7886f7;
    --accent-soft: #272c45;
    --danger: #f2555a;
    --danger-soft: #3a2426;
    --ok: #34c269;
    --ok-soft: #1d3328;
    --warn: #f0a33c;
    --warn-soft: #3a3022;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-sub); font-size: 13px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: filter .15s;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  width: 36px; height: 36px;
  font-size: 13px;
}

/* ===== 로그인 ===== */
#login-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--accent) 0%, #8a5bf5 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 22px;
  padding: 40px 32px;
  width: 100%; max-width: 380px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  text-align: center;
}
.login-logo { font-size: 48px; }
.login-card h1 { margin: 6px 0 2px; font-size: 26px; }
.login-sub { color: var(--text-sub); margin: 0 0 24px; }
.login-card input { width: 100%; margin-bottom: 10px; padding: 12px 14px; }
.google-auth-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
}
.google-auth-btn:hover { background: var(--bg); }
.google-auth-btn span {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #4285f4;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: Arial, sans-serif;
  font-weight: 800;
}
.login-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: 10px; padding: 9px 12px;
  font-size: 13px; margin-bottom: 10px;
}
.login-hint { font-size: 12.5px; color: var(--text-sub); margin: -4px 0 10px; text-align: left; }
.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tabs button {
  flex: 1;
  border: 0; background: none;
  padding: 9px 0;
  border-radius: 999px;
  font-size: 14px; font-weight: 700;
  color: var(--text-sub);
}
.auth-tabs button.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* ===== 상단바 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { font-size: 18px; font-weight: 800; white-space: nowrap; }
.search-box {
  flex: 1; position: relative; max-width: 480px; margin: 0 auto;
  display: flex; align-items: center;
}
.search-icon { position: absolute; left: 11px; font-size: 13px; opacity: .6; }
.search-box input { width: 100%; padding: 8px 32px 8px 34px; border-radius: 999px; font-size: 14px; }
.search-clear {
  position: absolute; right: 6px;
  border: 0; background: var(--line); color: var(--text-sub);
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 14px; line-height: 1;
}
/* 그룹 선택 */
.group-menu { position: relative; }
.group-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13.5px; font-weight: 700;
  max-width: 180px;
}
.group-btn #group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-btn .caret { color: var(--text-sub); font-size: 10px; }
.group-dropdown { left: 0; right: auto; min-width: 240px; max-height: 70dvh; overflow-y: auto; }
.gd-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  background: none; border: 0;
  padding: 11px 14px;
  font-size: 14px; color: var(--text);
}
.gd-item:hover { background: var(--accent-soft); }
.gd-item.active { background: var(--accent-soft); }
.gd-item.active .gd-name { color: var(--accent); font-weight: 800; }
.gd-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-meta { font-size: 11.5px; color: var(--text-sub); white-space: nowrap; }
.dropdown-divider { height: 1px; background: var(--line); margin: 4px 0; }

.user-menu { position: relative; }
.user-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 15px;
}
.dropdown {
  position: absolute; right: 0; top: 46px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 180px;
  overflow: hidden;
}
.dropdown-info { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); font-size: 14px; }
.dropdown-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0;
  padding: 11px 14px; font-size: 14px; color: var(--text);
}
.dropdown-item:hover { background: var(--accent-soft); }

/* ===== 탭 ===== */
.tabs {
  display: flex; gap: 4px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  position: sticky; top: calc(59px + env(safe-area-inset-top)); z-index: 40;
}
.tab {
  border: 0; background: none;
  padding: 11px 14px;
  font-size: 14px; font-weight: 600;
  color: var(--text-sub);
  border-bottom: 2.5px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: 16px 14px 110px; }

/* ===== 필터 ===== */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.segmented {
  display: inline-flex; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px;
}
.segmented button {
  border: 0; background: none; color: var(--text-sub);
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.segmented button.active { background: var(--accent); color: #fff; }
.select { padding: 8px 12px; font-size: 13px; border-radius: 999px; }
.search-info {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; padding: 9px 14px; margin-bottom: 12px;
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.search-info button { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: underline; }

/* ===== 빠른 추가 ===== */
.quick-add {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 8px 4px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.qa-icon { font-size: 15px; }
.quick-add input {
  flex: 1; border: 0; background: none; padding: 10px 4px; font-size: 14.5px;
}
.quick-add input:focus { box-shadow: none; }
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== 할일 목록 ===== */
.group-title {
  font-size: 13.5px; font-weight: 700; color: var(--text-sub);
  margin: 20px 4px 8px;
  display: flex; align-items: center; gap: 6px;
}
.group-title:first-child { margin-top: 4px; }
.group-title .count { background: var(--line); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.group-title.overdue { color: var(--danger); }
.group-title.today-group { color: var(--accent); }

.todo-item {
  display: flex; gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform .1s;
  border-left: 4px solid transparent;
}
.todo-item.p-high { border-left-color: var(--danger); }
.todo-item.p-low { border-left-color: var(--line); opacity: .92; }
.todo-item:active { transform: scale(.99); }
.check {
  flex: none;
  width: 24px; height: 24px; margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: none; color: transparent;
  font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.todo-item.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-weight: 600; word-break: break-all; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--text-sub); }
.todo-content-preview {
  color: var(--text-sub); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.todo-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px; padding: 2.5px 9px;
  background: var(--bg); color: var(--text-sub);
}
.chip.assignee { background: var(--accent-soft); color: var(--accent); }
.chip.overdue { background: var(--danger-soft); color: var(--danger); }
.chip.today { background: var(--warn-soft); color: var(--warn); }
.chip.done-at { background: var(--ok-soft); color: var(--ok); }
.chip.prio-high { background: var(--danger); color: #fff; }
.chip.prio-low { background: var(--bg); color: var(--text-sub); border: 1px dashed var(--line); }
/* 목록 안 체크리스트 (바로 체크 가능) */
.todo-checklist { margin-top: 7px; display: flex; flex-direction: column; gap: 2px; }
.cl-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px;
  padding: 4px 6px; margin-left: -6px;
  border-radius: 8px;
  cursor: pointer;
}
.cl-item:hover { background: var(--bg); }
.cl-box {
  flex: none;
  width: 18px; height: 18px;
  border: 2px solid var(--line); border-radius: 6px;
  color: transparent; font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cl-item.done .cl-box { background: var(--ok); border-color: var(--ok); color: #fff; }
.cl-item.done .cl-label { text-decoration: line-through; color: var(--text-sub); }
.cl-label { word-break: break-all; }

/* 이모지 반응 */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; }
.react-pill {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
}
.react-pill.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.react-add {
  border: 1px dashed var(--line);
  background: none;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text-sub);
  opacity: .45;
}
.todo-item:hover .react-add { opacity: 1; }
.react-picker {
  display: flex; gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 6px;
  box-shadow: var(--shadow);
}
.react-opt { border: 0; background: none; font-size: 17px; padding: 2px 4px; border-radius: 8px; }
.react-opt:hover { background: var(--accent-soft); }

.todo-thumbs { display: flex; gap: 6px; margin-top: 9px; }
.todo-thumbs img {
  width: 54px; height: 54px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line);
}
.thumb-more {
  width: 54px; height: 54px; border-radius: 8px;
  background: var(--bg); color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}

.empty {
  text-align: center; color: var(--text-sub);
  padding: 60px 20px;
}
.empty .empty-icon { font-size: 44px; margin-bottom: 10px; }

/* ===== 달력 ===== */
.cal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-title { font-size: 17px; font-weight: 800; min-width: 120px; text-align: center; }
.cal-header .btn { margin-left: auto; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 12px; font-weight: 700; color: var(--text-sub);
  margin-bottom: 4px;
}
.cal-weekdays .sun { color: var(--danger); }
.cal-weekdays .sat { color: var(--accent); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: 10px;
  min-height: 86px;
  padding: 5px 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cal-cell.other-month { opacity: .35; }
.cal-cell.selected { border-color: var(--accent); }
.cal-cell .d {
  font-size: 12.5px; font-weight: 700;
  width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 50%;
}
.cal-cell.sun .d { color: var(--danger); }
.cal-cell.sat .d { color: var(--accent); }
.cal-cell.is-today .d { background: var(--accent); color: #fff; }
.cal-mini {
  font-size: 11px; line-height: 1.35;
  margin-top: 3px; padding: 1.5px 5px;
  border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600;
}
.cal-mini.done { background: var(--bg); color: var(--text-sub); text-decoration: line-through; }
.cal-mini.high { background: var(--danger-soft); color: var(--danger); }
.cal-more { font-size: 10.5px; color: var(--text-sub); margin-top: 2px; padding-left: 3px; font-weight: 600; }

.day-panel { margin-top: 18px; }
.day-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.day-panel-header h3 { margin: 0; font-size: 15.5px; }

/* 좁은 화면: 달력 셀에 제목 대신 점 표시 */
@media (max-width: 560px) {
  .cal-cell { min-height: 56px; padding: 4px; }
  .cal-mini, .cal-more { display: none; }
  .cal-cell .dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; padding-left: 3px; }
  .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
  .dot.done { background: var(--text-sub); opacity: .5; }
}
@media (min-width: 561px) { .cal-cell .dots { display: none; } }

/* ===== 기록 (활동 + 휴지통) ===== */
.seg-badge {
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px;
  margin-left: 5px;
}
.act-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.act-row .avatar { width: 34px; height: 34px; font-size: 14px; }
.act-body { flex: 1; min-width: 0; font-size: 14px; }
.act-title { font-weight: 600; word-break: break-all; }
.act-icon { margin-left: 2px; }
.act-time { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.trash-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.trash-body { flex: 1; min-width: 0; }
.trash-body .todo-title { color: var(--text-sub); }
.trash-body .sub { font-size: 12.5px; color: var(--text-sub); margin-top: 2px; }

/* 모달 안 우선순위 선택 */
.prio-seg { width: 100%; display: flex; }
.prio-seg button { flex: 1; }

/* 그룹 관리 모달 */
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-row input { flex: 1; }
.code-box {
  flex: 1;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 18px; letter-spacing: 2px;
  text-align: center;
  border-radius: 10px;
  padding: 10px 12px;
  user-select: all;
}
.invite-card {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 16px;
  margin-top: 14px;
}
.invite-title { font-weight: 800; font-size: 14.5px; margin-bottom: 10px; }
.code-box.big {
  background: var(--card);
  font-size: 24px; letter-spacing: 4px;
  padding: 13px;
  margin-bottom: 10px;
}
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-actions .btn { flex: 1; min-width: 120px; white-space: nowrap; }
.invite-hint { font-size: 12px; color: var(--text-sub); margin-top: 9px; }

.role-pills {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.role-pill {
  border: 0; background: none;
  color: var(--text-sub);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap;
}
.role-pill.active { background: var(--accent); color: #fff; }
.role-legend { font-size: 12px; color: var(--text-sub); margin: 2px 0 8px; }
.user-row { flex-wrap: wrap; }
.user-row .actions { margin-left: auto; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.role-badge {
  font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 4px 10px;
  background: var(--bg); color: var(--text-sub);
}
.role-badge.owner { background: var(--accent-soft); color: var(--accent); }
.role-badge.viewer { border: 1px dashed var(--line); }
.badge-now {
  font-size: 11px; background: var(--ok); color: #fff;
  border-radius: 6px; padding: 1px 6px; margin-left: 4px;
  vertical-align: 1px;
}
.m-role { padding: 5px 8px; font-size: 12.5px; }

/* 댓글 */
.comments-box { display: flex; flex-direction: column; gap: 10px; max-height: 240px; overflow-y: auto; padding: 2px; }
.cm-item { display: flex; gap: 9px; }
.cm-item .avatar { width: 28px; height: 28px; font-size: 12px; flex: none; }
.cm-body { flex: 1; min-width: 0; }
.cm-head { font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.cm-time { color: var(--text-sub); font-size: 11.5px; }
.cm-del { border: 0; background: none; color: var(--text-sub); font-size: 11.5px; text-decoration: underline; margin-left: auto; }
.cm-del:hover { color: var(--danger); }
.cm-text { font-size: 14px; word-break: break-all; white-space: pre-wrap; margin-top: 1px; }

/* 토스트 실행취소 버튼 */
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast-action {
  border: 0; background: none;
  color: #9db4ff; font-weight: 800; font-size: 13.5px;
  padding: 0; text-decoration: underline;
  cursor: pointer;
}

/* ===== 카드 / 관리 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.user-list { margin-top: 14px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: 0; }
.avatar {
  flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.user-row .info { flex: 1; min-width: 0; }
.user-row .name { font-weight: 700; }
.user-row .name .badge {
  font-size: 11px; background: var(--accent); color: #fff;
  border-radius: 6px; padding: 1px 6px; margin-left: 6px;
  vertical-align: 1px;
}
.user-row .sub { font-size: 12.5px; color: var(--text-sub); }
.user-row .actions { display: flex; gap: 6px; }
.add-user-form { display: grid; gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-sub); }
.checkbox-label input { width: auto; }

/* ===== FAB ===== */
#fab {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1;
  box-shadow: 0 8px 22px rgba(91, 110, 245, .45);
  z-index: 60;
  transition: transform .12s;
}
#fab:hover { transform: scale(1.06); }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 18, 26, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card);
  width: 100%; max-width: 560px;
  max-height: 92dvh;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: slide-up .18s ease-out;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; max-height: 86dvh; }
}
@keyframes slide-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 0;
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: var(--bg); border-radius: 50%; width: 30px; height: 30px; font-size: 15px; color: var(--text-sub); }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-body label { display: block; font-size: 13px; font-weight: 700; color: var(--text-sub); margin: 14px 0 5px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body > .field-head:first-child label { margin-top: 0; }
.modal-body input[type="text"], .modal-body input[type="date"], .modal-body input[type="password"],
.modal-body textarea, .modal-body select { width: 100%; }
.modal-body textarea { resize: vertical; min-height: 84px; }
.modal-footer {
  display: flex; gap: 8px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.modal-footer .spacer { flex: 1; }
.todo-info-line { font-size: 12px; color: var(--text-sub); margin-top: 12px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; } }

/* 모달: 제목 줄 + '여러 개 한번에' 버튼 */
.field-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.field-head label { flex: 1; }
.link-btn {
  border: 0; background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 700;
  border-radius: 999px; padding: 5px 11px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.label-hint { font-weight: 400; font-size: 12px; }

/* 모달 안 체크리스트 편집기 */
.cl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cl-row .cl-text { flex: 1; padding: 8px 10px; font-size: 14px; }
.cl-check {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: none; color: transparent;
  font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cl-check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.cl-remove {
  flex: none;
  border: 0; background: none; color: var(--text-sub);
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 13px;
}
.cl-remove:hover { background: var(--danger-soft); color: var(--danger); }
.cl-new-row .cl-plus {
  flex: none;
  width: 24px; height: 24px;
  border: 0; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 15px; line-height: 1; font-weight: 700;
}
.cl-new-row input { flex: 1; border-style: dashed; padding: 8px 10px; font-size: 14px; }

/* 모달 안 사진 영역 */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.photo-tile { position: relative; }
.photo-tile img {
  width: 76px; height: 76px;
  object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.photo-del {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--card);
  background: var(--danger); color: #fff;
  font-size: 12px; line-height: 1; padding: 0;
}
.photo-add {
  width: 76px; height: 76px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: none; color: var(--text-sub);
  font-size: 22px;
}
.photo-hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }

/* ===== 라이트박스 ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .88);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 92dvh; border-radius: 6px; }

/* ===== 토스트 ===== */
#toast-root {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #2a2e3a; color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  animation: toast-in .2s ease-out;
  max-width: 86vw;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .brand span { display: none; }
  .topbar { gap: 8px; padding: 10px 10px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .group-btn { max-width: 124px; padding: 6px 9px; font-size: 12.5px; }
  .search-box { min-width: 0; }
  main { padding: 12px 10px 110px; }
}
