/* ============================================================
 * SchoolWeb Chatbot — 氣泡介面樣式（階段 C1）
 *
 * 設計原則
 *   1. 全部選擇器都掛在 #swchat 之下 → 不可能影響網站現有版型
 *   2. 不載入任何外部字型／圖示庫 → 不增加頁面請求
 *   3. z-index 9990 以下 → 不蓋住網站自己的燈箱／選單
 *
 * 視覺參考：Klook 客服機器人
 *   - 機器人的回答不使用對話氣泡（用排版區分，不用框）
 *   - 使用者訊息用淡紫氣泡
 *   - 每個答案點各自帶一個「來源」按鈕（不是把連結集中到底部）
 * ============================================================ */

#swchat,
#swchat * {
    box-sizing: border-box;
}

#swchat {
    --swc-brand: #0A4E3C;
    --swc-brand-2: #17705A;
    --swc-ink: #16211C;
    --swc-muted: #6C7B74;
    --swc-line: #E7ECE9;
    --swc-mint: #E8F8F0;
    --swc-mint-2: #D6F2E5;
    --swc-mint-deep: #0B7A56;
    --swc-lav: #EEF2FC;
    --swc-purple: #5B4BD6;

    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9985;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
                 "Microsoft JhengHei", "Noto Sans TC", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--swc-ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------- 浮動按鈕 ---------- */

#swchat .swc-launcher {
    position: relative;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    background: linear-gradient(150deg, var(--swc-brand-2), var(--swc-brand));
    border: 2px solid rgba(255, 255, 255, .92);
    box-shadow: 0 10px 26px rgba(10, 78, 60, .30), 0 2px 6px rgba(10, 78, 60, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .22s cubic-bezier(.34, 1.4, .64, 1), box-shadow .22s;
}

#swchat .swc-launcher:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 14px 32px rgba(10, 78, 60, .34);
}

#swchat .swc-launcher:active {
    transform: scale(.96);
}

#swchat .swc-launcher svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity .18s, transform .18s;
}

/* 開啟時圖示換成關閉 */
#swchat[data-open="1"] .swc-icon-chat { opacity: 0; transform: scale(.6) rotate(-30deg); }
#swchat[data-open="1"] .swc-icon-close { opacity: 1; transform: scale(1) rotate(0); }

#swchat .swc-icon-close {
    position: absolute;
    opacity: 0;
    transform: scale(.6) rotate(30deg);
}

/* 網站自己有開關按鈕時（社交欄的 chat-btn），收起內建的浮動按鈕
 *
 * 為甚麼不直接刪掉內建按鈕：其他學校未必有社交欄，
 * 那些站台仍然要靠這顆按鈕才能開氣泡。由 JS 判斷後加 class 才隱藏。
 */
#swchat.swc-site-trigger .swc-launcher {
    display: none !important;
}

/* 用社交欄按鈕開氣泡時，面板改成貼在社交欄左邊、底部對齊
 *
 * 為甚麼要分兩組位置：
 *   內建浮動按鈕在右下角，面板要開在它「上面」；
 *   社交欄是一整條直排圖示，面板要開在它「左邊」，
 *   否則會蓋住 facebook／instagram／back-to-top 那幾顆。
 */
/* 一定要包在 min-width 之內：
 *   手機版的面板是 position:fixed + left:0 + right:0（滿版），
 *   而這條選擇器的優先次序比 media query 內那條高，
 *   不包起來的話 right:64px 會蓋過右邊界，面板右側露出一條社交欄。
 */
@media (min-width: 561px) {
    #swchat.swc-site-trigger .swc-panel {
        right: 64px;

        /* 社交欄在 bottom: 15px，#swchat 在 bottom: 20px，所以往下一點點對齊 */
        bottom: -5px;
    }
}

/* 氣泡開著時，社交欄那顆對話圖示加一圈提示，讓家長知道「再按一次會收起」。
 * 用描邊而不是改邊框顏色：邊框顏色是 theme_v2.css 管的，不應該覆寫。 */
