/**
 * Chad Bot 0.3 — floating overlay.
 * Sizes in rem / vw / dvh so it fits phones and large screens.
 */
.eu-chad-root {
    position: fixed;
    inset: 0;
    z-index: 8600;
    pointer-events: none;
    --chad-h: 210;
    --chad-radius: 1.35rem;
}

.eu-chad-charge {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.eu-chad-root.is-armed .eu-chad-charge {
    opacity: 1;
}

.eu-chad-charge-veil {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--chad-ox, 50%) var(--chad-oy, 42%),
        hsla(var(--chad-h), 90%, 62%, 0.16),
        transparent 42%);
}

.eu-chad-charge-ring {
    position: absolute;
    left: var(--chad-ox, 50%);
    top: var(--chad-oy, 42%);
    width: 1.15rem;
    height: 1.15rem;
    margin: -0.575rem 0 0 -0.575rem;
    border-radius: 50%;
    border: 0.12rem solid hsla(var(--chad-h), 95%, 72%, 0.95);
    box-shadow:
        0 0 1.1rem hsla(var(--chad-h), 95%, 60%, 0.65),
        0 0 2.6rem hsla(calc(var(--chad-h) + 40), 90%, 55%, 0.35);
    transform: scale(0.4);
    opacity: 0.2;
}

.eu-chad-root.is-armed .eu-chad-charge-ring {
    animation: euChadCharge 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes euChadCharge {
    0% { transform: scale(0.35); opacity: 0.15; }
    70% { opacity: 1; }
    100% { transform: scale(4.6); opacity: 0.85; }
}

.eu-chad-stage {
    position: fixed;
    box-sizing: border-box;
    width: min(22rem, calc(100vw - 1.5rem));
    height: min(27rem, calc(100dvh - 2rem));
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1.25rem);
    border-radius: var(--chad-radius);
    overflow: visible;
    pointer-events: none;
    opacity: 0;
    z-index: 1;
}

.eu-chad-catch {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: none;
    pointer-events: none;
    touch-action: none;
    background: transparent;
}

.eu-chad-root.is-open .eu-chad-catch {
    display: block;
    pointer-events: auto;
}

.eu-chad-root.is-open .eu-chad-stage {
    pointer-events: auto;
    opacity: 1;
    transition:
        width 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        left 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        top 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        max-width 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        max-height 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.28s ease;
}

.eu-chad-root.is-dragging .eu-chad-stage {
    transition: none;
}

.eu-chad-root.is-full .eu-chad-stage {
    width: min(48rem, calc(100vw - 1rem));
    height: min(52rem, calc(100dvh - 1rem));
    max-width: calc(100vw - 1rem);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 0.75rem);
}

