/* ══════════════════════════════════════════════
   CuzCuz 輔助回覆工作台
   全螢幕三欄，不使用後台的 banner / nav
   ══════════════════════════════════════════════ */

:root {
  --gold: #E2B32F;
  --gold-dk: #c49a20;
  --brown: #756550;
  --cream: #FEF7F0;
  --gray-lt: #f4f4f4;
  --gray: #e0e0e0;
  --text: #444;
  --text-lt: #888;
  --white: #fff;
  --danger: #c0392b;
  --success: #27ae60;
  --line-green: #06C755;
  --radius: 8px;
  --font: '微軟正黑體', 'Microsoft JhengHei', sans-serif;

  --topbar-h: 52px;
  /* 以下三個由分隔線拖曳調整，並記憶在 localStorage */
  --col-list-w: 300px;
  --col-side-w: 320px;
  --composer-h: 150px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--gray-lt);
}

.hidden { display: none !important; }

/* ── 登入畫面 ── */

.login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  background: var(--white);
  border: 1px solid var(--gray);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  text-align: center;
}

.login-logo {
  font-size: 26px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

.login-title {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 600;
  color: var(--brown);
}

.login-desc {
  margin: 14px 0 24px;
  font-size: 13px;
  color: var(--text-lt);
  line-height: 1.7;
}

#g-signin { display: flex; justify-content: center; min-height: 44px; }

.login-error {
  margin-top: 18px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--danger);
  background: #fdf0ee;
  border: 1px solid #f3c9c2;
  border-radius: var(--radius);
  text-align: left;
}

/* ── 工作台骨架 ── */

.workspace {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-select {
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--brown);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  cursor: pointer;
}

.topbar-select:focus { outline: none; border-color: var(--gold); }

.mode-tag {
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 12px;
  background: #eef7ee;
  color: var(--success);
  border: 1px solid #cfe8cf;
}

.mode-tag.warn {
  background: #fdf6e8;
  color: var(--gold-dk);
  border-color: #f0dfae;
}

.quota-pill {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 12px;
  background: var(--gray-lt);
  color: var(--text-lt);
  border: 1px solid var(--gray);
}

.quota-pill.warn { background: #fdf6e8; color: var(--gold-dk); border-color: #f0dfae; }
.quota-pill.danger { background: #fdf0ee; color: var(--danger); border-color: #f3c9c2; }

.staff-label {
  font-size: 13px;
  color: var(--text-lt);
}

.topbar-btn {
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-lt);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  cursor: pointer;
}

.topbar-btn:hover { color: var(--text); border-color: var(--text-lt); }

/* ── 三欄 ── */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  /* 兩條可拖曳的垂直分隔線各佔一個 5px 軌道 */
  grid-template-columns: var(--col-list-w) 5px 1fr 5px var(--col-side-w);
}

/* ── 可拖曳分隔線 ── */

.resizer-v,
.resizer-h {
  background: var(--gray);
  transition: background 0.12s;
  user-select: none;
  touch-action: none;
}

.resizer-v {
  cursor: col-resize;
  position: relative;
}

.resizer-h {
  flex-shrink: 0;
  height: 5px;
  cursor: row-resize;
}

.resizer-v:hover,
.resizer-h:hover,
.resizer-v.dragging,
.resizer-h.dragging {
  background: var(--gold);
}

/* 分隔線本身只有 5px，加大實際可點擊範圍以免難抓 */
.resizer-v::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

/* 拖曳中鎖住整頁游標，避免經過 iframe/文字時游標亂跳或誤選取 */
body.resizing { cursor: col-resize; }
body.resizing.row { cursor: row-resize; }
body.resizing * { user-select: none !important; }

.col-list, .col-chat, .col-side {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.col-list { border-right: 1px solid var(--gray); }
.col-side { border-left: 1px solid var(--gray); background: #fcfbf9; }

/* ── 左欄：對話列表 ── */

.list-head {
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray);
}

.list-search {
  width: 100%;
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--gray);
  border-radius: var(--radius);
}

.list-search:focus { outline: none; border-color: var(--gold); }

.conv-list { flex: 1; overflow-y: auto; }

.list-empty, .side-list-empty, .side-empty {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--text-lt);
  text-align: center;
  line-height: 1.7;
}

.conv-item {
  padding: 11px 13px;
  border-bottom: 1px solid #f0eeea;
  cursor: pointer;
  transition: background 0.12s;
}

.conv-item:hover { background: var(--cream); }
.conv-item.active { background: #fdf3dd; border-left: 3px solid var(--gold); padding-left: 10px; }

.conv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-lt);
}

.conv-preview {
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-snippet {
  flex: 1;
  font-size: 12px;
  color: var(--text-lt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  color: var(--white);
  background: var(--danger);
  border-radius: 9px;
}

.conv-pending {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--gold-dk);
}

/* ── 中欄：對話視窗 ── */

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-lt);
  background: var(--gray-lt);
}

