.tcf-root {
  --tcf-gold: #e8c766;
  --tcf-gold2: #c9a227;
  --tcf-bg: #191718;
  --tcf-panel: #171a34;
  --tcf-ink: #f2ecdd;
  --tcf-muted: #9aa3c7;
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 12000;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.tcf-root.is-hidden {
  display: none;
}

.tcf-top {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(232, 199, 102, 0.45);
  border-radius: 50%;
  background: linear-gradient(145deg, #1c2140, #191718);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  color: var(--tcf-gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.18s ease;
}

.tcf-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tcf-top:hover {
  border-color: var(--tcf-gold);
  color: #fff7df;
}

.tcf-fab {
  width: 58px;
  height: 58px;
  border: 2px solid rgba(232, 199, 102, 0.55);
  border-radius: 50%;
  background: linear-gradient(145deg, #1c2140, #191718);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(20, 18, 20, 0.65);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tcf-fab:hover {
  transform: scale(1.05);
  border-color: var(--tcf-gold);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(201, 162, 39, 0.25);
}

.tcf-fab img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  pointer-events: none;
}

.tcf-fab[aria-expanded='true'] {
  transform: scale(0.96);
  opacity: 0.92;
}

.tcf-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100dvh - 120px));
  background: rgba(23, 26, 52, 0.96);
  border: 2px solid var(--tcf-gold2);
  border-radius: 20px;
  box-shadow: 0 0 0 5px rgba(20, 18, 20, 0.55), 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: right bottom;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
  backdrop-filter: blur(12px);
}

.tcf-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.tcf-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.28);
  background: linear-gradient(180deg, rgba(28, 33, 64, 0.95), rgba(23, 26, 52, 0.85));
}

.tcf-head-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(232, 199, 102, 0.45);
  object-fit: cover;
  background: #0f0e0f;
}

.tcf-head-meta {
  flex: 1;
  min-width: 0;
}

.tcf-head-meta strong {
  display: block;
  font-size: 14px;
  color: var(--tcf-gold);
  letter-spacing: 0.02em;
}

.tcf-head-meta span {
  display: block;
  font-size: 11px;
  color: var(--tcf-muted);
  margin-top: 2px;
}

.tcf-head-actions {
  display: flex;
  gap: 4px;
}

.tcf-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--tcf-ink);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.tcf-icon-btn:hover {
  background: rgba(232, 199, 102, 0.16);
  color: var(--tcf-gold);
}

.tcf-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.tcf-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.62;
  word-break: keep-all;
}

.tcf-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  color: var(--tcf-ink);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.tcf-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f3d58a, #d5a64d);
  color: #1c1408;
  border-bottom-right-radius: 4px;
}

.tcf-msg.typing {
  color: var(--tcf-muted);
  font-size: 12px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
}

.tcf-compose {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  background: rgba(20, 18, 20, 0.72);
}

.tcf-compose form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.tcf-compose textarea {
  flex: 1;
  min-height: 42px;
  max-height: 96px;
  resize: none;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 14px;
  background: rgba(11, 13, 34, 0.9);
  color: var(--tcf-ink);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}

.tcf-compose textarea:focus {
  border-color: var(--tcf-gold);
}

.tcf-compose textarea:disabled {
  opacity: 0.55;
}

.tcf-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #f3d58a, #c9a227);
  color: #1c1408;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.tcf-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tcf-footnote {
  margin: 8px 2px 0;
  font-size: 10.5px;
  color: var(--tcf-muted);
  text-align: center;
}

.tcf-footnote a {
  color: var(--tcf-gold);
  text-decoration: none;
}

.tcf-footnote a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .tcf-panel {
    right: -4px;
    width: min(360px, calc(100vw - 24px));
    height: min(68dvh, 520px);
  }
}

body:has(.mypage-page-v2) .tcf-root {
  right: auto;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
