/* ==========================================================================
   COGO Together Now v3 — 지금 함께하는 사람들 (응원 보내기)
   - 모든 스타일은 .cg-tn 안에서만 동작 (기존 사이트 스타일과 충돌 없음)
   - 필요: shared/cogo-tokens.css
   - 핵심 장치: 겹친 얼굴들(지금 함께 있음) + 하트가 터지는 응원 버튼
   ========================================================================== */

.cg-tn {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 24px;
  font-family: var(--cg-font);
  color: var(--cg-ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
:where(.cg-tn) *, :where(.cg-tn) *::before, :where(.cg-tn) *::after { box-sizing: border-box; }
:where(.cg-tn) :where(button, input) { font: inherit; color: inherit; margin: 0; letter-spacing: inherit; }
:where(.cg-tn) button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:where(.cg-tn) :where(p, h2, ul) { margin: 0; }
:where(.cg-tn) :focus { outline: none; }
.cg-tn :focus-visible { outline: 2.5px solid rgba(46, 91, 255, .6); outline-offset: 2px; }
.cg-tn .cg-ic { flex: none; display: block; }
.cg-tn [hidden] { display: none !important; }

.cg-tn .cg-tn-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 26, 43, .46);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.cg-tn .cg-tn-sheet {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(580px, 100%);
  height: min(760px, 100%);
  overflow: hidden;
  background: var(--cg-surface);
  border-radius: 28px;
  box-shadow: var(--cg-shadow-sheet);
}
.cg-tn .cg-tn-sheet:focus, .cg-tn .cg-tn-sheet:focus-visible { outline: none; }

/* ---------- 머리 ---------- */
.cg-tn .cg-tn-head {
  position: relative;
  padding: 24px 24px 22px 26px;
  overflow: hidden;
  background: var(--cg-paper);
  border-bottom: 1px solid var(--cg-line);
}
.cg-tn .cg-tn-head::before {
  content: "";
  position: absolute;
  right: -70px;
  top: -90px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(224, 69, 123, .16), rgba(224, 69, 123, 0));
  pointer-events: none;
}
.cg-tn .cg-tn-head-row { position: relative; display: flex; align-items: flex-start; gap: 12px; }
.cg-tn .cg-tn-head-text { flex: 1; min-width: 0; }
.cg-tn .cg-tn-brand { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--cg-heart); }
.cg-tn .cg-tn-title { margin-top: 4px; font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: -.025em; }
.cg-tn .cg-tn-lede { margin-top: 4px; font-size: 14px; font-weight: 500; color: var(--cg-ink-3); }
.cg-tn .cg-tn-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--cg-surface);
  border: 1.5px solid var(--cg-line);
  transition: background .2s, color .2s, border-color .2s;
}
.cg-tn .cg-tn-close:hover { background: var(--cg-ink); border-color: var(--cg-ink); color: #fff; }

.cg-tn .cg-tn-crowd { position: relative; display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.cg-tn .cg-tn-stack { display: flex; padding-left: 10px; }
.cg-tn .cg-tn-stack .cg-tn-ava { width: 42px; height: 42px; margin-left: -10px; box-shadow: 0 0 0 3px var(--cg-paper); font-size: 14px; }
.cg-tn .cg-tn-stack .cg-tn-ava::after { display: none; }
.cg-tn .cg-tn-more {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-left: -10px;
  border-radius: 50%;
  background: var(--cg-ink);
  color: #fff;
  box-shadow: 0 0 0 3px var(--cg-paper);
  font-size: 12.5px;
  font-weight: 800;
}
.cg-tn .cg-tn-count { min-width: 0; font-size: 15px; font-weight: 600; color: var(--cg-ink-2); }
.cg-tn .cg-tn-count b { font-size: 17px; font-weight: 800; color: var(--cg-ink); }
.cg-tn .cg-tn-count small { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: var(--cg-ink-3); }
.cg-tn .cg-tn-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cg-green); animation: cg-pulse 2s ease-out infinite; }
.cg-tn.is-opening .cg-tn-stack > * { animation: cg-pop .45s var(--cg-ease-spring) both; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(2) { animation-delay: 60ms; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(3) { animation-delay: 120ms; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(4) { animation-delay: 180ms; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(5) { animation-delay: 240ms; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(6) { animation-delay: 300ms; }
.cg-tn.is-opening .cg-tn-stack > :nth-child(n+7) { animation-delay: 360ms; }

/* ---------- 찾기 ---------- */
.cg-tn .cg-tn-tools { display: flex; align-items: center; gap: 8px; padding: 14px 18px 10px 20px; }
.cg-tn .cg-tn-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  background: var(--cg-surface);
  border: 1.5px solid var(--cg-line);
  border-radius: 13px;
  color: var(--cg-ink-3);
  cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.cg-tn .cg-tn-search:hover { border-color: var(--cg-ink-4); }
.cg-tn .cg-tn-search:focus-within { border-color: var(--cg-blue); box-shadow: 0 0 0 4px rgba(46, 91, 255, .12); color: var(--cg-blue); }
.cg-tn .cg-tn-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 14.5px; font-weight: 600; color: var(--cg-ink); }
.cg-tn .cg-tn-search input:focus-visible { outline: none; }
.cg-tn .cg-tn-search input::placeholder { color: var(--cg-ink-4); font-weight: 500; }
.cg-tn .cg-tn-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.cg-tn .cg-tn-refresh {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--cg-line);
  border-radius: 13px;
  color: var(--cg-ink-2);
  transition: border-color .2s;
}
.cg-tn .cg-tn-refresh:hover { border-color: var(--cg-ink-4); }
.cg-tn .cg-tn-refresh.is-spinning .cg-ic { animation: cg-spin .7s linear; }

/* ---------- 목록 ---------- */
.cg-tn .cg-tn-list-wrap { position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 12px 14px; }
.cg-tn.is-loading .cg-tn-list-wrap { opacity: .55; transition: opacity .2s; }
.cg-tn .cg-tn-list { list-style: none; padding: 0; }
.cg-tn .cg-tn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 10px 10px 10px;
  border-radius: 16px;
  transition: background .15s;
}
.cg-tn .cg-tn-row + .cg-tn-row { margin-top: 2px; }
.cg-tn .cg-tn-row:hover { background: var(--cg-surface-2); }
.cg-tn .cg-tn-row.is-me { margin-bottom: 8px; background: var(--cg-paper); }
.cg-tn .cg-tn-row.is-new { animation: cg-rise .35s var(--cg-ease) both; }
.cg-tn .cg-tn-ava {
  --h: var(--cg-blue);
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--h);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}
.cg-tn .cg-tn-ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.cg-tn .cg-tn-ava::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cg-green);
  border: 2.5px solid var(--cg-surface);
}
.cg-tn .cg-tn-row.is-me .cg-tn-ava::after { border-color: var(--cg-paper); }
.cg-tn .cg-tn-who { flex: 1; min-width: 0; }
.cg-tn .cg-tn-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.cg-tn .cg-tn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 800; }
.cg-tn .cg-tn-tag { flex: none; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--cg-line); font-size: 11.5px; font-weight: 700; color: var(--cg-ink-3); }
.cg-tn .cg-tn-tag.is-me { background: var(--cg-ink); border-color: var(--cg-ink); color: var(--cg-yellow); }
.cg-tn .cg-tn-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; font-size: 12.5px; color: var(--cg-ink-3); }
.cg-tn .cg-tn-sub b { font-weight: 700; color: var(--cg-ink-2); }
.cg-tn .cg-tn-got { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--cg-ink-2); }
.cg-tn .cg-tn-got .cg-ic { color: var(--cg-heart); }