.chat-empty-icon { font-size: 40px; opacity: 0.4; }

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;   /* 拖放覆蓋層 #drop-overlay 以此為定位基準 */
}

.chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray);
}

.chat-name { font-size: 15px; font-weight: 600; color: var(--text); }
.chat-status { font-size: 12px; color: var(--text-lt); }

.chat-name-edit {
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-lt);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}

.chat-name-edit:hover {
  color: var(--gold-dk);
  border-color: var(--gray);
  background: var(--cream);
}

.chat-name-input {
  flex: 1;
  max-width: 320px;
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--gold);
  border-radius: 4px;
}

.chat-name-input:focus { outline: none; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  background: #f7f6f4;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-date {
  align-self: center;
  padding: 3px 12px;
  margin: 6px 0;
  font-size: 12px;
  color: var(--text-lt);
  background: rgba(0,0,0,0.05);
  border-radius: 12px;
}

.msg { display: flex; flex-direction: column; max-width: 74%; }
.msg.from-user { align-self: flex-start; }
.msg.from-us { align-self: flex-end; align-items: flex-end; }

.msg-bubble {
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 14px;
}

.msg.from-user .msg-bubble {
  background: var(--white);
  border: 1px solid var(--gray);
  border-top-left-radius: 4px;
}

.msg.from-us .msg-bubble {
  background: #DCF8C6;
  border: 1px solid #cbe9b4;
  border-top-right-radius: 4px;
}

.msg.from-staff .msg-bubble {
  background: #d9ecff;
  border-color: #b9d9f5;
}

.msg-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-lt);
}

/* ── 輸入區 ── */

.chat-composer {
  flex-shrink: 0;
  height: var(--composer-h);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  background: var(--white);
  padding: 10px 14px 12px;
}

.suggestion-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: #fdf6e8;
  border: 1px solid #f0dfae;
  border-radius: var(--radius);
}

.suggestion-label { font-weight: 600; color: var(--gold-dk); }

.suggestion-btn {
  padding: 3px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-dk);
  background: var(--white);
  border: 1px solid #f0dfae;
  border-radius: 4px;
  cursor: pointer;
}

.suggestion-btn:hover { background: #fdf3dd; }
.suggestion-btn:disabled { color: var(--text-lt); cursor: not-allowed; }

.suggestion-hint {
  font-size: 12px;
  color: var(--text-lt);
}

.composer-input {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 9px 11px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  /* 高度改由分隔線拖曳控制，關掉原生 resize 把手避免兩套機制打架 */
  resize: none;
}

.composer-input:focus { outline: none; border-color: var(--gold); }
.composer-input:disabled { background: var(--gray-lt); cursor: not-allowed; }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.composer-hint { flex: 1; font-size: 12px; color: var(--text-lt); }

/* ── 表情符號 ── */

.emoji-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-lt);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  cursor: pointer;
}

.emoji-btn:hover { color: var(--gold-dk); border-color: var(--gold); background: var(--cream); }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  margin-top: 8px;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.emoji-item {
  padding: 5px 0;
  font-size: 19px;
  line-height: 1;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.emoji-item:hover { background: var(--cream); }

@media (max-width: 1100px) {
  .emoji-panel { grid-template-columns: repeat(8, 1fr); }
}

/* ── 貼圖面板 ── */

.sticker-panel {
  margin-top: 8px;
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  overflow: hidden;
}

.sticker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--gray);
}

.sticker-tab {
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-lt);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.sticker-tab:hover { color: var(--text); }
.sticker-tab.active { color: var(--gold-dk); font-weight: 600; border-bottom-color: var(--gold); }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  padding: 8px;
}

.sticker-item {
  padding: 2px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}

.sticker-item:hover { background: var(--cream); }
.sticker-item.sending { opacity: 0.4; }
.sticker-item img { width: 100%; display: block; }

.sticker-note {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-lt);
  background: var(--gray-lt);
  border-top: 1px solid var(--gray);
}

/* 對話中的貼圖顯示為圖片，不套氣泡樣式 */
.msg-sticker {
  width: 130px;
  max-width: 100%;
  display: block;
}

@media (max-width: 1100px) {
  .sticker-grid { grid-template-columns: repeat(5, 1fr); max-height: 180px; }
  .msg-sticker { width: 110px; }
}

