/* FRAMEFORM — customer-center chat widget (js/chat.js). Uses the tokens from css/styles.css.
   Bottom-right, above the scene slate HUD (z 46) and the header (z 50); never covers the KO|EN toggle. */

.ffc-fab {
  position: fixed; z-index: 60;
  right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 48px; padding: 0 1.05rem 0 0.9rem;
  background: var(--orange); color: var(--black);
  border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: var(--fs-sm);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: background-color .15s, transform .15s;
}
.ffc-fab:hover { background: var(--orange-hover); }
.ffc-fab:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }
.ffc-fab-icon {
  width: 18px; height: 16px; border: 2px solid currentColor; border-radius: 6px; position: relative; flex: none;
}
.ffc-fab-icon::after {
  content: ''; position: absolute; left: 3px; bottom: -6px; width: 6px; height: 6px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; background: var(--orange); transform: skewY(-35deg);
}
.ffc-dot { position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--white); box-shadow: 0 0 0 2px var(--orange); }
.ffc-open .ffc-fab { transform: scale(0.94); }

/* narrow screens: lift the button above the bottom-left slate line so they never collide */
@media (max-width: 520px) {
  .ffc-fab { bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 2.6rem); padding: 0; width: 52px; justify-content: center; }
  .ffc-fab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

.ffc-panel {
  position: fixed; z-index: 61;
  right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 60px);
  width: min(360px, calc(100vw - 2rem)); height: min(540px, calc(100vh - 7.5rem));
  display: flex; flex-direction: column;
  background: var(--blue-950); color: var(--white);
  border: 1px solid var(--line-strong); border-radius: var(--radius-m);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  font-size: var(--fs-sm); line-height: 1.55;
}
.ffc-panel[hidden] { display: none; }
@media (max-width: 640px) {
  /* full-height sheet */
  .ffc-panel { inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .ffc-open body, html.ffc-open { overflow: hidden; }
}

.ffc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; padding: 0.85rem 0.9rem 0.7rem 1rem; border-bottom: 1px solid var(--line); }
.ffc-title { font-size: var(--fs-base); font-weight: 650; margin: 0; }
.ffc-pill { display: inline-block; margin-top: 0.2rem; font-size: var(--fs-xs); color: var(--silver); }
.ffc-pill::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 0.4rem; background: var(--silver-dim); vertical-align: 1px; }
.ffc-pill-live::before { background: var(--success); }
.ffc-pill-ai::before { background: var(--orange); }
.ffc-head-actions { display: flex; align-items: center; gap: 0.25rem; }
.ffc-text-btn { background: none; border: 0; color: var(--silver); font: inherit; font-size: var(--fs-xs); cursor: pointer; min-height: 40px; padding: 0 0.4rem; text-decoration: underline; text-underline-offset: 3px; }
.ffc-text-btn:hover { color: var(--white); }
.ffc-close { background: none; border: 1px solid var(--line-strong); color: var(--white); width: 40px; height: 40px; border-radius: var(--radius-s); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.ffc-close:hover { border-color: var(--white); }

.ffc-list { list-style: none; margin: 0; padding: 0.9rem 1rem; flex: 1 1 auto; overflow-y: auto; display: grid; align-content: start; gap: 0.6rem; overscroll-behavior: contain; }
.ffc-msg { display: grid; gap: 0.2rem; max-width: 88%; }
.ffc-who { font-size: var(--fs-xs); color: var(--silver-dim); }
.ffc-bubble { margin: 0; padding: 0.55rem 0.75rem; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: keep-all; }
.ffc-me { justify-self: end; }
.ffc-me .ffc-bubble { background: var(--orange); color: var(--black); border-bottom-right-radius: 4px; }
.ffc-ai .ffc-bubble { background: var(--blue-900); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ffc-owner .ffc-bubble { background: var(--blue-800); border: 1px solid rgba(143, 224, 176, 0.45); border-bottom-left-radius: 4px; }
.ffc-owner .ffc-who { color: var(--success); }
.ffc-system { justify-self: center; max-width: 100%; }
.ffc-system .ffc-bubble { background: none; color: var(--silver); font-size: var(--fs-xs); text-align: center; padding: 0.2rem 0.4rem; }
.ffc-typing .ffc-bubble { color: var(--silver); letter-spacing: 0.2em; }
.ffc-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.ffc-me .ffc-link { color: var(--black); }

.ffc-extra:empty { display: none; }
.ffc-offline { margin: 0 1rem 0.6rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s); display: grid; gap: 0.45rem; font-size: var(--fs-xs); color: var(--silver); }
.ffc-contact { width: 100%; min-height: 40px; padding: 0.4rem 0.6rem; background: var(--black); color: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius-s); font: inherit; }
.ffc-agree { display: flex; gap: 0.45rem; align-items: flex-start; cursor: pointer; }
.ffc-agree input { margin-top: 0.2rem; accent-color: var(--orange); width: 16px; height: 16px; flex: none; }
.ffc-err { color: var(--error); margin: 0; }
.ffc-err:empty { display: none; }