@property --chad-a {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

.eu-chad-shell {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: visible;
    transform-origin: 50% 46%;
}

.eu-chad-root.is-pop:not(.is-open) .eu-chad-shell {
    opacity: 0;
    transform: translateY(0.65rem) scale(0.9);
}

.eu-chad-root.is-open.is-pop .eu-chad-shell {
    animation: euChadPop 0.52s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.eu-chad-glow {
    position: absolute;
    box-sizing: border-box;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
    background: conic-gradient(
        from var(--chad-a),
        #00f6ff 0deg,
        #3cf0ff 36deg,
        #6a7bff 72deg,
        #9b5cff 108deg,
        #e14dff 144deg,
        #ff2d9b 180deg,
        #ff7a3d 216deg,
        #ffd400 252deg,
        #3dff8a 300deg,
        #00f6ff 360deg
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    mask-composite: exclude;
    animation: euChadAngle 8s linear infinite;
}

.eu-chad-glow-core {
    inset: -0.05rem;
    padding: 0.11rem;
}

.eu-chad-glow-mid {
    inset: -0.12rem;
    padding: 0.2rem;
    opacity: 0.38;
}

.eu-chad-glow-soft {
    inset: -0.2rem;
    padding: 0.3rem;
    opacity: 0.2;
}

.eu-chad-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    color: #eef3fb;
    background:
        linear-gradient(180deg, rgba(22, 28, 44, 0.94) 0%, rgba(14, 16, 28, 0.97) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 1.4rem 3.6rem rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(1.1rem) saturate(1.15);
    -webkit-backdrop-filter: blur(1.1rem) saturate(1.15);
}

.eu-chad-root.is-open.is-pop .eu-chad-card {
    animation: none;
}

@keyframes euChadPop {
    0% { opacity: 0; transform: translateY(0.7rem) scale(0.9); }
    100% { opacity: 1; transform: none; }
}

@keyframes euChadAngle {
    to { --chad-a: 360deg; }
}

.eu-chad-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.7rem 0.6rem 0.9rem;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.eu-chad-root.is-dragging .eu-chad-head {
    cursor: grabbing;
}

.eu-chad-mark {
    width: 2.9rem;
    height: 2.9rem;
    border-radius: 0.72rem;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
}

.eu-chad-mark img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: 50% 32%;
    mix-blend-mode: screen;
}

.eu-chad-titles {
    min-width: 0;
    flex: 1;
}

.eu-chad-titles strong {
    display: block;
    font-family: Outfit, system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.eu-chad-tools {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.eu-chad-tools button,
.eu-chad-root .eu-chad-tools button:hover,
.eu-chad-root .eu-chad-tools button:focus,
.eu-chad-root .eu-chad-tools button:active,
.eu-chad-root.is-full .eu-chad-size,
.eu-chad-root.is-full .eu-chad-size:hover {
    appearance: none;
    -webkit-appearance: none;
    width: 2.25rem;
    height: 2.25rem;
    border: none !important;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border-radius: 0;
    color: #fff !important;
    font-size: 0.95rem;
    cursor: pointer;
    touch-action: manipulation;
    display: grid;
    place-items: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.eu-chad-tools button:hover {
    opacity: 0.72;
}

.eu-chad-size {
    display: grid;
    place-items: center;
    padding: 0;
}

.eu-chad-ico {
    grid-area: 1 / 1;
    width: 1.28rem;
    height: 1.28rem;
    display: block;
    stroke-width: 3;
}

.eu-chad-ico-shrink {
    display: none;
}

.eu-chad-root.is-full .eu-chad-ico-expand {
    display: none;
}

.eu-chad-root.is-full .eu-chad-ico-shrink {
    display: block;
}

.eu-chad-root.is-full .eu-chad-size {
    width: 2.25rem;
}

.eu-chad-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.7rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.eu-chad-msg {
    max-width: 92%;
    padding: 0.5rem 0.7rem;
    border-radius: 0.85rem;
    font-size: 0.95rem;
    line-height: 1.35;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    cursor: text;
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default;
}

.eu-chad-msg-user {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.1);
    color: #f4f7ff;
}

.eu-chad-msg-bot {
    align-self: flex-start;
    background: rgba(0, 246, 255, 0.12);
    color: #eef3fb;
}

.eu-chad-play {
    max-width: 100%;
    align-self: stretch;
    padding: 0.8rem 0.85rem 0.9rem;
    border-radius: 1.05rem;
    background: rgba(10, 16, 30, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(0, 246, 255, 0.08);
    white-space: normal;
}

.eu-chad-play-title {
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.35rem;
}

.eu-chad-play-status {
    white-space: pre-wrap;
    margin-bottom: 0.55rem;
    color: #eef3fb;
}

.eu-chad-play-flag {
    display: block;
    width: 100%;
    max-height: 8.2rem;
    object-fit: contain;
    object-position: center;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    margin: 0.15rem 0 0.55rem;
}

.eu-chad-play-row,
.eu-chad-play-pad {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 0.45rem;
}

.eu-chad-play-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.eu-chad-play-row.is-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.eu-chad-play-pad {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.eu-chad-play-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0;
}

.eu-chad-play-put {
    margin-bottom: 0.2rem;
}

.eu-chad-play-keys {
    white-space: pre-wrap;
    max-height: 12rem;
    overflow: auto;
    font-size: 0.82rem;
    line-height: 1.35;
    margin: 0.35rem 0 0.5rem;
    padding: 0.45rem 0.5rem;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.04);
}

.eu-chad-play-list {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
    max-height: 16rem;
    overflow: auto;
}

.eu-chad-play-back {
    width: 2.4rem;
    margin-bottom: 0.35rem;
}

.eu-chad-play-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #eef3fb;
    font: inherit;
    font-size: 0.92rem;
    padding: 0.55rem 0.4rem;
    border-radius: 0.7rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.eu-chad-play.is-done .eu-chad-play-btn,
.eu-chad-play.is-done {
    pointer-events: none;
    opacity: 0.72;
}

.eu-chad-msg-bot.eu-chad-think {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 1.15em;
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
}

.eu-chad-msg.is-pending {
    opacity: 0;
}

.eu-chad-msg-user.is-land {
    opacity: 1;
}

.eu-chad-msg-bot.is-arrive {
    animation: euChadBotIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes euChadBotIn {
    0% { opacity: 0; transform: translateY(0.4rem) scale(0.96); }
    100% { opacity: 1; transform: none; }
}

.eu-chad-flys {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
}

.eu-chad-msg-fly {
    position: absolute;
    margin: 0;
    max-width: none;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: center;
    box-shadow:
        0 0.45rem 1.2rem rgba(0, 0, 0, 0.34),
        0 0 0 1px rgba(255, 255, 255, 0.06);
    will-change: left, top, width, height;
}

.eu-chad-think span {
    width: 0.38rem;
    height: 0.38rem;
    border-radius: 50%;
    background: #9befff;
    opacity: 0.35;
    animation: euChadThink 0.5s ease-in-out infinite;
}

.eu-chad-think span:nth-child(2) { animation-delay: 0.12s; }
.eu-chad-think span:nth-child(3) { animation-delay: 0.24s; }

@keyframes euChadThink {
    0%, 100% { opacity: 0.28; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-0.2rem); }
}

.eu-chad-foot {
    padding: 0.65rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.eu-chad-foot #euChadTalk,
.eu-chad-foot input,
.eu-chad-foot textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #eef3fb;
    border-radius: 0.9rem;
    padding: 0.7rem 0.85rem;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.25;
    outline: none;
    caret-color: #eef3fb;
    transform: none;
    resize: none;
    min-height: 2.65rem;
    max-height: 2.65rem;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-touch-callout: default;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    user-select: text !important;
}

.eu-chad-foot #euChadTalk:focus,
.eu-chad-foot input:focus,
.eu-chad-foot textarea:focus {
    font-size: 16px;
    transform: none;
}

.eu-chad-foot #euChadTalk::placeholder,
.eu-chad-foot input::placeholder,
.eu-chad-foot textarea::placeholder {
    color: rgba(238, 243, 251, 0.42);
}

.eu-chad-foot.is-send #euChadTalk,
.eu-chad-foot.is-send input,
.eu-chad-foot.is-send textarea {
    animation: euChadAskSend 0.38s ease;
}

@keyframes euChadAskSend {
    0% { background: rgba(255, 255, 255, 0.05); }
    40% { background: rgba(255, 255, 255, 0.12); }
    100% { background: rgba(255, 255, 255, 0.05); }
}

.eu-chad-search-glow {
    box-shadow:
        0 0 0 0.18rem hsla(var(--chad-h, 210), 90%, 62%, 0.28),
        0 0 1.7rem hsla(var(--chad-h, 210), 90%, 55%, 0.35) !important;
    border-color: hsla(var(--chad-h, 210), 85%, 70%, 0.65) !important;
    transition: box-shadow 0.2s, border-color 0.2s;
}

@media (max-width: 40rem) {
    .eu-chad-stage {
        width: calc(100vw - 1.5rem);
        height: min(24rem, calc(100dvh - 5rem));
    }
    .eu-chad-root.is-full .eu-chad-stage {
        width: calc(100vw - 0.65rem);
        height: calc(100dvh - 0.65rem);
        max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 0.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .eu-chad-glow,
    .eu-chad-root.is-open.is-pop .eu-chad-shell,
    .eu-chad-root.is-pop:not(.is-open) .eu-chad-shell,
    .eu-chad-think span,
    .eu-chad-msg-bot.is-arrive,
    .eu-chad-foot.is-send input {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .eu-chad-root.is-open .eu-chad-stage {
        transition: opacity 0.15s ease;
    }
}
