:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #22262f;
  --border: #2d323d;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --accent-2: #a78bfa;
  --danger: #f87171;
  --ok: #34d399;
  --tile: #30343f;
  --tile-on: #4a3f63;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: #14161c;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.brand .logo {
  font-size: 20px;
  color: var(--accent-2);
}

.tagline {
  color: var(--muted);
  font-size: 12px;
}

#nav {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

#nav button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

#nav button:hover {
  color: var(--text);
}

main#view {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #0b1020;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

input, select, textarea {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 6px;
  width: 100%;
}

textarea { min-height: 72px; resize: vertical; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

/* ────────────────────────────────────────────────────────────── */
/*  Topic tabs — 팀 안의 대화 갈래 전환 탭 바                       */
/* ────────────────────────────────────────────────────────────── */

.topic-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.topic-tabs-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px;
  scroll-snap-type: x proximity;
}
.topic-tabs-scroll::-webkit-scrollbar { display: none; }
.topic-tab {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topic-tab:hover {
  color: var(--text);
  border-color: #3d4250;
}
.topic-tab.active {
  background: var(--tile-on);
  color: var(--text);
  border-color: var(--accent);
  font-weight: 600;
}
.topic-tab-label {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.topic-tab-rename,
.topic-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}
.topic-tab:hover .topic-tab-rename,
.topic-tab:hover .topic-tab-close,
.topic-tab.active .topic-tab-rename,
.topic-tab.active .topic-tab-close {
  opacity: 0.85;
}
.topic-tab-rename:hover { color: var(--accent); background: rgba(110, 168, 254, 0.14); opacity: 1; }
.topic-tab-close:hover  { color: #f87171; background: rgba(248, 113, 113, 0.14); opacity: 1; }

.topic-tabs-arrow {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.topic-tabs-arrow:hover:not(:disabled) {
  color: var(--text);
  border-color: #3d4250;
}
.topic-tabs-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}
.topic-tabs-new,
.topic-tabs-archive {
  flex: 0 0 auto;
  width: 30px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}
.topic-tabs-new:hover,
.topic-tabs-archive:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.topic-tabs-archive {
  border-style: solid;
}

/* 지난 토픽 팝오버 */
.topic-archive-popover {
  z-index: 140;
  min-width: 240px;
  max-width: 360px;
  max-height: 420px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  padding: 8px;
}
.topic-archive-title {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.topic-archive-list { display: flex; flex-direction: column; gap: 2px; }
.topic-archive-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topic-archive-open {
  flex: 1 1 auto;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.topic-archive-open:hover { background: rgba(110, 168, 254, 0.08); }
.topic-archive-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.topic-archive-restore {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.topic-archive-restore:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ────────────────────────────────────────────────────────────── */
/*  Feed — 요약 탭(이 토픽의 공용 요약 메모)                        */
/* ────────────────────────────────────────────────────────────── */

.feed-memo-body {
  color: var(--text);
  line-height: 1.6;
  font-size: 13.5px;
}
.feed-memo-body h1,
.feed-memo-body h2,
.feed-memo-body h3 {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--accent);
}
.feed-memo-body h1:first-child,
.feed-memo-body h2:first-child,
.feed-memo-body h3:first-child { margin-top: 0; }
.feed-memo-body ul,
.feed-memo-body ol { margin: 4px 0 10px; padding-left: 20px; }
.feed-memo-body p { margin: 4px 0; }
.feed-memo-body code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 4px;
}
.feed-memo-body pre.plain-memo {
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
  font-size: 13.5px;
}

/* 팀 상단 헤더 — 전역 .row > * { flex:1 } 를 쓰지 않음(예산 문구 줄바꿈 깨짐 방지) */
.project-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.project-header-main {
  flex: 1 1 220px;
  min-width: 0;
}
.project-header-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 1 auto;
}
.project-budget {
  white-space: nowrap;
  line-height: 1.35;
  text-align: right;
}
.project-budget-amount {
  color: var(--text);
  font-weight: 700;
  margin: 0 0.2em;
}
.project-budget-label {
  white-space: nowrap;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cards {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ────────────────────────────────────────────────────────────── */
/*  Login                                                         */
/* ────────────────────────────────────────────────────────────── */

.login {
  max-width: 380px;
  margin: 80px auto;
}

.login h2 {
  margin: 0 0 6px 0;
}

/* 로그인 주 버튼 + 연결 진단 — 전역 .row > * { flex:1 } 를 쓰지 않음 (보조 버튼이 찌그러짐) */
.login-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.login-actions #login-btn {
  flex: 1 1 160px;
  min-width: 0;
}
.login-actions #login-diag {
  flex: 0 0 auto;
  white-space: nowrap;
}

.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
}

.error-block {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.error-title {
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 6px;
}
.error-detail {
  margin: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

/* ────────────────────────────────────────────────────────────── */
/*  Lobby                                                         */
/* ────────────────────────────────────────────────────────────── */

.project-card {
  cursor: pointer;
  transition: border-color 120ms;
}
.project-card:hover {
  border-color: var(--accent);
}
.project-card h3 {
  margin: 0 0 4px 0;
}
.project-card .meta {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
}
.chip.accent { color: var(--accent); border-color: var(--accent); }
.chip.warn { color: #fbbf24; border-color: #fbbf24; }
.chip.chip-soft {
  color: var(--muted);
  border-style: dashed;
  margin-left: 6px;
}

/* ────────────────────────────────────────────────────────────── */
/*  Project / Office                                              */
/* ────────────────────────────────────────────────────────────── */

.office-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.28fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .office-layout { grid-template-columns: 1fr; }
}

.office-canvas {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px 18px;
  min-height: 0;
  overflow: visible;
}

/* 오피스 상단 액션 — .row > * { flex:1 } 금지(버튼이 세로로 늘어나며 글자 깨짐) */
.office-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.office-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.office-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.office-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  min-width: 0;
  overflow: visible;
}

.seat {
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px 10px;
  min-height: 132px;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.seat.speaking {
  background: var(--tile-on);
  border-color: var(--accent-2);
}
.seat.empty {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  min-height: 132px;
  height: 100%;
}

/* 혼: 뱃지 행 → 컨트롤 행 → 이름. 사람: 뱃지 → 이름 */
.seat-head-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.seat-row1 {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 28px;
  min-width: 0;
}

.seat-controls-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.seat-controls-row .seat-toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seat-name-row {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-kind-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.seat-kind-badge--human {
  color: var(--accent);
  border-color: rgba(110, 168, 254, 0.5);
  background: rgba(110, 168, 254, 0.12);
}
.seat-kind-badge--hon {
  color: var(--accent-2);
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.12);
}

.seat-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 0;
  flex-shrink: 0;
  min-width: 0;
}

.seat-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.seat-sub {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}
.seat .role {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}
.seat .balance {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}
.seat .bubble {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  min-width: 120px;
  max-width: min(240px, 34vw);
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.seat .bubble .bubble-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.35;
  max-height: calc(1.35em * 3 + 2px);
  color: var(--text);
}
.seat.speaking .bubble {
  opacity: 1;
}
.seat-mandate {
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
}
.seat-mandate:hover {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.seat-rename {
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
}
.seat-rename:hover {
  color: var(--text);
  border-color: var(--accent);
}

.seat-fire {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  border-radius: 4px;
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.45);
  cursor: pointer;
}
.seat-fire:hover {
  background: rgba(248, 113, 113, 0.28);
  color: #fecaca;
}

.feed {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: min(560px, 52vh);
  max-height: min(820px, calc(100vh - 132px));
  overflow: hidden;
}

.reply-preparing-bar {
  flex-shrink: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: rgba(110, 168, 254, 0.08);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  position: relative;
  z-index: 2;
}
.reply-preparing-bar[hidden] {
  display: none !important;
}
.reply-preparing-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.reply-preparing-text {
  flex: 1;
  min-width: 0;
}
.reply-preparing-stop {
  flex-shrink: 0;
  font-size: 12px;
  padding: 4px 10px;
}
.reply-preparing-inner::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: reply-prep-pulse 1s ease-in-out infinite;
}
@keyframes reply-prep-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

.seat.seat-preparing {
  border-color: rgba(110, 168, 254, 0.65);
  box-shadow: 0 0 0 1px rgba(110, 168, 254, 0.25);
}

.feed .list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

/* 미확인 턴 안내 — 스크롤이 위쪽에 있을 때 피드 하단에 스티키로 붙는다. */
.feed-unread {
  position: sticky;
  bottom: 10px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 3;
  max-width: 92%;
  animation: feed-unread-pop 160ms ease-out;
}
.feed-unread[hidden] { display: none !important; }
.feed-unread:hover { filter: brightness(1.05); }
.feed-unread-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-unread-cta {
  font-weight: 700;
  opacity: 0.85;
  flex-shrink: 0;
}
@keyframes feed-unread-pop {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.feed .turn {
  max-width: min(82%, 520px);
  align-self: flex-start;
}
.feed .turn.mine {
  align-self: flex-end;
}
.feed .turn.system {
  max-width: 100%;
  align-self: stretch;
}

.feed .turn .head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.feed .turn.mine .head {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.feed .turn .speaker {
  font-weight: 600;
}
.feed .turn .ts {
  color: var(--muted);
  font-size: 11px;
}
.feed .turn .cost {
  color: var(--accent-2);
  font-size: 11px;
}

/* 피드 멘션 하이라이트 — dispatcher OPTIONAL_JOSA 와 동일 규칙으로 매칭됨 */
.mention-tag {
  display: inline;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.94em;
  border: 1px solid var(--border);
  vertical-align: baseline;
}
.mention-tag.mention-hon {
  color: var(--accent-2);
  background: rgba(167, 139, 250, 0.16);
  border-color: rgba(167, 139, 250, 0.45);
}
.mention-tag.mention-human {
  color: var(--accent);
  background: rgba(110, 168, 254, 0.16);
  border-color: rgba(110, 168, 254, 0.42);
}
.mention-tag.mention-unknown {
  color: var(--muted);
  background: rgba(139, 147, 167, 0.12);
  border-color: rgba(139, 147, 167, 0.35);
}
.mention-tag.mention-bot {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.4);
}

.feed .turn .body {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  line-height: 1.45;
}
.feed .turn.mine .body {
  border-radius: 14px 14px 6px 14px;
  background: rgba(110, 168, 254, 0.18);
  border-color: rgba(110, 168, 254, 0.35);
}
.feed .turn.system .body {
  color: var(--muted);
  font-style: italic;
  background: transparent;
  border: none;
  padding: 4px 0;
  border-radius: 0;
}

.feed .turn .body-md {
  white-space: normal;
}
.feed .turn .body-md :first-child {
  margin-top: 0;
}
.feed .turn .body-md :last-child {
  margin-bottom: 0;
}
.feed .turn .body-md p {
  margin: 0.45em 0;
}
.feed .turn .body-md ul,
.feed .turn .body-md ol {
  margin: 0.35em 0;
  padding-left: 1.25rem;
}
.feed .turn .body-md pre {
  overflow-x: auto;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0a0c10;
  border: 1px solid var(--border);
  font-size: 12px;
}
.feed .turn .body-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.feed .turn .body-md img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 8px 0;
  cursor: zoom-in;
  max-height: 220px;
  object-fit: contain;
}
.feed .turn .body-md a {
  color: var(--accent);
  word-break: break-all;
}
.feed .turn .body-md .video-embed {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  max-height: 240px;
}
.feed .turn .body-md .video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.img-lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.img-lightbox-inner {
  max-width: 96vw;
  max-height: 92vh;
}
.img-lightbox-inner img {
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
}

.rules-textarea {
  width: 100%;
  min-height: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-shrink: 0;
}

.composer-field-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.composer textarea {
  width: 100%;
  min-height: 50px;
}

/* ────────────────────────────────────────────────────────────── */
/*  Feed tabs — 대화창/입력창 영역 전체를 전환                      */
/* ────────────────────────────────────────────────────────────── */

.feed-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
.feed-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.feed-tab:hover {
  color: var(--text);
  border-color: #3d4250;
}
.feed-tab.is-active {
  background: var(--tile-on);
  color: var(--text);
  border-color: var(--accent);
  font-weight: 600;
}
.feed-tab-label { font-weight: inherit; }
.feed-memo-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.feed-memo-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.2);
}
.feed-memo-dot[hidden] { display: none; }

