/* ==========================================================================
   [w-settings-p0] 916-2 統一「⚙️ 會話設定」抽屜樣式（對標 Afizzy Direct Panel）
   深度融合 916-2 黑金暗夜影院美學 + 響應式雙端（手機底抽屜 / 寬屏右側滑出）
   ========================================================================== */

/* ── 次頂欄瘦身增強 ─────────────────────────────────────────────────────── */
.chat-sub-model-bar {
  gap: 6px !important;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-sub-model-bar::-webkit-scrollbar { display: none; }

.chat-sub-left-group,
.chat-sub-right-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 0;
}
.chat-sub-left-group { flex: 1; overflow-x: auto; scrollbar-width: none; }
.chat-sub-left-group::-webkit-scrollbar { display: none; }

.chat-settings-trigger-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(212, 180, 131, 0.34);
  background: linear-gradient(135deg, rgba(212, 180, 131, 0.16), rgba(32, 24, 24, 0.78));
  color: #F3DCAC;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}
.chat-settings-trigger-pill:hover {
  background: linear-gradient(135deg, rgba(212, 180, 131, 0.26), rgba(44, 32, 30, 0.88));
  border-color: rgba(243, 220, 172, 0.56);
}
.chat-settings-trigger-pill:active { transform: scale(0.96); }
.chat-settings-trigger-pill .csp-trig-quote {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(212, 180, 131, 0.18);
  color: #F8E5BF;
  font-size: 10.5px;
  font-weight: 700;
  margin-left: 1px;
}
.chat-settings-trigger-pill .csp-trig-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.75);
  display: none;
}
.chat-settings-trigger-pill.has-auto-active .csp-trig-dot {
  display: inline-block;
}

/* ── 抽屜容器（手機底部彈出 / 桌面右側滑出） ─────────────────────────────── */
.csp-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 5, 8, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: cspFadeIn 0.18s ease;
}
.csp-overlay.is-open { display: flex; }

.csp-sheet {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #0F0E12;
  border: 1px solid rgba(212, 180, 131, 0.18);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.68);
  color: #F5EFEA;
  overflow: hidden;
  animation: cspSlideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: var(--wd-font-sans, -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif);
}

