:root {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1c2030;
  --text: #e7e9ee;
  --muted: #8a92a6;
  --accent: #d4a85a;
  --accent-2: #f0c878;
  --claude: #cc785c;
  --gpt: #10a37f;
  --gemini: #4285f4;
  --synth: #d4a85a;
  --border: #262a37;
  --radius: 14px;
  --danger: #f47272;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }

/* ────────── 레이아웃 ────────── */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: #0b0d12;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main { overflow-y: auto; padding: 0; }
.view { max-width: 1100px; margin: 0 auto; padding: 24px 28px 200px; }

/* ────────── 사이드바 ────────── */
.sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.sidebar-head h1 { margin: 0 0 12px; font-size: 16px; line-height: 1.35; letter-spacing: -0.01em; }
.new-btn {
  width: 100%; background: var(--accent); color: #1a1a1a;
  border: none; border-radius: 8px; padding: 9px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.new-btn:hover { opacity: 0.92; }

.filter { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filter label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.filter select {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 8px; font-size: 13px;
}

.meetings-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.meetings-list .empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }

.meeting-item {
  position: relative;
  padding: 10px 16px;
  border-bottom: 1px solid #1a1d27;
  cursor: pointer;
  transition: background 0.1s;
}
.meeting-item:hover { background: #14171f; }
.meeting-item.active { background: #1a1d27; border-left: 3px solid var(--accent); padding-left: 13px; }

.item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 14px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  line-height: 1;
  padding: 0;
}
.meeting-item:hover .item-delete { opacity: 1; }
.item-delete:hover { background: rgba(244,114,114,0.15); color: var(--danger); }
.meeting-item .date { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.meeting-item .title {
  font-size: 13px; line-height: 1.45; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.meeting-item .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  font-size: 10px; background: var(--panel-2); color: var(--muted);
  padding: 2px 6px; border-radius: 3px; border: 1px solid var(--border);
}

/* ────────── 새 회의 입력 (composeView) ────────── */
.topbar { padding: 8px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar .sub { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.composer {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.composer textarea {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-size: 15px; line-height: 1.55;
  resize: vertical; font-family: inherit;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 12px; margin-top: 12px; align-items: flex-end; }
.ctx { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.ctx span { font-size: 12px; color: var(--muted); }
.ctx input {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px;
}
.ctx input:focus { outline: none; border-color: var(--accent); }

#askBtn {
  background: var(--accent); color: #1a1a1a; border: none;
  border-radius: 10px; padding: 12px 22px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#askBtn:hover { opacity: 0.92; }
#askBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ────────── thread 헤더 ────────── */
.thread-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.thread-head .head-main { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.icon-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(244,114,114,0.08);
}
.thread-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 12px;
  background: rgba(212,168,90,0.18); color: var(--accent); font-weight: 600;
}
.status-badge.closed { background: #1c2030; color: var(--muted); }
.round-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 12px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}
.tags-inline { display: flex; gap: 4px; flex-wrap: wrap; }
.thread-head h2 {
  font-size: 18px; line-height: 1.5; margin: 0;
  word-break: keep-all; white-space: pre-wrap;
}

/* ────────── thread 타임라인 ────────── */
.thread { display: flex; flex-direction: column; gap: 14px; }

.thread-block {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.prompt-block { border-color: var(--accent); }
.block-head {
  font-size: 12px; color: var(--accent); font-weight: 600;
  margin-bottom: 8px; letter-spacing: 0.02em;
}
.prompt-body {
  font-size: 15px; line-height: 1.65; white-space: pre-wrap;
}
.ctx-line {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}

.round-heading {
  margin: 18px 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.round-heading.synth-heading { color: var(--accent); border-bottom-color: var(--accent); }

/* ────────── 합의도 진행 바 ────────── */
.consensus-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
}
.consensus-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.consensus-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.consensus-score { font-size: 22px; font-weight: 700; color: var(--text); }
.consensus-score small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }

.consensus-track {
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.consensus-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.consensus-fill.high { background: linear-gradient(90deg, #4ade80, #22c55e); }
.consensus-fill.mid  { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.consensus-fill.low  { background: linear-gradient(90deg, #f87171, #ef4444); }

.consensus-tier {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}
.consensus-tier.high { color: #4ade80; }
.consensus-tier.mid  { color: #fbbf24; }
.consensus-tier.low  { color: #f87171; }
.round-heading.loading-round::after {
  content: " ⏳";
}

.round-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.round-grid.synth-grid { grid-template-columns: 1fr; }

/* ────────── turn 카드 ────────── */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.card.synthesis { border-color: var(--accent); }
.card.synthesis header { background: linear-gradient(90deg, rgba(212,168,90,0.15), transparent); }

.card header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.card header .title { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card .model {
  font-size: 11px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.c { background: var(--claude); }
.dot.g { background: var(--gpt); }
.dot.m { background: var(--gemini); }
.dot.s { background: var(--synth); }

.card .body {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  min-height: 100px;
  color: var(--text);
}
.card .body.loading { color: var(--muted); font-style: italic; }
.card .body.error { color: var(--danger); }

/* 마크다운 */
.card .body strong { color: var(--accent); font-weight: 700; }
.card .body em { color: #c8d0e0; font-style: italic; }
.card .body ul { margin: 8px 0; padding-left: 22px; }
.card .body li { margin: 4px 0; }
.card .body h2, .card .body h3, .card .body h4 {
  margin: 12px 0 6px; font-weight: 700; color: var(--text);
}
.card .body h2 { font-size: 16px; }
.card .body h3 { font-size: 15px; }
.card .body h4 { font-size: 14px; color: var(--accent); }
.card .body code {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.card .body pre {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0;
}
.card .body pre code { background: transparent; border: none; padding: 0; }

/* ────────── 하단 컨트롤바 ────────── */
.thread-controls {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 60%, rgba(15,17,21,0.0));
  padding: 18px 0 14px;
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
  z-index: 10;
}
.thread-controls button {
  flex: 1;
  min-width: 180px;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity 0.15s, transform 0.05s;
}
.thread-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.thread-controls button:not(:disabled):hover { opacity: 0.92; }
.thread-controls button:not(:disabled):active { transform: translateY(1px); }

.thread-controls .primary {
  background: var(--accent); color: #1a1a1a; border-color: var(--accent);
}
.thread-controls .secondary {
  background: var(--panel-2); color: var(--text); border-color: var(--accent);
}
.thread-controls .ghost {
  background: transparent; color: var(--muted); flex: 0 0 auto; min-width: 100px;
}
.thread-controls .ghost:hover { color: var(--danger); border-color: var(--danger); }

/* ────────── 반응형 ────────── */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .round-grid { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
  #askBtn { width: 100%; }
  .thread-controls { flex-direction: column; }
  .thread-controls button { width: 100%; }
}