/* 요약 탭 활성 시: 채팅 관련 자식을 전부 숨기고 feed-memo 가 자리를 넘겨받는다. */
.feed[data-feed-tab="memo"] > #feed-list,
.feed[data-feed-tab="memo"] > .reply-preparing-bar,
.feed[data-feed-tab="memo"] > .composer {
  display: none !important;
}

.feed-memo {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 20px;
  background: rgba(110, 168, 254, 0.03);
}
.feed-memo[hidden] { display: none !important; }
.feed-memo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.mention-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: auto;
  /* 입력창 아래로 두면 화면 하단에서 잘리므로, 래퍼(텍스트영역) 위로 띄움 */
  bottom: calc(100% + 4px);
  max-height: min(220px, 42vh);
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.mention-dropdown[hidden] {
  display: none !important;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

.mention-item:last-child {
  border-bottom: none;
}

.mention-item:hover,
.mention-item.selected {
  background: rgba(110, 168, 254, 0.12);
}

.mention-item.muted {
  color: var(--muted);
  cursor: default;
  font-weight: 400;
}

.mention-item .mention-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

/* ────────────────────────────────────────────────────────────── */
/*  Modal                                                         */
/* ────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  max-width: 520px;
  width: 90%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

.modal-scout,
.modal-wide {
  max-width: 640px;
}

.scout-list {
  max-height: 380px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.scout-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}

.scout-row:last-child {
  border-bottom: none;
}

.scout-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scout-bonus {
  width: 4.5rem;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

/* 템플릿 리스트 · 긴 목록은 모달 내부에서 스크롤 */
.modal #tpl-list {
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 4px;
}

