/* === 小蜜鋒 全站樣式 === */
:root {
    --bee-yellow: #ffd23f;
    --bee-yellow-deep: #f6b800;
    --bee-black: #1f1f1f;
    --bee-cream: #fff8e1;
    --bee-line: #06c755;        /* LINE 綠 */
    --bee-line-deep: #04a047;
    --bee-grey: #6b6b6b;
    --bee-grey-light: #f4f4f4;
    --bee-danger: #e0413a;
    --bee-shadow: 0 4px 14px rgba(0,0,0,.08);
    --bee-radius: 14px;
    --bee-max-width: 1100px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}
body {
    font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--bee-black);
    background: linear-gradient(180deg, #fff8e1 0%, #ffffff 100%);
    min-height: 100%;
    -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font-family: inherit; }

/* === 全站链接样式 === */
a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
}

/* 全局链接：带颜色和悬停效果 */
a:not([class]) {
    color: var(--bee-yellow-deep);
    font-weight: 500;
    position: relative;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

a:not([class]):hover {
    color: var(--bee-yellow);
    border-bottom-color: var(--bee-yellow);
}

a:not([class]):active {
    opacity: 0.8;
}

/* 主要导航链接 */
a[href*="login"],
a[href*="register"],
a[href*="logout"],
a[href*="admin"] {
    color: var(--bee-yellow-deep);
    font-weight: 600;
}

a[href*="login"]:hover,
a[href*="register"]:hover,
a[href*="logout"]:hover,
a[href*="admin"]:hover {
    color: var(--bee-yellow);
}

/* 聊天页面中的链接 */
.bee-chat-item a {
    color: inherit;
}

.bee-chat-item a:hover {
    color: var(--bee-yellow-deep);
}

/* === 一般容器 === */
/* 因為 html/body 設了 overflow:hidden（為了讓 chat 介面可獨立捲動），
   一般頁面必須讓 .bee-page 自己成為「定高 + 內部捲動」的容器，
   否則內容超過視窗高度時整頁會被裁掉、且無法滾動。 */
.bee-page {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;   /* iOS 慣性滾動 */
    overscroll-behavior: contain;
    padding: 24px 16px 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.bee-card {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: var(--bee-radius);
    box-shadow: var(--bee-shadow);
    padding: 28px 22px;
    margin-top: 24px;
}
.bee-card.lg { max-width: 720px; }

/* === Logo === */
.bee-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 22px;
}
.bee-logo .dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bee-yellow);
    box-shadow: 0 2px 6px rgba(246,184,0,.4);
    font-size: 22px;
}
.bee-logo small {
    color: var(--bee-grey);
    font-weight: 500;
    font-size: 12px;
    margin-left: 4px;
}

/* === 表單 === */
.bee-field { margin-bottom: 16px; }
.bee-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}
.bee-field .required { color: var(--bee-danger); }
.bee-field input,
.bee-field select,
.bee-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
}
.bee-field input:focus,
.bee-field select:focus,
.bee-field textarea:focus {
    outline: none;
    border-color: var(--bee-yellow-deep);
    box-shadow: 0 0 0 3px rgba(255,210,63,.25);
}
.bee-field .hint { color: var(--bee-grey); font-size: 12px; margin-top: 4px; }
.bee-error {
    color: var(--bee-danger);
    font-size: 13px;
    margin-top: 4px;
}
.bee-checkline {
    display: flex; gap: 8px; align-items: flex-start;
    font-size: 14px; color: var(--bee-grey);
}
.bee-checkline input { margin-top: 3px; }

/* === 按鈕 === */
.bee-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .05s ease, box-shadow .15s, background .15s;
}
.bee-btn:active { transform: translateY(1px); }
.bee-btn.primary {
    background: var(--bee-yellow);
    color: var(--bee-black);
    box-shadow: 0 4px 0 var(--bee-yellow-deep);
}
.bee-btn.primary:hover { background: var(--bee-yellow-deep); color:#000; }
.bee-btn.line {
    background: var(--bee-line);
    color: #fff;
    box-shadow: 0 4px 0 var(--bee-line-deep);
}
.bee-btn.line:hover { background: var(--bee-line-deep); }
.bee-btn.ghost {
    background: #fff;
    color: var(--bee-black);
    border: 1.5px solid #e3e3e3;
}
.bee-btn.danger {
    background: var(--bee-danger);
    color: #fff;
}
.bee-btn.sm { padding: 8px 14px; font-size: 14px; }
.bee-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* === 頁面標題 === */
.bee-title { font-size: 22px; font-weight: 900; margin: 16px 0 6px; }
.bee-subtitle { color: var(--bee-grey); font-size: 14px; margin-bottom: 18px; }

/* === 進度步驟條（註冊流程） === */
.bee-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 22px;
}
@media (min-width: 720px) {
    .bee-stepper { gap: 14px; margin: 10px 0 28px; }
    .bee-stepper .step { min-width: 96px; }
    .bee-stepper .step .num { width: 38px; height: 38px; font-size: 16px; }
    .bee-stepper .step .label { font-size: 13px; }
    .bee-stepper .bar { margin-top: 19px; }
}
.bee-stepper .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 64px;
}
.bee-stepper .step .num {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 14px;
    background: #f0f0f0;
    color: var(--bee-grey);
    border: 2px solid #e3e3e3;
    transition: all .2s;
}
.bee-stepper .step .label {
    font-size: 12px;
    color: var(--bee-grey);
    white-space: nowrap;
    font-weight: 500;
}
.bee-stepper .step.done .num {
    background: var(--bee-yellow);
    color: var(--bee-black);
    border-color: var(--bee-yellow-deep);
}
.bee-stepper .step.done .label { color: var(--bee-black); }
.bee-stepper .step.active .num {
    background: var(--bee-yellow);
    color: var(--bee-black);
    border-color: var(--bee-yellow-deep);
    box-shadow: 0 0 0 4px rgba(255,210,63,.25);
    transform: scale(1.05);
}
.bee-stepper .step.active .label {
    color: var(--bee-black);
    font-weight: 700;
}
.bee-stepper .bar {
    flex: 1 1 auto;
    height: 2px;
    background: #e3e3e3;
    border-radius: 2px;
    margin: -16px 0 0;  /* 對齊圓點中線 */
    align-self: flex-start;
    margin-top: 16px;
}
.bee-stepper .bar.done { background: var(--bee-yellow-deep); }

