/* TT 도우미 (assets/chatbot.js): floating chat button and panel, added to public pages by server.mjs.
 * Colours come only from the site palette variables, so the black theme (base.css) restyles it without generated rules. */
/* Filled buttons use the darker fill tones that base.css defines for the black theme (white labels stay AA there). */
.ttc-launcher, .ttc-panel { --ttc-fill: var(--accent-fill, var(--accent)); --ttc-live-fill: var(--live-fill, var(--live)); }
.ttc-launcher { position: fixed; right: 24px; bottom: 24px; z-index: 88; display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 18px 0 15px; border: 0; border-radius: 999px; background: var(--ttc-fill); color: var(--accent-ink); font: inherit; font-size: 14px; font-weight: 800; letter-spacing: -0.01em; box-shadow: var(--shadow); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.ttc-launcher:hover { transform: translateY(-2px); }
.ttc-launcher:focus-visible, .ttc-panel :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ttc-launcher svg { width: 22px; height: 22px; flex: none; }
.ttc-launcher[aria-expanded="true"] { display: none; }
/* The board keeps its own round buttons on the right, so the chat moves to the left there. */
body:has(.community-floating) .ttc-launcher, body:has(.community-floating) .ttc-panel { right: auto; left: 24px; }
body:has(.sig-audio-dock:not([hidden])) .ttc-launcher { bottom: 96px; }

.ttc-panel { position: fixed; right: 24px; bottom: 24px; z-index: 89; display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 48px)); overflow: hidden; background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: var(--shadow); }
.ttc-panel[hidden] { display: none; }
.ttc-head { display: flex; align-items: center; gap: 10px; padding: 13px 10px 12px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.ttc-head-logo { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface); padding: 4px; object-fit: contain; }
.ttc-head-text { flex: 1; min-width: 0; }
.ttc-head h2 { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.3; color: var(--fg); }
.ttc-head p { margin: 1px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.ttc-icon-btn { display: grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.ttc-icon-btn:hover { background: var(--line); color: var(--fg); }
.ttc-icon-btn svg { width: 18px; height: 18px; }

.ttc-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding: 16px 14px 12px; }
.ttc-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 90%; }
.ttc-msg.user { align-self: flex-end; align-items: flex-end; max-width: 84%; }
.ttc-bubble { margin: 0; padding: 10px 13px; border-radius: 16px 16px 16px 6px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--fg); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; word-break: keep-all; }
.ttc-msg.user .ttc-bubble { border-radius: 16px 16px 6px 16px; background: var(--ttc-fill); border-color: transparent; color: var(--accent-ink); }
.ttc-msg.error .ttc-bubble { border-color: var(--line-strong); color: var(--muted); }
.ttc-source { margin-top: 4px; padding-left: 4px; font-size: 11px; color: var(--faint); }

.ttc-links, .ttc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ttc-link, .ttc-chip-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--accent-strong); font: inherit; font-size: 13px; font-weight: 700; line-height: 1.3; text-decoration: none; cursor: pointer; }
.ttc-link:hover, .ttc-chip-btn:hover { background: var(--accent-soft); }
.ttc-chip-btn:disabled { opacity: .55; cursor: default; }

.ttc-cards { display: grid; gap: 8px; width: 100%; margin-top: 8px; }
.ttc-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ttc-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); }
.ttc-avatar-empty { display: grid; place-items: center; color: var(--accent-strong); font-weight: 800; font-size: 18px; }
.ttc-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ttc-card-title strong { font-size: 15px; color: var(--fg); }
.ttc-role { padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 800; }
.ttc-live { padding: 2px 7px; border-radius: 999px; background: var(--ttc-live-fill); color: var(--accent-ink); font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.ttc-card-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.ttc-card-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ttc-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--fg); font: inherit; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; }
.ttc-chip:hover { background: var(--accent-soft); color: var(--accent-strong); }
.ttc-chip.primary { border-color: transparent; background: var(--accent-soft); color: var(--accent-strong); }
.ttc-chip.live { border-color: transparent; background: var(--live-soft); color: var(--live); }
.ttc-thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.ttc-thumbs[hidden] { display: none; }
.ttc-thumbs a { flex: none; display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-soft); }
.ttc-thumbs img { display: block; width: auto; height: 120px; max-width: 220px; object-fit: contain; }

.ttc-typing .ttc-bubble { display: inline-flex; gap: 5px; align-items: center; min-height: 42px; }
.ttc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: ttc-bounce 1.1s ease-in-out infinite; }
.ttc-typing i:nth-child(2) { animation-delay: .15s; }
.ttc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ttc-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }

.ttc-suggest { display: grid; gap: 2px; max-height: 176px; overflow-y: auto; overscroll-behavior: contain; padding: 6px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.ttc-suggest[hidden] { display: none; }
.ttc-suggest-title { padding: 2px 8px 4px; font-size: 11px; font-weight: 800; color: var(--faint); }
.ttc-suggest-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--fg); font: inherit; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.ttc-suggest-item:hover, .ttc-suggest-item:focus-visible { background: var(--surface); }
.ttc-suggest-item strong { flex: none; font-weight: 800; }
.ttc-suggest-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }

.ttc-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); }
.ttc-input { flex: 1; min-width: 0; height: 44px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--fg); font: inherit; font-size: 15px; }
.ttc-input::placeholder { color: var(--faint); }
.ttc-input:focus { outline: none; border-color: var(--accent); }
.ttc-send { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 12px; background: var(--ttc-fill); color: var(--accent-ink); cursor: pointer; }
.ttc-send:disabled { opacity: .5; cursor: default; }
.ttc-send svg { width: 20px; height: 20px; }
.ttc-note { margin: 0; padding: 0 14px 9px; background: var(--surface); font-size: 11px; color: var(--faint); line-height: 1.4; }
.ttc-note a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.ttc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 600px) {
  .ttc-launcher { right: 16px; bottom: 16px; width: 54px; height: 54px; padding: 0; justify-content: center; }
  .ttc-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body:has(.community-floating) .ttc-launcher { left: 16px; }
  body:has(.sig-audio-dock:not([hidden])) .ttc-launcher { bottom: 128px; }
  .ttc-panel, body:has(.community-floating) .ttc-panel { inset: auto 0 0 0; width: 100%; height: min(88dvh, 720px); border-radius: 20px 20px 0 0; border-bottom: 0; }
  .ttc-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ttc-launcher { transition: none; }
  .ttc-launcher:hover { transform: none; }
  .ttc-typing i { animation: none; opacity: .7; }
}
@media print { .ttc-launcher, .ttc-panel { display: none !important; } }