.template-option {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  margin-bottom: 6px;
}
.template-option:hover { border-color: var(--accent); }
.template-option.selected { border-color: var(--accent-2); background: var(--panel-2); }
.template-option .name { font-weight: 600; }
.template-option .desc { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ─── 좌석 카드 클릭 상호작용 ─────────────────────────────────── */
.seat.clickable {
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.seat.clickable:hover {
  border-color: var(--accent-2);
}
.seat.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── 좌석 상세 모달 ─────────────────────────────────────────── */
.member-profile-modal {
  max-width: 720px;
  padding: 0;
}
.member-profile-modal .mp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.member-profile-modal .mp-head-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.member-profile-modal .mp-name {
  font-size: 18px;
  font-weight: 700;
}
.member-profile-modal .mp-sub {
  color: var(--muted);
  font-size: 13px;
}
.member-profile-modal .mp-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
}
.member-profile-modal .mp-close:hover { border-color: var(--accent); }
.member-profile-modal .mp-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tier-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
}
.tier-pill.tier-pro { color: var(--accent-2); border-color: var(--accent-2); }
.tier-pill.tier-flagship { color: var(--accent); border-color: var(--accent); }

.mp-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.mp-fact {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}
.mp-fact-k {
  color: var(--muted);
  font-size: 11px;
}
.mp-fact-v {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
  word-break: break-all;
}

