/* 星時電子 AI 助理 浮動視窗 ── 沿用首頁暖色系 */
#st-ai {
    --ai-cream:   #faf9f5;
    --ai-warm:    #f4f3ee;
    --ai-card:    #ffffff;
    --ai-border:  #e8e6dc;
    --ai-text:    #1a1915;
    --ai-text2:   #5a5750;
    --ai-muted:   #8a877f;
    --ai-accent:  #cc785c;
    --ai-accent2: #b8694e;
    --ai-soft:    #f3e7e0;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    font-family: "Noto Sans TC", -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* 啟動按鈕（純文字 pill） */
#st-ai-launcher {
    background-color: var(--ai-accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 13px 22px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 30px -10px rgba(26, 25, 21, 0.45);
    transition: transform 0.15s ease, background-color 0.2s ease;
}
#st-ai-launcher:hover { background-color: var(--ai-accent2); transform: translateY(-1px); }

/* 對話面板 */
#st-ai-panel {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background-color: var(--ai-cream);
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 70px -25px rgba(26, 25, 21, 0.5);
}
#st-ai.open #st-ai-panel { display: flex; }
#st-ai.open #st-ai-launcher { display: none; }

/* 標題列 */
#st-ai-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background-color: var(--ai-card);
    border-bottom: 1px solid var(--ai-border);
}
#st-ai-head .st-ai-title {
    font-family: "Noto Serif TC", Georgia, serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--ai-text);
}
#st-ai-head .st-ai-sub {
    font-size: 12px;
    color: var(--ai-muted);
    margin-top: 2px;
    min-height: 14px;
}
#st-ai-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--ai-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}
#st-ai-close:hover { background-color: var(--ai-warm); color: var(--ai-text); }

/* 訊息區 */
#st-ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.st-ai-msg { display: flex; }
.st-ai-msg.user { justify-content: flex-end; }
.st-ai-bubble {
    max-width: 84%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--ai-text);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.st-ai-msg.user .st-ai-bubble {
    background-color: var(--ai-accent);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.st-ai-msg.bot .st-ai-bubble {
    background-color: var(--ai-card);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 5px;
}

/* 打字指示 */
.st-ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.st-ai-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background-color: var(--ai-muted);
    animation: st-ai-blink 1.2s infinite both;
}
.st-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.st-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes st-ai-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Markdown 內容樣式 */
.st-ai-bubble > :first-child { margin-top: 0; }
.st-ai-bubble > :last-child { margin-bottom: 0; }
.st-ai-bubble p { margin: 0 0 8px; }
.st-ai-bubble ul, .st-ai-bubble ol { margin: 6px 0 8px; padding-left: 20px; }
.st-ai-bubble li { margin: 2px 0; }
.st-ai-bubble h1, .st-ai-bubble h2, .st-ai-bubble h3, .st-ai-bubble h4 {
    font-size: 15px; margin: 10px 0 6px; font-family: inherit; font-weight: 600;
}
.st-ai-bubble a { color: var(--ai-accent2); text-decoration: underline; }
.st-ai-bubble code {
    background-color: var(--ai-warm);
    padding: 1px 5px; border-radius: 5px;
    font-size: 13px; font-family: "Consolas", "Menlo", monospace;
}
.st-ai-bubble pre {
    background-color: #2b2924; color: #f4f3ee;
    padding: 12px 14px; border-radius: 10px;
    overflow-x: auto; margin: 8px 0; font-size: 13px;
}
.st-ai-bubble pre code { background: none; padding: 0; color: inherit; }
.st-ai-bubble table {
    border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px;
}
.st-ai-bubble th, .st-ai-bubble td {
    border: 1px solid var(--ai-border); padding: 6px 9px; text-align: left;
}
.st-ai-bubble th { background-color: var(--ai-warm); font-weight: 600; }
.st-ai-bubble blockquote {
    margin: 8px 0; padding-left: 12px;
    border-left: 3px solid var(--ai-border); color: var(--ai-text2);
}

/* 輸入區 */
#st-ai-foot {
    border-top: 1px solid var(--ai-border);
    background-color: var(--ai-card);
    padding: 12px;
    display: flex;
    gap: 9px;
    align-items: flex-end;
}
#st-ai-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    color: var(--ai-text);
    background-color: var(--ai-cream);
    outline: none;
    scrollbar-width: none;        /* Firefox：隱藏捲軸與上下箭頭 */
    -ms-overflow-style: none;     /* 舊版 Edge/IE */
}
#st-ai-input::-webkit-scrollbar { display: none; }  /* Chrome/Edge/Safari */
#st-ai-input:focus { border-color: var(--ai-accent); }
#st-ai-send {
    background-color: var(--ai-accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 18px;
    height: 42px;
    font-size: 14.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}
#st-ai-send:hover:not(:disabled) { background-color: var(--ai-accent2); }
#st-ai-send:disabled { background-color: var(--ai-muted); cursor: default; }

@media (max-width: 480px) {
    #st-ai { right: 16px; bottom: 16px; }
    #st-ai-panel { width: calc(100vw - 32px); height: calc(100vh - 90px); }
}