/* === LINE 個人資訊小卡（顯示已綁定的 LINE 帳號） === */
.bee-line-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    margin-bottom: 20px;
}
.bee-line-chip img,
.bee-line-chip .ph {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bee-line);
    color: #fff;
    display: inline-flex;
    align-items: center; justify-content: center;
    font-weight: 700;
    flex: 0 0 auto;
    object-fit: cover;
}
.bee-line-chip .meta { flex: 1; min-width: 0; line-height: 1.4; }
.bee-line-chip .meta .top {
    font-size: 12px;
    color: var(--bee-line-deep);
    font-weight: 600;
    letter-spacing: .5px;
}
.bee-line-chip .meta .name {
    font-weight: 700;
    color: var(--bee-black);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === 表單區塊（將欄位分組） === */
.bee-section {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 16px 16px 4px;
    margin-bottom: 16px;
    background: #fafafa;
}
.bee-section + .bee-section { margin-top: 4px; }
.bee-section .sec-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
}
.bee-section .sec-head .icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--bee-yellow);
    display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 14px;
}
.bee-section .sec-head .title {
    font-weight: 700;
    font-size: 15px;
}
.bee-section .sec-head .desc {
    color: var(--bee-grey);
    font-size: 12px;
    margin-left: 4px;
}

/* 同一列放兩個欄位 */
.bee-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .bee-row { grid-template-columns: 1fr; gap: 0; }
}

/* === 桌面版加寬的卡片（給註冊類較複雜的表單用） === */
@media (min-width: 720px) {
    .bee-card.bee-card--wide {
        max-width: 760px;
        padding: 36px 40px;
    }
    .bee-card.bee-card--wide .bee-title { font-size: 26px; }
    .bee-card.bee-card--wide .bee-subtitle { font-size: 15px; }
    .bee-card.bee-card--wide .bee-section { padding: 18px 20px 6px; }
    .bee-card.bee-card--wide .sec-head .title { font-size: 16px; }
}

/* === 表單分組 2 欄佈局（桌面才開啟） === */
.bee-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.bee-form-grid > .bee-section { margin-bottom: 0; }

@media (min-width: 720px) {
    .bee-form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        align-items: start;       /* 兩欄高度可不相同 */
    }
    .bee-form-grid > .bee-section--full {
        grid-column: 1 / -1;       /* 跨整列 */
    }
}

/* 欄位錯誤態 */
.bee-field input.has-error,
.bee-field select.has-error,
.bee-field textarea.has-error {
    border-color: var(--bee-danger);
    box-shadow: 0 0 0 3px rgba(224,65,58,.15);
}

/* === 註冊頁：李鋒文教補習科目（複選） chip 樣式 === */
.bee-subject-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}
@media (max-width: 480px) {
    .bee-subject-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }
}
.bee-subject-grid.has-error {
    padding: 6px;
    border: 1px solid var(--bee-danger);
    border-radius: 10px;
    background: rgba(224,65,58,.04);
}
.bee-subject-chip {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 4px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    background: #fff;
    font-size: 18px;
    font-weight: 800;
    color: #1a1f1f;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}
.bee-subject-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
/* 勾選圖示：未勾選時為灰色空框；勾選後變綠色 ✓ */
.bee-subject-chip .chip-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #d6d6d6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    color: transparent;
    transition: all 0.15s ease;
    pointer-events: none;
}
.bee-subject-chip:hover {
    border-color: var(--bee-yellow);
    background: #fffbf0;
    transform: translateY(-1px);
}
.bee-subject-chip:hover .chip-check {
    border-color: var(--bee-yellow);
}
.bee-subject-chip:has(input:checked) {
    border-color: var(--bee-yellow-deep);
    background: var(--bee-yellow);
    color: #1a1f1f;
    box-shadow: 0 2px 6px rgba(246,184,0,0.35);
}
.bee-subject-chip:has(input:checked) .chip-check {
    background: #1a8a3a;
    border-color: #1a8a3a;
    color: #fff;
}
.bee-subject-chip:has(input:focus-visible) {
    outline: 2px solid var(--bee-yellow-deep);
    outline-offset: 2px;
}

/* 同意卡片內的法律條款連結 */
.bee-agree-card .legal-link {
    color: #b87900;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.bee-agree-card .legal-link:hover {
    color: #8a5a00;
    text-decoration-thickness: 2px;
}

/* 提交按鈕區 */
.bee-submit-row {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bee-submit-row .note {
    text-align: center;
    color: var(--bee-grey);
    font-size: 12px;
}

/* === 同意條款高亮卡片 ===
   把原本不起眼的 checkbox 包成一張黃底的可點擊卡片,
   並用自訂大尺寸勾選框（appearance:none）讓使用者一眼就看到要勾選。 */
.bee-agree-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    margin: 18px 0 0;
    background: #fffdf0;
    border: 2px solid #ffe88a;
    border-radius: 14px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    box-shadow: 0 2px 8px rgba(246,184,0,.10);
    position: relative;
    animation: beeAgreePulse 2.4s ease-in-out 1.6s 2;
}
.bee-agree-card:hover {
    border-color: var(--bee-yellow-deep);
    box-shadow: 0 4px 14px rgba(246,184,0,.20);
}
.bee-agree-card:active { transform: translateY(1px); }