.btn-send {
  padding: 7px 22px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  background: var(--line-green);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-send:hover { background: #05b34c; }
.btn-send:disabled { background: var(--gray); cursor: not-allowed; }

/* ── 右欄 ── */

.side-panel { flex: 1; overflow-y: auto; padding: 14px; }

.side-block {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
}

.side-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.side-block-title { font-size: 13px; font-weight: 600; color: var(--brown); }
.side-block-status { font-size: 11px; color: var(--text-lt); }

.notes-input {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  resize: vertical;
}

.notes-input:focus { outline: none; border-color: var(--gold); }

.side-btn {
  margin-top: 8px;
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--brown);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: var(--radius);
  cursor: pointer;
}

.side-btn:hover { background: var(--cream); border-color: var(--gold); }

.side-list { display: flex; flex-direction: column; gap: 6px; }

.side-list-empty { padding: 12px 0; text-align: left; }

/* 歷史訂單 */

.order-item {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--text);
  background: var(--gray-lt);
  border: 1px solid var(--gray);
  border-radius: 6px;
  transition: background 0.12s;
}

.order-item:hover { background: var(--cream); border-color: var(--gold); }

.order-name {
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.order-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-lt);
}

.order-tag {
  padding: 1px 6px;
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: 8px;
}

/* 對話摘要：公司戶／公家機關標記 */

.customer-type-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #e8f1fb;
  border: 1px solid #b9d4ee;
  border-radius: 6px;
}

.badge-tag {
  flex-shrink: 0;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  background: #2f74c0;
  border-radius: 10px;
}

.badge-reason {
  font-size: 11px;
  line-height: 1.5;
  color: #2f74c0;
}

/* 對話摘要項目 */

.insight-item {
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.6;
  border-radius: 6px;
  border-left: 3px solid var(--gray);
  background: var(--gray-lt);
}

.insight-item.req { border-left-color: var(--success); background: #f2f9f2; }
.insight-item.risk { border-left-color: var(--danger); background: #fdf2f0; }

/* ── 手機／窄螢幕：比照 LINE OA App 的三層導覽 ──
   對話列表 →（點選）→ 對話視窗 →（點右上 ⋯）→ 客戶資訊
   由 .workspace[data-mobile-view] 控制當前顯示哪一層。 */

.icon-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 22px;
  line-height: 1;
  color: var(--brown);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.icon-btn:active { background: var(--gray-lt); }

.chat-head-right { margin-left: auto; }

.side-head {
  flex-shrink: 0;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--gray);
}

.side-head-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }

  /* 分隔線只在桌機有意義 */
  .resizer-v, .resizer-h { display: none; }

  /* 一次只顯示一層 */
  .col-list, .col-chat, .col-side { display: none; }
  .workspace[data-mobile-view="list"] .col-list { display: flex; }
  .workspace[data-mobile-view="chat"] .col-chat { display: flex; }
  .workspace[data-mobile-view="side"] .col-side { display: flex; }

  .col-list, .col-side { border: none; }

  /* 返回鍵與 ⋯ 只在此模式出現 */
  .mobile-only.icon-btn { display: inline-flex; }
  .side-head.mobile-only { display: flex; }

  /* 手機不需要固定輸入框高度，讓內容自然撐開 */
  .chat-composer { height: auto; }
  .composer-input { min-height: 76px; }

  /* 訊息氣泡在窄螢幕可以佔更寬 */
  .msg { max-width: 88%; }

  .topbar { padding: 0 10px; }
  .staff-label { display: none; }
  .side-panel { padding: 12px 10px; }
}

/* ══════════════════════════════════════════════
   附件：上傳、拖放、以及訊息中的圖片
   ══════════════════════════════════════════════ */

.hidden-input { display: none; }

/* ── 訊息氣泡內的圖片 ── */

.msg-image {
  display: block;
  max-width: min(260px, 60vw);
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--gray);
  cursor: zoom-in;
  background: var(--gray-lt);
}

.msg.from-user .msg-image { border-top-left-radius: 4px; }
.msg.from-us   .msg-image { border-top-right-radius: 4px; }

/* 客人傳來的圖片還沒抓下來（下載失敗或是 v5 之前的舊訊息） */
.msg-image-missing {
  padding: 9px 13px;
  font-size: 13px;
  color: var(--text-lt);
  background: var(--gray-lt);
  border: 1px dashed var(--gray);
  border-radius: 12px;
}

/* 檔案（PDF 等）：LINE 收到的是連結，這裡顯示成檔案卡片 */
.msg-file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--white);
  border: 1px solid var(--gray);
  max-width: min(280px, 62vw);
}