.chat-btn.swc-active {
    box-shadow: 0 0 0 3px rgba(160, 227, 124, .55);
}
.chat-btn.swc-active img {
    transform: scale(.92);
}

/* ---------- 對話面板 ---------- */

#swchat .swc-panel {
    position: absolute;

    /* 預設：開在內建浮動按鈕正上方（沒有社交欄的站台用這組） */
    right: 0;
    bottom: 76px;
    width: 384px;
    height: 640px;
    max-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 28px 64px rgba(10, 78, 60, .18), 0 4px 14px rgba(10, 78, 60, .08);
    border: 1px solid rgba(10, 78, 60, .07);
    overflow: hidden;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(12px) scale(.96);
    pointer-events: none;
    transition: opacity .2s ease, transform .24s cubic-bezier(.32, 1.3, .58, 1);
}

#swchat[data-open="1"] .swc-panel {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* ---------- 標題列 ---------- */

#swchat .swc-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 16px 13px;
    background: linear-gradient(180deg, #F7FCF9, #fff);
    border-bottom: 1px solid var(--swc-line);
}

#swchat .swc-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: linear-gradient(145deg, var(--swc-brand-2), var(--swc-brand));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.3px;
}

#swchat .swc-avatar--img {
    width: 34px;
    height: 34px;
    padding: 2px;
    background: #fff;
    /* 學校的標誌多數是橫長形，用 contain 才不會只看到中間一小截 */
    object-fit: contain;
    border: 1px solid var(--swc-line);
}

#swchat .swc-avatar--sm.swc-avatar--img {
    width: 26px;
    height: 26px;
    padding: 1px;
}

#swchat .swc-avatar--sm {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    font-size: 12px;
    background: var(--swc-mint);
    color: var(--swc-brand);
    border: 1px solid #CFEDE0;
}

#swchat .swc-head-txt {
    flex: 1 1 auto;
    min-width: 0;
}

#swchat .swc-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--swc-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#swchat .swc-sub {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--swc-muted);
    margin-top: 1px;
}

#swchat .swc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #18C37E;
    box-shadow: 0 0 0 3px rgba(24, 195, 126, .16);
}

#swchat .swc-close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--swc-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background .15s, color .15s;
}

#swchat .swc-close:hover {
    background: #F2F5F3;
    color: var(--swc-ink);
}

/* ---------- 放大／還原鈕 ---------- */

/* 為甚麼放在 × 左邊、同樣 30×30：
 *   兩顆不同高度的按鈕會讓標題列看起來歪，
 *   直接在 .swc-close 的規則上再加一組等價的尺寸即可，
 *   不需要動 .swc-close 既有規則。
 * 為甚麼不用 <a>：這是不換頁的狀態切換，按鈕語意（aria-pressed）比連結準確。 */
#swchat .swc-expand {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--swc-muted);
    cursor: pointer;
    padding: 0;
    /* 用 grid 而不是 flex：兩顆 SVG 要疊在同一個格位互相淡入淡出，
     * grid-area: 1/1 + place-items: center 是最直接的疊法，
     * 也不會讓其中一顆影響按鈕的對齊。 */
    display: grid;
    place-items: center;
    transition: background .15s, color .15s;
}

#swchat .swc-expand:hover {
    background: #F2F5F3;
    color: var(--swc-ink);
}

#swchat .swc-expand:focus-visible {
    outline: 2px solid var(--swc-brand-2);
    outline-offset: 1px;
}

#swchat .swc-expand-ico {
    width: 16px;
    height: 16px;
    /* 這個圖示是實心 (fill) 造型，不是描邊。
     * 沿用 fill: currentColor 才能跟著按鈕的顏色（含 :hover 變深）走，
     * 並且一定要把 stroke 設成 none —— 否則會多出一圈描邊，圖示看起來糊一團。
     *
     * 兩顆圖示疊在同一個格位，靠 data-expanded 決定顯示哪一顆：
     *   收合中 (0) → --on  （向外擴張的雙箭頭）
     *   放大中 (1) → --off （向內收合的雙箭頭）
     * 為甚麼不用旋轉：兩組 SVG 的視覺比例不同，旋轉後箭頭會變粗、
     * 重心也會偏，直接換圖比旋轉準確。 */
    grid-area: 1 / 1;
    fill: currentColor;
    stroke: none;
    transition: opacity .18s ease;
}

