/* ============================================================
   入境游营销中台 · 统一设计系统
   参考 workstation-demo.html 的暖色 + 精品 SaaS 质感
   ============================================================ */

:root {
  --bg: #FAF9F5;
  --bg-subtle: #F4F2EC;
  --bg-deep: #EEEBE1;
  --card: #FFFFFF;
  --border: #E5E3DC;
  --border-strong: #CFCCC0;
  --text: #1F1E1B;
  --text-muted: #6F6E68;
  --text-subtle: #A39F94;
  --accent: #C15F3C;
  --accent-bg: #FAF0EA;
  --success: #6B7F5C;
  --success-bg: #F4F7EF;
  --warning: #C9894A;
  --warning-bg: #FAF4EA;
  --danger: #B85C5C;
  --danger-bg: #FBF4F4;
  --purple: #8B7BDF;
  --purple-bg: #F3F1FB;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.font-serif { font-family: Georgia, "Times New Roman", "Songti SC", serif; }
.font-mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", monospace; }

/* ---------- Scrollbar ---------- */
.scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.scrollbar::-webkit-scrollbar-track { background: transparent; }

/* ---------- Button ---------- */
.btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: #000; }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-subtle); border-color: var(--text-muted); }
.btn-ghost { color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-success { background: var(--success); color: var(--bg); border-color: var(--success); }
.btn-success:hover { background: #556649; }
.btn-danger { color: var(--danger); border-color: #E6C8C8; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-accent:hover { background: #A24E2F; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ---------- Input ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
  transition: border-color .12s ease;
}
textarea { resize: vertical; line-height: 1.55; font-family: inherit; }
select {
  padding: 6px 28px 6px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236F6E68' stroke-width='1.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
}
label.inline-radio {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; cursor: pointer; background: var(--card);
  transition: all .12s;
}
label.inline-radio:hover { border-color: var(--text-muted); }
label.inline-radio input { accent-color: var(--accent); }
label.inline-radio.checked { border-color: var(--text); background: var(--bg-subtle); }

/* ---------- Tab bar ---------- */
.tab-bar {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-deep);
  border-radius: 8px;
}
.tab-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  transition: all .12s;
  border: none;
  background: transparent;
  font-family: inherit;
}
.tab-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
}

/* ---------- Chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--card);
}
.chip-accent { color: var(--accent); border-color: #EDC9B9; background: var(--accent-bg); }
.chip-success { color: var(--success); border-color: #CAD5BF; background: var(--success-bg); }
.chip-pending { color: var(--warning); border-color: #E8D4B5; background: var(--warning-bg); }
.chip-rejected { color: var(--danger); border-color: #E6C8C8; background: var(--danger-bg); }
.chip-purple { color: var(--purple); border-color: #D9D3F3; background: var(--purple-bg); }

/* ---------- Dot ---------- */
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-success { background: var(--success); }
.dot-pending { background: var(--warning); }
.dot-idle { background: var(--text-subtle); }
.dot-rejected { background: var(--danger); }
.dot-accent { background: var(--accent); }

/* ---------- Label ---------- */
.label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

/* ---------- Agent card (left sidebar) ---------- */
.agent-card {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  padding: 11px 13px;
  transition: all .15s ease;
  cursor: pointer;
  position: relative;
}
.agent-card:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.agent-card.active {
  border-color: var(--text);
  background: var(--card);
}
.agent-card.active .agent-icon {
  color: var(--text);
  border-color: var(--text);
}
.agent-icon {
  width: 28px; height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: var(--card);
  flex-shrink: 0;
  transition: all .15s ease;
}
.pending-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 0 0 2px var(--bg);
}
.freq-badge {
  font-size: 9.5px;
  color: var(--text-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---------- Instruction (preset) button ---------- */
.ins-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
  width: 100%;
}
.ins-btn:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.ins-btn.active {
  border-color: var(--text);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--text);
}

/* ---------- Markdown output ---------- */
.md-output {
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
}
.md-output h1 { font-family: Georgia, serif; font-size: 1.4rem; font-weight: 600; margin: 0.5rem 0 0.75rem; letter-spacing: -0.01em; }
.md-output h2 { font-family: Georgia, serif; font-size: 1.1rem; font-weight: 600; margin: 1.1rem 0 0.4rem; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.md-output h3 { font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.md-output p { margin: 0.5rem 0; }
.md-output strong { font-weight: 600; }
.md-output code { background: var(--bg-deep); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, monospace; }
.md-output blockquote { border-left: 2px solid var(--border-strong); padding-left: 12px; color: var(--text-muted); margin: 0.5rem 0; }
.md-output table { border-collapse: collapse; width: 100%; margin: 0.5rem 0; font-size: 12.5px; }
.md-output th, .md-output td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-output th { background: var(--bg-subtle); font-weight: 600; }
.md-output ul, .md-output ol { padding-left: 1.3rem; margin: 0.4rem 0; }
.md-output li { margin: 0.2rem 0; }

.typing-cursor::after { content: "▌"; color: var(--accent); animation: blink 1s steps(1) infinite; margin-left: 1px; font-weight: 300; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Toast ---------- */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  animation: toastIn .22s cubic-bezier(.2,.9,.3,1);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(31, 30, 27, 0.18);
  max-width: 340px;
}
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Modal ---------- */
.modal-backdrop { background: rgba(31, 30, 27, 0.32); backdrop-filter: blur(3px); }

/* ---------- Utilities ---------- */
.bg-app { background: var(--bg); }
.bg-app-subtle { background: var(--bg-subtle); }
.bg-app-deep { background: var(--bg-deep); }
.bg-app-card { background: var(--card); }
.text-app { color: var(--text); }
.text-app-muted { color: var(--text-muted); }
.text-app-subtle { color: var(--text-subtle); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.border-app { border-color: var(--border); }
.hidden { display: none !important; }
[x-cloak] { display: none !important; }

/* ---------- Chat bubble ---------- */
.chat-bubble-user {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 12px 12px 2px 12px;
  max-width: 80%;
  margin-left: auto;
  font-size: 13.5px;
  line-height: 1.55;
}
.chat-bubble-agent {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 12px 12px 12px 2px;
  max-width: 85%;
  font-size: 13.5px;
  line-height: 1.65;
}

/* ---------- Feedback card ---------- */
.feedback-card {
  background: linear-gradient(to bottom right, var(--accent-bg), var(--bg-subtle));
  border: 1px solid #EED6CB;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
}

/* ---------- Onboarding steps ---------- */
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  display: grid; place-items: center;
  font-size: 12px; color: var(--text-muted);
  font-weight: 500;
  transition: all .15s;
}
.step-dot.active { border-color: var(--text); background: var(--text); color: var(--bg); }
.step-dot.done { border-color: var(--success); background: var(--success); color: var(--bg); }
.step-line {
  flex: 1; height: 1px; background: var(--border); margin: 0 6px;
}
.step-line.done { background: var(--success); }