.ffc-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1rem 0.6rem; }
.ffc-chip { min-height: 36px; padding: 0.3rem 0.75rem; background: transparent; color: var(--white); border: 1px solid var(--line-strong); border-radius: 999px; font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.ffc-chip:hover { border-color: var(--white); }
.ffc-chip-strong { border-color: var(--orange); color: var(--orange); }

.ffc-form { border-top: 1px solid var(--line); padding: 0.6rem 0.8rem 0.5rem 1rem; display: grid; gap: 0.35rem; }
.ffc-form[hidden] { display: none; }
.ffc-input { width: 100%; resize: none; min-height: 44px; max-height: 120px; padding: 0.6rem 0.7rem; background: var(--black); color: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius-s); font: inherit; line-height: 1.45; }
.ffc-input:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; }
.ffc-form-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.ffc-count { font-size: var(--fs-xs); color: var(--silver-dim); font-variant-numeric: tabular-nums; }
.ffc-send { min-height: 40px; padding: 0 1rem; background: var(--orange); color: var(--black); border: 0; border-radius: var(--radius-s); font: inherit; font-weight: 700; cursor: pointer; }
.ffc-send[disabled] { opacity: 0.55; cursor: progress; }
.ffc-foot { margin: 0; padding: 0 1rem 0.75rem; font-size: 0.72rem; color: var(--silver-dim); line-height: 1.45; }
.ffc-foot a { color: var(--silver); }

@media (prefers-reduced-motion: reduce) { .ffc-fab { transition: none; } }

/* 상담 만족도 + 새 상담 구분선 */
.ffc-rate-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.ffc-rate-row .ffc-chip:disabled { opacity: 0.5; cursor: default; }
.ffc-divider {
  list-style: none; display: flex; align-items: center; gap: 0.6rem; margin: 0.75rem 0;
  font-size: 0.75rem; color: var(--silver, #9aa4b2); letter-spacing: 0.04em;
}
.ffc-divider::before, .ffc-divider::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: 0.35; }

/* 상담사 프로필 (로고) */
.ffc-who { display: inline-flex; align-items: center; gap: 0.4rem; }
.ffc-avatar { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); background: #000; object-fit: cover; flex: none; }

/* 모바일: 말풍선 버튼 왼쪽에 "상담원 연결" 안내 꼬리표 (2026-11-15). 채팅창이 열리면 숨김 */
.ffc-fab-tag { display: none; }
@media (max-width: 520px) {
  .ffc-fab-tag {
    display: block; position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%);
    white-space: nowrap; padding: 0.4rem 0.75rem; border-radius: 999px;
    background: rgba(12, 12, 12, 0.92); color: #fff; border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: var(--fs-xs); font-weight: 700; line-height: 1.2; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); pointer-events: none;
  }
  html.ffc-open .ffc-fab-tag { display: none; }
}