#swchat .swc-expand-ico--off {
    opacity: 0;
}

#swchat[data-expanded="1"] .swc-expand-ico--on {
    opacity: 0;
}

#swchat[data-expanded="1"] .swc-expand-ico--off {
    opacity: 1;
}

#swchat[data-expanded="1"] .swc-expand {
    color: var(--swc-brand-2);
}

/* ---------- 放大後的桌面尺寸（1.5 倍） ---------- */

/* 原本 384×640（見上方 .swc-panel），放大後 576×960。
 *
 * 為甚麼 height 要配 max-height：
 *   960px 比很多筆電的可視高度（約 700–800px）還高，
 *   直接寫死會被切掉，變成「放大反而看不完整」。
 *   max-height 用 calc(100dvh - 120px) 與原本的收起狀態一致，
 *   差別只是原本寫死 640 時永遠碰不到這個上限。
 *
 * 為甚麼仍然貼右（right: 0）：
 *   面板從右下角長大最不容易蓋住左側的內容導覽，
 *   使用者的游標也剛好在右下，還原後不必移動視線。
 *
 * 只在 ≥561px 生效（手機版另有自己的尺寸，見檔案末段）。 */
@media (min-width: 561px) {
    #swchat[data-expanded="1"] .swc-panel {
        width: 576px;
        height: 960px;
        max-height: calc(100dvh - 120px);
        border-radius: 24px;
    }

    /* 放大後內容區變寬，行長容易過長。
     * 訊息本身沒有固定寬度，這裡不加 max-width，
     * 但要給比原本多一點左右留白，避免文字貼邊。 */
    #swchat[data-expanded="1"] .swc-body {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ---------- 訊息區 ---------- */

#swchat .swc-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 8px;
    scroll-behavior: smooth;
}

#swchat .swc-body::-webkit-scrollbar { width: 6px; }
#swchat .swc-body::-webkit-scrollbar-thumb {
    background: #DDE4E0;
    border-radius: 3px;
}
#swchat .swc-body::-webkit-scrollbar-track { background: transparent; }

/* 使用者訊息：淡紫氣泡 */
#swchat .swc-user {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 18px;
}

#swchat .swc-user > div {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px 16px 4px 16px;
    background: var(--swc-lav);
    color: #24304A;
    font-size: 14px;
    line-height: 1.62;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 機器人訊息：無氣泡，靠排版區分 */
#swchat .swc-bot {
    display: flex;
    gap: 9px;
    margin: 0 0 20px;
    animation: swc-rise .26s ease both;
}

@keyframes swc-rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

#swchat .swc-bot-main {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 2px;
}

/* ── 答案框：結論與卡片同一個框 ────────────────────────
 * 之前結論與卡片是分開的兩塊，看起來像兩個不相干的東西。
 * 現在收在同一個框裡：結論在頂部（淡綠），卡片由上往下排，
 * 收尾句在底部（淺灰）。整體像一份小答案。
 */
#swchat .swc-answer-box {
    background: #fff;
    border: 1px solid var(--swc-line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(10, 78, 60, .05);
    overflow: hidden;
    margin: 0 0 14px;
}

/* 結論：完整一句話 + 冒號，字最大 */
#swchat .swc-conclusion {
    padding: 13px 15px;
    background: var(--swc-mint);
    border-bottom: 1px solid #D8EEE3;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.6;
    color: #0B2F26;
    word-break: break-word;
}

/* 結論是一小段時的排版：字級比標題小一點，行距放寬才好讀 */
#swchat .swc-conclusion--para {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.85;
    color: #17352C;
    letter-spacing: .01em;
}

#swchat .swc-answer-box .swc-intro {
    margin: 0;
    padding: 11px 15px 0;
    font-size: 13.5px;
    color: #4C5C55;
}

/* 卡片：不再各自帶邊框，改用分隔線串起來 */
#swchat .swc-cards {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
}

