#site-chat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 10000; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#site-chat-toggle {
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(99,102,241,.4);
    transition: transform .2s, box-shadow .2s;
}
#site-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(99,102,241,.5); }

#site-chat-panel {
    position: absolute; bottom: 70px; right: 0;
    width: 380px;
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: all .3s ease;
}
@media (max-width: 480px) {
    #site-chat-panel:not(.sc-fullscreen) { width: calc(100vw - 32px); right: -4px; }
}

/* 全画面モード */
#site-chat-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 9999; backdrop-filter: blur(2px);
}
#site-chat-panel.sc-fullscreen {
    position: fixed;
    inset: 20px;
    bottom: 20px; right: 20px;
    width: auto; max-height: none;
    border-radius: 16px;
    z-index: 10001;
    box-shadow: 0 16px 64px rgba(0,0,0,.3);
}
#site-chat-panel.sc-fullscreen #site-chat-messages {
    max-height: none; min-height: 0;
}

#site-chat-header {
    padding: 12px 16px; background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; font-weight: bold; font-size: .95rem;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
#site-chat-header button {
    background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer;
    padding: 4px; border-radius: 4px;
}
#site-chat-header button:hover { color: white; background: rgba(255,255,255,.15); }

#site-chat-messages {
    flex: 1; overflow-y: auto; padding: 12px;
    min-height: 200px; max-height: calc(100vh - 260px);
    display: flex; flex-direction: column; gap: 10px;
}

.sc-msg { display: flex; gap: 8px; align-items: flex-start; }
.sc-msg.sc-user { flex-direction: row-reverse; }
.sc-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; font-weight: bold; flex-shrink: 0;
}
.sc-msg.sc-user .sc-avatar { background: #6366f1; color: white; }
.sc-msg.sc-assistant .sc-avatar { background: #e5e7eb; color: #374151; }
.sc-bubble {
    max-width: 80%; padding: 8px 12px; border-radius: 12px;
    font-size: .85rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.sc-msg.sc-user .sc-bubble { background: #6366f1; color: white; border-bottom-right-radius: 4px; }
.sc-msg.sc-assistant .sc-bubble { background: #f3f4f6; color: #1e293b; border-bottom-left-radius: 4px; }
.sc-fullscreen .sc-bubble { max-width: 70%; font-size: .9rem; }

#site-chat-typing {
    display: flex; gap: 8px; padding: 0 12px 8px; align-items: flex-start;
    flex-shrink: 0;
}
.sc-typing-dots { padding: 10px 14px; background: #f3f4f6; border-radius: 12px; border-bottom-left-radius: 4px; }
.sc-typing-dots span {
    display: inline-block; width: 5px; height: 5px; background: #9ca3af;
    border-radius: 50%; animation: sc-dot 1.2s infinite; margin: 0 1px;
}
.sc-typing-dots span:nth-child(2) { animation-delay: .2s; }
.sc-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes sc-dot {
    0%, 80%, 100% { opacity: .3; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

#site-chat-footer {
    display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e5e7eb; background: #fafafa;
    flex-shrink: 0;
}
#site-chat-input {
    flex: 1; resize: none; border: 1px solid #d1d5db; border-radius: 8px;
    padding: 8px 10px; font-size: .85rem; font-family: inherit;
    max-height: 120px; overflow-y: auto;
}
.sc-fullscreen #site-chat-input { font-size: .9rem; }
#site-chat-input:focus { outline: none; border-color: #6366f1; }
#site-chat-send {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    background: #6366f1; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; align-self: flex-end;
}
#site-chat-send:hover { background: #4f46e5; }
#site-chat-send:disabled { background: #a5b4fc; cursor: not-allowed; }

/* 改善実行ボタン */
.sc-improve-btn {
    display: inline-block; margin-top: 8px; padding: 6px 16px;
    background: #059669; color: white; border: none; border-radius: 6px;
    cursor: pointer; font-size: .8rem; font-weight: bold;
}
.sc-improve-btn:hover { background: #047857; }
.sc-improve-btn:disabled { background: #6ee7b7; cursor: not-allowed; }

.sc-task-status {
    margin-top: 8px; padding: 8px 12px; border-radius: 6px;
    font-size: .8rem; line-height: 1.5;
}
.sc-task-status.pending { background: #fef3c7; color: #92400e; }
.sc-task-status.running { background: #dbeafe; color: #1e40af; }
.sc-task-status.completed { background: #d1fae5; color: #065f46; }
.sc-task-status.failed { background: #fee2e2; color: #991b1b; }

.sc-task-status a { color: inherit; font-weight: bold; text-decoration: underline; }

.sc-spinner-sm {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid #93c5fd; border-top-color: #1e40af;
    border-radius: 50%; animation: sc-dot 0.6s linear infinite;
    margin-right: 4px; vertical-align: middle;
}
