/* チャット全体のベース文字サイズ（テーマより一段小さめ） */
.myaichat-widget {
    font-size: 0.8125rem;
    line-height: 1.45;
}

/* 埋め込み（ショートコード） */
.myaichat-widget:not(.myaichat-widget--floating) {
    max-width: 640px;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
}

.myaichat-log {
    height: 420px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    background: #f9fafb;
}

.myaichat-log[aria-busy="true"] {
    opacity: 0.92;
}

.myaichat-row {
    margin: 6px 0;
    padding: 6px 8px;
    border-radius: 6px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8125rem;
}

.myaichat-row-user {
    background: #e0f2fe;
}

.myaichat-row-bot {
    background: #ecfccb;
}

.myaichat-row-pending {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    color: #334155;
}

.myaichat-row-error {
    background: #fee2e2;
    color: #991b1b;
}

.myaichat-spinner {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    border: 2px solid #cbd5e1;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: myaichat-spin 0.65s linear infinite;
}

@keyframes myaichat-spin {
    to {
        transform: rotate(360deg);
    }
}

.myaichat-pending-label {
    font-size: 0.8125rem;
}

.myaichat-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.myaichat-input {
    flex: 1;
    padding: 6px 8px;
    box-sizing: border-box;
    font-size: 0.8125rem;
}

.myaichat-form button[type="submit"] {
    padding: 6px 12px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.8125rem;
}

.myaichat-form button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* フローティング（Phase 3） */
.myaichat-float {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99999;
    font-family: inherit;
}

.myaichat-float-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid #c7d2fe;
    background: #4f46e5;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
    line-height: 1;
}

.myaichat-float-toggle:hover,
.myaichat-float-toggle:focus-visible {
    background: #4338ca;
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
}

.myaichat-float-panel {
    position: absolute;
    right: 0;
    bottom: 68px;
    width: min(92vw, 380px);
    max-height: min(70vh, 520px);
    display: flex;
    flex-direction: column;
    border: 1px solid #d0d7de;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.myaichat-float-panel[hidden] {
    display: none !important;
}

.myaichat-float--open .myaichat-float-toggle {
    opacity: 0.88;
}

.myaichat-float-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 0.8125rem;
}

.myaichat-float-close {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 4px;
}

.myaichat-float-close:hover,
.myaichat-float-close:focus-visible {
    background: #e2e8f0;
    color: #0f172a;
    outline: none;
}

.myaichat-widget--floating {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px 10px 10px;
    border: none;
    max-width: none;
}

.myaichat-widget--floating .myaichat-log {
    flex: 1;
    min-height: 260px;
    height: auto;
    max-height: 58vh;
}

@media (max-width: 480px) {
    .myaichat-float {
        right: 12px;
        bottom: 12px;
    }

    .myaichat-float-panel {
        width: calc(100vw - 24px);
        bottom: 64px;
        max-height: 75vh;
    }

    .myaichat-float--open .myaichat-float-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        width: auto;
        max-height: var(--myaichat-panel-max-height, 75vh);
        bottom: var(--myaichat-panel-bottom, 12px);
    }

    .myaichat-widget--floating .myaichat-log {
        max-height: none;
        min-height: 120px;
        flex: 1 1 auto;
    }

    /* iOS Safari: 16px未満だと入力フォーカス時にページが自動ズームする */
    .myaichat-input {
        font-size: 16px;
        line-height: 1.4;
        min-height: 44px;
        padding: 10px 12px;
    }

    .myaichat-form button[type="submit"] {
        font-size: 16px;
        min-height: 44px;
        padding: 10px 14px;
    }
}