.bee-agree-card .agree-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--bee-black);
}
.bee-agree-card .agree-text .lead {
    display: inline-block;
    font-weight: 800;
    margin-right: 2px;
    color: var(--bee-yellow-deep);
}

/* 放大的自訂勾選框（保留 native input,確保表單驗證仍由瀏覽器處理） */
.bee-agree-check {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    margin: 0;
    background: #fff;
    border: 2.5px solid #d0d0d0;
    border-radius: 9px;
    cursor: pointer;
    position: relative;
    transition: background .15s, border-color .15s, transform .1s;
}
.bee-agree-check:hover {
    border-color: var(--bee-yellow-deep);
    background: #fffbe6;
}
.bee-agree-check:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255,210,63,.35);
}
.bee-agree-check:checked {
    background: var(--bee-yellow);
    border-color: var(--bee-yellow-deep);
}
.bee-agree-check:checked::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 3px;
    width: 9px;
    height: 16px;
    border-right: 3px solid var(--bee-black);
    border-bottom: 3px solid var(--bee-black);
    transform: rotate(45deg);
}

/* 已勾選時,整張卡片變綠（確認感） */
.bee-agree-card:has(.bee-agree-check:checked) {
    background: #f0fdf4;
    border-color: #86efac;
    box-shadow: 0 2px 8px rgba(34,197,94,.12);
    animation: none;
}
.bee-agree-card:has(.bee-agree-check:checked) .agree-text .lead {
    color: #15803d;
}
.bee-agree-card:has(.bee-agree-check:checked) .bee-agree-check {
    background: #22c55e;
    border-color: #16a34a;
}
.bee-agree-card:has(.bee-agree-check:checked) .bee-agree-check::after {
    border-color: #fff;
}

/* 載入時的吸引注意脈動（兩下後停止） */
@keyframes beeAgreePulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(246,184,0,.10); }
    50%      { box-shadow: 0 0 0 6px rgba(255,210,63,.30), 0 4px 14px rgba(246,184,0,.25); }
}

/* 桌面版稍大一些 */
@media (min-width: 720px) {
    .bee-agree-card {
        padding: 16px 22px;
        gap: 16px;
    }
    .bee-agree-card .agree-text { font-size: 15px; }
}

/* 尊重使用者「減少動畫」偏好 */
@media (prefers-reduced-motion: reduce) {
    .bee-agree-card { animation: none; }
}

/* === 訊息提示 === */
.bee-flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
}
.bee-flash.info  { background: #eef6ff; color:#0b3d91; }
.bee-flash.warn  { background: #fff4d6; color:#8a5a00; }
.bee-flash.error { background: #fde4e2; color:#7a1a16; }

/* ========================================== */
/* === 聊天主畫面 layout (mobile-first) === */
/* ========================================== */
.bee-shell {
    height: 100%;
    height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    overflow: hidden;
}
.bee-sidebar {
    display: none;
    background: #fff;
    border-right: 1px solid #eee;
    padding: 16px 12px;
    overflow-y: auto;
}
.bee-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    background: #fff;
    overflow: hidden;
}
.bee-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #f0e8c2;
    flex-shrink: 0;
    z-index: 5;
}
.bee-topbar .left, .bee-topbar .right { display: flex; align-items: center; gap: 8px; }
.bee-topbar .icon-btn {
    border: none; background: transparent; padding: 8px;
    border-radius: 8px; cursor: pointer; font-size: 20px;
}
.bee-topbar .icon-btn:hover { background: var(--bee-grey-light); }

.bee-chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    overscroll-behavior-y: auto;
    background: #fff;
}
.bee-bubble {
    width: 100%;
    max-width: 100%;
    padding: 8px 0;
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
    font-size: 16px;
    background: transparent;
    border: none;
    position: relative;
}
.bee-bubble.user {
    padding-top: 16px;
    padding-bottom: 8px;
    margin-bottom: 0;
}
.bee-bubble.assistant {
    border-bottom: 1.5px solid #eee;
    padding-top: 20px;
    padding-bottom: 24px;
    margin-bottom: 4px;
}
.bee-bubble:last-child {
    border-bottom: none;
}
.bee-bubble .bubble-title {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-weight: 900 !important;
    font-size: 18px !important;
    margin-bottom: 12px !important;
    color: var(--bee-black) !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.9;
    line-height: 1.2;
    white-space: nowrap;
}
.bee-bubble.user .bubble-title::before { content: '❓'; margin-right: 0; }
.bee-bubble.assistant .bubble-title::before { content: '💡'; margin-right: 0; }

/* 管理者專用：模型與 token 資訊 pill */
.admin-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 10px;
    background: #f0f4ff;
    border: 1px solid #c9d6f5;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: #3a5ab8;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
    opacity: 1;
}
.admin-meta-model {
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
    color: #2a4aa0;
}
.admin-meta-sep {
    color: #93a8e0;
    font-size: 10px;
}
.bee-bubble .user-content,
.bee-bubble .assistant-content {
    margin-top: 8px;
    white-space: pre-wrap;
    line-height: 1.6;
}
.bee-bubble .assistant-content {
    font-size: 16px;
}
.bee-bubble .att {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 4px;
}
.bee-bubble .att img {
    max-width: 100%; max-height: 350px;
    border-radius: 10px; border: 1px solid #eee;
    margin-top: -2px;
}
.bee-bubble .att .file {
    background: rgba(0,0,0,.06);
    padding: 6px 10px; border-radius: 8px;
    font-size: 13px;
}