/* 응원 버튼 */
.cg-tn .cg-tn-cheer {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px 0 12px;
  border: 1.5px solid var(--cg-heart-100);
  border-radius: 999px;
  background: var(--cg-surface);
  font-size: 13.5px;
  font-weight: 800;
  color: var(--cg-heart-600);
  white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
}
.cg-tn .cg-tn-cheer:hover:not(:disabled) { background: var(--cg-heart-50); border-color: var(--cg-heart); }
.cg-tn .cg-tn-cheer:active:not(:disabled) { transform: scale(.96); }
.cg-tn .cg-tn-cheer .i-fill { display: none; }
.cg-tn .cg-tn-cheer.is-sent { border-color: transparent; background: var(--cg-heart-50); color: var(--cg-heart-600); cursor: default; }
.cg-tn .cg-tn-cheer.is-sent .i-line { display: none; }
.cg-tn .cg-tn-cheer.is-sent .i-fill { display: block; }
.cg-tn .cg-tn-cheer.is-busy { color: var(--cg-ink-4); border-color: var(--cg-line); cursor: progress; }
.cg-tn .cg-tn-cheer.just-sent .i-fill { animation: cg-tn-beat .6s var(--cg-ease-spring); }
.cg-tn .cg-tn-burst { position: absolute; left: 22px; top: 50%; width: 0; height: 0; pointer-events: none; }
.cg-tn .cg-tn-burst i {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  color: var(--cg-heart);
  animation: cg-tn-fly .75s var(--cg-ease) forwards;
}
.cg-tn .cg-tn-burst i svg { width: 10px; height: 10px; display: block; }