@media (min-width: 768px) {
  .csp-overlay {
    align-items: stretch;
    justify-content: flex-end;
  }
  .csp-sheet {
    max-width: 404px;
    max-height: 100vh;
    height: 100%;
    border-radius: 20px 0 0 20px;
    border-bottom: 1px solid rgba(212, 180, 131, 0.18);
    border-right: none;
    box-shadow: -16px 0 48px rgba(0, 0, 0, 0.65);
    animation: cspSlideLeft 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes cspFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cspSlideUp { from { transform: translateY(28px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
@keyframes cspSlideLeft { from { transform: translateX(32px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }

.csp-grabber {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  margin: 10px auto 2px;
  flex-shrink: 0;
}
@media (min-width: 768px) { .csp-grabber { display: none; } }

/* ── 抽屜頂欄 ───────────────────────────────────────────────────────────── */
.csp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.csp-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.csp-back-btn,
.csp-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #EDE3DC;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.csp-back-btn:hover,
.csp-close-btn:hover { background: rgba(255, 255, 255, 0.12); }

.csp-title-wrap { min-width: 0; }
.csp-title {
  font-size: 16px;
  font-weight: 700;
  color: #FAF3EB;
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.csp-sub {
  font-size: 11.5px;
  color: rgba(235, 220, 210, 0.56);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csp-wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 180, 131, 0.3);
  background: rgba(212, 180, 131, 0.1);
  color: #F3DCAC;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.csp-wallet-chip:hover { background: rgba(212, 180, 131, 0.18); }

/* ── 主體捲動區 ─────────────────────────────────────────────────────────── */
.csp-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 26px;
  -webkit-overflow-scrolling: touch;
}
.csp-body::-webkit-scrollbar { width: 4px; }
.csp-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

/* ── 分組卡片（對標 Afizzy Settings 質感） ───────────────────────────────── */
.csp-group { margin-bottom: 16px; }
.csp-group-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(235, 220, 210, 0.52);
  padding: 0 4px 7px;
  letter-spacing: 0.03em;
}
.csp-card {
  background: #17151C;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  overflow: hidden;
}

.csp-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}
.csp-row:last-child { border-bottom: none; }
.csp-row:hover { background: rgba(255, 255, 255, 0.035); }
.csp-row.is-readonly { cursor: default; }
.csp-row.is-readonly:hover { background: transparent; }

.csp-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.csp-row-label {
  font-size: 14.5px;
  font-weight: 600;
  color: #F6EFEA;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.csp-row-mini-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(212, 180, 131, 0.16);
  color: #F3DCAC;
  border: 1px solid rgba(212, 180, 131, 0.28);
}
.csp-row-mini-badge.is-free {
  background: rgba(52, 211, 153, 0.14);
  color: #6EE7B7;
  border-color: rgba(52, 211, 153, 0.28);
}
.csp-row-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-align: right;
}
.csp-val-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.csp-val-main {
  font-size: 14px;
  font-weight: 600;
  color: #F3DCAC;
}
.csp-val-main.is-muted { color: rgba(235, 220, 210, 0.68); font-weight: 500; }
.csp-val-sub {
  font-size: 11px;
  color: rgba(235, 220, 210, 0.5);
}
.csp-chevron {
  color: rgba(235, 220, 210, 0.38);
  font-size: 16px;
  line-height: 1;
}

/* ── 底部實時明碼預估條（核心錨點：下一條訊息預計 X 💎） ──────────────────── */
.csp-quote-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 15px 13px;
  background: linear-gradient(180deg, rgba(212, 180, 131, 0.05), rgba(212, 180, 131, 0.11));
  border-top: 1px solid rgba(212, 180, 131, 0.16);
  cursor: pointer;
}
.csp-quote-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.csp-quote-hint {
  font-size: 11.5px;
  color: rgba(235, 220, 210, 0.55);
}
.csp-quote-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(245, 235, 225, 0.85);
}
.csp-quote-num {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 800;
  color: #F8DC9F;
}
.csp-quote-num.is-free { color: #6EE7B7; }
.csp-quote-breakdown {
  font-size: 11.5px;
  color: rgba(235, 220, 210, 0.68);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 10px;
  padding: 7px 10px;
  line-height: 1.5;
}

/* ── 二級選項頁 ─────────────────────────────────────────────────────────── */
.csp-sub-intro {
  font-size: 12.5px;
  color: rgba(235, 220, 210, 0.62);
  margin: 0 2px 12px;
  line-height: 1.5;
}
.csp-opt-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.csp-opt-card {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 15px;
  background: #17151C;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.1s ease;
}
.csp-opt-card:hover {
  background: #1E1B24;
  border-color: rgba(212, 180, 131, 0.34);
}
.csp-opt-card.is-selected {
  background: linear-gradient(135deg, rgba(212, 180, 131, 0.15), rgba(28, 22, 28, 0.96));
  border-color: rgba(212, 180, 131, 0.72);
  box-shadow: 0 0 0 1px rgba(212, 180, 131, 0.22);
}
.csp-opt-card.is-locked {
  opacity: 0.68;
}
.csp-opt-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.csp-opt-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.csp-opt-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #FAF3EB;
}
.csp-opt-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(212, 180, 131, 0.18);
  color: #F5DCAC;
  border: 1px solid rgba(212, 180, 131, 0.32);
}
.csp-opt-badge.is-addon {
  background: rgba(244, 114, 182, 0.16);
  color: #FBCFE8;
  border-color: rgba(244, 114, 182, 0.34);
}
.csp-opt-desc {
  font-size: 12px;
  color: rgba(235, 220, 210, 0.62);
  line-height: 1.45;
}
.csp-opt-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.csp-opt-cost {
  font-size: 12px;
  font-weight: 700;
  color: #F3DCAC;
  white-space: nowrap;
}
.csp-opt-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.26);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.csp-opt-card.is-selected .csp-opt-radio {
  border-color: #D4B483;
  background: #D4B483;
}
.csp-opt-card.is-selected .csp-opt-radio::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #141216;
}

/* ── 底部「顯示與氛圍」跳轉卡 ───────────────────────────────────────────── */
.csp-footer-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(240, 226, 216, 0.85);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}
.csp-footer-link:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(212, 180, 131, 0.28);
}

/* ── 首次開啟扣費確認守衛彈窗（firstConfirmationRequired） ───────────────── */
.csp-confirm-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(8, 7, 11, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.csp-confirm-card {
  width: 100%;
  max-width: 330px;
  background: #1B1822;
  border: 1px solid rgba(212, 180, 131, 0.36);
  border-radius: 18px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.72);
  text-align: center;
}
.csp-confirm-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(212, 180, 131, 0.16);
  border: 1px solid rgba(212, 180, 131, 0.34);
  color: #F3DCAC;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.csp-confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: #FAF3EB;
  margin-bottom: 8px;
}
.csp-confirm-desc {
  font-size: 13px;
  color: rgba(235, 220, 210, 0.76);
  line-height: 1.55;
  margin-bottom: 16px;
}
.csp-confirm-actions {
  display: flex;
  gap: 10px;
}
.csp-confirm-btn {
  flex: 1;
  height: 40px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #E5D9D1;
}
.csp-confirm-btn.is-primary {
  background: linear-gradient(135deg, #E2C38F, #C99D62);
  color: #18130F;
  border: none;
}
.csp-confirm-btn.is-primary:hover { filter: brightness(1.06); }
