/* 당근헬스 메신저 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --orange: #ff7f2a;
  --orange-dark: #e86a15;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #222;
  --sub: #8a8f98;
  --line: #e7e9ee;
  --green: #22a15c;
  --red: #e5484d;
  --amber: #d9820b;
}
html, body { height: 100%; }
body {
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100dvh; }
.loading { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--sub); }

/* ---------- 로그인 ---------- */
.login-wrap { display: flex; height: 100dvh; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; background: var(--card); border-radius: 20px; padding: 36px 28px; box-shadow: 0 8px 30px rgba(0,0,0,.08); text-align: center; }
.login-box .logo { font-size: 52px; }
.login-box h1 { font-size: 22px; margin: 10px 0 4px; }
.login-box .sub { color: var(--sub); font-size: 13px; margin-bottom: 24px; }
.login-box input { width: 100%; margin-bottom: 10px; }

/* ---------- 공통 ---------- */
input, textarea, select {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); }
textarea { resize: none; }
.btn {
  padding: 12px 18px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 15px; font-family: inherit; cursor: pointer; color: var(--text);
}
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.btn.primary:active { background: var(--orange-dark); }
.btn.danger { color: var(--red); border-color: #f3c4c6; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn:disabled { opacity: .5; }

.page { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--bg); }
.top {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  background: var(--orange); color: #fff; flex: none;
}
.top h2 { font-size: 18px; font-weight: 700; }
.back-btn { background: none; border: none; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; padding: 0 6px 4px 0; }
.body { flex: 1; overflow-y: auto; padding: 14px; }
.body.room-body { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.nav { display: flex; background: var(--card); border-top: 1px solid var(--line); flex: none; padding-bottom: env(safe-area-inset-bottom); }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; border: none; background: none; font-size: 11px; color: var(--sub); cursor: pointer; font-family: inherit;
}
.nav-item.active { color: var(--orange); font-weight: 700; }
.nav-icon { position: relative; font-size: 21px; }
.badge {
  position: absolute; top: -5px; right: -14px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; padding: 2px 5px; min-width: 17px; text-align: center;
}
.room-right .badge, .room-name .badge { position: static; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(16px);
  background: #333; color: #fff; padding: 12px 20px; border-radius: 24px; font-size: 14px;
  opacity: 0; transition: all .25s; z-index: 999; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }
.empty { text-align: center; color: var(--sub); padding: 60px 20px; line-height: 1.7; }
.section-title { font-size: 14px; color: var(--sub); margin: 18px 4px 10px; }

