﻿.assistant3d {
    --assistant-accent: var(--kieto-accent, #00b5bc);
    --assistant-panel-width: min(460px, calc(100vw - 20px));
    --assistant-panel-height: 560px;
    position: fixed;
    right: 20px;
    bottom: 18px;
    z-index: 1100;
    width: min(980px, calc(100vw - 20px));
    min-height: 180px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.assistant3d.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.assistant3d * {
    box-sizing: border-box;
}

.assistant3d-focus-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    z-index: 1040;
    transition: opacity 0.25s ease;
}

.assistant3d-focus-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.assistant3d-dock {
    position: absolute;
    right: 74px;
    bottom: 0;
    pointer-events: none;
    transition: transform 0.35s ease;
}

.assistant3d.is-panel-open .assistant3d-dock {
    transform: translateX(calc((var(--assistant-panel-width) + 22px) * -1));
}

.assistant3d-bubble {
    position: absolute;
    right: calc(100% - 12px);
    bottom: 112px;
    width: 260px;
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    opacity: 0;
    pointer-events: none;
    transform: translate(-8px, 14px) scale(0.92);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dark .assistant3d-bubble {
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    border-color: rgba(71, 85, 105, 0.74);
}

.assistant3d-bubble::after {
    content: '';
    position: absolute;
    right: -7px;
    bottom: 18px;
    width: 12px;
    height: 12px;
    background: inherit;
    border-top: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    transform: rotate(45deg);
}

.assistant3d-bubble.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, 0) scale(1);
}

.assistant3d.is-panel-open .assistant3d-bubble {
    opacity: 0;
    transform: translate(-8px, 14px) scale(0.92);
    pointer-events: none;
}

.assistant3d-bubble-text {
    font-size: 16px;
    line-height: 1.45;
    font-weight: 400;
    white-space: pre-wrap;
}

.assistant3d-bubble-text .assistant3d-user-name {
    font-weight: 700;
    color: #0f172a;
}

.assistant3d-bubble-text .assistant3d-kieto-name {
    color: var(--assistant-accent);
    font-weight: 700;
}

.assistant3d-toggle {
    pointer-events: auto;
    width: 148px;
    height: 148px;
    margin-left: auto;
    position: relative;
    left: 1.25rem;
    z-index: 3;
    border-radius: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant3d-toggle model-viewer {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent !important;
    --progress-bar-color: transparent;
    transform: scaleX(-1);
}

.assistant3d-toggle-fallback {
    display: none;
}

.assistant3d-toggle.is-model-error model-viewer {
    opacity: 0;
}

.assistant3d-toggle.is-model-error .assistant3d-toggle-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #e5e7eb;
    color: var(--assistant-accent);
    font-size: 36px;
    font-weight: 700;
}

.assistant3d-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    pointer-events: auto;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: none;
    width: var(--assistant-panel-width);
    height: var(--assistant-panel-height);
    font-family: inherit;
    transform-origin: right bottom;
    transform: translate3d(0, 0, 0);
    transition: width 0.35s ease, height 0.35s ease, transform 0.35s ease, box-shadow 0.25s ease;
}

.assistant3d.is-expanded {
    --assistant-panel-width: min(552px, calc(100vw - 20px));
    --assistant-panel-height: 672px;
}

.dark .assistant3d-panel {
    background: #0f172a;
    border-color: rgba(71, 85, 105, 0.75);
}

.assistant3d-panel.is-open {
    display: block;
}

.assistant3d.is-expanded .assistant3d-panel {
    transform: translate3d(-6px, -4px, 0);
}

.assistant3d-head {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.assistant3d-head-main {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.assistant3d-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.assistant3d-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 24px;
    font-weight: 700;
    color: #2d3436;
    line-height: 1;
}

.assistant3d-title::before {
    content: 'K';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.12);
    color: var(--assistant-accent);
    font-size: 12px;
    font-weight: 700;
}

.dark .assistant3d-title {
    color: #e2e8f0;
}

.assistant3d-status {
    font-size: 14px;
    font-weight: 600;
    color: var(--assistant-accent);
}

.assistant3d-close {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 23px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
}

