:root {
  --acs-primary: #3a6ea5;
  --acs-primary-soft: #eef3f9;
  --acs-bg: #f8f8f8;
  --acs-card: #ffffff;
  --acs-border: #ebeef2;
  --acs-text: #23272f;
  --acs-text-sub: #8a919c;
  --acs-radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--acs-text);
  background: var(--acs-bg);
  font-size: 14px;
  line-height: 1.6;
}

.acs-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--acs-bg);
  overflow: hidden;
}

/* ---------------- 顶部栏 ---------------- */
.acs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--acs-card);
  border-bottom: 1px solid var(--acs-border);
}

.acs-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.acs-logo {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--acs-primary);
}

.acs-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.acs-title strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acs-title span {
  font-size: 12px;
  color: var(--acs-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acs-header-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.acs-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--acs-border);
  background: #fff;
  border-radius: 8px;
  color: var(--acs-text-sub);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s;
}

.acs-icon-btn:hover {
  color: var(--acs-primary);
  border-color: var(--acs-primary);
  background: var(--acs-primary-soft);
}

/* ---------------- 主体 ---------------- */
.acs-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acs-picker {
  background: var(--acs-card);
  border: 1px solid var(--acs-border);
  border-radius: var(--acs-radius);
  padding: 16px;
}

.acs-picker-title {
  margin: 0 0 4px;
  font-weight: 600;
}

.acs-picker-tip {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--acs-text-sub);
}

.acs-system-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.acs-system-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--acs-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: 0.15s;
  font: inherit;
  color: inherit;
}

.acs-system-item:hover {
  border-color: var(--acs-primary);
  background: var(--acs-primary-soft);
}

.acs-system-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acs-primary);
  flex: none;
}

.acs-system-item .name {
  font-weight: 600;
}

.acs-system-item .desc {
  font-size: 12px;
  color: var(--acs-text-sub);
  display: block;
}

/* ---------------- 聊天区 ---------------- */
.acs-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acs-welcome {
  background: var(--acs-card);
  border: 1px solid var(--acs-border);
  border-radius: var(--acs-radius);
  padding: 14px;
}

.acs-welcome-text {
  white-space: pre-wrap;
}

.acs-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.acs-quick button {
  border: 1px solid var(--acs-border);
  background: #fff;
  color: var(--acs-primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
}

.acs-quick button:hover {
  border-color: var(--acs-primary);
  background: var(--acs-primary-soft);
}

.acs-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acs-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.acs-row.user {
  align-items: flex-end;
}

.acs-row.assistant,
.acs-row.agent,
.acs-row.system {
  align-items: flex-start;
}

.acs-bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.acs-row.user .acs-bubble {
  background: var(--acs-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.acs-row.assistant .acs-bubble {
  background: #fff;
  border: 1px solid var(--acs-border);
  border-bottom-left-radius: 4px;
}

.acs-row.agent .acs-bubble {
  background: #f2f7f2;
  border: 1px solid #d8e7d8;
  border-bottom-left-radius: 4px;
}

.acs-row.system .acs-bubble {
  background: #fff8ec;
  border: 1px solid #f2e3c6;
  font-size: 13px;
  color: #8a6d3b;
}

.acs-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--acs-text-sub);
}

.acs-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--acs-border);
  background: #fff;
}

.acs-tag.free {
  color: #2f855a;
  border-color: #cde9d6;
  background: #f2fbf5;
}

.acs-tag.llm {
  color: #2b5d92;
  border-color: #d6e4f4;
  background: #f3f8fd;
}

.acs-tag.fallback {
  color: #8a6d3b;
  border-color: #f0e2cd;
  background: #fdf8ef;
}

.acs-source {
  max-width: 86%;
}

.acs-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.acs-actions button {
  border: none;
  background: none;
  color: var(--acs-text-sub);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
}

.acs-actions button:hover {
  color: var(--acs-primary);
}

.acs-actions button.active {
  color: var(--acs-primary);
  font-weight: 600;
}

.acs-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.acs-reasons button {
  border: 1px solid var(--acs-border);
  background: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--acs-text-sub);
  cursor: pointer;
  font-family: inherit;
}

.acs-reasons button:hover {
  border-color: var(--acs-primary);
  color: var(--acs-primary);
}

.acs-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.acs-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c6ccd6;
  animation: acs-blink 1.1s infinite;
}

.acs-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.acs-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes acs-blink {
  0%,
  60%,
  100% {
    opacity: 0.35;
  }
  30% {
    opacity: 1;
  }
}

.acs-disclaimer {
  font-size: 12px;
  color: var(--acs-text-sub);
  text-align: center;
  padding: 4px 0 0;
  line-height: 1.5;
}

/* ---------------- 底部输入区 ---------------- */
.acs-footer {
  background: var(--acs-card);
  border-top: 1px solid var(--acs-border);
  padding: 8px 12px 10px;
}

.acs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
}

.acs-current {
  font-size: 12px;
  color: var(--acs-text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acs-link {
  border: 1px solid var(--acs-primary);
  color: var(--acs-primary);
  background: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  flex: none;
  font-family: inherit;
}

.acs-link:hover {
  background: var(--acs-primary-soft);
}

.acs-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.acs-input-row textarea {
  flex: 1;
  resize: none;
  max-height: 96px;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--acs-border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--acs-text);
  outline: none;
  background: #fff;
}

.acs-input-row textarea:focus {
  border-color: var(--acs-primary);
}

.acs-send {
  width: 38px;
  height: 38px;
  flex: none;
  border: none;
  border-radius: 10px;
  background: var(--acs-primary);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s;
}

.acs-send:hover {
  filter: brightness(1.08);
}

.acs-send:disabled {
  background: #c6ccd6;
  cursor: not-allowed;
}

/* ---------------- 弹窗 ---------------- */
.acs-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.acs-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.35);
}

.acs-modal-box {
  position: relative;
  width: min(320px, 88vw);
  background: #fff;
  border-radius: var(--acs-radius);
  padding: 18px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
}

.acs-modal-title {
  margin: 0;
  font-weight: 600;
}

.acs-modal-tip {
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--acs-text-sub);
  line-height: 1.6;
}

.acs-modal-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--acs-border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.acs-modal-input:focus {
  border-color: var(--acs-primary);
}

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

.acs-btn {
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--acs-border);
  background: #fff;
  color: var(--acs-text);
  font-family: inherit;
}

.acs-btn.primary {
  background: var(--acs-primary);
  border-color: var(--acs-primary);
  color: #fff;
}

.acs-btn.ghost:hover {
  border-color: var(--acs-primary);
  color: var(--acs-primary);
}

/* 空态 */
.acs-empty {
  background: #fff;
  border: 1px dashed var(--acs-border);
  border-radius: var(--acs-radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--acs-text-sub);
  font-size: 13px;
}

/* 修复：.acs-modal 等元素自带 display，会覆盖浏览器默认的 [hidden] 规则，导致 hidden 属性失效（弹窗一直显示） */
[hidden] {
  display: none !important;
}

/* 修复：弹窗内容必须位于遮罩之上，否则遮罩会拦走「提交 / 取消」的点击 */
.acs-modal-box {
  z-index: 1;
}