/* ---------- 대화 목록 ---------- */
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 16px; padding: 14px; cursor: pointer; border: 1px solid var(--line);
}
.room-item:active { background: #fff7f0; }
.room-avatar {
  width: 46px; height: 46px; border-radius: 50%; background: #ffe9d8; color: var(--orange-dark);
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; flex: none;
}
.room-mid { flex: 1; min-width: 0; }
.room-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.room-preview { color: var(--sub); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-right { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.room-time { color: var(--sub); font-size: 11px; }

/* ---------- 칩 ---------- */
.chip {
  display: inline-block; padding: 8px 14px; border-radius: 20px; font-size: 14px;
  border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; color: var(--text);
}
.chip.small { padding: 2px 8px; font-size: 11px; }
.chip.toggle.selected { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.chip.green { background: #e6f6ec; border-color: #bfe6ce; color: var(--green); font-weight: 700; }
.chip.red { background: #fdebec; border-color: #f5c6c8; color: var(--red); font-weight: 700; }
.chip.amber { background: #fdf3e2; border-color: #f0d9ae; color: var(--amber); font-weight: 700; }
.chip.gray { background: #f0f1f4; color: var(--sub); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 대화방 ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg-who { font-size: 11px; color: var(--sub); margin-bottom: 3px; }
.bubble { border-radius: 16px; padding: 10px 14px; font-size: 15px; line-height: 1.55; word-break: break-word; }
.msg.mine .bubble { background: var(--orange); color: #fff; border-bottom-right-radius: 5px; }
.msg.theirs .bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-time { font-size: 10px; color: var(--sub); margin-top: 4px; }
.msg-text { white-space: pre-wrap; }
.msg-system { align-self: center; background: #fdf3e2; color: var(--amber); font-size: 12.5px; padding: 7px 14px; border-radius: 14px; max-width: 92%; text-align: center; }
.msg-photo-img { max-width: 100%; border-radius: 10px; margin: 4px 0; cursor: pointer; display: block; }

.input-row { display: flex; gap: 8px; padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); align-items: flex-end; flex: none; }
.input-row textarea { flex: 1; max-height: 110px; padding: 11px 13px; }
.photo-btn { font-size: 22px; cursor: pointer; padding: 8px 4px; }
.send-btn { flex: none; }
.photo-preview { padding: 6px 14px; background: #fff7f0; font-size: 13px; color: var(--orange-dark); flex: none; }
.photo-preview button { border: none; background: none; cursor: pointer; color: var(--red); font-size: 14px; margin-left: 6px; }

/* ---------- 작업 카드 ---------- */
.task-card {
  background: #fff; border: 1.5px solid #ffd9bd; border-radius: 14px; padding: 13px;
  display: flex; flex-direction: column; gap: 8px; color: var(--text); min-width: 220px;
}
.msg.mine .task-card { border-color: #fff; }
.task-card.list { margin-bottom: 10px; border-color: var(--line); }
.task-card.list.overdue { border-color: var(--red); background: #fffafa; }
.task-card.done-card { border-color: #bfe6ce; background: #f7fdf9; }
.task-head { font-size: 12px; font-weight: 700; color: var(--orange-dark); }
.done-card .task-head { color: var(--green); }
.task-title { font-size: 16px; font-weight: 700; }
.task-content { font-size: 14px; color: #555; white-space: pre-wrap; }
.task-meta { font-size: 12.5px; color: var(--sub); }
.task-done { color: var(--green); font-weight: 700; font-size: 14px; }
.task-pending { color: var(--sub); font-size: 13px; }
.over-tag { color: var(--red); font-weight: 700; font-size: 13px; }
.late-tag { color: var(--amber); font-size: 12px; font-weight: 700; }

/* ---------- 작업 현황판 ---------- */
.batch-list { display: flex; flex-direction: column; gap: 12px; }
.batch { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 15px; }
.batch-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.batch-title { font-weight: 700; font-size: 16px; }
.batch-count { font-size: 13px; font-weight: 700; color: var(--sub); flex: none; }
.batch-count.all-done { color: var(--green); }
.batch-count.over { color: var(--red); }
.batch-meta { font-size: 12.5px; color: var(--sub); margin: 5px 0 11px; }
.batch-chips { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---------- 폼 / 설정 ---------- */
.form { display: flex; flex-direction: column; gap: 16px; padding-bottom: 30px; }
.field label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.field .req { color: var(--red); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 17px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font-size: 15px; }
.hint { font-size: 13px; color: var(--sub); line-height: 1.6; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input, .inline select { width: auto; flex: 1; min-width: 90px; }
.inline .btn { flex: none; }
.file-label { display: block; font-size: 14px; font-weight: 700; }
.file-label input { margin-top: 8px; font-weight: 400; }
.switch-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.switch-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--orange); }
.inline input[type="number"], .inline input[type="time"] { flex: none; }
.small-btn { padding: 7px 12px; font-size: 13px; flex: none; }
.pay-table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
.pay-table th, .pay-table td { border-bottom: 1px solid var(--line); padding: 8px 7px; text-align: right; }
.pay-table th:first-child, .pay-table td:first-child, .pay-table th:nth-child(2), .pay-table td:nth-child(2) { text-align: left; }
.pay-table th { background: #fff7f0; color: var(--orange-dark); font-size: 12px; }
.pay-row { cursor: pointer; }
.pay-row:active { background: #fff7f0; }
.pay-total td { font-weight: 700; background: #fafafa; }
.worker-card { margin-bottom: 4px; }
.rec-row, .rc-row { border-top: 1px solid var(--line); padding-top: 8px; }
a.btn { text-decoration: none; display: inline-block; }

/* ---------- 모달 ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 12px; max-height: 85dvh; overflow-y: auto;
}
.modal h3 { font-size: 17px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.detail-photo { max-width: 100%; border-radius: 10px; cursor: pointer; }
