/* ── Kellian AI Companion — Frontend Styles ── */

.ku-wrap {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: #050810;
    border-radius: 24px;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #e0d8ff;
    padding-bottom: 32px;
}

/* Stars */
.ku-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.ku-star {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    animation: ku-twinkle var(--dur) ease-in-out infinite alternate;
    opacity: var(--op);
}
@keyframes ku-twinkle {
    from { opacity: var(--op); transform: scale(1); }
    to   { opacity: calc(var(--op) * 0.15); transform: scale(0.6); }
}

/* Nebula */
.ku-nebula {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.ku-nebula::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(124,77,189,0.15) 0%, transparent 70%);
    top: -120px; left: -80px;
    animation: ku-drift 18s ease-in-out infinite alternate;
}
.ku-nebula::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(57,255,176,0.07) 0%, transparent 70%);
    bottom: -80px; right: -60px;
    animation: ku-drift 22s ease-in-out infinite alternate-reverse;
}
@keyframes ku-drift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(30px, 20px) scale(1.12); }
}

/* Inner layout */
.ku-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px 0;
    gap: 0;
}

/* Title */
.ku-title {
    font-family: 'Orbitron', 'Courier New', monospace;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    background: linear-gradient(135deg, #bf93ff, #ff6aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}
.ku-subtitle {
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    color: #a97de8;
    text-transform: uppercase;
    margin-bottom: 20px;
    text-align: center;
}

/* Stage */
.ku-stage {
    position: relative;
    width: 260px;
    height: 300px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 4px;
}
.ku-ground-glow {
    position: absolute;
    bottom: 0;
    width: 160px; height: 36px;
    background: radial-gradient(ellipse, rgba(124,77,189,0.55) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(8px);
    z-index: 0;
    animation: ku-glow-pulse 2.2s ease-in-out infinite alternate;
}
@keyframes ku-glow-pulse {
    from { opacity: 0.5; transform: scaleX(1); }
    to   { opacity: 0.95; transform: scaleX(1.14); }
}
.ku-alien-wrap {
    position: relative;
    z-index: 2;
    cursor: pointer;
}
.ku-alien-img {
    width: 220px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(124,77,189,0.55));
    animation: ku-idle 3.6s ease-in-out infinite;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
}
@keyframes ku-idle {
    0%,100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-11px) rotate(1deg); }
}
.ku-alien-img.talking {
    animation: ku-talking 0.17s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 32px rgba(191,147,255,0.9));
}
@keyframes ku-talking {
    from { transform: scale(1) rotate(-1deg); }
    to   { transform: scale(1.03) rotate(1deg); }
}
.ku-alien-img.listening {
    animation: ku-listening 0.6s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 28px rgba(57,255,176,0.85));
}
@keyframes ku-listening {
    from { transform: scale(0.98); }
    to   { transform: scale(1.02); }
}

/* Bubble */
.ku-bubble {
    position: absolute;
    top: 0;
    right: -10px;
    background: rgba(12,8,36,0.94);
    border: 1.5px solid #a97de8;
    border-radius: 16px 16px 16px 4px;
    padding: 10px 13px;
    max-width: 190px;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #e8e0ff;
    box-shadow: 0 0 18px rgba(124,77,189,0.28);
    opacity: 0;
    transform: scale(0.85) translateY(6px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 10;
}
.ku-bubble.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}
.ku-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px; left: 14px;
    border: 5px solid transparent;
    border-top-color: #a97de8;
}

/* Status */
.ku-status {
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: #a97de8;
    text-transform: uppercase;
    min-height: 18px;
    text-align: center;
    margin-bottom: 14px;
    transition: color 0.3s;
}
.ku-status.listening { color: #39ffb0; }
.ku-status.talking   { color: #ff6aff; }
.ku-status.error     { color: #ff6b6b; }

/* Chips */
.ku-chips {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 16px;
    width: 100%;
}
.ku-chip {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(180,130,255,0.18);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #a97de8;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    user-select: none;
}
.ku-chip:hover,
.ku-chip.active {
    background: var(--ku-accent, #7c4dbd);
    border-color: #a97de8;
    color: #fff;
}

/* Controls */
.ku-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

/* Mic button */
.ku-mic-btn {
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 2px solid #a97de8;
    background: linear-gradient(145deg, rgba(124,77,189,0.3), rgba(20,8,60,0.7));
    color: #fff;
    font-size: 1.9rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 0 18px rgba(124,77,189,0.3), inset 0 0 18px rgba(124,77,189,0.1);
    outline: none;
    line-height: 1;
}
.ku-mic-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(124,77,189,0.6), inset 0 0 18px rgba(124,77,189,0.2);
}
.ku-mic-btn.active {
    border-color: #39ffb0;
    box-shadow: 0 0 36px rgba(57,255,176,0.5), inset 0 0 18px rgba(57,255,176,0.1);
    animation: ku-mic-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes ku-mic-pulse {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}
.ku-mic-btn.active::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid #39ffb0;
    animation: ku-ripple 1s ease-out infinite;
}
@keyframes ku-ripple {
    from { opacity: 0.8; transform: scale(1); }
    to   { opacity: 0;   transform: scale(1.55); }
}
.ku-mic-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    animation: none !important;
}
.ku-mic-btn:disabled::before { display: none; }

/* Type row */
.ku-type-row {
    display: flex;
    gap: 7px;
    width: 100%;
}
.ku-type-input {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(180,130,255,0.18);
    border-radius: 12px;
    padding: 9px 13px;
    color: #e0d8ff;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.ku-type-input:focus { border-color: #a97de8; }
.ku-type-input::placeholder { color: rgba(180,150,255,0.3); }

.ku-send-btn {
    background: linear-gradient(135deg, var(--ku-accent, #7c4dbd), #4a1a9e);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 9px 15px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
}
.ku-send-btn:hover { opacity: 0.86; transform: scale(1.04); }
.ku-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Transcript */
.ku-transcript {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(180,130,255,0.14);
    border-radius: 14px;
    padding: 12px;
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 16px;
}
.ku-transcript::-webkit-scrollbar { width: 4px; }
.ku-transcript::-webkit-scrollbar-track { background: transparent; }
.ku-transcript::-webkit-scrollbar-thumb { background: rgba(180,130,255,0.2); border-radius: 4px; }

.ku-msg {
    font-size: 0.8rem;
    line-height: 1.44;
    padding: 5px 10px;
    border-radius: 10px;
    max-width: 88%;
    animation: ku-fade-in 0.3s ease;
}
@keyframes ku-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ku-msg.user {
    background: rgba(124,77,189,0.22);
    border: 1px solid rgba(124,77,189,0.3);
    align-self: flex-end;
    color: #ddd0ff;
}
.ku-msg.alien {
    background: rgba(57,255,176,0.07);
    border: 1px solid rgba(57,255,176,0.18);
    align-self: flex-start;
    color: #d0ffe8;
}
.ku-msg.ku-label {
    font-size: 0.63rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #a97de8;
    background: none;
    border: none;
    padding: 2px 4px;
}

/* Load Orbitron if available */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@900&display=swap');
