/* 前台小幫手：風格 B 山稜、固定淺色；不跟網站主題變色，所以不引用網站的主題變數 */
.kb-root {
    --kb-primary: #E81340;
    --kb-primary-dark: #b80f33;
    --kb-primary-soft: #fde7ec;
    --kb-earth: #2b1d1a;
    --kb-ochre: #d99a1e;
    --kb-text: #2b2d33;
    --kb-muted: #5d616c;
    --kb-line: #e3e4e8;
    --kb-bot-bg: #f1f2f5;
    --kb-panel-bg: #ffffff;
    --kb-notice-bg: #fff6e0;
    --kb-notice-text: #6b4e00;
    --kb-danger-bg: #fdecec;
    --kb-danger-text: #9b1c1c;
    font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

.kb-root *,
.kb-root *::before,
.kb-root *::after {
    box-sizing: border-box;
}

/* 既有回頂部按鈕往上移，讓出右下角 */
body .back-top {
    bottom: 96px;
}

.kb-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1040;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 20px;
    overflow: hidden;
    border: 0;
    border-radius: 26px;
    background: var(--kb-primary);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
    cursor: pointer;
}

.kb-launcher:hover {
    background-color: var(--kb-primary-dark);
}

.kb-launcher[hidden],
.kb-panel[hidden] {
    display: none;
}

.kb-launcher-ridge {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.kb-launcher-icon,
.kb-launcher-text {
    position: relative;
}

.kb-launcher-icon {
    width: 22px;
    height: 22px;
    flex: none;
}

.kb-launcher:focus-visible,
.kb-panel button:focus-visible,
.kb-panel textarea:focus-visible {
    outline: 3px solid #1a73e8;
    outline-offset: 2px;
}

.kb-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(580px, calc(100vh - 48px));
    margin: 0;
    /* 網站 style.css 對所有 section 加上下 padding，面板要拿掉 */
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--kb-panel-bg);
    color: var(--kb-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

.kb-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 4px 16px;
    background: #2b1d1a;
    color: #fff;
}

.kb-seal {
    width: 34px;
    height: 34px;
    flex: none;
}

.kb-head h2 {
    flex: 1;
    margin: 0;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
}

.kb-icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.kb-icon-button:hover {
    background: rgba(255, 255, 255, .18);
}

.kb-icon-button svg {
    width: 20px;
    height: 20px;
}

.kb-ridge {
    display: block;
    flex: none;
    width: 100%;
    height: 30px;
    background: #2b1d1a;
}

.kb-ridge .r1 {
    fill: #d99a1e;
    opacity: .85;
}

.kb-ridge .r2 {
    fill: #E81340;
}

.kb-ridge .r3 {
    fill: #fff6e0;
}

.kb-notice {
    margin: 0;
    padding: 8px 14px;
    border-bottom: 1px solid var(--kb-line);
    background: var(--kb-notice-bg);
    color: var(--kb-notice-text);
    font-size: 13px;
    line-height: 1.55;
}

.kb-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow-y: auto;
}

.kb-msg {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.kb-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--kb-primary-soft);
}

.kb-bot {
    align-self: flex-start;
    border-top-left-radius: 4px;
    background: var(--kb-bot-bg);
}

.kb-error {
    align-self: stretch;
    max-width: none;
    background: var(--kb-danger-bg);
    color: var(--kb-danger-text);
    font-size: 14px;
}

.kb-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--kb-line);
    color: var(--kb-muted);
    font-size: 13px;
    white-space: normal;
}

.kb-sources ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.kb-retry {
    margin-top: 8px;
    padding: 4px 12px;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.kb-faqs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kb-faq {
    padding: 6px 12px;
    border: 1px solid var(--kb-primary);
    border-radius: 16px;
    background: var(--kb-panel-bg);
    color: var(--kb-primary);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.kb-faq:hover {
    background: var(--kb-primary-soft);
}

.kb-root button:disabled {
    cursor: not-allowed;
    opacity: .6;
}

.kb-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.kb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--kb-muted);
    animation: kb-blink 1.2s infinite;
}

.kb-typing span:nth-child(2) {
    animation-delay: .2s;
}

.kb-typing span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes kb-blink {
    0%, 80%, 100% {
        opacity: .25;
    }

    40% {
        opacity: 1;
    }
}

.kb-form {
    margin: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--kb-line);
}

.kb-pii {
    margin: 0 0 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--kb-notice-bg);
    color: var(--kb-notice-text);
    font-size: 13px;
    line-height: 1.5;
}

.kb-pii[hidden] {
    display: none;
}

.kb-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.kb-row textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 12px;
    resize: none;
    border: 1px solid var(--kb-line);
    border-radius: 8px;
    background: var(--kb-panel-bg);
    color: var(--kb-text);
    font: inherit;
    font-size: 15px;
    line-height: 1.5;
}

.kb-submit {
    flex: none;
    height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--kb-primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.kb-root .kb-submit:disabled {
    background: #b9bbc2;
    opacity: 1;
}

.kb-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    color: var(--kb-muted);
    font-size: 12px;
}

.kb-meta .kb-over {
    color: var(--kb-danger-text);
    font-weight: 700;
}

.kb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 576px) {
    body .back-top {
        bottom: 88px;
    }

    .kb-launcher {
        right: 12px;
        bottom: 12px;
        justify-content: center;
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
    }

    .kb-launcher-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .kb-panel {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}