.msg.from-us .msg-file { background: #DCF8C6; border-color: #cbe9b4; }
.msg.from-staff .msg-file { background: #d9ecff; border-color: #b9d9f5; }
.msg-file:hover { filter: brightness(0.97); }

.msg-file-icon { font-size: 22px; flex-shrink: 0; }
.msg-file-body { min-width: 0; }

.msg-file-name {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.msg-file-size { font-size: 11px; color: var(--text-lt); margin-top: 2px; }

/* ── 全螢幕看圖 ── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 24px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

/* ── 拖放覆蓋層 ── */

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(226, 179, 47, 0.13);
  border: 3px dashed var(--gold);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;   /* 不可攔截 dragleave，否則覆蓋層會閃爍 */
}

.drop-overlay-inner {
  text-align: center;
  color: var(--brown);
  font-size: 16px;
  font-weight: 600;
  background: var(--white);
  padding: 22px 34px;
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
}

.drop-icon { font-size: 34px; margin-bottom: 6px; }

/* ── 送出前的確認視窗 ── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 14px;
}

.upload-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--gray);
  border-radius: var(--radius);
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray);
}

.upload-item:last-child { border-bottom: none; }

.upload-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-lt);
  border-radius: 6px;
  overflow: hidden;
}

.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb .upload-file-icon { font-size: 22px; }

.upload-item-body { flex: 1; min-width: 0; }

.upload-item-name {
  font-size: 13px;
  word-break: break-all;
  line-height: 1.4;
}

.upload-size { color: var(--text-lt); font-size: 12px; margin-top: 1px; }

.upload-item-ok   { color: var(--success); font-size: 15px; flex-shrink: 0; }
.upload-item-err  { color: var(--danger);  font-size: 11px; flex-shrink: 0; }
.upload-item-wait { color: var(--text-lt); font-size: 11px; flex-shrink: 0; }

.upload-summary {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-lt);
}

.upload-warning {
  white-space: pre-line;
  margin-top: 10px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.6;
  background: #fff5e0;
  border: 1px solid #f0d79a;
  border-radius: 6px;
  color: #8a6d1f;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-plain {
  padding: 8px 16px;
  border: 1px solid var(--gray);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
}

.btn-plain:hover { background: var(--gray-lt); }
.modal-actions .btn-send:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── 卡妹建議附帶的候選產品照 ── */

.suggestion-photos {
  padding: 8px 10px 10px;
  background: #fffdf6;
  border-bottom: 1px solid var(--gray);
}

.suggestion-photos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-lt);
  margin-bottom: 7px;
}

.photo-count { color: var(--gold-dk); flex-shrink: 0; }
.photo-count.warn { color: var(--danger); }

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.photo-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  padding: 0;
  border: 2px solid var(--gray);
  border-radius: 6px;
  background: var(--gray-lt);
  cursor: pointer;
  overflow: hidden;
  opacity: 0.5;
  transition: opacity 0.12s, border-color 0.12s;
}

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-thumb.on {
  opacity: 1;
  border-color: var(--gold);
}

.photo-check {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 17px;
  height: 17px;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  color: var(--white);
  background: var(--gold);
  border-radius: 50%;
  display: none;
}

.photo-thumb.on .photo-check { display: block; }

/* ── 常用語（對應 LINE OA 的預設訊息）── */

.preset-panel {
  max-height: 320px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--gray);
  background: var(--white);
}

.preset-head {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  flex-shrink: 0;
}

.preset-search {
  flex: 1;
  padding: 6px 9px;
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--gray);
  border-radius: 6px;
}

.preset-search:focus { outline: none; border-color: var(--gold); }

.preset-manage-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-lt);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: 6px;
  cursor: pointer;
}

.preset-manage-btn:hover { color: var(--text); border-color: var(--text-lt); }

.preset-list { flex: 1; overflow-y: auto; }

.preset-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid #f0eeea;
  cursor: pointer;
  font-family: var(--font);
}

.preset-item:hover { background: var(--cream); }

.preset-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.preset-item-snippet {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-lt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 管理視窗 ── */

.modal-wide { max-width: 560px; max-height: 88vh; overflow-y: auto; }

.preset-input, .preset-textarea {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--gray);
  border-radius: 6px;
  margin-bottom: 8px;
}

.preset-textarea { resize: vertical; line-height: 1.6; }
.preset-input:focus, .preset-textarea:focus { outline: none; border-color: var(--gold); }

.preset-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.preset-editing {
  flex: 1;
  font-size: 12px;
  color: var(--gold-dk);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-manage-list {
  margin-top: 14px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--gray);
  border-radius: var(--radius);
}

.preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f0eeea;
}

.preset-row:last-child { border-bottom: none; }
.preset-row-body { flex: 1; min-width: 0; }

.preset-row-btn {
  flex-shrink: 0;
  padding: 4px 9px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-lt);
  background: var(--white);
  border: 1px solid var(--gray);
  border-radius: 5px;
  cursor: pointer;
}

.preset-row-btn:hover { color: var(--text); }
.preset-row-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.preset-import { margin-top: 14px; }

.preset-import summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--brown);
  padding: 6px 0;
}

.preset-import-note {
  font-size: 12px;
  color: var(--text-lt);
  line-height: 1.7;
  margin: 4px 0 8px;
}

.preset-import-note code {
  padding: 1px 5px;
  background: var(--gray-lt);
  border-radius: 3px;
  font-size: 12px;
}