.mp-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
}
.mp-section.mp-empty {
  border-style: dashed;
  background: transparent;
}
.mp-section-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  display: inline-block;
}
.mp-subtle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* 스탯 바 */
.mp-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-row {
  display: grid;
  grid-template-columns: 56px 1fr 68px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.stat-name { color: var(--muted); }
.stat-bar {
  position: relative;
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.stat-bar.vitality .stat-bar-fill {
  background: linear-gradient(90deg, #ffb36b, #ff6b6b);
}
.stat-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.stat-delta { margin-left: 4px; font-weight: 500; font-size: 11px; }
.stat-delta.up { color: var(--accent-2); }
.stat-delta.down { color: #ff6b6b; }

/* 욕구 */
.mp-needs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mp-needs li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 12px;
}
.mp-needs .need-urgency {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* 재능/MCP */
.mp-skills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.mp-skills li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.mp-skills .skill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-skills .skill-mastery {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
}

/* 어시스턴트 태그들 */
.mp-tag-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.mp-tag-label {
  color: var(--muted);
  font-size: 11px;
  margin-right: 4px;
}
.mp-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 11px;
}
.mp-tag-tool { color: var(--accent-2); border-color: var(--accent-2); }
.mp-tag-more { color: var(--muted); }

/* 혼 전용 지침 */
.mp-mandate {
  max-height: 280px;
  overflow-y: auto;
}

/* 역할 플레이북 (접힘) */
.mp-playbook summary {
  cursor: pointer;
  list-style: none;
}
.mp-playbook summary::-webkit-details-marker { display: none; }
.mp-playbook summary::before {
  content: "▸ ";
  color: var(--muted);
}
.mp-playbook[open] summary::before { content: "▾ "; }
.mp-playbook-body {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.55;
  max-height: 240px;
  overflow-y: auto;
}