/* 빈 상태 */
.cg-tn .cg-tn-empty { display: grid; justify-items: center; gap: 6px; padding: 34px 20px 20px; text-align: center; }
.cg-tn .cg-tn-empty svg { margin-bottom: 8px; }
.cg-tn .cg-tn-empty strong { font-size: 16.5px; font-weight: 800; }
.cg-tn .cg-tn-empty p { max-width: 320px; font-size: 13.5px; line-height: 1.6; color: var(--cg-ink-3); }
.cg-tn .cg-tn-empty button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  margin-top: 10px;
  padding: 0 14px;
  border: 1px solid var(--cg-line);
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 700;
}
.cg-tn .cg-tn-empty button:hover { border-color: var(--cg-ink-4); }
.cg-tn .cg-tn-empty .cg-ic { color: var(--cg-ink-3); }

/* ---------- 바닥 ---------- */
.cg-tn .cg-tn-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px 14px 22px;
  background: var(--cg-surface);
  border-top: 1px solid var(--cg-line);
}
.cg-tn .cg-tn-rule-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--cg-heart-50);
  color: var(--cg-heart);
}
.cg-tn .cg-tn-rule { flex: 1; min-width: 0; font-size: 12.5px; color: var(--cg-ink-3); }
.cg-tn .cg-tn-rule strong { display: block; font-size: 13.5px; font-weight: 800; color: var(--cg-ink); }
.cg-tn .cg-tn-sent { flex: none; text-align: right; font-size: 12px; color: var(--cg-ink-3); }
.cg-tn .cg-tn-sent b { display: block; font-size: 20px; line-height: 1.1; font-weight: 800; color: var(--cg-ink); }

/* 알림 */
.cg-tn .cg-tn-toasts { position: fixed; left: 50%; bottom: 28px; z-index: 1300; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.cg-tn .cg-tn-toast {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--cg-ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--cg-shadow-float);
  animation: cg-toast-in .3s var(--cg-ease) both;
  transition: opacity .25s, transform .25s;
}
.cg-tn .cg-tn-toast.is-error { background: #8A1F26; }
.cg-tn .cg-tn-toast.is-out { opacity: 0; transform: translateY(8px); }

/* 열기·닫기 */
.cg-tn.is-opening .cg-tn-backdrop { animation: cg-fade-in .3s ease both; }
.cg-tn.is-opening .cg-tn-sheet { animation: cg-tn-in .5s var(--cg-ease) both; }
.cg-tn.is-closing .cg-tn-backdrop { animation: cg-tn-fade-out .22s ease both; }
.cg-tn.is-closing .cg-tn-sheet { animation: cg-tn-out .22s ease both; }
@keyframes cg-tn-in { from { opacity: 0; transform: translateY(22px) scale(.985) } to { opacity: 1; transform: none } }
@keyframes cg-tn-out { to { opacity: 0; transform: translateY(12px) scale(.99) } }
@keyframes cg-tn-fade-out { to { opacity: 0 } }
@keyframes cg-tn-beat { 0% { transform: scale(1) } 30% { transform: scale(1.45) } 60% { transform: scale(.9) } 100% { transform: scale(1) } }
@keyframes cg-tn-fly {
  0% { opacity: 0; transform: translate(0, 0) scale(.4) rotate(0deg) }
  20% { opacity: 1 }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(1.1) rotate(var(--r)) }
}

