/* ARIA chat widget: floating launcher + panel. Scoped to #aria-widget. */
#aria-widget {
    --aria-navy: #0a0e1a;
    --aria-deep: #0d1528;
    --aria-blue: #1a2a4a;
    --aria-accent: #4a90d9;
    --aria-gold: #c9a227;
    --aria-gold-light: #f0c84a;
    --aria-muted: #8899bb;
    --aria-text: #dbe4f5;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.55;
    color: var(--aria-text);
}

#aria-widget *,
#aria-widget *::before,
#aria-widget *::after {
    box-sizing: border-box;
}

/* ---------- launcher ---------- */
.aria-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px 6px 6px;
    border: 1px solid rgba(201, 162, 39, .45);
    border-radius: 40px;
    background: rgba(10, 14, 26, .92);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .45), 0 0 18px rgba(74, 144, 217, .18);
    color: var(--aria-text);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.aria-launcher:hover,
.aria-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .5), 0 0 24px rgba(74, 144, 217, .35);
    outline: none;
}

.aria-launcher img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--aria-accent);
    object-fit: cover;
    background: var(--aria-deep);
}

.aria-launcher-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.2;
}

.aria-launcher-text strong {
    color: var(--aria-gold-light);
    letter-spacing: .12em;
    font-size: 14px;
}

.aria-launcher-text span {
    color: var(--aria-muted);
    font-size: 12px;
}

.aria-led {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: #3ddc84;
    box-shadow: 0 0 6px #3ddc84;
    vertical-align: middle;
}

#aria-widget.is-offline .aria-led {
    background: var(--aria-gold);
    box-shadow: 0 0 6px var(--aria-gold);
}

#aria-widget.is-open .aria-launcher {
    display: none;
}

/* ---------- panel ---------- */
.aria-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1041;
    display: none;
    flex-direction: column;
    width: 390px;
    height: min(640px, calc(100vh - 40px));
    border: 1px solid rgba(201, 162, 39, .35);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--aria-deep) 0%, var(--aria-navy) 100%);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .6), 0 0 30px rgba(74, 144, 217, .15);
    overflow: hidden;
}

#aria-widget.is-open .aria-panel {
    display: flex;
}

/* portrait header */
.aria-head {
    position: relative;
    flex: 0 0 auto;
    height: 190px;
    overflow: hidden;
    border-bottom: 1px solid rgba(74, 144, 217, .3);
    background:
        radial-gradient(ellipse at 50% 70%, rgba(74, 144, 217, .28), transparent 65%),
        var(--aria-navy);
}

.aria-portrait {
    position: absolute;
    left: 50%;
    top: -8px;
    width: 300px;
    height: 300px;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 10px rgba(74, 144, 217, .45));
    animation: aria-float 6s ease-in-out infinite;
}

.aria-portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.aria-portrait img.is-on {
    opacity: 1;
}

/* hologram scanlines + flicker over the portrait */
.aria-head::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(120, 180, 255, .07) 0 1px, transparent 1px 3px);
    mix-blend-mode: screen;
    animation: aria-flicker 7s infinite;
}

.aria-head-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 28px 14px 10px;
    background: linear-gradient(0deg, rgba(10, 14, 26, .95), transparent);
}

.aria-title strong {
    display: block;
    color: var(--aria-gold-light);
    letter-spacing: .16em;
    font-size: 16px;
}

.aria-title span {
    color: var(--aria-muted);
    font-size: 12px;
}

.aria-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 6px;
    background: rgba(13, 21, 40, .8);
    color: var(--aria-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.aria-icon-btn:hover,
.aria-icon-btn:focus-visible {
    border-color: var(--aria-accent);
    outline: none;
}

.aria-icon-btn.is-muted {
    color: var(--aria-muted);
    font-size: 12px;
    letter-spacing: -2px;
}

.aria-head-actions {
    display: flex;
    gap: 6px;
}

/* messages */
.aria-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 14px 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--aria-blue) transparent;
}

.aria-msg {
    max-width: 88%;
    margin: 0 0 10px;
    padding: 9px 12px;
    border-radius: 10px;
    word-wrap: break-word;
}

.aria-msg p {
    margin: 0 0 8px;
}

.aria-msg p:last-child,
.aria-msg ul:last-child {
    margin-bottom: 0;
}

.aria-msg ul {
    margin: 0 0 8px;
    padding-left: 18px;
}

.aria-msg--aria {
    border: 1px solid rgba(74, 144, 217, .25);
    border-top-left-radius: 2px;
    background: rgba(26, 42, 74, .55);
}

.aria-msg--aria a {
    color: var(--aria-gold-light);
    text-decoration: underline;
}

.aria-msg--user {
    margin-left: auto;
    border-top-right-radius: 2px;
    background: rgba(201, 162, 39, .16);
    border: 1px solid rgba(201, 162, 39, .3);
}

.aria-typing {
    color: var(--aria-muted);
    font-style: italic;
}

.aria-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 10px;
}

.aria-chip {
    padding: 5px 10px;
    border: 1px solid rgba(74, 144, 217, .45);
    border-radius: 14px;
    background: transparent;
    color: var(--aria-text);
    font-size: 13px;
    cursor: pointer;
}

.aria-chip:hover,
.aria-chip:focus-visible {
    background: rgba(74, 144, 217, .18);
    outline: none;
}

/* input */
.aria-form {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    padding: 10px 12px 6px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.aria-form textarea {
    flex: 1;
    height: 40px;
    padding: 9px 11px;
    overflow-y: hidden;
    line-height: 20px;
    border: 1px solid rgba(74, 144, 217, .35);
    border-radius: 8px;
    background: rgba(10, 14, 26, .8);
    color: var(--aria-text);
    resize: none;
    font: inherit;
    font-size: 14px;
}

.aria-form textarea:focus {
    border-color: var(--aria-accent);
    outline: none;
}

.aria-send {
    flex: 0 0 auto;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: var(--aria-gold);
    color: var(--aria-navy);
    font-weight: 700;
    cursor: pointer;
}

.aria-send:disabled {
    opacity: .5;
    cursor: default;
}

.aria-hp {
    position: absolute;
    left: -9999px;
}

.aria-foot {
    flex: 0 0 auto;
    padding: 0 12px 9px;
    color: var(--aria-muted);
    font-size: 11px;
    text-align: center;
}

@keyframes aria-float {
    0%, 100% { margin-top: 0; }
    50% { margin-top: 4px; }
}

@keyframes aria-flicker {
    0%, 92%, 100% { opacity: 1; }
    93% { opacity: .55; }
    94% { opacity: 1; }
    96% { opacity: .75; }
}

@media (max-width: 560px) {
    .aria-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .aria-head {
        height: 160px;
    }

    .aria-launcher {
        right: 12px;
        bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aria-portrait,
    .aria-head::after {
        animation: none;
    }
}
