/* HaoYong support surface. The widget intentionally borrows the storefront tokens. */
.hy-support {
    --hy-support-ink: var(--hy-ink, #15181d);
    --hy-support-muted: var(--hy-muted, #6b737d);
    --hy-support-subtle: var(--hy-subtle, #9299a1);
    --hy-support-canvas: var(--hy-canvas, #f4f2ed);
    --hy-support-surface: var(--hy-surface, #fffefa);
    --hy-support-surface-2: var(--hy-surface-2, #eeece6);
    --hy-support-line: var(--hy-line, #dedbd2);
    --hy-support-accent: var(--hy-accent, #ff684d);
    --hy-support-lime: var(--hy-lime, #d8ee6a);
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 1080;
    color: var(--hy-support-ink);
    font-family: inherit;
}

.hy-support-launcher {
    position: relative;
    display: inline-flex;
    min-width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--hy-support-ink);
    border-radius: 14px;
    background: var(--hy-support-ink);
    color: #fff;
    box-shadow: 5px 5px 0 rgba(21, 24, 29, .14), 0 14px 30px rgba(21, 24, 29, .16);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.hy-support-launcher:hover,
.hy-support-launcher:focus-visible {
    background: #292e36;
    box-shadow: 6px 7px 0 rgba(21, 24, 29, .12), 0 17px 34px rgba(21, 24, 29, .2);
    transform: translateY(-2px);
}

.hy-support-launcher:focus-visible,
.hy-support-close:focus-visible,
.hy-support-start:focus-visible,
.hy-support-send:focus-visible,
.hy-support-quick button:focus-visible {
    outline: 3px solid rgba(255, 104, 77, .38);
    outline-offset: 2px;
}

.hy-support-launcher > i { font-size: 19px; }
.hy-support-launcher__dot {
    width: 7px;
    height: 7px;
    border: 2px solid var(--hy-support-ink);
    border-radius: 50%;
    background: var(--hy-support-lime);
}

.hy-support-panel {
    display: flex;
    width: min(398px, calc(100vw - 32px));
    height: min(620px, calc(100dvh - 32px));
    min-height: 440px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(21, 24, 29, .16);
    border-radius: 20px;
    background: var(--hy-support-surface);
    box-shadow: 14px 16px 0 rgba(21, 24, 29, .06), 0 24px 60px rgba(21, 24, 29, .24);
}

.hy-support-panel[hidden] { display: none !important; }
.hy-support-grabber { display: none; }

.hy-support-panel__head {
    display: flex;
    min-height: 80px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    background: var(--hy-support-ink);
    color: #fff;
}

.hy-support-panel__identity { display: flex; min-width: 0; align-items: center; gap: 11px; }
.hy-support-avatar {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px 12px 12px 4px;
    background: var(--hy-support-lime);
    color: var(--hy-support-ink);
    font-size: 18px;
}
.hy-support-panel__head strong { display: block; font-size: 16px; line-height: 1.2; }
.hy-support-status { display: flex; align-items: center; gap: 5px; margin-top: 5px; color: rgba(255, 255, 255, .68); font-size: 11px; }
.hy-support-status::before { width: 6px; height: 6px; border-radius: 50%; background: var(--hy-support-lime); content: ""; }
.hy-support.is-closed .hy-support-status::before { background: var(--hy-support-accent); }

.hy-support-close {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font: inherit;
}
.hy-support-close:hover { background: rgba(255, 255, 255, .12); }
.hy-support-close > i { font-size: 17px; }

.hy-support-context {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--hy-support-line);
    background: var(--hy-support-surface-2);
    color: var(--hy-support-muted);
    font-size: 11px;
    line-height: 1.35;
}
.hy-support-context > i { flex: 0 0 auto; color: var(--hy-support-accent); }
.hy-support-context > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hy-support-messages {
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding: 18px 15px;
    background: var(--hy-support-canvas);
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.hy-support-empty {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 14px;
    text-align: center;
}
.hy-support-welcome-mark {
    display: grid;
    width: 52px;
    height: 52px;
    margin-bottom: 13px;
    place-items: center;
    border-radius: 16px 16px 16px 6px;
    background: var(--hy-support-lime);
    color: var(--hy-support-ink);
    box-shadow: 4px 4px 0 rgba(21, 24, 29, .1);
    font-size: 21px;
}
.hy-support-empty strong { font-size: 15px; }
.hy-support-empty p { max-width: 245px; margin: 6px 0 17px; color: var(--hy-support-muted); font-size: 12px; line-height: 1.5; }
.hy-support-quick { display: grid; width: min(285px, 100%); grid-template-columns: repeat(3, 1fr); gap: 7px; }
.hy-support-quick button {
    min-height: 40px;
    padding: 8px 5px;
    border: 1px solid var(--hy-support-line);
    border-radius: 10px;
    background: var(--hy-support-surface);
    color: var(--hy-support-ink);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    line-height: 1.3;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.hy-support-quick button:hover { border-color: var(--hy-support-accent); background: #fff; transform: translateY(-1px); }

.hy-support-message { display: flex; margin: 0 0 11px; }
.hy-support-message--visitor { justify-content: flex-end; }
.hy-support-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border: 1px solid var(--hy-support-line);
    border-radius: 14px 14px 14px 4px;
    background: var(--hy-support-surface);
    color: var(--hy-support-ink);
    box-shadow: 0 2px 7px rgba(21, 24, 29, .06);
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.hy-support-message--visitor .hy-support-bubble { border-color: var(--hy-support-accent); border-radius: 14px 14px 4px 14px; background: var(--hy-support-accent); color: #fff; }
.hy-support-time { display: block; margin-top: 4px; color: inherit; font-size: 10px; opacity: .58; }
.hy-support-image { display: block; max-width: 190px; max-height: 150px; border-radius: 9px; object-fit: cover; }

.hy-support-error { margin: 0 14px 8px; padding: 8px 10px; border: 1px solid rgba(201, 53, 32, .18); border-radius: 9px; background: #fff0ed; color: #a33123; font-size: 12px; }
.hy-support-compose { display: none; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--hy-support-line); background: var(--hy-support-surface); }
.hy-support.is-active .hy-support-compose { display: flex; }
.hy-support-input { min-width: 0; height: 40px; flex: 1; padding: 0 11px; border: 1px solid var(--hy-support-line); border-radius: 10px; outline: 0; background: var(--hy-support-surface); color: var(--hy-support-ink); font: inherit; font-size: 13px; }
.hy-support-input::placeholder { color: var(--hy-support-subtle); }
.hy-support-input:focus { border-color: var(--hy-support-accent); box-shadow: 0 0 0 3px rgba(255, 104, 77, .14); }
.hy-support-input:disabled { background: var(--hy-support-surface-2); cursor: not-allowed; }
.hy-support-send { display: inline-flex; min-width: 68px; height: 40px; align-items: center; justify-content: center; gap: 5px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--hy-support-ink); color: #fff; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
.hy-support-send:hover { background: #292e36; }
.hy-support-send:disabled { opacity: .42; cursor: not-allowed; }
.hy-support-send > i { font-size: 15px; }
.hy-support-start { display: none; width: calc(100% - 24px); min-height: 44px; align-items: center; justify-content: center; gap: 7px; margin: 0 12px 7px; border: 0; border-radius: 11px; background: var(--hy-support-accent); color: #fff; cursor: pointer; font: inherit; font-size: 13px; font-weight: 750; }
.hy-support.is-idle .hy-support-start,
.hy-support.is-closed .hy-support-start { display: flex; }
.hy-support-start:hover { background: var(--hy-accent-dark, #db4e39); }
.hy-support-start:disabled { opacity: .58; cursor: wait; }
.hy-support-note { display: none; align-items: center; justify-content: center; gap: 5px; padding: 0 12px 12px; color: var(--hy-support-subtle); font-size: 10px; }
.hy-support.is-idle .hy-support-note,
.hy-support.is-closed .hy-support-note { display: flex; }

.hy-support.is-open .hy-support-launcher { display: none; }

@media (max-width: 767px) and (min-width: 641px) {
    .hy-support { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .hy-support-panel { width: min(390px, calc(100vw - 24px)); }
}

@media (max-width: 640px) {
    body.hy-support-lock { overflow: hidden; }
    .hy-support { right: 0; bottom: 0; width: 100%; pointer-events: none; }
    .hy-support-launcher { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); width: 52px; height: 52px; min-width: 52px; padding: 0; border-radius: 50%; pointer-events: auto; }
    .hy-support-launcher__label { display: none; }
    .hy-support-launcher__dot { position: absolute; top: 5px; right: 4px; width: 9px; height: 9px; border-width: 2px; }
    .hy-support-panel { width: 100%; height: min(650px, 78dvh); max-height: calc(100dvh - 8px); min-height: 360px; border-right: 0; border-bottom: 0; border-radius: 20px 20px 0 0; pointer-events: auto; box-shadow: 0 -12px 42px rgba(21, 24, 29, .2); }
    .hy-support-grabber { display: block; width: 38px; height: 4px; position: absolute; z-index: 2; top: 7px; left: 50%; border-radius: 999px; background: rgba(255, 255, 255, .42); transform: translateX(-50%); }
    .hy-support-panel__head { min-height: 76px; padding: 17px 14px 13px; }
    .hy-support-close { width: 40px; height: 40px; }
    .hy-support-messages { padding: 15px 12px; }
    .hy-support-quick { width: min(320px, 100%); }
    .hy-support-quick button { min-height: 44px; font-size: 12px; }
    .hy-support-compose { padding: 9px 10px; }
    .hy-support-input, .hy-support-send { height: 44px; }
    .hy-support-send { min-width: 72px; }
    .hy-support-start { min-height: 46px; margin-right: 10px; margin-left: 10px; width: calc(100% - 20px); }
    .hy-support-note { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    .hy-support-launcher, .hy-support-quick button, .hy-support-messages { transition: none; scroll-behavior: auto; }
}

@media (forced-colors: active) {
    .hy-support-launcher, .hy-support-panel__head, .hy-support-send { border: 1px solid CanvasText; }
    .hy-support-quick button, .hy-support-input { border: 1px solid CanvasText; }
}

[data-theme="dark"] .hy-support {
    --hy-support-canvas: #202326;
    --hy-support-surface: #282c30;
    --hy-support-surface-2: #32373c;
    --hy-support-line: #454c53;
    --hy-support-muted: #b2bac2;
    --hy-support-subtle: #87919a;
}
