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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --accent: #7c6af7;
  --accent-hover: #9585f8;
  --success: #3fb950;
  --error: #f85149;
  --warning: #d29922;
  --radius: 8px;
  --sidebar-w: 340px;

  /* 角色颜色 */
  --role-0: #7c6af7;
  --role-1: #3fb950;
  --role-2: #f78166;
  --role-3: #ffa657;
  --role-4: #76e3ea;
  --role-5: #f2cc60;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Section ─────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Form elements ─────────────────────────────────────────── */
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

select {
  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='%237d8590' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Range input ─────────────────────────────────────────── */
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] {
  flex: 1; padding: 0; border: none; background: transparent;
  cursor: pointer; accent-color: var(--accent);
}
.range-val {
  font-size: 13px; font-weight: 600; color: var(--text);
  width: 20px; text-align: center;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; padding: 8px 14px; transition: all 0.15s;
  text-decoration: none; white-space: nowrap;
}

.btn-primary {
  background: var(--accent); color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: transparent; color: var(--error); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(248, 81, 73, 0.1); border-color: var(--error); }

.btn-icon {
  width: 26px; height: 26px; padding: 0;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; transition: all 0.15s;
}
.btn-icon:hover { background: var(--border); color: var(--text); }

.btn-full { width: 100%; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}

/* ── Roles list ─────────────────────────────────────────── */
.role-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.role-item:hover { border-color: var(--accent); }

.role-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  color: white;
}

.role-info { flex: 1; min-width: 0; }
.role-name { font-size: 13px; font-weight: 500; overflow: hidden; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.role-type-badge { font-size: 10px; padding: 1px 6px; border-radius: 10px; border: 1px solid; flex-shrink: 0; }
.role-desc { font-size: 11px; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Role type selector ─────────────────────────────────── */
.role-type-group {
  display: flex; gap: 8px;
}

.role-type-option {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.role-type-option:hover { border-color: var(--accent); }
.role-type-option input[type=radio] { display: none; }
.role-type-option input[type=radio]:checked ~ span { color: var(--accent); }
.role-type-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.08);
}
.role-type-option span { font-size: 13px; font-weight: 500; }
.role-type-option small { font-size: 10px; color: var(--text-muted); line-height: 1.3; }

.role-actions { display: flex; gap: 4px; }
.role-actions .btn-icon { width: 22px; height: 22px; font-size: 12px; }

.roles-empty {
  text-align: center; color: var(--text-muted); font-size: 12px;
  padding: 16px; border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ── Prompts editor ─────────────────────────────────────── */
details { border: 1px solid var(--border); border-radius: var(--radius); }
details summary {
  padding: 10px 12px; font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-muted);
}
details summary::after { content: '▾'; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(-180deg); }
details summary::-webkit-details-marker { display: none; }

.prompts-body { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.prompt-field label { font-size: 11px; margin-bottom: 4px; }
.prompt-field textarea { font-size: 12px; min-height: 70px; }
.prompt-vars { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.prompt-vars code { background: var(--surface); padding: 1px 4px; border-radius: 3px; color: var(--accent); }

/* ── Main area ─────────────────────────────────────────────── */
.main-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.main-header h2 { font-size: 14px; font-weight: 600; }

.save-status { font-size: 12px; transition: color 0.2s; }

/* ── 任务编辑器 ─────────────────────────────────────────── */
.task-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.task-editor #taskEditorContainer {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* CodeMirror 编辑器撑满容器 */
.task-editor .cm-editor          { flex: 1; overflow: hidden; }
.task-editor .cm-scroller::-webkit-scrollbar { width: 4px; }
.task-editor .cm-scroller::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.meeting-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.meeting-stream::-webkit-scrollbar { width: 4px; }
.meeting-stream::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Placeholder */
.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.placeholder-icon { font-size: 48px; opacity: 0.3; }
.placeholder h3 { font-size: 18px; font-weight: 500; color: var(--text); }
.placeholder p { font-size: 13px; max-width: 300px; }

/* Meeting events */
.event-banner {
  font-size: 12px; color: var(--text-muted);
  padding: 6px 0; text-align: center;
  display: flex; align-items: center; gap: 8px;
}
.event-banner::before, .event-banner::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Session info card（静态开场卡片） */
.session-info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.sic-topic {
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.sic-label {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); flex-shrink: 0;
}
.sic-task { font-size: 13px; color: var(--text); line-height: 1.5; }
.sic-members { display: flex; flex-direction: column; gap: 8px; }
.sic-member { display: flex; align-items: center; gap: 8px; }
.sic-member-info { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sic-member-name { font-size: 13px; font-weight: 500; }
.sic-member-desc { font-size: 11px; color: var(--text-muted); }

.turn {
  margin-bottom: 24px;
}

.turn-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}

.turn-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0; color: white;
}

.turn-meta { flex: 1; }
.turn-role { font-size: 14px; font-weight: 600; }
.turn-round { font-size: 11px; color: var(--text-muted); }

.turn-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-left: 46px;
}

.mention {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
}

.turn-content.streaming::after {
  content: '▋';
  display: inline-block;
  animation: blink 0.8s step-end infinite;
  color: var(--accent);
}

.turn-error {
  margin-left: 46px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--error);
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.meeting-complete {
  text-align: center; padding: 20px;
  font-size: 13px; color: var(--success);
}

/* ── Status indicator ─────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.idle { background: var(--text-muted); }
.status-dot.running {
  background: var(--success);
  animation: pulse 1.5s ease-in-out infinite;
}
.status-dot.error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(63, 185, 80, 0); }
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  transform: translateY(10px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-header .btn-icon { border: none; }

.modal-body {
  padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

/* ── Misc ─────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-muted);
}