.bee-empty {
    text-align: center;
    color: var(--bee-grey);
    margin: 40px auto;
    max-width: 320px;
}
.bee-empty .big { font-size: 64px; margin-bottom: 10px; }
.bee-empty h3 { color: var(--bee-black); margin: 0 0 6px; }

/* === 輸入區 === */
.bee-composer {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #f0e8c2;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}
.bee-attach-preview {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 8px;
}

/* === 今日提問配額指示 === */
.quota-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}
.quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    background: #fff8e1;
    color: #7a5b00;
    border: 1px solid #ffe88a;
    line-height: 1.4;
    transition: background .2s, color .2s, border-color .2s;
}
.quota-pill strong { font-weight: 800; }
.quota-pill--low {
    background: #fff1e6;
    color: #c2410c;
    border-color: #fdba74;
}
.quota-pill--full {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.quota-pill--unlim {
    background: #ecfdf5;
    color: #15803d;
    border-color: #86efac;
}
.bee-attach-preview .item {
    position: relative; padding: 6px 28px 6px 10px;
    background: var(--bee-cream); border-radius: 10px;
    font-size: 12px; max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border: 1px solid #f0e8c2;
}
.bee-attach-preview .item img {
    max-height: 36px; vertical-align: middle; border-radius: 4px; margin-right: 6px;
}
.bee-attach-preview .item .x {
    position: absolute; right: 4px; top: 4px;
    background: rgba(0,0,0,.5); color: #fff;
    border-radius: 50%; width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer;
}

.bee-input-row {
    display: flex; gap: 8px; align-items: flex-end;
}
.bee-input-row textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    border: 1.5px solid #e3e3e3;
    border-radius: 18px;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    background: #fff;
}
.bee-input-row textarea:focus {
    outline: none;
    border-color: var(--bee-yellow-deep);
}
.bee-input-row .icon-btn {
    width: 44px; height: 44px;
    border: 1.5px solid #e3e3e3;
    background: #fff;
    border-radius: 50%;
    cursor: pointer; font-size: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 44px;
}
.bee-input-row .icon-btn:hover { background: var(--bee-cream); }
.bee-input-row .send-btn {
    width: 44px; height: 44px;
    border: none;
    background: var(--bee-yellow);
    color: var(--bee-black);
    border-radius: 50%; cursor: pointer; font-size: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 44px;
}
.bee-input-row .send-btn:hover { background: var(--bee-yellow-deep); }
.bee-input-row .send-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* === 側邊對話列表（行動版用 drawer） === */
.bee-drawer {
    position: fixed; inset: 0; z-index: 20;
    display: none;
}
.bee-drawer.open { display: block; }
.bee-drawer .mask {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.4);
}
.bee-drawer .panel {
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 84%; max-width: 320px;
    background: #fff;
    box-shadow: 4px 0 16px rgba(0,0,0,.15);
    display: flex; flex-direction: column;
}
.bee-drawer .panel header {
    padding: 14px 14px 8px;
    border-bottom: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
}
.bee-drawer .panel .body { flex: 1; overflow-y: auto; padding: 8px; }
.bee-drawer .panel .footer { padding: 12px; border-top: 1px solid #eee; }
.bee-chat-item {
    padding: 10px 12px;
    border-radius: 10px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 4px;
    font-size: 14px;
}
.bee-chat-item:hover { background: var(--bee-cream); }
.bee-chat-item.active { background: var(--bee-cream); border: 1px solid var(--bee-yellow-deep); }
/* 舊版 .title（保留向下相容） */
.bee-chat-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 新版：科目 badge + 標題兩列 */
.bee-chat-item-body {
    flex: 1; min-width: 0; overflow: hidden;
}
.bee-chat-subject-row {
    margin-bottom: 3px;
}
.bee-subject-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    white-space: nowrap;
}
.bee-chat-title {
    font-size: 13px; color: #1a1f1f;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bee-chat-title.muted { color: #bbb; font-style: italic; }
.bee-chat-item .del {
    color: #999; font-size: 14px; padding: 2px 6px; border-radius: 6px;
    flex-shrink: 0; margin-top: 1px;
}
.bee-chat-item .del:hover { background: rgba(224,65,58,.1); color: var(--bee-danger); }

/* loading dots */
.bee-typing {
    display: inline-flex; gap: 4px;
    padding: 16px 0;
    background: transparent; border: none;
}
.bee-typing span {
    width: 7px; height: 7px;
    background: var(--bee-yellow-deep);
    border-radius: 50%;
    animation: typing 1.2s infinite ease-in-out both;
}
.bee-typing span:nth-child(2) { animation-delay: .15s; }
.bee-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,80%,100% {opacity:.3; transform:translateY(0)} 40% {opacity:1; transform:translateY(-3px)} }

/* === Markdown 簡單樣式 === */
.bee-md p { margin: 0; font-size: 16px; }
.bee-md p:first-child { margin-top: 0; }

/* === KaTeX 公式對齐 === */
.bee-md .katex-display {
    display: block !important;
    text-align: left !important;
    margin: 8px 0 !important;
}
.bee-md div > .katex-display {
    text-align: left !important;
}
.katex-display {
    text-align: left !important;
}
.bee-md p > .katex,
.bee-md span > .katex {
    text-align: left !important;
}
.bee-md .katex {
    font-size: 0.95em;
}

/* === SVG 圖形尺寸限制與間距 === */
/* 全局 SVG 規則 - 最高優先級 */
svg {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
    display: block !important;
    margin: 20px auto !important;
}

