/* =========================
   Reset & base
   ========================= */
* { box-sizing: border-box; }

:root{
  --brand: hsl(193, 32%, 46%);
  --bg: #eef2f6;
  --panel: #ffffff;
  --muted: #6b7280;
  --line: #e5e5e5;
  --chatbg: #f0f2f5;
}

html, body{
  margin: 0;
  overflow-x: hidden; /* 防止 Safari 横向滚动条 */
}

body{
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #1c1e21;
}

/* =========================
   Default container layout
   ========================= */
.container{
  background: var(--panel);
  width: 100%;
  max-width: none;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* =========================
   Chat page = small widget layout
   ========================= */
body.chat-page{
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

body.chat-page .container{
  width: 400px;
  max-width: 100%;
  height: 600px;
  min-height: 0;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* =========================
   Header (shared)
   ========================= */
.chat-header{
  display: flex;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.bot-info{
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-header-logo{
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.bot-info h3{
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* =========================
   Chat UI (only used on chat page)
   ========================= */
.controls{
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.pill-group{ margin-bottom: 8px; }

.pill-label{
  font-size: 11px;
  color: #9aa0a6;
  margin-bottom: 6px;
  display: block;
}

.pills{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill{
  background: #f5f6f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: #1c1e21;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.pill:hover{ background: #eceeef; }

.pill.active{
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.rewrite-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rewrite-row button{
  background: #ffffff;
  color: var(--brand);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

.rewrite-row button:hover{
  transform: translateY(-1px);
  background: rgba(79, 147, 156, 0.08);
  border-color: rgba(79, 147, 156, 0.25);
}

.rewrite-row button:active{ transform: translateY(0); }

.rewrite-row button:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(79, 147, 156, 0.18);
}

.chatbox{
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--chatbg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message{
  display: flex;
  align-items: flex-end;
  max-width: 80%;
}

.message.user{ align-self: flex-end; }
.message.bot{ align-self: flex-start; }

.message.bot .bot-chat-logo{
  width: 28px;
  height: 28px;
  border-radius: 50%;
  align-self: flex-end;
  flex-shrink: 0;
  margin-right: 8px;
}

.message .text-bubble{
  background: #ffffff;
  padding: 12px 16px;
  border-radius: 20px;
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.message.user .text-bubble{
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.bot .text-bubble{
  background: #e5e5ea;
  color: #1c1e21;
  border-bottom-left-radius: 4px;
}

.message.system{ align-self: flex-start; }
.message.system .text-bubble{
  background: transparent;
  color: #9aa0a6;
  font-size: 12px;
  padding: 4px 0;
  box-shadow: none;
}

.input-area{
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: #ffffff;
  border-top: 1px solid var(--line);
}

input[type="text"]{
  flex-grow: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 25px;
  font-size: 15px;
  background: var(--chatbg);
  outline: none;
  transition: background-color 0.2s ease;
}

input[type="text"]:focus{ background: #e5e7eb; }

button{
  background: transparent;
  color: var(--brand);
  border: none;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

button:disabled{
  color: #c0c0c0;
  cursor: not-allowed;
}

/* =========================
   Scenarios page (final): stacked single card + arrows
   ========================= */
body.scenarios-page{
  padding: 0;
}

body.scenarios-page .chat-header{
  position: sticky;
  top: 0;
  z-index: 10;
}

body.scenarios-page .scenarios-content{
  width: 100%;
  min-height: calc(100vh - 56px);
  padding: 28px 32px 32px;
  background: var(--chatbg);
  overflow-y: auto;
  overflow-x: hidden;
}

.page-title{
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: #1c1e21;
}

.page-subtitle{
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

/* stage wrapper (space for arrows) */
body.scenarios-page .scenario-wrapper{
  position: relative;
  width: min(640px, 96vw);
  margin: 0 auto;
  padding: 0 56px;
  box-sizing: border-box;
  overflow: visible; /* arrows visible */
}

/* stack area */
body.scenarios-page .scenario-list{
  display: block;
  position: relative;
  width: 100%;
  height: 520px;
  overflow: hidden; /* clip cards */
  contain: layout paint; /* Safari: transforms won't create scrollWidth */
  clip-path: inset(0);   /* Safari extra safety */
}

/* cards (absolute stack) */
body.scenarios-page .scenario-card{
  position: absolute;
  left: 50%;
  top: 50%;
  width: 420px;
  max-width: 92%;
  transform: translate(-50%, -50%) scale(0.94);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s ease, opacity 0.35s ease;
  z-index: 1;

  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);

  display: flex;
  flex-direction: column;
}

body.scenarios-page .scenario-card.active{
  opacity: 1;
  pointer-events: auto;
  z-index: 3;
  transform: translate(-50%, -50%) scale(1);
}

body.scenarios-page .scenario-card.prev{
  opacity: 0.35;
  z-index: 2;
  transform: translate(calc(-50% - 220px), -50%) scale(0.94);
}

body.scenarios-page .scenario-card.next{
  opacity: 0.35;
  z-index: 2;
  transform: translate(calc(-50% + 220px), -50%) scale(0.94);
}

/* card content */
body.scenarios-page .scenario-card h2{
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: #1c1e21;
}

body.scenarios-page .scenario-thought{
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #4b5563;
}

body.scenarios-page .scenario-card ul{
  margin: 0 0 12px;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

body.scenarios-page .scenario-card li{ margin: 4px 0; }

/* PNG illustration */
body.scenarios-page .scenario-image.png{
  width: 100%;
  height: 160px;
  object-fit: contain;
  object-position: center;
  display: block;
  margin-bottom: 10px;
  border-radius: 10px;
  padding: 10px;
  background: #f7f7f5;
  border: 1px solid var(--line);
}

/* CTA button */
body.scenarios-page .scenario-btn{
  margin-top: auto;
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.10);
  background: #ffffff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s ease, border-color .15s ease;
}

body.scenarios-page .scenario-btn:hover{
  background: rgba(79, 147, 156, 0.08);
  border-color: rgba(79, 147, 156, 0.25);
}

body.scenarios-page .scenario-btn:active{
  background: rgba(79, 147, 156, 0.14);
}

/* arrows */
body.scenarios-page .nav-btn{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;

  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--line);
  color: #374151;
  font-size: 26px;
  font-weight: 500;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}

body.scenarios-page .nav-btn.left{ left: 10px; }
body.scenarios-page .nav-btn.right{ right: 10px; }

body.scenarios-page .nav-btn:hover{
  background: #ffffff;
  transform: translateY(-50%) scale(1.05);
}

body.scenarios-page .nav-btn.disabled{
  opacity: 0;
  pointer-events: none;
}

/* footer */
.page-footer{
  margin: 14px 0 0;
  font-size: 12px;
  color: #9aa0a6;
  text-align: center;
}

/* responsive tweaks */
@media (max-width: 700px){
  body.scenarios-page .scenarios-content{
    padding: 22px 16px 24px;
  }
  body.scenarios-page .scenario-wrapper{
    padding: 0 44px;
  }
  body.scenarios-page .scenario-card{
    width: 360px;
  }
  body.scenarios-page .scenario-card.prev{
    transform: translate(calc(-50% - 170px), -50%) scale(0.94);
  }
  body.scenarios-page .scenario-card.next{
    transform: translate(calc(-50% + 170px), -50%) scale(0.94);
  }
}

/* Quick starters */
.quick-starters{
  padding: 10px 15px;
  border-top: 1px solid #e5e5e5;
  background: #ffffff;
}

.qs-label{
  font-size: 11px;
  color: #9aa0a6;
  margin-bottom: 8px;
}

.qs-pills{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.qs-pill{
  background: #f5f6f7;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: #1c1e21;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.qs-pill:hover{
  background: #eceeef;
}

.qs-pill:active{
  background: #e5e7eb;
}
/* =========================
   Collapsible Controls Panel
   ========================= */

.controls-wrap{
  padding: 12px 18px 0;
}

.controls-toggle{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  background: #fff;
  border: 1px solid var(--line, #e5e5e5);
  border-radius: 14px;
  padding: 10px 12px;

  cursor: pointer;
  font-size: 14px;
  color: #4b5563;
}

.controls-toggle .toggle-icon{
  font-size: 14px;
  opacity: 0.85;
}

.controls-toggle .toggle-text{
  flex: 1;
  text-align: left;
  font-weight: 600;
}

.controls-toggle .toggle-caret{
  transition: transform 0.25s ease;
  opacity: 0.7;
}

.controls-toggle[aria-expanded="true"] .toggle-caret{
  transform: rotate(180deg);
}

/* Panel spacing */
.controls{
  margin-top: 10px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line, #e5e5e5);
}

/* Optional: make pills wrap nicely on small screens */
.pills, .qs-pills{
  flex-wrap: wrap;
  gap: 10px;
}
/* ===== Fix: ensure chat layout allocates space to chatbox ===== */
body.chat-page .container{
  display: flex;
  flex-direction: column;
  height: 600px;     /* 你本来就希望是 widget 高度 */
  min-height: 0;     /* 关键：允许内部滚动区域正确计算 */
}

/* If your chatbox isn't getting height, force it */
body.chat-page #chatbox,
body.chat-page .chatbox{
  flex: 1 1 auto;    /* 比 flex-grow 更稳 */
  min-height: 0;     /* 关键：否则 overflow-y 可能失效 */
  overflow-y: auto;
}
/* Draft reply options (NOT chat bubbles) */
.options-section{
  margin-left: 36px; /* 对齐 bot 头像右侧 */
  margin-top: 6px;
}

.options-label{
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}

.option-row{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-chip{
  text-align: left;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: hsl(193, 32%, 46%);
  font-size: 14px;
  cursor: pointer;
}

.option-chip:hover{
  background: #eef2ff;
}
.global-back-btn{
  position: fixed;
  top: 16px;
  left: 16px;
  background: none;
  border: none;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  z-index: 1000;
}

.global-back-btn:hover{
  opacity: 0.7;
}
