/* ============ Council Roundtable Demo 样式 ============ */
/* 纯手写 CSS，无构建依赖。浅色主题。 */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6472;
  --ink-3: #9aa3b0;
  --line: #e5e8ec;
  --accent: #3b6ef6;
  --accent-soft: #ecf1fe;
  --green: #1d9e5f;
  --green-soft: #e7f6ee;
  --red: #d9463e;
  --red-soft: #fdeeec;
  --amber: #b97e12;
  --amber-soft: #fbf3e0;
  --purple: #7a5af8;
  --purple-soft: #f0edfd;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app { height: 100%; }

button {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  transition: filter .15s, opacity .15s, transform .05s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn {
  padding: 8px 16px;
  font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #f2f4f7; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-green { background: var(--green); color: #fff; }

input, textarea, select {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 12px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 通用视图容器 ---------- */
.view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- 大厅 ---------- */
.lobby-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}
.lobby {
  width: 100%;
  max-width: 860px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.brand-logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b6ef6, #7a5af8);
  display: grid; place-items: center;
  font-size: 28px;
  box-shadow: var(--shadow-lg);
}
.brand-logo-img { object-fit: cover; border: 2px solid #fff; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }

.identity-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 18px 0 26px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.identity-bar .id-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.identity-bar .btn { padding: 5px 12px; font-size: 13px; flex: none; white-space: nowrap; }
.identity-bar select.btn { width: auto; flex: none; }
.identity-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.identity-bar .hint { color: var(--ink-3); font-size: 13px; margin-left: auto; }

.lobby-actions { display: flex; gap: 12px; margin-bottom: 30px; }

.section-title {
  font-size: 15px; font-weight: 700;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; padding: 1px 8px; border-radius: 99px;
}

.meeting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.meeting-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s;
}
.meeting-card:hover { box-shadow: var(--shadow-lg); }
.meeting-card .topic { font-weight: 700; font-size: 15px; line-height: 1.4; }
.meeting-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meeting-card .foot { display: flex; align-items: center; margin-top: auto; }
.meeting-card .foot .join { margin-left: auto; }

.empty {
  padding: 40px;
  text-align: center;
  color: var(--ink-3);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.badge-state-lobby { background: #eef1f5; color: var(--ink-2); }
.badge-state-opening { background: var(--purple-soft); color: var(--purple); }
.badge-state-discussion { background: var(--accent-soft); color: var(--accent); }
.badge-state-voting { background: var(--amber-soft); color: var(--amber); }
.badge-state-summary { background: var(--green-soft); color: var(--green); }
.badge-state-closed { background: #eef1f5; color: var(--ink-3); }
.badge-kind { background: var(--accent-soft); color: var(--accent); }
.badge-kind.ai { background: var(--purple-soft); color: var(--purple); }
.badge-host { background: var(--amber-soft); color: var(--amber); }
.badge-online { background: var(--green-soft); color: var(--green); }
.badge-offline { background: #eef1f5; color: var(--ink-3); }
.badge-hand { background: var(--amber-soft); color: var(--amber); }

/* ---------- 创建页 ---------- */
.create-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex; justify-content: center;
  padding: 40px 20px;
}
.create-card {
  width: 100%; max-width: 720px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex; flex-direction: column; gap: 20px;
}
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field .sub { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.field textarea { min-height: 84px; resize: vertical; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.seg button {
  padding: 8px 18px;
  background: #fff;
  color: var(--ink-2);
  font-weight: 600;
}
.seg button.on { background: var(--accent); color: #fff; }

.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.persona-grid .persona-group-title {
  grid-column: 1 / -1;           /* 组标题横跨整行 */
  margin: 14px 0 0;
  padding-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  border-bottom: 1px dashed var(--line);
}
.persona-grid .persona-group-title:first-child { margin-top: 0; }

/* 默认话题模板 chips */
.topic-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-btn {
  padding: 4px 12px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2, #f6f7fb);
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.persona-chip {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  transition: border-color .12s, background .12s;
}
.persona-chip:hover { border-color: var(--accent); }
.persona-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.persona-chip .avatar { font-size: 22px; line-height: 1; }
.persona-chip .pname { font-weight: 700; font-size: 14px; }
.persona-chip .prole { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.persona-chip .pstance { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.create-foot { display: flex; gap: 12px; justify-content: flex-end; }

/* ---------- 会议页 ---------- */
.room { display: flex; flex-direction: column; height: 100%; }

.room-top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.room-top .topic { font-weight: 800; font-size: 16px; }
.room-top .spacer { flex: 1; }

.room-body { flex: 1; display: flex; min-height: 0; }

/* 左栏：参会人 */
.room-left {
  width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.room-left h3, .room-right h3 {
  margin: 0; padding: 14px 16px 8px;
  font-size: 12px; letter-spacing: 1px;
  color: var(--ink-3);
  text-transform: uppercase;
}
.p-list { display: flex; flex-direction: column; gap: 4px; padding: 0 10px 10px; }
.p-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.p-item:hover { background: #f4f6f9; }
.p-item .pavatar { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.p-item.ai .pavatar { background: var(--purple-soft); }
.p-item .pinfo { min-width: 0; flex: 1; }
.p-item .pname { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.p-item .prole { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-item .pstat { display: flex; gap: 4px; }
.p-item .hand { font-size: 14px; animation: wave 1s infinite; }
@keyframes wave { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }

.invite-box { padding: 10px 14px; border-top: 1px solid var(--line); margin-top: auto; }
.invite-box select { margin-bottom: 8px; font-size: 13px; padding: 7px 10px; }
.invite-box button { width: 100%; font-size: 13px; }

/* 中央：消息流 */
.room-center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.msg-flow {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg { display: flex; gap: 10px; max-width: 86%; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .mavatar { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; font-size: 17px; background: var(--accent-soft); }
.msg.ai .mavatar { background: var(--purple-soft); }
.msg.host .mavatar { background: var(--amber-soft); }
.msg .mbody { min-width: 0; }
.msg .mhead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.msg .mname { font-weight: 700; font-size: 13px; }
.msg .mtime { font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.msg .mtext {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 4px 12px 12px 12px;
  font-size: 14px;
  line-height: 1.65;
  box-shadow: var(--shadow);
  word-break: break-word;
}
.msg.self .mtext { background: var(--accent-soft); border-color: #d4e0fd; }
.msg.system { align-self: center; max-width: 92%; }
.msg.system .mtext {
  background: #f0f2f5;
  border: none;
  border-radius: 99px;
  padding: 5px 16px;
  font-size: 12.5px;
  color: var(--ink-2);
  box-shadow: none;
}
.msg.vote .mtext { background: var(--amber-soft); border-color: #f0e2bd; }

/* 决策卡片 */
.msg.card { align-self: stretch; max-width: 100%; }
.dcard {
  background: linear-gradient(135deg, #f6f8ff, #fdf7ff);
  border: 1px solid #dcd9f5;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-lg);
}
.dcard h4 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dcard .conclusion { font-size: 16px; font-weight: 800; margin: 0 0 12px; }
.dcard ul { margin: 6px 0; padding-left: 20px; }
.dcard li { font-size: 13.5px; line-height: 1.8; color: var(--ink-2); }
.dcard .risk { background: var(--red-soft); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; color: var(--red); margin: 8px 0; }
.dcard .votebars { display: flex; gap: 10px; margin-top: 10px; }
.dcard .vbar { flex: 1; border-radius: 8px; padding: 6px 10px; text-align: center; font-size: 13px; font-weight: 700; }
.dcard .vbar.approve { background: var(--green-soft); color: var(--green); }
.dcard .vbar.reject { background: var(--red-soft); color: var(--red); }
.dcard .vbar.abstain { background: #eef1f5; color: var(--ink-2); }

/* 投票横幅 */
.vote-banner {
  background: var(--amber-soft);
  border-top: 1px solid #f0e2bd;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px;
}
.vote-banner .bars { flex: 1; display: flex; gap: 14px; color: var(--ink-2); font-family: var(--mono); }
.vote-banner button { padding: 6px 14px; border-radius: 7px; font-weight: 700; font-size: 13px; }

/* 输入区 */
.msg-input {
  display: flex; gap: 10px;
  padding: 12px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.msg-input input { flex: 1; }
.msg-input .btn { padding: 9px 18px; }
.hand-btn.on { background: var(--amber); color: #fff; }

/* 右栏：议程与产出 */
.room-right {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.agenda { padding: 4px 16px 14px; }
.agenda-step {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0;
  color: var(--ink-3);
  font-size: 13.5px;
}
.agenda-step .idx {
  width: 20px; height: 20px; border-radius: 50%;
  background: #eef1f5; color: var(--ink-3);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  margin-top: 1px;
}
.agenda-step.done { color: var(--ink-2); }
.agenda-step.done .idx { background: var(--green-soft); color: var(--green); }
.agenda-step.now { color: var(--ink); font-weight: 700; }
.agenda-step.now .idx { background: var(--accent); color: #fff; }

.right-block { padding: 4px 16px 16px; }
.mini-decision {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--ink-2);
  background: #fafbfd;
}
.mini-decision strong { color: var(--ink); }
.right-actions { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 18px; }
.right-actions .btn { font-size: 13px; padding: 9px; }

/* toast */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 36, 48, .92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: fadein .2s ease;
  z-index: 999;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #d3d8df; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b9c0ca; }

/* 响应式 */
@media (max-width: 1080px) {
  .room-right { display: none; }
}
@media (max-width: 780px) {
  .room-left { display: none; }
}

/* ---------- 使用指引卡片 ---------- */
.guide-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.guide-card h3 { margin: 0 0 10px; font-size: 15px; }
.guide-card ol { margin: 0; padding-left: 20px; }
.guide-card li { font-size: 13.5px; line-height: 1.9; color: var(--ink-2); }
.guide-card li b { color: var(--ink); }
.guide-card code {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 6px; border-radius: 4px; font-size: 12px;
  font-family: var(--mono);
}
.guide-card .warn { color: var(--amber); }

/* ---------- LLM 配置弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 20, 30, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: min(440px, 92vw);
  padding: 22px 24px;
}
.modal h3 { margin: 0 0 4px; }
.modal .field { margin-bottom: 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- 创建页：自定义角色 + Excel ---------- */
.paradigm-desc {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.7;
}
.custom-box {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fafbfd;
}
.cf-row { display: flex; gap: 8px; margin-bottom: 8px; }
.cf-row input { flex: 1; min-width: 0; font-size: 13px; padding: 7px 10px; }
.excel-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.persona-chip { position: relative; }
.persona-chip .chip-del {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-size: 11px; line-height: 1;
  box-shadow: var(--shadow);
}
.persona-chip .badge-kind { font-size: 10px; padding: 0 6px; }
