/* 사이트 공통 미니 AI 상담 — Quiet 톤 유지, 얇은 플로팅만 */
.jc-mini-chat {
  --jc-mc-w: min(360px, calc(100vw - 1.5rem));
  --jc-mc-h: min(420px, calc(100vh - 7rem));
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 45;
  font-family: inherit;
  pointer-events: none;
}

.jc-mini-chat * {
  box-sizing: border-box;
}

.jc-mini-chat__fab,
.jc-mini-chat__panel {
  pointer-events: auto;
}

.jc-mini-chat__fab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  margin-left: auto;
  padding: 0.7rem 1rem;
  border: 1px solid var(--jc-border, #d7dee8);
  border-radius: 999px;
  background: #fff;
  color: var(--jc-text, #1e293b);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.jc-mini-chat__fab:hover {
  border-color: color-mix(in srgb, var(--jc-teal, #2563eb) 45%, var(--jc-border, #d7dee8));
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.jc-mini-chat__fab:focus-visible {
  outline: 2px solid var(--jc-teal, #2563eb);
  outline-offset: 2px;
}

.jc-mini-chat__fab-ico {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--jc-teal, #2563eb) 12%, #fff);
  color: var(--jc-teal, #2563eb);
  font-size: 0.75rem;
  line-height: 1;
}

.jc-mini-chat.is-open .jc-mini-chat__fab {
  display: none;
}

.jc-mini-chat__panel {
  display: none;
  flex-direction: column;
  width: var(--jc-mc-w);
  height: var(--jc-mc-h);
  background: var(--jc-bg-card, #fff);
  border: 1px solid var(--jc-border, #d7dee8);
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}

.jc-mini-chat.is-open .jc-mini-chat__panel {
  display: flex;
}

.jc-mini-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 1px solid var(--jc-border, #e2e8f0);
  background: #f8fafc;
}

.jc-mini-chat__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--jc-text, #1e293b);
}

.jc-mini-chat__sub {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--jc-text-muted, #64748b);
  word-break: keep-all;
}

.jc-mini-chat__close {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin: -0.15rem -0.25rem 0 0;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--jc-text-muted, #64748b);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.jc-mini-chat__close:hover {
  background: #eef2f7;
  color: var(--jc-text, #1e293b);
}

.jc-mini-chat__msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: #fff;
}

.jc-mini-chat__msg {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: keep-all;
}

.jc-mini-chat__msg--bot {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--jc-text, #1e293b);
  border: 1px solid #e2e8f0;
}

.jc-mini-chat__msg--user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--jc-teal, #2563eb) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--jc-teal, #2563eb) 28%, #e2e8f0);
  color: var(--jc-text, #1e293b);
}

.jc-mini-chat__msg--typing,
.jc-mini-chat .assistant-msg--typing {
  opacity: 0.75;
  font-style: italic;
}

/* assistant.js가 넣는 .assistant-msg 를 미니챗 톤에 맞춤 */
.jc-mini-chat .assistant-msg {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: keep-all;
}

.jc-mini-chat .assistant-msg--bot {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--jc-text, #1e293b);
  border: 1px solid #e2e8f0;
}

.jc-mini-chat .assistant-msg--user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--jc-teal, #2563eb) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--jc-teal, #2563eb) 28%, #e2e8f0);
  color: var(--jc-text, #1e293b);
}

.jc-mini-chat__form {
  display: flex;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--jc-border, #e2e8f0);
  background: #f8fafc;
}

.jc-mini-chat__input {
  flex: 1;
  min-width: 0;
  resize: none;
  height: 2.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--jc-border, #d7dee8);
  border-radius: 0.65rem;
  background: #fff;
  color: var(--jc-text, #1e293b);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
}

.jc-mini-chat__input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--jc-teal, #2563eb) 55%, var(--jc-border, #d7dee8));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--jc-teal, #2563eb) 14%, transparent);
}

.jc-mini-chat__send {
  flex: 0 0 auto;
  padding: 0 0.9rem;
  border: none;
  border-radius: 0.65rem;
  background: var(--jc-teal, #2563eb);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.jc-mini-chat__send:hover {
  filter: brightness(1.05);
}

.jc-mini-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.jc-mini-chat__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem 0.65rem;
  border-top: 1px solid transparent;
  background: #f8fafc;
}

.jc-mini-chat__note {
  margin: 0;
  font-size: 0.7rem;
  color: var(--jc-text-muted, #64748b);
  line-height: 1.4;
}

.jc-mini-chat__mcp {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--jc-teal, #2563eb);
  text-decoration: none;
  white-space: nowrap;
}

.jc-mini-chat__mcp:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .jc-mini-chat {
    right: 0.65rem;
    bottom: 0.65rem;
  }

  .jc-mini-chat__fab-label {
    display: none;
  }

  .jc-mini-chat__fab {
    width: 3rem;
    height: 3rem;
    padding: 0;
    justify-content: center;
  }

  .jc-mini-chat__fab-ico {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* 스크롤탑과 겹치지 않게 — 스크롤탑이 보이면 채팅을 조금 올림 */
body:has(.scrolltop.is-visible) .jc-mini-chat {
  bottom: 4.25rem;
}