#swchat .swc-card {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 13px 15px;
    border-top: 1px solid #EEF3F0;
}

#swchat .swc-card:first-child {
    border-top: 0;
}

#swchat .swc-card:hover {
    background: #FBFDFC;
}

/* 卡片標題：一句話說明這張卡在講什麼 */
/* 沒有引用來源的卡片（校曆）：標題不用深綠，也不加粗
 *
 * 深綠色在整個介面裡代表「有出處的重點」。
 * 校曆是查表結果，不是引用校網某一頁，用同一種顏色會誤導。
 * 改成一般內文字重與顏色，靠字號與位置區分層級就足夠。 */
#swchat .swc-card--noref .swc-card-title {
    color: var(--swc-muted);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .02em;
    margin-bottom: 7px;
}

#swchat .swc-card-title {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.55;
    color: #0B3D2F;
    margin-bottom: 5px;
    word-break: break-word;
}

/* 卡片編號：圓形 */
#swchat .swc-card-num {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--swc-mint);
    color: var(--swc-mint-deep);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

#swchat .swc-card-body {
    flex: 1 1 auto;
    min-width: 0;
}

#swchat .swc-card-text {
    font-size: 14px;
    line-height: 1.75;
    color: #2B3A33;
    word-break: break-word;
}

#swchat .swc-card-text .swc-line {
    margin-bottom: 4px;
}

#swchat .swc-card-text .swc-line:last-child {
    margin-bottom: 0;
}

/* 合併卡內的單點：小標題 + 內文
 * 注意：不要用 .swc-sub，那是標題列「根據校網內容回答」的 class，
 * 撞名會讓這裡變成橫向排列（實測踩過）。
 */
#swchat .swc-entry {
    margin-bottom: 12px;
}

#swchat .swc-entry:last-child {
    margin-bottom: 0;
}

#swchat .swc-entry-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--swc-mint-deep);
    line-height: 1.5;
    margin-bottom: 2px;
}

/* 收尾句：框內底部 */
#swchat .swc-answer-box .swc-closing {
    margin: 0;
    padding: 11px 15px;
    background: #FAFCFB;
    border-top: 1px solid #EEF3F0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.7;
    color: #4C5C55;
}

/* 舊版排版保留給其他位置使用（不刪，避免影響已存在的樣式） */
#swchat .swc-point {
    position: relative;
    padding-left: 26px;
    margin: 0 0 15px;
}

#swchat .swc-point--single {
    padding-left: 0;
}

#swchat .swc-point:last-of-type {
    margin-bottom: 4px;
}

#swchat .swc-num {
    position: absolute;
    left: 0;
    top: 1px;
    font-size: 15px;
    font-weight: 700;
    font-style: italic;
    color: var(--swc-mint-deep);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.5px;
}

#swchat .swc-text {
    font-size: 14px;
    line-height: 1.75;
    color: var(--swc-ink);
    word-break: break-word;
    white-space: pre-wrap;
}

/* 同一來源合併後的多行內容 */
#swchat .swc-text--multi {
    white-space: normal;
}

#swchat .swc-line {
    display: flex;
    gap: 7px;
    margin-bottom: 5px;
    line-height: 1.72;
}

#swchat .swc-line:last-child {
    margin-bottom: 0;
}

/* 多行要點（校曆的活動／假期清單）
 *
 * 用 pre-line 而不是 pre：保留換行，但仍然會自動折行。
 * 用 pre 的話，一句較長的「2026年11月19日至11月24日　第一次考試」
 * 會超出卡片，出現橫向滾動。 */
#swchat .swc-line--multi {
    display: block;
    white-space: pre-line;
}

#swchat .swc-bullet {
    flex: 0 0 auto;
    color: #9DB7AC;
    font-weight: 700;
}

#swchat .swc-text b,
#swchat .swc-text strong {
    font-weight: 700;
    color: #0B3D2F;
}

/* 關鍵數字／專有名詞 */
#swchat .swc-text mark {
    background: linear-gradient(180deg, transparent 58%, var(--swc-mint-2) 58%);
    color: inherit;
    padding: 0 1px;
}