.bee-md svg {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
    display: block !important;
    margin: 20px auto !important;
    aspect-ratio: auto !important;
}

.bee-bubble svg {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
}

/* 確保 SVG 在助手回覆中被正確顯示 */
.assistant-content svg {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
}

/* 強制覆蓋內聯樣式和 HTML 屬性 */
svg[style] {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
}

/* 針對帶 width 屬性的 SVG */
svg[width] {
    width: 85% !important;
    height: auto !important;
    max-width: 720px !important;
    max-height: 600px !important;
}

.bee-md p + svg,
svg + .bee-md p {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
}

/* SVG 容器 - 不設定固定高度 */
.bee-bubble div[style*="display: flex"][style*="minHeight"] svg {
    max-width: 95% !important;
    height: auto !important;
}

.bee-md h1 {
    font-size: 19px;
    font-weight: 800;
    margin: 12px 0 8px 0;
    color: var(--bee-black);
}
.bee-md h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 10px 0 6px 0;
    color: var(--bee-black);
}
.bee-md h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: var(--bee-black);
}
.bee-md h4, .bee-md h5, .bee-md h6 {
    font-size: 16px;
    font-weight: 600;
    margin: 6px 0 4px 0;
    color: var(--bee-black);
}
.bee-md ul, .bee-md ol { margin: 0 0 0 18px; font-size: 16px; }
.bee-md li { margin: 4px 0; }
.bee-md pre {
    background: #1f1f1f; color: #f8f8f2;
    padding: 8px 12px; border-radius: 8px;
    overflow-x: auto; font-size: 14px; line-height: 1.4;
    margin: 4px 0;
}
.bee-md code {
    background: rgba(0,0,0,.06);
    padding: 1px 4px; border-radius: 4px;
    font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
    font-size: 14px;
}
.bee-md pre code { background: transparent; padding: 0; color: inherit; }
.bee-md blockquote {
    border-left: 3px solid var(--bee-yellow);
    padding: 2px 10px; margin: 4px 0; color: var(--bee-grey);
    font-size: 16px;
}
.bee-md table { border-collapse: collapse; margin: 4px 0; }
.bee-md th, .bee-md td { border: 1px solid #ddd; padding: 4px 8px; font-size: 15px; }

/* === 桌面版 === */
@media (min-width: 900px) {
    .bee-shell {
        grid-template-columns: 280px 1fr;
    }
    .bee-sidebar {
        display: flex; flex-direction: column;
        height: 100%;
    }
    .bee-topbar .menu-btn { display: none; }
    .bee-bubble { max-width: 100%; }
}

/* === Admin 版型 === */
.admin-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    background: #f5f6f9;
}

/* 隱形滾軸設計 - 默認隱形，懸停時出現 */
.admin-content::-webkit-scrollbar {
    width: 6px;
}
.admin-content::-webkit-scrollbar-track {
    background: transparent;
}
.admin-content::-webkit-scrollbar-thumb {
    background: rgba(180, 180, 180, 0);
    border-radius: 3px;
    transition: background 0.3s ease;
}
.admin-content::-webkit-scrollbar-thumb:hover {
    background: rgba(180, 180, 180, 0.5);
}
.admin-content::-webkit-scrollbar-thumb:active {
    background: rgba(160, 160, 160, 0.7);
}

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    color: #1f1f1f;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.admin-topbar .bee-logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--bee-yellow-deep);
    flex-shrink: 0;
}

.admin-topbar nav {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* 使用者區塊推到最右側 */
.admin-topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.admin-topbar__name {
    font-size: 13px;
    color: #1f1f1f;
    font-weight: 500;
    white-space: nowrap;
}

.admin-topbar a.tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(31, 31, 31, 0.6);
    text-decoration: none;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    line-height: 1;
}

.admin-topbar a.tab:hover {
    color: #1f1f1f;
    background: rgba(0, 0, 0, 0.03);
}

.admin-topbar a.tab.active {
    color: var(--bee-yellow-deep);
    border-color: var(--bee-yellow-deep);
    background: rgba(255, 210, 63, 0.08);
}

.admin-topbar a.tab .badge {
    margin-left: 0;
    animation: pulse 2s infinite;
    vertical-align: middle;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === 後台導覽列：手機版（logo + 使用者同一行，導覽分頁第二行可橫向捲動） === */
@media (max-width: 700px) {
    .admin-topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 14px;
    }
    .admin-topbar .bee-logo {
        font-size: 16px;
        letter-spacing: 0;
    }
    .admin-topbar .bee-logo small {
        display: none;
    }
    .admin-topbar__user {
        gap: 8px;
    }
    .admin-topbar__name {
        max-width: 40vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* 導覽分頁獨佔下方，自動換行全部攤開（不橫向捲動，避免項目被遮蔽） */
    .admin-topbar nav {
        order: 3;
        flex-basis: 100%;
        width: 100%;
        flex-wrap: wrap;
        row-gap: 4px;
        gap: 4px;
    }
    .admin-topbar a.tab {
        padding: 7px 10px;
        font-size: 13px;
        border-radius: 6px;
    }
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 28px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    background: #f5f6f9;
}

.admin-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    color: #1f1f1f;
    transition: all 0.2s ease;
}

.admin-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.admin-card h3 {
    color: #1f1f1f;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 18px;
    letter-spacing: 0.5px;
}

.admin-stat-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 24px;
}

.admin-stat-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.admin-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--bee-yellow), transparent);
}

