:root {
  --brand: #e85d3a;
  --brand-dark: #c94a2b;
  --bg: #f7f5f2;
  --bubble-bot: #ffffff;
  --bubble-user: var(--brand);
  --text: #2b2724;
  --muted: #8a817a;
  --warn-bg: #fff6e6;
  --radius: 16px;
  --max-w: 720px;
}

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

html, body { height: 100%; }

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── Header：橫式 logo 專用 ─────────────────── */
.site-header {
  background: #fff;
  border-bottom: 1px solid #eee7e0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  /* iOS 安全區域 */
  padding-top: calc(10px + env(safe-area-inset-top));
}

.logo-link { display: inline-flex; align-items: center; }

.logo-link img {
  height: 44px;          /* 橫式 logo：鎖高度、寬度等比縮放不變形 */
  width: auto;
  max-width: min(78vw, 320px);
  object-fit: contain;
  display: block;
}

#brand-fallback {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
}

/* ── 對話區 ─────────────────────────────────── */
#chat-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 12px 8px;
  overflow-y: auto;
}

.msg { display: flex; margin-bottom: 12px; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

.bot .bubble { background: var(--bubble-bot); border-top-left-radius: 4px; }
.user .bubble { background: var(--bubble-user); color: #fff; border-top-right-radius: 4px; }

.bubble a {
  color: var(--brand-dark);
  text-underline-offset: 2px;
}

/* 參考來源 chips */
.sources { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.source-chip {
  font-size: .78rem;
  text-decoration: none;
  color: var(--brand-dark);
  background: #fdf0ec;
  border: 1px solid #f3cdc3;
  padding: 3px 10px;
  border-radius: 999px;
}
.source-chip::before { content: "🔗 "; }

/* 非官方資訊警示 */
.warn-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: .75rem;
  color: #92600a;
  background: var(--warn-bg);
  border: 1px solid #f0ddb0;
  border-radius: 8px;
  padding: 4px 10px;
}

/* typing 動畫 */
.typing .bubble span {
  display: inline-block; width: 6px; height: 6px; margin-right: 4px;
  background: #c9beb6; border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing .bubble span:nth-child(2) { animation-delay: .2s; }
.typing .bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

/* 真人客服區塊 */
.support-block {
  background: var(--warn-bg);
  border: 1px solid #f0ddb0;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 4px 0 12px;
  font-size: .9rem;
}
.support-block p { color: #92600a; margin-bottom: 8px; }
.support-links-row { display: flex; gap: 8px; flex-wrap: wrap; }
.support-btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: #06c755;   /* LINE 品牌綠 */
}
.support-btn.mail { background: #5a7bd8; }

/* ── 輸入列 ─────────────────────────────────── */
.chat-input-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #eee7e0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

#chat-form { display: flex; gap: 8px; max-width: var(--max-w); margin: 0 auto; }

#chat-input {
  flex: 1;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid #ddd3ca;
  border-radius: 999px;
  outline: none;
  background: var(--bg);
}
#chat-input:focus { border-color: var(--brand); background: #fff; }

#send-btn {
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  padding: 0 20px;
  border-radius: 999px;
  cursor: pointer;
}
#send-btn:disabled { opacity: .45; cursor: not-allowed; }

.disclaimer {
  text-align: center;
  font-size: .7rem;
  color: var(--muted);
  margin-top: 6px;
}

/* 桌機微調 */
@media (min-width: 768px) {
  .logo-link img { height: 52px; }
  .bubble { font-size: 1rem; }
}