/* 要點的來源按鈕群組（一個要點可能引用多段） */
#swchat .swc-cites {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

/* ★ 每個要點自己的來源按鈕 */
#swchat .swc-cite {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 9px;
    padding: 5px 11px 5px 8px;
    max-width: 100%;
    border-radius: 999px;
    background: var(--swc-mint);
    border: 1px solid #CBEBDB;
    color: #0B6E4E;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}

#swchat .swc-cite:hover,
#swchat .swc-cite:focus-visible {
    background: var(--swc-mint-2);
    border-color: #A9DFC5;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(11, 122, 86, .14);
    outline: none;
}

#swchat .swc-cite:active {
    transform: translateY(0);
}

#swchat .swc-cite .swc-cite-ico {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    font-size: 9px;
    line-height: 1;
    color: var(--swc-mint-deep);
}

#swchat .swc-cite .swc-cite-k {
    color: #6E9C89;
    font-weight: 500;
    font-size: 11px;
}

#swchat .swc-cite .swc-cite-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

#swchat .swc-cite .swc-cite-go {
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .55;
}

/* 收尾句 */
#swchat .swc-closing {
    margin-top: 0;
    padding: 11px 13px;
    border-radius: 12px;
    background: #F7FAF8;
    border: 1px solid var(--swc-line);
    font-size: 13px;
    line-height: 1.7;
    color: #3D4E46;
}

/* 純文字回答（短答、拒答） */
#swchat .swc-plain {
    font-size: 14.5px;
    line-height: 1.78;
    color: var(--swc-ink);
    white-space: pre-wrap;
    word-break: break-word;
}

/* 拒答樣式 */
#swchat .swc-bot[data-kind="refuse"] .swc-plain {
    color: #4A5A53;
}

/* ---------- 思考中的訊息（跟著對話走） ---------- */

#swchat .swc-thinking {
    margin-bottom: 18px;
}

#swchat .swc-thinking-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    background: #F5F9F7;
    border: 1px dashed #D8E7DF;
    border-radius: 12px;
    font-size: 13px;
    color: #5C6E66;
    width: fit-content;
    max-width: 100%;
}

#swchat .swc-thinking-text {
    transition: opacity .2s;
}

/* ---------- 舊版固定狀態列（保留但不使用） ---------- */

#swchat .swc-status {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 12.5px;
    color: var(--swc-muted);
}

#swchat .swc-status[data-on="1"] {
    display: flex;
}

#swchat .swc-dots {
    display: inline-flex;
    gap: 3px;
}

#swchat .swc-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--swc-mint-deep);
    opacity: .35;
    animation: swc-blink 1.15s infinite;
}

#swchat .swc-dots i:nth-child(2) { animation-delay: .16s; }
#swchat .swc-dots i:nth-child(3) { animation-delay: .32s; }

@keyframes swc-blink {
    0%, 60%, 100% { opacity: .28; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-2px); }
}

/* ---------- 答案評分 ---------- */

/* 兩顆膠囊按鈕，貼在答案框下方
 *
 * 為什麼不是兩顆大方塊按鈕：
 *   評分是「順手按一下」的動作，做大了會跟「繼續問」搶注意力，
 *   家長反而以為要填問卷才能往下問。
 *
 * 為什麼用 negative margin：
 *   答案框本身 margin-bottom 14px，按鈕若不拉上來會像另一個區塊。
 */
#swchat .swc-vote {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -6px 0 20px 0;
    animation: swc-rise .26s ease both;
}

#swchat .swc-vote-b {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 10px;
    border: 1px solid var(--swc-line);
    border-radius: 999px;
    background: #fff;
    color: var(--swc-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}

#swchat .swc-vote-b svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}

#swchat .swc-vote-b:hover {
    background: var(--swc-mint);
    border-color: #A9DFC5;
    color: var(--swc-mint-deep);
    transform: translateY(-1px);
}

#swchat .swc-vote-b:focus-visible {
    outline: 2px solid var(--swc-brand-2);
    outline-offset: 2px;
}

