/* 福工档案助手：只服务于档案区，不代表何巍本人。 */
#archive-assistant {
    --assistant-gold: #c9a96e;
    --assistant-bg: #111;
    --assistant-border: #302c26;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;
    font-family: var(--font-cn, "Noto Serif SC", "PingFang SC", "Microsoft YaHei", serif);
}

#archive-assistant,
#archive-assistant * { box-sizing: border-box; }

#archive-assistant-trigger {
    min-width: 112px;
    height: 44px;
    padding: 0 16px;
    border: 1px solid rgba(201, 169, 110, .55);
    border-radius: 999px;
    background: rgba(15, 15, 15, .94);
    color: var(--assistant-gold);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 13px;
    letter-spacing: .08em;
}

#archive-assistant-trigger > span:first-child {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(201, 169, 110, .45);
    border-radius: 50%;
    font-size: 10px;
    letter-spacing: 0;
}

#archive-assistant-trigger:hover,
#archive-assistant-trigger:focus-visible {
    border-color: var(--assistant-gold);
    outline: none;
}

#archive-assistant-trigger[aria-expanded="true"] { visibility: hidden; }

#archive-assistant-panel {
    position: absolute;
    right: 0;
    bottom: 58px;
    width: min(390px, calc(100vw - 32px));
    height: min(590px, calc(100vh - 110px));
    border: 1px solid var(--assistant-border);
    border-radius: 10px;
    background: var(--assistant-bg);
    color: #d8d5cf;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .58);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#archive-assistant-panel[hidden] { display: none; }

.assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--assistant-border);
    background: #0b0b0b;
    width: 100%;
}

.assistant-title {
    color: var(--assistant-gold);
    font-size: 15px;
    letter-spacing: .12em;
}

.assistant-subtitle {
    margin-top: 3px;
    color: #85817a;
    font-size: 11px;
}

#archive-assistant-close {
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: #8b877f;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

#archive-assistant-close:hover,
#archive-assistant-close:focus-visible {
    color: var(--assistant-gold);
    outline: 1px solid rgba(201, 169, 110, .45);
    border-radius: 4px;
}

#archive-assistant-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant-message {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.assistant-message.user {
    align-self: flex-end;
    background: var(--assistant-gold);
    color: #111;
}

.assistant-message.bot {
    align-self: flex-start;
    border: 1px solid #2c2925;
    background: #191817;
    color: #c9c5bd;
}

.assistant-message.typing { color: #8f8a82; }

.assistant-sources,
.assistant-no-source {
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid #34302b;
    color: #8f8a82;
    font-size: 11px;
}

.assistant-sources a {
    color: var(--assistant-gold);
    text-decoration: none;
}

.assistant-sources a:hover,
.assistant-sources a:focus-visible { text-decoration: underline; }

.assistant-no-source { color: #b9a47e; }

.assistant-boundary {
    padding: 9px 16px;
    border-top: 1px solid var(--assistant-border);
    background: #0d0d0d;
    color: #77736c;
    font-size: 10px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

#archive-assistant-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid var(--assistant-border);
    background: #0b0b0b;
    width: 100%;
}

#archive-assistant-input {
    flex: 1;
    min-width: 0;
    height: 42px;
    max-height: 112px;
    padding: 10px 12px;
    resize: none;
    border: 1px solid #34312c;
    border-radius: 5px;
    background: #181716;
    color: #ece8e1;
    font: inherit;
    font-size: 13px;
    line-height: 1.55;
    outline: none;
    width: 0;
}

#archive-assistant-input:focus { border-color: var(--assistant-gold); }
#archive-assistant-input::placeholder { color: #66625c; }

#archive-assistant-send {
    align-self: stretch;
    padding: 0 16px;
    border: 0;
    border-radius: 5px;
    background: var(--assistant-gold);
    color: #111;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    flex: 0 0 auto;
}

#archive-assistant-send:disabled { cursor: wait; opacity: .5; }

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 560px) {
    #archive-assistant {
        right: 12px;
        bottom: 12px;
    }

    #archive-assistant-trigger {
        min-width: 104px;
        height: 42px;
    }

    #archive-assistant-panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #archive-assistant * { scroll-behavior: auto !important; }
}