.admin-stat-card:hover {
    border-color: #d8d8d8;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.admin-stat-card h4 {
    margin: 0 0 12px;
    color: var(--bee-grey);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-stat-card .num {
    font-size: 32px;
    font-weight: 900;
    color: var(--bee-yellow-deep);
    line-height: 1;
    margin-bottom: 8px;
}

.admin-stat-card > div:last-child {
    font-size: 12px;
    color: var(--bee-grey);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    color: #1f1f1f;
}

.admin-table th {
    background: #f9f9f9;
    color: #1f1f1f;
    text-align: left;
    padding: 14px 16px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e8e8e8;
}

.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.admin-table tbody tr {
    transition: all 0.2s ease;
    background: transparent;
}

.admin-table tbody tr:hover {
    background: #f9f9f9;
    border-left: 3px solid var(--bee-yellow-deep);
}

.admin-table a {
    color: var(--bee-yellow-deep);
    font-weight: 500;
    transition: all 0.2s ease;
}

.admin-table a:hover {
    color: var(--bee-yellow);
}
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.pending {
    background: #fff4d6;
    color: #8a5a00;
    border: none;
}

.badge.approved {
    background: #e1f7d8;
    color: #1d6c0e;
    border: none;
}

.badge.rejected {
    background: #fde4e2;
    color: #7a1a16;
    border: none;
}

.badge.suspended {
    background: #e8e8e8;
    color: #666;
    border: none;
}

.badge.admin {
    background: #fff8e1;
    color: var(--bee-yellow-deep);
    border: none;
}

/* === 使用者列表：合併欄位的版面樣式 === */
.badge.role-admin   { background:#f59e0b; color:#fff; text-transform:none; padding:3px 8px; font-size:11px; letter-spacing:0; }
.badge.role-student { background:#3b82f6; color:#fff; text-transform:none; padding:3px 8px; font-size:11px; letter-spacing:0; }

.user-cell { line-height: 1.45; }
.user-cell__top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.user-cell__top strong { font-size: 14px; color: #1a1f1f; }
.user-cell__sub,
.cell-sub {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.cell-sub code,
.user-cell__sub code {
    background: #f4f4f4;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}
.contact-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

/* 今日提問 pill */
.usage-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #f4f4f4;
    color: #555;
    border: 1px solid #e0e0e0;
    line-height: 1.4;
    min-width: 56px;
    text-align: center;
}
.usage-pill--ok      { background:#ecfdf5; color:#15803d; border-color:#86efac; }
.usage-pill--low     { background:#fff7ed; color:#c2410c; border-color:#fdba74; }
.usage-pill--full    { background:#fee2e2; color:#b91c1c; border-color:#fca5a5; }
.usage-pill--unlim   { background:#eef2ff; color:#4338ca; border-color:#c7d2fe; }
.usage-pill--admin   { background:#fffbeb; color:#92400e; border-color:#fcd34d; }
.usage-pill--blocked { background:#1f1f1f; color:#fff; border-color:#1f1f1f; }

/* 手機版調整：聯絡 cell 不再限寬 */
@media (max-width: 700px) {
    .contact-cell { max-width: none; white-space: normal; }
}

/* === Row 操作下拉選單（kebab 樣式） === */
.row-actions {
    position: relative;
    display: inline-block;
}
.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: #555;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s, color .15s;
    padding: 0;
}
.action-btn:hover,
.action-btn[aria-expanded="true"] {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #1a1f1f;
}
.action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,210,63,.35);
}

.action-menu {
    list-style: none;
    margin: 6px 0 0;
    padding: 5px;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    z-index: 50;
    animation: actionMenuIn .12s ease-out;
}
@keyframes actionMenuIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.action-menu[hidden] { display: none; }
.action-menu li { list-style: none; margin: 0; padding: 0; }
.action-menu .separator {
    height: 1px;
    background: #eee;
    margin: 4px 4px;
}
.action-menu a,
.action-menu button,
.action-menu form button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 13.5px;
    color: #1a1f1f;
    border-radius: 7px;
    text-decoration: none;
    font-weight: 500;
    line-height: 1.3;
    transition: background .12s, color .12s;
}
.action-menu a:hover,
.action-menu button:hover {
    background: #f6f6f6;
}
.action-menu .item-icon {
    width: 18px;
    text-align: center;
    flex: 0 0 18px;
    font-size: 14px;
}
.action-menu .danger {
    color: #b91c1c;
}
.action-menu .danger:hover {
    background: #fee2e2;
    color: #991b1b;
}

/* 表格 cell 內的 form 不要產生多餘的 margin */
.action-menu form { margin: 0; display: block; }

/* 手機版：菜單置中對齊 cell 右側 */
@media (max-width: 700px) {
    .action-menu {
        right: auto;
        left: 0;
        min-width: 200px;
    }
}

/* ============================================================
   使用者詳細頁 (admin/users/{id}) — Hero / Info / 等等
   ============================================================ */

/* 返回 / breadcrumb 列 */
.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--bee-grey);
    font-size: 13px;
    margin-bottom: 12px;
    text-decoration: none;
    transition: color .15s;
}
.detail-back:hover { color: var(--bee-yellow-deep); }

/* Hero 卡片：頭像 + 名稱 + meta + 動作 */
.user-hero {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
}
.user-hero__main {
    display: flex;
    gap: 18px;
    align-items: center;
    flex: 1;
    min-width: 280px;
}
.user-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    flex: 0 0 72px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--bee-yellow), var(--bee-yellow-deep));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 900;
    color: #1f1f1f;
    box-shadow: 0 4px 12px rgba(246,184,0,.25);
    overflow: hidden;
}
.user-hero__info { flex: 1; min-width: 0; }
.user-hero__name {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    line-height: 1.2;
}
.user-hero__meta {
    color: var(--bee-grey);
    font-size: 13px;
    margin: 0;
    line-height: 1.7;
}
.user-hero__meta .sep { margin: 0 8px; opacity: .5; }

/* 動作按鈕工具列(右上) */
.user-hero__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    background: #fff;
    color: #374151;
    transition: background .12s, border-color .12s, color .12s, transform .05s;
    text-decoration: none;
}
.btn-tool:hover  { background: #f6f6f6; }
.btn-tool:active { transform: translateY(1px); }
.btn-tool .ic { font-size: 14px; }

.btn-tool--primary {
    background: var(--bee-yellow);
    color: #1f1f1f;
    border-color: var(--bee-yellow-deep);
    box-shadow: 0 2px 0 var(--bee-yellow-deep);
}
.btn-tool--primary:hover { background: var(--bee-yellow-deep); }
.btn-tool--ghost {
    background: #fff;
    border-color: #e5e7eb;
}
.btn-tool--danger {
    background: #fff;
    color: #b91c1c;
    border-color: #fca5a5;
}
.btn-tool--danger:hover { background: #fef2f2; }
.btn-tool--warn {
    background: #fff;
    color: #c2410c;
    border-color: #fdba74;
}
.btn-tool--warn:hover { background: #fff7ed; }

/* 用 form 包按鈕時去掉 form 的多餘 margin */
.user-hero__actions form { margin: 0; display: inline-block; }

/* 帳號資訊：2 欄定義列 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4px 28px;
}
.info-grid .item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f3f3f3;
    font-size: 14px;
    line-height: 1.5;
}
.info-grid .item:last-child { border-bottom: none; }
.info-grid .label {
    color: var(--bee-grey);
    font-size: 12px;
    flex: 0 0 90px;
    font-weight: 600;
}
.info-grid .value {
    flex: 1;
    color: #1f1f1f;
    word-break: break-all;
}
.info-grid .value code {
    background: #f4f4f4;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.info-grid .empty { color: #bbb; }

/* 每日上限：radio 卡片 */
.limit-radio-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.limit-radio {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: all .15s;
    position: relative;
}
.limit-radio:hover {
    border-color: var(--bee-yellow-deep);
    background: #fffdf5;
}
.limit-radio input[type=radio] { margin: 0; flex: 0 0 auto; accent-color: var(--bee-yellow-deep); transform: scale(1.2); }
.limit-radio:has(input[type=radio]:checked) {
    border-color: var(--bee-yellow-deep);
    background: #fffbeb;
    box-shadow: 0 0 0 3px rgba(255,210,63,.18);
}
.limit-radio .title { font-weight: 700; font-size: 14px; color: #1f1f1f; }
.limit-radio .desc { color: var(--bee-grey); font-size: 12px; margin-top: 2px; }
.limit-radio .input-inline {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    margin-left: 4px;
}
.limit-radio .body { flex: 1; }
.limit-radio .body .inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }

/* 統計卡片強化 */
.admin-stat-card.with-icon {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 14px;
    align-items: center;
}
.admin-stat-card .icon-box {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #fff8e1 0%, #fef3c7 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex: 0 0 44px;
}
.admin-stat-card .stat-num {
    font-size: 24px;
    font-weight: 900;
    color: #1f1f1f;
    line-height: 1.1;
}
.admin-stat-card .stat-num-sm {
    font-size: 18px;
}
.admin-stat-card .stat-label {
    font-size: 11px;
    color: var(--bee-grey);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 4px;
}

/* 區塊小標題（card heading） */
.card-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 800;
    color: #1f1f1f;
}
.card-heading .pill {
    margin-left: 6px;
    background: #f4f4f4;
    color: #555;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

/* 對話列表 cell 內的 title 加粗 */
.chat-title-cell {
    font-weight: 600;
    color: #1f1f1f;
}
.chat-title-cell .sub {
    font-size: 12px;
    color: var(--bee-grey);
    font-weight: 400;
    margin-top: 2px;
}

/* 手機版調整 */
@media (max-width: 700px) {
    .user-hero { gap: 16px; }
    .user-hero__main { width: 100%; }
    .user-hero__actions { width: 100%; justify-content: stretch; }
    .user-hero__actions > * { flex: 1 1 auto; justify-content: center; }
    .info-grid { grid-template-columns: 1fr; gap: 0; }
}

/* responsive table → cards on phone */
@media (max-width: 700px) {
    .admin-table thead {
        display: none;
    }

    .admin-table tr {
        display: block;
        background: #fff;
        border: 1px solid #e8e8e8;
        margin-bottom: 12px;
        border-radius: 10px;
        padding: 14px;
    }

    .admin-table tr:hover {
        background: #f9f9f9;
        border-color: #d8d8d8;
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        border: none;
        padding: 8px 0;
        color: #1f1f1f;
    }

    .admin-table td::before {
        content: attr(data-label);
        color: var(--bee-grey);
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
    }

    .admin-stat-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .admin-stat-card .num {
        font-size: 24px;
    }

    .admin-content {
        padding: 16px;
    }

    .admin-card {
        padding: 16px;
    }
}

/* === 改进的附件预览样式（手机相簿优化） === */
.attach-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    background: var(--bee-cream);
    border: 1px solid #f0e8c2;
    border-radius: 10px;
    font-size: 12px;
    color: var(--bee-grey);
    min-width: 80px;
    max-width: 100px;
    overflow: hidden;
    text-align: center;
}

.attach-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 4px;
}

.attach-item div {
    font-size: 24px;
    margin-bottom: 4px;
    line-height: 1;
}

.attach-size {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

.attach-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #e0413a;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.attach-remove:hover {
    background: #c1372e;
    transform: scale(1.1);
}

/* 优化手机上的附件预览滚动 */
.bee-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    padding: 4px 0;
    max-height: 150px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* === 输入框响应式优化 === */
.bee-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.bee-input-row textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    border: 1.5px solid #e3e3e3;
    border-radius: 18px;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.bee-input-row textarea:focus {
    outline: none;
    border-color: var(--bee-yellow-deep);
    box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.15);
}

/* 改进的圆形图标按钮 */
.bee-input-row .icon-btn {
    width: 44px;
    height: 44px;
    border: 1.5px solid #e3e3e3;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    -webkit-touch-callout: none;
}

.bee-input-row .icon-btn:active {
    transform: scale(0.95);
    background: var(--bee-cream);
}

.bee-input-row .icon-btn:not(:disabled) {
    cursor: pointer;
}

.bee-input-row .send-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #ffd23f 0%, #f6b800 100%);
    color: var(--bee-black);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(246, 184, 0, 0.3);
    -webkit-appearance: none;
    appearance: none;
}