/* 已選：顏色留下來，讓家長知道自己按了哪一顆 */
#swchat .swc-vote-b.is-on {
    background: var(--swc-mint);
    border-color: #A9DFC5;
    color: var(--swc-mint-deep);
}

/* 送出中：兩顆都暫時不能再按，但外觀不變（灰掉會像壞了） */
#swchat .swc-vote--busy .swc-vote-b {
    pointer-events: none;
}

/* 已記錄：整排換成一句謝謝，不再有可按的東西 */
#swchat .swc-vote--done {
    margin-bottom: 18px;
}

#swchat .swc-vote-thanks {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--swc-mint-deep);
}

/* ---------- 快速問題 ---------- */

/* 「接下來可以問」：跟在答案後面 */
#swchat .swc-followup {
    margin: -4px 0 22px 35px;
    animation: swc-rise .26s ease both;
}

#swchat .swc-followup .swc-quick-label {
    margin-bottom: 7px;
}

#swchat .swc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

#swchat .swc-quick {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 16px 10px;
}

#swchat .swc-quick:empty {
    display: none;
}

/* 「接下來可以問」標籤 */
#swchat .swc-quick-label {
    flex: 0 0 100%;
    font-size: 11.5px;
    font-weight: 600;
    color: #8A9992;
    letter-spacing: .02em;
    margin-bottom: 1px;
}

#swchat .swc-chip {
    border: 1px solid #CBEBDB;
    background: #fff;
    color: #0B6E4E;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
}

#swchat .swc-chip:hover {
    background: var(--swc-mint);
    border-color: #A9DFC5;
    transform: translateY(-1px);
}

/* ---------- 輸入區 ---------- */

#swchat .swc-foot {
    flex: 0 0 auto;
    position: relative;
    padding: 0 16px 14px;
    background: #fff;
}

/* 上方漸層：讓「下面還有內容」看得出來，而不是像被切掉 */
#swchat .swc-foot::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -20px;
    height: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff);
    pointer-events: none;
}

#swchat .swc-inputwrap {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 5px 5px 5px 14px;
    border-radius: 24px;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(110deg, #9FE3C4, #E4F08C, #B9AEF5) border-box;
    border: 1.5px solid transparent;
    transition: box-shadow .2s;
}

#swchat .swc-inputwrap:focus-within {
    box-shadow: 0 0 0 4px rgba(159, 227, 196, .22);
}

#swchat .swc-input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--swc-ink);
    padding: 7px 0;
    max-height: 96px;
    min-height: 24px;
    overflow-y: auto;
}

#swchat .swc-input::placeholder {
    color: #9AA8A2;
}

#swchat .swc-send {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--swc-brand-2), var(--swc-brand));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s, transform .15s;
}

#swchat .swc-send svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#swchat .swc-send:disabled {
    opacity: .38;
    cursor: default;
}

#swchat .swc-send:not(:disabled):hover {
    transform: scale(1.06);
}

/* ---------- 輸入框下方的兩句提示 ---------- */

/* 為甚麼獨立成一塊：這兩句是家長要「看到」的，不是版面裝飾。
   舊版 10.5px 淺灰居中，實測在 384px 寬的氣泡內幾乎讀不到；
   現在加圖示、加字級、加深顏色，並用一條細線與輸入框分開。 */
#swchat .swc-notes {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--swc-line);
}

#swchat .swc-note {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 5px;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #5F726B;
    text-align: center;
}

#swchat .swc-note-ico {
    flex: 0 0 auto;
    width: 13px;
    height: 13px;
    margin-top: 2.5px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .9;
}

/* 個資提示：比免責聲明更重要，所以用底色整條托起來（不是角落小字）。
   但要與「錯誤」區分 —— 用品牌綠的淺底，不用紅色或黃色警告色。 */
#swchat .swc-note--privacy {
    padding: 6px 10px;
    border-radius: 10px;
    background: #F1F7F3;
    color: #2F5548;
    font-weight: 500;
}

/* ---------- 手機版：由底部起的 3/4 高 ---------- */