.assistant3d-expand {
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dark .assistant3d-close {
    color: #cbd5e1;
    border-color: rgba(100, 116, 139, 0.85);
}

.assistant3d-messages {
    height: calc(var(--assistant-panel-height) - 142px);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant3d-msg {
    max-width: 84%;
    padding: 9px 12px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 400;
    color: #374151;
    white-space: pre-wrap;
}

.dark .assistant3d-msg {
    color: #e2e8f0;
}

.assistant3d-msg.user {
    align-self: flex-end;
    background: var(--assistant-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.assistant3d-msg.bot {
    align-self: flex-start;
    background: #f3f4f6;
    border-bottom-left-radius: 4px;
}

.assistant3d-msg .ai-message-content {
    line-height: 1.16;
    font-weight: 400;
}

.assistant3d-msg .ai-message-content p {
    margin: 0;
}

.assistant3d-msg .ai-message-content p:last-child {
    margin-bottom: 0;
}

.assistant3d-msg .ai-message-content p + p {
    margin-top: 1px;
}

.assistant3d-msg .ai-message-content strong,
.assistant3d-msg .ai-message-content b {
    font-weight: 500;
    color: #111827;
}

.assistant3d-msg .ai-message-content .assistant3d-user-name {
    font-weight: 700;
    color: #111827;
}

.assistant3d-msg .ai-message-content .assistant3d-kieto-name {
    font-weight: 700;
    color: var(--assistant-accent);
}

.assistant3d-msg .ai-message-content ul {
    margin: 0 0 0 13px;
    padding: 0;
}

.assistant3d-msg .ai-message-content ol {
    margin: 0 0 0 15px;
    padding: 0;
}

.assistant3d-msg .ai-message-content li {
    margin-bottom: 0;
    line-height: 1.14;
}

.assistant3d-msg .ai-message-content li p {
    margin: 0;
}

.assistant3d-msg .ai-message-content h1,
.assistant3d-msg .ai-message-content h2,
.assistant3d-msg .ai-message-content h3,
.assistant3d-msg .ai-message-content h4,
.assistant3d-msg .ai-message-content h5,
.assistant3d-msg .ai-message-content h6 {
    margin: 2px 0 1px;
    line-height: 1.14;
}

.assistant3d-msg .ai-message-content h1 {
    font-size: 1.12rem;
}

.assistant3d-msg .ai-message-content h2 {
    font-size: 1.04rem;
}

.assistant3d-msg .ai-message-content h3,
.assistant3d-msg .ai-message-content h4,
.assistant3d-msg .ai-message-content h5,
.assistant3d-msg .ai-message-content h6 {
    font-size: 0.98rem;
}

.assistant3d-msg .ai-message-content li::marker {
    color: var(--assistant-accent);
}

.assistant3d-msg .ai-message-content a[href*="project-single.php?id="] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--assistant-accent, #00b5bc);
    color: var(--assistant-accent, #00b5bc);
    font-weight: 600;
    text-decoration: none;
    background: rgba(0, 181, 188, 0.08);
}

.assistant3d-msg .ai-message-content .assistant3d-project-links {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.assistant3d-msg .ai-message-content .assistant3d-project-links strong {
    font-weight: 700;
}

.assistant3d-msg .ai-message-content .assistant3d-project-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.assistant3d-msg .ai-message-content .assistant3d-project-link-row a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--assistant-accent, #00b5bc);
    color: var(--assistant-accent, #00b5bc);
    font-weight: 600;
    text-decoration: none;
    background: rgba(0, 181, 188, 0.08);
}

.assistant3d-msg .ai-message-content .assistant3d-inline-project-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--assistant-accent, #00b5bc);
    color: var(--assistant-accent, #00b5bc);
    font-weight: 600;
    text-decoration: none;
    background: rgba(0, 181, 188, 0.08);
    vertical-align: middle;
}

.assistant3d-msg .ai-message-content .assistant3d-inline-project-link:hover {
    background: var(--assistant-accent, #00b5bc);
    color: #ffffff;
}

.assistant3d-msg .ai-message-content .assistant3d-project-link-row a:hover {
    background: var(--assistant-accent, #00b5bc);
    color: #ffffff;
}

.assistant3d-msg .ai-message-content a[href*="project-single.php?id="]:hover {
    background: var(--assistant-accent, #00b5bc);
    color: #ffffff;
}

.dark .assistant3d-msg .ai-message-content a[href*="project-single.php?id="] {
    border-color: var(--assistant-accent, #00b5bc);
    color: #67e8f9;
    background: rgba(0, 181, 188, 0.16);
}

.dark .assistant3d-msg .ai-message-content .assistant3d-project-link-row a {
    border-color: var(--assistant-accent, #00b5bc);
    color: #67e8f9;
    background: rgba(0, 181, 188, 0.16);
}

.dark .assistant3d-msg .ai-message-content .assistant3d-inline-project-link {
    border-color: var(--assistant-accent, #00b5bc);
    color: #67e8f9;
    background: rgba(0, 181, 188, 0.16);
}

.dark .assistant3d-msg.bot {
    background: #334155;
}

.dark .assistant3d-msg .ai-message-content strong,
.dark .assistant3d-msg .ai-message-content b {
    color: #f8fafc;
}

.dark .assistant3d-msg .ai-message-content .assistant3d-user-name {
    color: #f8fafc;
}

.assistant3d-msg.user .ai-message-content .assistant3d-user-name,
.assistant3d-msg.user .ai-message-content .assistant3d-kieto-name {
    color: #ffffff;
}

.assistant3d-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.assistant3d-typing span {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.3;
    animation: assistantTyping 0.9s infinite;
}

.assistant3d-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.assistant3d-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes assistantTyping {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    40% {
        transform: translateY(-3px);
        opacity: 0.85;
    }
}

.assistant3d-form {
    border-top: 1px solid #e5e7eb;
    padding: 14px 16px 16px;
    left: 1.25rem;
    width: calc(100% - 1.25rem);
    position: relative;
}

.assistant3d-input {
    width: 100%;
    min-height: 52px;
    border-radius: 99px;
    border: 1px solid #e5e7eb;
    padding: 0 68px 0 18px;
    background: #f9fafb;
    color: #0f172a;
    font-size: 16px;
    font-weight: 400;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.assistant3d-input:focus {
    border-color: rgba(6, 182, 212, 0.55);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

.dark .assistant3d-input {
    background: rgba(15, 23, 42, 0.75);
    color: #e2e8f0;
    border-color: rgba(71, 85, 105, 0.82);
}

.assistant3d-send {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    border-radius: 999px;
    background: var(--assistant-accent);
    color: transparent;
    font-size: 0;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.assistant3d-send i {
    color: #ffffff;
    font-size: 17px;
    line-height: 1;
    transform: translate(-1px, -1px) rotate(8deg);
}

.assistant3d-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.assistant3d-name-gate {
    --assistant-accent: var(--kieto-accent, #00b5bc);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1200;
    width: min(360px, calc(100vw - 24px));
    transform: translate(0, 20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s ease, opacity 0.28s ease;
}

.assistant3d-name-gate.is-visible {
    transform: translate(0, 0);
    opacity: 1;
    pointer-events: auto;
}

.assistant3d-name-card {
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    padding: 12px;
}

.assistant3d-name-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #2d3436;
}

.assistant3d-name-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px;
    align-items: center;
}

.assistant3d-name-input {
    min-height: 44px;
    border-radius: 99px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 0 16px;
    color: #0f172a;
    font-size: 15px;
    font-weight: 400;
    outline: none;
}

.assistant3d-name-input:focus {
    border-color: rgba(6, 182, 212, 0.55);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

.assistant3d-name-submit i {
    color: #ffffff !important;
    font-size: 16px;
    line-height: 1;
    transform: translate(-1px, -1px) rotate(8deg);
}

.assistant3d-name-submit {
    width: 46px;
    height: 46px;
    min-width: 46px;
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    background: var(--assistant-accent, #00b5bc) !important;
    border: 1px solid var(--assistant-accent, #00b5bc) !important;
    color: #ffffff;
    padding: 0;
    font-size: 0;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.28);
    visibility: visible;
    opacity: 1;
    position: relative;
    cursor: pointer;
}

.assistant3d-name-submit:hover,
.assistant3d-name-submit:focus-visible,
.assistant3d-name-submit:active {
    background: #009ea5 !important;
    border-color: #009ea5 !important;
    box-shadow: 0 8px 18px rgba(6, 182, 212, 0.4);
}

.assistant3d-name-submit::before,
.assistant3d-name-submit::after {
    content: none;
}

@media (max-width: 640px) {
    .assistant3d {
        right: 10px;
        bottom: 10px;
        --assistant-panel-width: calc(100vw - 20px);
        width: calc(100vw - 20px);
        min-height: 120px;
    }

    .assistant3d-dock {
        right: 0;
    }

    .assistant3d.is-panel-open .assistant3d-dock {
        transform: translateX(0);
    }

    .assistant3d-bubble {
        width: min(220px, 62vw);
        right: calc(100% - 14px);
        bottom: 86px;
    }

    .assistant3d-toggle {
        width: 108px;
        height: 108px;
    }

    .assistant3d-panel {
        width: calc(100vw - 20px);
        height: min(76vh, 680px);
    }

    .assistant3d-name-gate {
        width: calc(100vw - 20px);
        left: 10px !important;
        top: auto !important;
        bottom: 12px;
    }

    .assistant3d-messages {
        max-height: 44vh;
    }
}