.bee-input-row .send-btn:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(246, 184, 0, 0.2);
}

.bee-input-row .send-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === 移动端输入优化（解决iOS问题） === */
@media (max-width: 600px) {
    .bee-composer {
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    }

    .bee-input-row {
        gap: 6px;
    }

    .bee-input-row textarea {
        min-height: 40px;
        font-size: 16px;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 16px;
    }

    .bee-input-row .icon-btn,
    .bee-input-row .send-btn {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
    }

    /* 防止输入框被键盘遮挡 */
    body.keyboard-active {
        position: fixed;
        width: 100%;
        overflow: hidden;
    }

    /* 确保消息列表在键盘打开时也能正确滚动 */
    .bee-chat-list {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
}

/* === 桌面端样式 === */
@media (min-width: 900px) {
    .bee-input-row .icon-btn:hover {
        background: var(--bee-cream);
        border-color: var(--bee-yellow-deep);
    }

    .bee-input-row .send-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(246, 184, 0, 0.4);
    }
}

/* ============================================================ */
/* === 手機版橫向溢出修復（chat 頁面 學生提問 / AI 解答） === */
/* 目的：避免長公式、長 URL、寬表格、長標題造成畫面左右可滑動 */
/* ============================================================ */

/* 1. 主容器強制不允許橫向滾動 */
.bee-shell,
.bee-main,
.bee-chat-list {
    max-width: 100%;
    overflow-x: hidden;
}