@media (max-width: 560px) {
    #swchat {
        right: 14px;
        bottom: 14px;
    }

    #swchat .swc-launcher {
        width: 56px;
        height: 56px;
    }

    /* 為甚麼是 80% 而不是全螢幕：
     *   全螢幕會蓋住整頁，家長看不到自己剛才在看的那一段內容；
     *   留 1/5 在頂部，他仍然知道自己身處哪一頁，也不會覺得「跳走了」。
     *
     * 為甚麼用 dvh 而不是 vh：
     *   手機瀏覽器的工具列會隨捲動伸縮，vh 會用「最大可視高度」，
     *   結果面板底部被工具列切掉；dvh 用「當前可視高度」，不會被切。
     *   舊瀏覽器（iOS < 15.4）不支援 dvh，所以先寫一行 vh 做後備。
     *
     * 為甚麼是 90% 闊、貼右（2026-11-19）：
     *   全寬面板會把整個畫面蓋住，家長連「自己在哪一頁」都看不到。
     *   改成 90% 之後，左邊留一條約 39px 的頁面可以看見／點到，
     *   視覺上也知道這是一個可以收起的面板，而不是換了一頁。
     *   貼右而不是居中：手機的返回手勢、以及家長的拇指活動範圍
     *   都在右邊，面板貼右就不必把手指移去畫面左邊。
     *
     * 為甚麼用 % 而不是 vw：
     *   position: fixed 之下，90% 就是可視闊度的 90%，與 90vw 等值；
     *   但 vw 在桌面會把捲軸闊度也算進去，用 % 少一個誤差來源。
     */
    #swchat .swc-panel {
        position: fixed;
        right: 0;
        left: auto;
        bottom: 0;
        top: auto;
        width: 90%;
        max-width: 90%;
        height: 80vh;
        height: 80dvh;
        max-height: 80vh;
        max-height: 80dvh;

        /* 四角都圓：面板不是貼滿整個畫面，左下角是露出來的，
         * 只圓上面兩角會讓左下角變成一個尖角，看起來像破圖。 */
        border-radius: 20px;
        border: 0;
        border-top: 1px solid rgba(10, 78, 60, .08);
    }

    #swchat[data-open="1"] .swc-launcher {
        display: none;
    }

    /* 放大狀態（手機）：90% 闊 × 90% 高，仍然貼右、貼底。
     *
     * 為甚麼不是 100%：
     *   留 10% 讓家長看得到自己在哪一頁，且左下角露出的那一條
     *   就是他熟悉的「滑走」手勢的起點。
     *
     * 為甚麼要寫 !important：fitPanel() 會在開啟與 resize 時
     *   直接寫 inline 的 height，inline 優先於這裡的 CSS。
     *   放大時的 90% 由 JS 的 fitPanel() 一起算，這裡只是後備，
     *   讓 JS 未執行時也得到同樣結果。 */
    #swchat[data-expanded="1"] .swc-panel {
        width: 90%;
        max-width: 90%;
        height: 90vh;
        height: 90dvh;
        max-height: 90vh;
        max-height: 90dvh;
    }

    /* 開啟時氣泡佔畫面下方 3/4，社交欄（z-index 2）會被蓋住。
     * 不加任何規則去移動社交欄 —— 那是網站自己的版面，
     * 家長用氣泡右上角的 × 或 Esc 關閉即可。 */

    #swchat .swc-head {
        padding-top: max(15px, env(safe-area-inset-top));
    }

    #swchat .swc-foot {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    #swchat .swc-text,
    #swchat .swc-plain,
    #swchat .swc-intro--plain {
    margin: 0 0 2px;
    padding: 0;
    color: var(--swc-ink);
    font-size: 14.5px;
}

#swchat .swc-intro {
        font-size: 15px;
    }
}

/* ---------- 尊重系統「減少動態」 ---------- */

@media (prefers-reduced-motion: reduce) {
    #swchat *,
    #swchat *::before,
    #swchat *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- 列印時隱藏 ---------- */

@media print {
    #swchat {
        display: none !important;
    }
}

/* ---------- 字級 ---------- */