@media (max-width: 640px) {
  .cg-tn { padding: 0; align-items: end; }
  .cg-tn .cg-tn-sheet { width: 100%; height: min(92vh, 100%); border-radius: 24px 24px 0 0; }
  .cg-tn .cg-tn-head { padding: 20px 16px 18px 18px; }
  .cg-tn .cg-tn-title { font-size: 21px; }
  .cg-tn .cg-tn-crowd { flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 14px; }
  .cg-tn .cg-tn-tools { padding: 12px 12px 8px 14px; }
  .cg-tn .cg-tn-list-wrap { padding: 4px 6px 12px; }
  .cg-tn .cg-tn-cheer { padding: 0 12px 0 10px; }
  .cg-tn .cg-tn-cheer .cg-tn-cheer-label { display: none; }
  .cg-tn .cg-tn-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .cg-tn *, .cg-tn *::before, .cg-tn *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Native modal top layer keeps focus on the sheet and allows COGO profiles above it. */
dialog.cg-tn[open] { box-sizing: border-box; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; border: 0; border-radius: 0; background: transparent; overflow: hidden; }
dialog.cg-tn::backdrop { background: transparent; }
.cg-tn .cg-tn-search [data-act=clear] { flex: none; color: var(--cg-ink-3); background: transparent; border: 0; padding: 4px; font-size: 12px; }
.cg-tn button.cg-tn-name { color: var(--cg-ink); background: none; padding: 0; border: 0; cursor: pointer; }
.cg-tn button.cg-tn-name:hover { text-decoration: underline; }
.cg-tn .cg-tn-more-btn { display: block; margin: 10px auto 0; padding: 9px 16px; border: 1px solid var(--cg-line); border-radius: 12px; background: var(--cg-surface); color: var(--cg-ink); }
.cg-tn .cg-tn-ava.is-layered { background: var(--cg-paper); }
.cg-tn .cg-tn-ava .face285 { position: relative; display: block; overflow: hidden; border-radius: 50%; width: 100% !important; height: 100% !important; min-width: 0 !important; }
.cg-tn .cg-tn-ava .face285 > .cogo-avatar { position: absolute !important; left: 50% !important; top: -6px !important; width: 100px !important; height: 100px !important; transform: translateX(-50%) !important; }
.cg-tn .cg-tn-ava .cogo-avatar img { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; max-width: none !important; border-radius: 0; object-fit: contain !important; }
html body dialog.cg-tn[open] { width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; box-shadow: none !important; }
html body dialog.cg-tn::backdrop { background: transparent !important; backdrop-filter: none !important; }
html.cogo-app27 body dialog.cg-tn button.cg-tn-name:not([disabled]),
html.cogo-app27 body dialog.cg-tn [data-act=clear]:not([disabled]) { min-width: 0 !important; min-height: 0 !important; }
html.cogo-app27 body dialog.cg-tn .cg-tn-search input { padding: 0; min-height: 0; border-radius: 0; }
html.cogo-app27 body dialog.cg-tn #cgTnTitle { font-weight: 800; line-height: 1.25; }
dialog.cg-tn:not([open]) { display: none; }

dialog.cg-tn #cgTnTitle { font-weight: 800 !important; line-height: 1.25 !important; }