/* 2. 對話氣泡：強制不超出寬度，並允許在任意處斷行 */
.bee-bubble {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 3. 訊息內文（學生提問 / AI 解答）長字串、長英文、URL 都要能斷行 */
.bee-bubble .user-content,
.bee-bubble .assistant-content {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 4. 標題（bubble-title）取消 nowrap，避免 admin pill 撐爆寬度 */
.bee-bubble .bubble-title {
    flex-wrap: wrap;
    white-space: normal;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.admin-meta-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 5. Markdown 區塊：表格、pre/code、blockquote、圖片都不能超出 */
.bee-md {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.bee-md p,
.bee-md li,
.bee-md blockquote {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 6. 寬表格：包進可橫向滾動的容器（自身滾，不撐版面） */
.bee-md table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 7. pre / code：已是 overflow-x:auto，再加一道保險 */
.bee-md pre {
    max-width: 100%;
    overflow-x: auto;
}
.bee-md code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 8. MathJax 公式：display math 改成可橫向滾動的區塊，避免撐爆畫面 */
.bee-md mjx-container[display="true"],
.bee-md .MathJax,
.bee-md .MathJax_Display,
.bee-bubble mjx-container[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
/* MathJax 行內公式不需橫向滾，但要允許在外層斷行 */
.bee-md mjx-container:not([display="true"]) {
    max-width: 100%;
}

/* 9. 圖片、SVG 都不能超過容器 */
.bee-bubble img,
.bee-bubble .att img,
.bee-bubble svg,
.bee-md img,
.bee-md svg {
    max-width: 100% !important;
    height: auto !important;
}

/* 10. 行動裝置上加強：頁面整體禁止橫向滾動 */
@media (max-width: 768px) {
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }
    .bee-bubble {
        font-size: 15px;
    }
    .bee-bubble .bubble-title {
        font-size: 16px !important;
    }
}

/* === 小蜜鋒 自製分頁元件（admin 後台 / 列表頁） ===================== */
.bee-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}
.bee-pagination__info {
    color: #777;
    font-size: 13px;
}
.bee-pagination__info span {
    color: var(--bee-black, #222);
    font-weight: 600;
}
.bee-pagination__list {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
}
.bee-pagination__list .page-item {
    display: inline-flex;
}
.bee-pagination__list .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    background: #fff;
    color: var(--bee-black, #222);
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.bee-pagination__list .page-link:hover {
    background: var(--bee-cream, #fff8e1);
    border-color: var(--bee-yellow, #ffd23f);
    color: var(--bee-yellow-deep, #f6b800);
}
.bee-pagination__list .page-item.active .page-link {
    background: var(--bee-yellow, #ffd23f);
    border-color: var(--bee-yellow-deep, #f6b800);
    color: #222;
    cursor: default;
}
.bee-pagination__list .page-item.disabled .page-link {
    color: #bbb;
    background: #fafafa;
    cursor: not-allowed;
    pointer-events: none;
}
/* 防呆：若任何 SVG 跑進分頁列，限制其尺寸，避免「箭頭被撐到滿版」 */
.bee-pagination svg {
    width: 16px;
    height: 16px;
    flex: none;
}
@media (max-width: 640px) {
    .bee-pagination { justify-content: center; }
    .bee-pagination__info { width: 100%; text-align: center; }
}