/* 為甚麼集中在檔案末段、用一組覆寫規則（2026-11-24）
 *
 * 原本各元素的 font-size 散在 30 多處，改一次要翻半個檔案，
 * 而且容易漏改。現在把「使用者要的字級」集中成一組變數，
 * 由一個區塊統一套用；上方既有規則保留原值作為後備，
 * 這一組在檔案最後、優先於前面所有宣告。
 *
 * 數值是使用者指定的（不是按比例推算）：
 *   正文（回答內容）          14   → 16px
 *   回答結論                  15   → 17px
 *   標題（助理名稱）        14.5   → 16px
 *   小字（來源、提示）      12   → 16px
 *   輸入框                    14   → 16px
 *
 * 小字統一拉到 16px 是刻意的：家長在手機上看「資料來源」這類字，
 * 11–12px 常要放大才讀得到。代價是來源區塊會變高，
 * 因此下方把 .swc-cite 的行距收緊一點，避免每一條來源佔兩行。
 */
#swchat {
    --swc-fs-body: 16px;
    --swc-fs-conclusion: 17px;
    --swc-fs-title: 16px;
    --swc-fs-small: 16px;
    --swc-fs-input: 16px;
}

/* 正文 */
#swchat .swc-text,
#swchat .swc-text--multi,
#swchat .swc-line,
#swchat .swc-line--multi,
#swchat .swc-card-text .swc-line,
#swchat .swc-user > div,
#swchat .swc-answer-box .swc-intro {
    font-size: var(--swc-fs-body);
}

/* 結論 */
#swchat .swc-conclusion,
#swchat .swc-conclusion--para {
    font-size: var(--swc-fs-conclusion);
}

/* 標題：助理名稱、卡片標題、條目標題 */
#swchat .swc-title,
#swchat .swc-card-title,
#swchat .swc-card--noref .swc-card-title,
#swchat .swc-entry-title,
#swchat .swc-plain {
    font-size: var(--swc-fs-title);
}

/* 小字：來源、提示、狀態、評分、建議問句、關閉提示 */
#swchat .swc-sub,
#swchat .swc-card-text,
#swchat .swc-cite,
#swchat .swc-cite .swc-cite-k,
#swchat .swc-cite .swc-cite-go,
#swchat .swc-closing,
#swchat .swc-answer-box .swc-closing,
#swchat .swc-status,
#swchat .swc-thinking-row,
#swchat .swc-vote-b,
#swchat .swc-vote-thanks,
#swchat .swc-quick-label,
#swchat .swc-chip,
#swchat .swc-note,
#swchat .swc-card-num,
#swchat .swc-intro--plain {
    font-size: var(--swc-fs-small);
}

/* 輸入框 */
#swchat .swc-input {
    font-size: var(--swc-fs-input);
}

/* 字放大之後，來源區塊的行距與圖示要一起收，
 * 否則每一條來源都會折成兩行，答案看起來很長。
 * 圖示維持小尺寸（不跟隨文字），它是裝飾而非內容。 */
#swchat .swc-cite {
    line-height: 1.35;
}

#swchat .swc-cite .swc-cite-ico {
    font-size: 12px;
}

/* 建議問句變大後，一個 chip 可能撐滿整行；
 * 允許換行並收緊上下留白，維持原本的視覺密度。 */
#swchat .swc-chip {
    line-height: 1.4;
}

/* ---------- 字放大後的面板寬度 ---------- */

/* 原本 384px 是為 14px 文字設計的。
 * 正文升到 16px、小字升到 16px 之後，同樣寬度每行只剩 20 個中文字左右，
 * 一段三行的答案會變成五行，看起來很零碎。
 * 加寬到 440px 讓每行回到約 24 個字，接近原本的閱讀節奏。
 * 放大狀態同步調整（576 → 660，維持 1.5 倍）。
 *
 * 手機版不加寬：那裡本來就是 90% 闊，寬度由裝置決定。 */
@media (min-width: 561px) {
    #swchat .swc-panel {
        width: 440px;
    }

    #swchat[data-expanded="1"] .swc-panel {
        width: 660px;
    }
}

