/* ═══════════════════════════════════════════════════════════════════
   CTW v4.0 — "Quiet OS"
   Linear/Vercel/Raycast 톤: neutral 그레이 + 단일 액센트(Anthropic orange)
   Inter sans 통합 + JetBrains Mono(데이터)
   ═══════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');
/* 2026-05-24: 한글 폰트 통일 — Pretendard (Inter 비례에 맞춰 디자인된 한국어 글꼴, jsdelivr CDN)
   이전: Inter → 한글 fallback (Malgun Gothic / system) 으로 떨어져 mixed 시 어색. */
@import url('https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/variable/pretendardvariable.min.css');
@import url('./tokens.css');

:root {
  /* ── Surfaces ────────────────────────────────────────────── */
  --bg-primary:    #0A0A0B;   /* near-black */
  --bg-secondary:  #131316;   /* surface */
  --bg-tertiary:   #1B1B1F;   /* elevated */
  --border:        #26262B;   /* hairline */
  --border-warm:   #34343A;   /* hover/focus */

  --text-primary:  #FAFAFA;
  --text-secondary:#A1A1AA;
  --text-faint:    #71717A;

  /* ── Accent (Anthropic orange — single spark) ────────────── */
  --rust:          var(--ctw-brand-9);   /* main */
  --rust-soft:     var(--ctw-brand-10);   /* hover/highlight */
  --rust-deep:     var(--ctw-brand-pressed);   /* pressed */

  /* ── Status (modern muted) ───────────────────────────────── */
  --sage:          #34D399;   /* success/active */
  --sage-deep:     #10B981;
  --ochre:         #FBBF24;   /* warn */
  --burgundy:      var(--ctw-danger-9);   /* error */
  --paper:         #FAFAFA;

  /* ── 호환 alias (기존 클래스명 유지) ─────────────────────── */
  --accent-green:  var(--sage);
  --accent-blue:   #60A5FA;
  --accent-orange: var(--rust);
  --accent-yellow: var(--ochre);
  --accent-purple: #A78BFA;

  --brand-start:   var(--rust);
  --brand-end:     var(--rust-deep);
  --brand-gradient: linear-gradient(135deg, var(--rust-soft) 0%, var(--rust) 100%);
  --brand-fg:      var(--paper);

  --bg:    var(--bg-primary);
  --bg2:   var(--bg-secondary);
  --fg:    var(--text-primary);
  --muted: var(--text-secondary);
  --card:  var(--bg-tertiary);
  --accent: var(--rust);

  /* ── Typography (single sans) ────────────────────────────── */
  --font-display: 'Inter', 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  --font-body:    'Inter', 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* ── Grain 제거 (Quiet OS = flat) ────────────────────────── */
  --grain-url: none;

  /* ── Radius/Shadow tokens ────────────────────────────────── */
  --radius:       var(--ctw-radius-md);
  --radius-sm:    var(--ctw-radius-sm);
  --radius-lg:    var(--ctw-radius-lg);
  --shadow-sm:    0 1px 0 rgba(0,0,0,0.04);
  --shadow:       0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
}

[data-theme="light"] {
  --bg-primary:    #FAFAFA;
  --bg-secondary:  #FFFFFF;
  --bg-tertiary:   #F4F4F5;
  --border:        #E5E5E7;
  --border-warm:   #D4D4D8;
  --text-primary:  #09090B;
  --text-secondary:#52525B;
  --text-faint:    #71717A;
}

/* ═══════════════════════════════════════════════════════════════════
   Global typography & texture
   ═══════════════════════════════════════════════════════════════════ */
html, body {
  font-family: var(--font-body);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  font-optical-sizing: auto;
  letter-spacing: -0.005em;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* PWA: iOS Safari 가 가로/standalone 모드에서 글자를 임의 확대하는 동작 차단 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Grain texture removed (CTW v4.0 Quiet OS — flat surfaces) */

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

code, pre, kbd, samp, .sid, [data-mono],
.session-id, .card-meta .sid, .card-meta .branch,
.an-kpi-val, .ds-chip strong, .ds-chip b {
  font-family: var(--font-mono);
  font-feature-settings: "ss01" 1, "calt" 1, "zero" 1;
}

/* 서브셋 utility */
.smallcaps {
  font-variant: all-small-caps;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.italic-caption {
  font-style: italic;
  color: var(--text-secondary);
  font-feature-settings: "swsh" 1;
}

/* 더블 헤어라인 (신문지) */
.rule-double {
  border: none;
  height: 4px;
  border-top: 1px solid var(--border-warm);
  border-bottom: 1px solid var(--border-warm);
  background: var(--bg-secondary);
}

/* 페이지 진입 stagger */
@keyframes ctw-fade-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.grid > * {
  animation: ctw-fade-rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

/* 상태 도트 호흡 */
@keyframes ctw-breath {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.92); }
}
.status-dot.working,
.session-card-mini.tool_executing::before,
.session-card-mini.awaiting_input::before {
  animation: ctw-breath 2.4s ease-in-out infinite;
}

/* === Dashboard === */
.title-row { display: flex; align-items: center; gap: 6px; margin: 6px 0 10px 0; padding-bottom: 8px; border-bottom: 1px dashed #30363d; }
.title-text { flex: 1; font-size: 15px; font-weight: 700; color: #f0f6fc; cursor: pointer; }
.title-text.placeholder { color: #6e7681; font-weight: 400; font-style: italic; }
.title-text:hover { color: var(--accent); }
.title-edit-ico { font-size: 12px; color: #6e7681; cursor: pointer; padding: 2px 6px; }
.title-edit-ico:hover { color: var(--accent); }
.title-input { flex: 1; background: #0d1117; border: 1px solid #58a6ff; color: #f0f6fc; padding: 4px 8px; border-radius: 4px; font-size: 14px; font-weight: 600; outline: none; }
.focus-btn { font-size: 10px; padding: 3px 8px; border-radius: 4px; background: #21262d; color: #8b949e; border: 1px solid #30363d; cursor: pointer; }
.focus-btn:hover { background: #1f6feb; color: #fff; border-color: #58a6ff; }
.chat { margin: 6px 0; max-height: 380px; overflow-y: auto; padding-right: 4px; }
.chat::-webkit-scrollbar { width: 12px; height: 12px; }
.chat::-webkit-scrollbar-thumb { background: #30363d; border-radius: 6px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.turn { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dotted #21262d; }
.turn:last-child { border-bottom: none; }
.msg-user {
  display: flex; gap: 6px; font-size: 12px; color: #e6edf3;
  background: rgba(110,118,129,0.12);
  padding: 6px 10px; border-radius: 6px;
  border-left: 3px solid var(--accent);
  margin-bottom: 4px;
}
.msg-user .who { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.msg-user .txt { line-height: 1.45; white-space: pre-wrap; }
.msg-asst { display: flex; gap: 6px; font-size: 11px; color: #8b949e; margin-top: 4px; }
.msg-asst .who { color: #58a6ff; font-weight: 700; flex-shrink: 0; }
.msg-asst .txt { line-height: 1.45; white-space: pre-wrap; }
.msg-tools { font-size: 10px; color: #ffa657; font-family: ui-monospace, monospace; margin-top: 3px; margin-left: 24px; opacity: .75; }
.turn.current .msg-user .txt { color: #f0f6fc; }
.turn.current .msg-asst .txt { color: #c9d1d9; }

/* === Rich markdown rendering inside chat (.txt.md) === */
.txt.md { white-space: normal; min-width: 0; flex: 1; }
.txt.md > *:first-child { margin-top: 0; }
.txt.md > *:last-child { margin-bottom: 0; }
.txt.md p { margin: 4px 0; line-height: 1.5; }
/* Default (dark) — boost assistant text contrast vs. base #8b949e */
.msg-user .txt.md { color: #f0f6fc; }
.msg-asst .txt.md { color: #d1d8e0; }
.turn.current .msg-asst .txt.md { color: #e6edf3; }
.txt.md h1, .txt.md h2, .txt.md h3, .txt.md h4 {
  margin: 8px 0 4px 0; font-weight: 700; line-height: 1.3;
}
.txt.md h1 { font-size: 15px; color: #f0f6fc; }
.txt.md h2 { font-size: 14px; color: #f0f6fc; }
.txt.md h3 { font-size: 13px; color: #c9d1d9; }
.txt.md h4 { font-size: 12px; color: #c9d1d9; }
.txt.md ul, .txt.md ol { margin: 4px 0; padding-left: 20px; }
.txt.md li { margin: 2px 0; line-height: 1.45; }
.txt.md code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: rgba(110,118,129,0.18); color: #ffa657;
  padding: 1px 5px; border-radius: 3px; font-size: 0.9em;
}
.txt.md pre {
  background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
  padding: 8px 10px; margin: 6px 0; overflow-x: auto;
  font-size: 11px; line-height: 1.4;
}
.txt.md pre code {
  background: transparent; color: #c9d1d9; padding: 0; font-size: 11px;
}
.txt.md table {
  border-collapse: collapse; margin: 6px 0; font-size: 11px;
  display: block; overflow-x: auto; max-width: 100%;
}
.txt.md th, .txt.md td { border: 1px solid #30363d; padding: 4px 8px; text-align: left; }
.txt.md th { background: rgba(110,118,129,0.15); font-weight: 600; }
.txt.md blockquote {
  border-left: 3px solid #30363d; padding: 0 10px; margin: 6px 0;
  color: #8b949e;
}
.txt.md a { color: #58a6ff; text-decoration: none; }
.txt.md a:hover { text-decoration: underline; }
.txt.md hr { border: 0; border-top: 1px solid #21262d; margin: 8px 0; }
.txt.md strong { color: #f0f6fc; font-weight: 700; }
.txt.md em { color: #c9d1d9; font-style: italic; }

/* === Typing indicator (CC ▸ 응답 생성 중...) === */
.typing-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #8b949e; font-style: italic;
}
.typing-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #58a6ff;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }
.typing-indicator .typing-text { margin-left: 4px; opacity: 0.8; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* Light theme overrides */
[data-theme="light"] .msg-user {
  background: rgba(208,215,222,0.45);
  border-left-color: var(--rust-deep);
}
[data-theme="light"] .msg-user .txt.md { color: #1f2328; }
[data-theme="light"] .msg-asst .txt.md { color: #24292f; }
[data-theme="light"] .turn.current .msg-asst .txt.md { color: #1f2328; }
[data-theme="light"] .txt.md h1, [data-theme="light"] .txt.md h2 { color: #1f2328; }
[data-theme="light"] .txt.md h3, [data-theme="light"] .txt.md h4 { color: #24292f; }
[data-theme="light"] .txt.md code { background: rgba(175,184,193,0.25); color: #cf222e; }
[data-theme="light"] .txt.md pre { background: #f6f8fa; border-color: #d0d7de; }
[data-theme="light"] .txt.md pre code { color: #1f2328; }
[data-theme="light"] .txt.md th, [data-theme="light"] .txt.md td { border-color: #d0d7de; color: #1f2328; }
[data-theme="light"] .txt.md th { background: #f6f8fa; }
[data-theme="light"] .txt.md blockquote { border-left-color: #d0d7de; color: #424a53; }
[data-theme="light"] .txt.md strong { color: #1f2328; font-weight: 700; }
[data-theme="light"] .txt.md em { color: #24292f; }
[data-theme="light"] .txt.md a { color: #0969da; }
[data-theme="light"] .typing-indicator { color: #424a53; }
[data-theme="light"] .typing-indicator .dot { background: #0969da; }
.send-row {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 10px; padding: 10px 12px 10px 12px;
  background: #0d1117; border: 1px solid #30363d; border-radius: 10px;
  transition: border-color .15s;
}
.send-row:focus-within { border-color: #58a6ff; box-shadow: 0 0 0 2px rgba(88,166,255,.15); }

/* === Send status bar (delivery feedback) === */
.send-status-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 6px 0 0 0; padding: 5px 10px;
  border-radius: 6px; font-size: 11px;
  background: rgba(110,118,129,0.08); border: 1px solid rgba(110,118,129,0.18);
}
.send-status-bar .send-stat { flex: 1; min-width: 0; }
.send-status-bar .muted { opacity: 0.55; font-size: 10px; margin-left: 6px; }
.send-status-bar .send-stat.pending   { color: #8b949e; }
.send-status-bar .send-stat.delivered { color: #58a6ff; }
.send-status-bar .send-stat.confirmed { color: var(--accent); }
.send-status-bar .send-stat.aborted   { color: #d29922; font-weight: 600; }
.send-status-bar .send-stat.failed    { color: #f85149; font-weight: 600; }
.send-retry {
  font-size: 10px; padding: 3px 8px; border-radius: 4px;
  background: #21262d; color: #c9d1d9; border: 1px solid #30363d;
  cursor: pointer; font-weight: 600;
}
.send-retry:hover { background: #1f6feb; color: #fff; border-color: #58a6ff; }
[data-theme="light"] .send-status-bar { background: rgba(208,215,222,0.30); border-color: rgba(175,184,193,0.4); }
[data-theme="light"] .send-status-bar .send-stat.pending { color: #656d76; }
[data-theme="light"] .send-status-bar .send-stat.delivered { color: #0969da; }
[data-theme="light"] .send-status-bar .send-stat.confirmed { color: var(--rust-deep); }
[data-theme="light"] .send-status-bar .send-stat.aborted { color: #9a6700; }
[data-theme="light"] .send-status-bar .send-stat.failed { color: #cf222e; }
[data-theme="light"] .send-retry { background: #f6f8fa; color: #1f2328; border-color: #d0d7de; }
.send-textarea {
  width: 100%; background: transparent; border: none; color: #e6edf3;
  padding: 4px 0; font-size: 13px; outline: none; font-family: inherit;
  resize: none; line-height: 1.45; min-height: 20px; max-height: 140px;
  overflow-y: auto;
}
.send-textarea::placeholder { color: #484f58; }
.send-bottom { display: flex; justify-content: space-between; align-items: center; }
.send-hint { font-size: 10px; color: #484f58; user-select: none; }
.send-hint kbd { background: #21262d; color: #8b949e; padding: 1px 5px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 9px; }
.send-btn {
  padding: 5px 14px; background: var(--rust); color: #fff; border: none;
  border-radius: 14px; font-size: 11px; cursor: pointer; font-weight: 600;
  transition: background .15s, transform .1s;
}
.send-btn:hover { background: var(--rust-deep); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { background: #21262d; color: #6e7681; cursor: not-allowed; }
.send-btn svg { vertical-align: middle; margin-left: 2px; }
* { box-sizing: border-box; }
body {
  font-family: -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
  background: #0d1117; color: #e6edf3; margin: 0; padding: 0;
}
h1 { margin: 0 0 8px 0; font-size: 20px; color: var(--accent); }
.meta { color: #8b949e; font-size: 12px; margin-bottom: 16px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 14px; align-items: start;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-size: 12.5px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0; width: 0;
  background: var(--rust);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card:hover {
  border-color: var(--border-warm);
  box-shadow: var(--shadow);
}
.card .row1 { margin-bottom: 4px; }
.card .topic, .card .title-row { margin: 4px 0 6px 0; padding-bottom: 6px; }
.card .tags { margin: 4px 0; }
.card .tag { font-size: 12px; padding: 2px 6px; }
.card .chat { max-height: 400px; margin: 4px 0; overflow-y: auto; }
.card .turn { margin-bottom: 6px; padding-bottom: 6px; }
.card .msg-user { font-size: 13px; }
.card .msg-asst { font-size: 12px; }
.card .msg-tools { font-size: 11px; margin-left: 20px; }
.card .msg-user .txt, .card .msg-asst .txt { }
.card .turn.current .msg-user .txt { }
.card .turn.current .msg-asst .txt { }
.card .files { font-size: 12px; margin: 4px 0; }
.card .files .label { font-size: 11px; }
.card .footer { font-size: 11px; margin-top: 4px; }
/* === Work Log === */
.work-log { margin: 8px 0; font-size: 11px; border-top: 1px dashed #30363d; padding-top: 6px; }
.work-log > .label { color: #ffa657; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 4px; font-size: 10px; font-weight: bold; }
.log-entry { display: flex; gap: 6px; padding: 2px 0; }
.log-idx { color: var(--accent); font-weight: 700; font-family: ui-monospace, monospace; font-size: 10px; flex-shrink: 0; min-width: 20px; }
.log-line { color: #c9d1d9; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* === Card Meta (bottom) === */
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; padding-top: 6px; border-top: 1px dashed #30363d; font-size: 11px; }
.card-meta .sid { font-family: ui-monospace, monospace; color: var(--accent); font-size: 11px; }
.card-meta .project { color: #c9d1d9; }
.card-meta .branch { color: #d2a8ff; font-family: ui-monospace, monospace; font-size: 10px; }
.card-meta-actions { margin-left: auto; display: flex; gap: 4px; }
.card .send-row { margin-top: 6px; padding: 6px 10px; }
.card .send-textarea { font-size: 14px; max-height: 90px; }
.card .send-hint { font-size: 11px; }
.card .send-btn { padding: 4px 10px; font-size: 12px; }
.card .title-text { font-size: 15px; }
.card .sid { font-size: 11px; }
.card .badge { font-size: 10px; padding: 1px 6px; }
.card .project, .card .branch { font-size: 10px; }
.card .focus-btn { font-size: 27px; padding: 0 18px; line-height: 0.7; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.topic {
  font-size: 15px; font-weight: 600; color: #f0f6fc; line-height: 1.4;
  margin: 6px 0 8px 0; padding-bottom: 8px; border-bottom: 1px dashed #30363d;
}
.topic .label { color: var(--accent); font-size: 10px; font-weight: normal; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 2px; }
.narrative {
  background: #0d1117; border-left: 3px solid #58a6ff; padding: 8px 12px;
  margin: 8px 0; font-size: 12px; color: #c9d1d9; line-height: 1.5;
  white-space: pre-wrap; max-height: 100px; overflow: hidden;
  position: relative;
}
.narrative::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 24px;
  background: linear-gradient(transparent, #0d1117);
}
.narrative .label { color: #58a6ff; font-size: 10px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 10px;
  background: #21262d; color: #c9d1d9; border: 1px solid #30363d;
}
.files {
  margin: 6px 0; font-size: 11px; color: #8b949e;
  font-family: ui-monospace, 'SF Mono', monospace;
}
.files .label { color: #ffa657; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 3px; font-size: 10px; font-weight: bold; }
.files .file { display: block; padding: 1px 0; color: #e6edf3; }
.files .file .dir { color: #6e7681; }
.turns { font-size: 10px; color: #6e7681; margin-left: 8px; }
.card.working { border-color: var(--rust); box-shadow: 0 0 0 1px var(--rust) inset; }
.card.input   { border-color: #d29922; box-shadow: 0 0 16px rgba(210,153,34,.35); animation: pulse 1.2s infinite; }
.card.active  { border-color: #58a6ff; }
.card.idle    { border-color: #484f58; opacity: .75; }
.card.away    { border-color: #30363d; opacity: .45; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 16px rgba(210,153,34,.35); }
  50%     { box-shadow: 0 0 28px rgba(210,153,34,.75); }
}
.row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sid { font-family: ui-monospace, 'SF Mono', Menlo, monospace; color: var(--accent); font-size: 13px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #21262d; color: #8b949e; }
.badge.working { background: rgba(229, 74, 26, 0.15); color: var(--accent); }
.badge.input   { background: #664d03; color: #ffdf5d; }
.badge.active  { background: #0c2d6b; color: #79c0ff; }
.badge.idle    { background: #21262d; color: #8b949e; }
.project { color: #c9d1d9; font-size: 12px; }
.branch { color: #d2a8ff; font-size: 11px; font-family: ui-monospace, monospace; }
.prompt {
  background: #0d1117; border-left: 3px solid var(--accent); padding: 6px 10px;
  margin: 6px 0; font-size: 13px; color: #e6edf3; white-space: pre-wrap;
  max-height: 80px; overflow: hidden; text-overflow: ellipsis;
}
.tool {
  font-family: ui-monospace, monospace; font-size: 12px; color: #ffa657;
  background: #0d1117; padding: 6px 10px; border-radius: 4px; margin-top: 4px;
  white-space: pre-wrap; word-break: break-all; max-height: 60px; overflow: hidden;
}
.tool .name { color: #d2a8ff; font-weight: bold; }
.footer { color: #6e7681; font-size: 10px; margin-top: 6px; display: flex; justify-content: space-between; }
.empty { color: #6e7681; text-align: center; padding: 40px; font-size: 14px; }
.conn { position: fixed; top: 12px; right: 16px; font-size: 11px; color: #6e7681; }
.conn .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rust-deep); margin-right: 4px; }
.conn.dead .dot { background: #f85149; }

/* Conn dot folded into header right rail (T1 zone) */
.dash-actions .conn {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* === Navigation === */
/* CTW dash-header 의 직속 nav 만 — 글로벌 nav 셀렉터는 외부 페이지 (예: /workflow 컨펌 목업) 의 nav 와 충돌 발생 */
header.dash-header > nav { position: static; top: auto; left: auto; transform: none; z-index: auto; display: flex; gap: 4px; }
header.dash-header > nav a { color: #8b949e; text-decoration: none; margin: 0 10px; font-size: 12px; padding: 4px 10px; border-radius: 4px; }
header.dash-header > nav a:hover, header.dash-header > nav a.active { color: var(--accent); background: #161b22; }

/* === World === */
html.world-page, html.world-page body { margin: 0; padding: 0; overflow: hidden; height: 100%; }
#world { position: fixed; inset: 0; }
.room {
  position: absolute; border: 1px solid #30363d; border-radius: 12px; padding: 10px;
  background: linear-gradient(180deg, rgba(22,27,34,.9), rgba(13,17,23,.9));
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.room-title { font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }
.avatars { display: flex; flex-wrap: wrap; gap: 14px; }
.avatar { width: 100px; cursor: pointer; transition: transform .25s; }
.avatar:hover { transform: scale(1.08); }
.body {
  width: 80px; height: 80px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; position: relative;
  background: radial-gradient(circle at 30% 30%, #30363d, #0d1117);
  border: 2px solid #484f58;
}
.avatar.working .body { background: radial-gradient(circle at 30% 30%, var(--rust-deep), rgba(229, 74, 26, 0.15)); border-color: var(--accent); animation: bob .8s ease-in-out infinite alternate; }
.avatar.active  .body { background: radial-gradient(circle at 30% 30%, #388bfd, #0c2d6b); border-color: #79c0ff; }
.avatar.input   .body { background: radial-gradient(circle at 30% 30%, #e3b341, #664d03); border-color: #ffdf5d; animation: world-pulse 1s ease-in-out infinite; box-shadow: 0 0 28px #e3b341; }
.avatar.idle    .body { background: radial-gradient(circle at 30% 30%, #484f58, #21262d); border-color: #6e7681; }
.avatar.away    .body { opacity: .35; filter: grayscale(1); }
@keyframes bob   { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes world-pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 20px #e3b341; } 50% { transform: scale(1.1); box-shadow: 0 0 40px #ffdf5d; } }
.name { text-align: center; margin-top: 4px; font-size: 11px; color: #c9d1d9; font-family: ui-monospace, monospace; }
.proj { text-align: center; font-size: 9px; color: #8b949e; }
.tooltip {
  position: absolute; background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  padding: 8px 12px; font-size: 12px; min-width: 260px; max-width: 420px; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.8); z-index: 100; display: none;
}
.tooltip .t-sid { color: var(--accent); font-family: ui-monospace, monospace; font-size: 11px; }
.tooltip .t-prompt { color: #e6edf3; margin: 6px 0; padding: 6px; background: #0d1117; border-left: 2px solid var(--accent); font-size: 12px; }
.tooltip .t-tool { color: #ffa657; font-family: ui-monospace, monospace; font-size: 11px; }
#log {
  position: fixed; left: 0; right: 0; bottom: 0; height: 140px; overflow: hidden;
  background: linear-gradient(0deg, #0d1117, rgba(13,17,23,.7)); border-top: 1px solid #30363d;
  padding: 8px 16px; font-family: ui-monospace, monospace; font-size: 11px; color: #8b949e;
}
#log .ev { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log .ev .t { color: #6e7681; }
#log .ev .s { color: var(--accent); }
#log .ev .e { color: #d2a8ff; }
#log .ev .m { color: #e6edf3; }

/* === Analytics === */
.analytics-controls { margin: 10px 0 20px; }
.analytics-controls select { background: #21262d; color: #e6edf3; border: 1px solid #30363d; padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; margin-top: 16px; }
.chart-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px; }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; color: var(--accent); }
.stats-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px; text-align: center; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 11px; color: #8b949e; margin-top: 4px; }

/* === Analytics Page === */
.an-page { padding: 16px 20px; }
#an-err-badge { display: none; background: #FEE2E2; color: #B91C1C; padding: 7px 12px; border-radius: 6px; margin-bottom: 10px; font-size: 12px; font-weight: 600; }
#an-err-badge.is-shown { display: block; }
.an-action-link { color: #2563EB; margin-left: 8px; text-decoration: none; font-size: 11px; }
.an-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.an-controls select { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.an-spacer { flex: 1; }
.an-export { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); padding: 4px 10px; border-radius: 4px; font-size: 11px; cursor: pointer; }
.an-export:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* KPI Row */
.an-kpi { display: flex; gap: 8px; margin-bottom: 14px; }
.an-kpi-item { flex: 1; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; text-align: center; min-width: 0; }
.an-kpi-val { font-size: 22px; font-weight: 800; color: var(--text-primary); white-space: nowrap; }
.an-kpi-label { font-size: 10px; color: var(--text-secondary); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.an-kpi-item.highlight .an-kpi-val { color: #c4a35a; }
.an-kpi-item.good .an-kpi-val { color: #8bbf7a; }
.an-kpi-item.alert .an-kpi-val { color: #b07878; }

/* iter#4 B1 — 카드 높이 표준화 (Forge v3) */
/* Layout */
.an-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; align-items: stretch; }
.an-row-2 { grid-template-columns: 1fr 1fr; }     /* Phase G: explicit (was 1fr 1fr fallback) */
.an-row-3 { grid-template-columns: 1fr 1fr 1fr; }
/* Phase G: row with a single full-width child should not leave empty column */
.an-row:has(> .an-card:only-child) { grid-template-columns: 1fr; }
.an-row > .an-card-wide:only-child { grid-column: 1 / -1; }
.an-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 12px; min-width: 0; overflow: hidden; height: 100%; box-sizing: border-box; }
/* --card-height-standard: wide-row 표준 높이 (clock-chart polarArea 억제 기준) */
:root { --card-height-standard-wide: 520px; --card-height-standard-normal: 460px; }
/* an-card-wide: 단독 전폭 카드의 최대 높이 제한 (clock-chart 1.4x 팽창 방지) */
.an-card-wide { max-height: var(--card-height-standard-wide); overflow: hidden; }
/* an-card-row-equal: 같은 an-row 내 다중 카드에 min-height 통일 (mcp-chart 등 짧은 카드) */
.an-card-row-equal { min-height: var(--card-height-standard-normal); }
.an-card-wide { }
.an-card-flex2 { grid-column: 1 / -1; }            /* Phase G: span all columns (heatmap full width) */
.an-card-head {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.an-card-sub {
  font-size: 10px; font-weight: 400; color: var(--text-tertiary, #6b7280);
  text-transform: none; letter-spacing: 0;
}
.an-empty { color: var(--text-secondary); font-size: 12px; text-align: center; padding: 20px 0; }
.an-hint {
  font-size: 11px; color: var(--text-tertiary, #6b7280);
  padding: 2px 8px; background: rgba(108,180,238,.08);
  border: 1px solid rgba(108,180,238,.18); border-radius: 4px;
}

/* Phase G: 차트 아래 1-2줄 자동 인사이트 (context line) */
.an-context {
  margin-top: 8px; padding: 6px 8px;
  background: rgba(108,180,238,.05);
  border-left: 2px solid #6cb4ee;
  border-radius: 0 4px 4px 0;
  font-size: 11px; color: var(--text-secondary);
  line-height: 1.5;
}
.an-context strong { color: var(--text-primary); font-weight: 700; }
.an-context .up { color: #b07878; }   /* warn — 비용 증가 같은 신호 */
.an-context .down { color: #8bbf7a; } /* good — 비용 감소 */

/* Phase G: clickable affordance on tables / cells / chart canvases */
.an-tbl tbody tr.an-clickable { cursor: pointer; }
.an-tbl tbody tr.an-clickable:hover td { background: rgba(108,180,238,.08); }
.hm-c.an-clickable { cursor: pointer; }
.hm-c.an-clickable:hover { outline: 1px solid #6cb4ee; outline-offset: 1px; z-index: 1; position: relative; }
.an-kpi-item.an-clickable { cursor: pointer; transition: transform .15s, border-color .15s; }
.an-kpi-item.an-clickable:hover { transform: translateY(-1px); border-color: #6cb4ee; }
canvas.an-clickable { cursor: pointer; }

/* iter 1 P1: KPI sparkline + status badge (신호등) */
.an-kpi-item { position: relative; }
.an-kpi-spark {
  display: block;
  margin: 4px auto 0;
  width: 120px !important;
  height: 32px !important;
  opacity: 0.85;
}
.an-kpi-status {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  line-height: 1;
  cursor: help;
  user-select: none;
}

/* iter 1 P1: 컨텍스트 인사이트 클릭 가능 (an-ctx-action) */
.an-context .an-ctx-action {
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 3px;
  transition: background .12s, color .12s;
}
.an-context .an-ctx-action:hover {
  background: rgba(108,180,238,.18);
  color: var(--text-primary);
}

/* iter 1 P0: heatmap cell flash animation (인사이트 클릭 시 빨강 outline) */
.hm-c.hm-flash {
  outline: 2px solid #DC2626 !important;
  outline-offset: 1px;
  z-index: 2;
  position: relative;
  animation: hmFlashPulse 1.2s ease-out;
}
@keyframes hmFlashPulse {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,0.7) inset; }
  50%  { box-shadow: 0 0 0 3px rgba(220,38,38,0.5) inset; }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0) inset; }
}

/* Phase G: heatmap busy-spot highlight + cell legend */
.hm-c.hm-busy {
  box-shadow: 0 0 0 2px #c4a35a inset;
}
.hm-legend {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: 10px; color: var(--text-secondary);
}
.hm-legend-cells { display: flex; gap: 2px; }
.hm-legend-cells .hm-c {
  width: 12px; height: 12px; aspect-ratio: unset; border-radius: 2px;
}

/* Tables */
.an-table-wrap { max-height: 320px; overflow-y: auto; }
.an-table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.an-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.an-table-wrap::-webkit-scrollbar-track { background: transparent; }
.an-tbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.an-tbl th { text-align: left; color: var(--text-secondary); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; background: var(--bg-secondary); }
.an-tbl td { padding: 5px 6px; border-bottom: 1px solid var(--bg-tertiary); color: var(--text-primary); }
.an-tbl tr:hover td { background: var(--bg-tertiary); }
.an-tbl .r { text-align: right; font-family: ui-monospace, monospace; }
.an-tbl-title { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-tbl-team { color: var(--text-secondary); font-size: 10px; }
.an-cache { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; }
.an-cache.good { background: rgba(139,191,122,.12); color: #8bbf7a; }
.an-cache.warn { color: var(--text-secondary); }
.an-cache.bad { background: rgba(176,120,120,.12); color: #b07878; }

/* Bar in team table */
.an-bar-wrap { display: flex; align-items: center; gap: 6px; min-width: 80px; }
.an-bar-wrap span { font-size: 10px; color: var(--text-secondary); white-space: nowrap; }
.an-bar { height: 6px; background: #6cb4ee; border-radius: 3px; min-width: 2px; }

/* Heatmap */
.hm { display: grid; grid-template-columns: 28px repeat(24, 1fr); gap: 2px; }
.hm-corner { }
.hm-h { text-align: center; color: var(--text-secondary); font-size: 9px; line-height: 16px; }
.hm-d { font-size: 10px; color: var(--text-secondary); display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; }
.hm-c { aspect-ratio: 1; border-radius: 2px; cursor: default; }
.hm-c.lv0 { background: var(--bg-tertiary); }
.hm-c.lv1 { background: #1a3a50; }
.hm-c.lv2 { background: #2a5575; }
.hm-c.lv3 { background: #4080a8; }
.hm-c.lv4 { background: #6cb4ee; }
[data-theme="light"] .hm-c.lv0 { background: #ebedf0; }
[data-theme="light"] .hm-c.lv1 { background: #c8dff0; }
[data-theme="light"] .hm-c.lv2 { background: #8bbfdf; }
[data-theme="light"] .hm-c.lv3 { background: #5a9cc5; }
[data-theme="light"] .hm-c.lv4 { background: #3a7db0; }
[data-theme="light"] .an-card { background: #fff; }
[data-theme="light"] .an-kpi-item { background: #fff; }
[data-theme="light"] .an-tbl th { background: #fff; }
[data-theme="light"] .an-tbl tr:hover td { background: #f6f8fa; }

@media (max-width: 900px) {
  .an-row, .an-row-2, .an-row-3 { grid-template-columns: 1fr; }
  .an-kpi { flex-wrap: wrap; }
  .an-kpi-item { min-width: calc(50% - 4px); flex: unset; }
}
/* Phase G: explicit phone breakpoint (heatmap remains scrollable) */
@media (max-width: 480px) {
  .an-page { padding: 10px 8px; }
  .an-kpi-item { min-width: calc(50% - 4px); padding: 8px 6px; }
  .an-kpi-val { font-size: 17px; }
  .an-card { padding: 10px 8px; }
  .an-controls { flex-wrap: wrap; }
  .an-hint { display: none; }    /* save space on small screens */
  /* Allow heatmap to horizontally scroll on phones so cells stay square */
  #heatmap-container { overflow-x: auto; }
  .hm { min-width: 560px; }
}

/* ── Phase G: Drill-down Modal ── */
.an-modal-overlay {
  display: none;  /* hidden by default — JS adds .is-open */
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(2px);
  z-index: 10000;
  align-items: flex-start; justify-content: center;
  padding: 5vh 16px;
}
.an-modal-overlay.is-open {
  display: flex;
  animation: anModalFade .15s ease-out;
}
@keyframes anModalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.an-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%; max-width: 920px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 48px rgba(0,0,0,0.4);
  overflow: hidden;
}
.an-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.an-modal-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  letter-spacing: .3px;
}
.an-modal-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 18px; cursor: pointer; padding: 0 6px; line-height: 1;
  border-radius: 4px;
}
.an-modal-close:hover { background: var(--border); color: var(--text-primary); }
.an-modal-body {
  padding: 16px;
  overflow-y: auto; flex: 1;
  font-size: 12px; color: var(--text-primary);
}
.an-modal-section {
  margin-bottom: 18px;
}
.an-modal-section h4 {
  font-size: 11px; color: var(--text-secondary); margin: 0 0 8px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
}
.an-modal-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px;
  margin-bottom: 12px;
}
.an-modal-stat {
  background: var(--bg-tertiary); border-radius: 6px; padding: 8px 10px;
  border: 1px solid var(--border);
}
.an-modal-stat-val { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.an-modal-stat-label { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.an-modal-body .an-tbl { font-size: 11px; }
.an-mini-bar {
  display: inline-block; height: 6px; background: #6cb4ee; border-radius: 2px;
  vertical-align: middle;
}
[data-theme="light"] .an-modal { background: #fff; }
[data-theme="light"] .an-modal-head { background: #f6f8fa; }
[data-theme="light"] .an-modal-stat { background: #f6f8fa; }
[data-theme="light"] .an-context { background: rgba(58,125,176,.06); border-left-color: #3a7db0; }
[data-theme="light"] .an-hint { background: rgba(58,125,176,.08); border-color: rgba(58,125,176,.2); }

/* === T3 Toolbar / T4 Actions — semantic placement primitives ===
   T3 = filters/scope (search, project, status, period)
   T4 = page-specific actions (right-aligned)
   Used by index.html, world.html, analytics.html for consistent layout. */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 20px;
  flex-wrap: wrap;
}
#grid { padding: 0 20px 20px; }

/* === KPI Bar (collapsible) === */
.dash-spacer { flex: 1 1 auto; }
.kpi-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.kpi-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 20px;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  min-height: 28px;
}
.kpi-summary:hover { background: rgba(255,255,255,0.025); color: var(--text-primary); }
[data-theme="light"] .kpi-summary:hover { background: rgba(0,0,0,0.03); }
.kpi-arrow {
  display: inline-block;
  font-size: 9px;
  color: var(--text-faint);
  transition: transform 0.2s ease;
}
.kpi-bar:not(.collapsed) .kpi-arrow { transform: rotate(90deg); color: var(--rust); }
.kpi-sum-text { font-family: var(--font-body); }
.kpi-sum-text strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600;
  margin-right: 1px;
}
.kpi-sep { color: var(--text-faint); margin: 0 6px; }
.kpi-toggle-hint {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-expanded {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 20px 12px;
  border-top: 1px solid var(--border);
}
.kpi-bar.collapsed .kpi-expanded { display: none; }
.kpi-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.kpi-card-title {
  font-size: 10px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}
.kpi-card-body { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
@media (max-width: 1100px) {
  .kpi-expanded { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-expanded { grid-template-columns: 1fr; }
  .kpi-summary { padding: 6px 12px; }
  .kpi-expanded { padding: 8px 12px 12px; }
}
.page-toolbar > .pt-spacer { flex: 1 1 auto; }
.page-toolbar select,
.page-toolbar input[type="text"] {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
}
.page-toolbar select:hover,
.page-toolbar input[type="text"]:focus { border-color: var(--rust-soft); outline: none; }
.page-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* === Filters (legacy class kept for back-compat) === */
.filter-row { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; align-items: center; }
.filter-row select { background: #21262d; color: #e6edf3; border: 1px solid #30363d; padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.filter-row select:hover { border-color: #58a6ff; }
.new-session-btn {
  background: var(--brand-gradient);
  color: var(--paper);
  border: 1px solid var(--rust-deep);
  padding: 6px 16px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.18) inset,
    0 4px 10px -4px var(--rust-deep);
}
.new-session-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 0 rgba(255,255,255,0.22) inset,
    0 8px 18px -6px var(--rust-deep);
}

/* Report button & panel */
.report-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.22s ease;
}
.report-btn:hover {
  border-color: var(--rust);
  color: var(--rust-soft);
  background: rgba(193,95,60,0.05);
}
.report-panel {
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px;
  margin: 0 20px 12px; padding: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.report-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px;
}
.report-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.report-type-btn {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 16px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all 0.15s; min-width: 140px;
  color: var(--text-primary);
}
.report-type-btn:hover { border-color: var(--accent-blue); background: rgba(88,166,255,0.08); }
.report-type-btn:disabled { opacity: 0.5; cursor: wait; }
.report-type-btn .rpt-icon { font-size: 24px; }
.report-type-btn .rpt-name { font-size: 13px; font-weight: 700; }
.report-type-btn .rpt-desc { font-size: 10px; color: var(--text-secondary); }
.report-result { margin-top: 12px; }
.report-result-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--text-primary); }
.report-telegram-status { font-size: 10px; padding: 2px 8px; border-radius: 8px; }
.report-telegram-status.sent { background: rgba(126,231,135,0.15); color: var(--accent-green); }
.report-telegram-status.failed { background: rgba(248,81,73,0.15); color: #f85149; }
.report-content {
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-size: 12px; line-height: 1.6; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word; max-height: 400px; overflow-y: auto;
  font-family: -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
}

/* Status filter buttons */
.status-btns { display: flex; gap: 2px; background: var(--bg-tertiary); border-radius: 6px; padding: 2px; }
.status-btn {
  padding: 4px 10px; border: none; border-radius: 4px; font-size: 11px; font-weight: 600;
  cursor: pointer; background: transparent; color: var(--text-secondary); transition: all 0.15s;
  white-space: nowrap;
}
.status-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.status-btn.active-filter { background: var(--accent-blue); color: #fff; }

/* === Office View === */
.team-row { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid #21262d; padding-bottom: 12px; }
.team-row:last-child { border-bottom: none; }
.team-label { width: 90px; flex-shrink: 0; padding: 8px 12px 8px 0; border-right: 3px solid var(--accent); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; text-align: right; }
.team-label-name { font-size: 13px; font-weight: 700; color: var(--accent); }
.team-label-stats { font-size: 10px; color: #8b949e; }
.team-label-cost { font-size: 12px; font-weight: 700; color: #ffa657; }
.team-label-status { font-size: 9px; color: #6e7681; }
.team-del { background: none; border: none; color: #6e7681; cursor: pointer; font-size: 10px; padding: 0; }
.team-del:hover { color: #f85149; }
.team-cards { display: flex; flex-wrap: wrap; gap: 10px; align-items: start; padding-left: 12px; flex: 1; min-width: 0; }
.team-cards .card { width: 624px; max-width: 624px; flex-shrink: 0; flex-grow: 0; display: flex; flex-direction: column; }
.team-select { background: #21262d; color: #e6edf3; border: 1px solid #30363d; padding: 2px 6px; border-radius: 4px; font-size: 10px; cursor: pointer; flex-shrink: 0; }
.team-select:hover { border-color: #58a6ff; }
.team-row.team-drop-ready { transition: border-color 0.2s; }
.team-row.team-drop-hover { background: rgba(88,166,255,0.08); border: 2px dashed var(--accent-blue) !important; border-radius: 8px; }
.team-row.team-drop-hover .team-label-name { color: var(--accent-blue); }

/* === Focused card (textarea has focus) — bold blue border via ::after overlay === */
/* Using a pseudo-element overlay to avoid cascade conflicts with
   .card.working/.card.input box-shadow status rules. */
.card { position: relative; }
.card:focus-within::after {
  content: ''; position: absolute; inset: 0;
  border: 6px solid #1f6feb;
  border-radius: inherit;
  pointer-events: none;
  box-sizing: border-box;
}
[data-theme="light"] .card:focus-within::after {
  border-color: #0550ae;
}

/* === Card drag-and-drop visual feedback === */
.card.drag-source {
  opacity: 0.4;
  transform: scale(0.98);
  transition: opacity 0.15s, transform 0.15s;
}
.card { position: relative; transition: transform 0.15s ease; }
.card.drop-before::before,
.card.drop-after::after {
  content: ''; position: absolute; top: 8px; bottom: 8px; width: 3px;
  background: #58a6ff;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(88,166,255,0.4);
  z-index: 10; pointer-events: none;
  transition: opacity 0.15s ease;
}
.card.drop-before::before { left: -6px; }
.card.drop-after::after  { right: -6px; }
.card.drop-before, .card.drop-after {
  outline: 1px solid rgba(88,166,255,0.2);
  outline-offset: 2px;
}
[data-theme="light"] .card.drop-before::before,
[data-theme="light"] .card.drop-after::after {
  background: linear-gradient(180deg, #0969da, #0550ae);
  box-shadow: 0 0 12px rgba(9,105,218,0.5);
}
[data-theme="light"] .card.drop-before, [data-theme="light"] .card.drop-after {
  background: rgba(9,105,218,0.05);
  outline: 1px solid rgba(9,105,218,0.3);
}
.card-details { transition: max-height .2s ease; overflow: hidden; }
.card-details.collapsed { max-height: 0; }
.details-toggle { cursor: pointer; color: #58a6ff; font-size: 10px; }
.details-toggle:hover { color: var(--accent); }
.cleanup-btn {
  background: transparent;
  color: var(--text-faint);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-left: auto;
  transition: all 0.22s ease;
}
.cleanup-btn:hover {
  color: var(--burgundy);
  border-color: var(--burgundy);
  background: rgba(107,44,31,0.08);
}

/* === Header — Quiet OS === */
.dash-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 24px;
}
.dash-header::after { display: none; }
.dash-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dash-logo {
  width: 26px; height: 26px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px; letter-spacing: -0.04em;
  color: var(--paper);
}
.dash-logo-cnc {
  width: 36px;
  height: 26px;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 3px;
  box-sizing: border-box;
}
.dash-logo-cnc img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
[data-theme="light"] .dash-logo-cnc {
  border-color: rgba(0,0,0,0.10);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
[data-theme="dark"] .dash-logo-cnc {
  background: #F3F4F6;
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}
.dash-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}
.dash-subtitle {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--text-secondary);
  letter-spacing: 0;
  margin-top: 2px;
  font-weight: 400;
}
.dash-header nav {
  display: flex; gap: 4px; margin: 0;
  position: static; transform: none;
  align-self: center; align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.dash-header nav a {
  font-family: var(--font-body);
  letter-spacing: -0.005em;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.dash-header nav a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}
.dash-header nav a.active {
  color: var(--text-primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 1px var(--border-warm), 0 1px 2px rgba(0,0,0,0.2);
}
[data-theme="light"] .dash-header nav a:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .dash-header nav a.active { background: var(--bg-secondary); }
.dash-stats { display: flex; gap: 12px; margin-left: auto; align-items: center; }
.dash-stat-group { display: flex; flex-direction: column; gap: 3px; }
.dash-stat-row { display: flex; gap: 6px; align-items: center; }
.dash-stat-group-title {
  font-size: 10px; color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-family: var(--font-body);
}
.ds-chip {
  /* iter05 P0-#1: emoji font fallback chain — WSL/Linux tofu (□) 영구 해소.
     Apple Color Emoji (macOS/iOS), Segoe UI Emoji (Win), Noto Color Emoji (Linux),
     Symbola/Twemoji Mozilla 순으로 시도. var(--font-body) 는 텍스트 글리프용. */
  font-family: var(--font-body), "Apple Color Emoji", "Segoe UI Emoji",
               "Noto Color Emoji", "Twemoji Mozilla", "Symbola",
               system-ui, sans-serif;
  font-size: 11.5px; color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.ds-chip:hover { border-color: var(--border-warm); color: var(--text-primary); }
.ds-chip strong, .ds-chip b {
  color: var(--rust-soft);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-right: 1px;
}
/* iter05 P0-#1: ds-chip status dot (emoji 대체) — variant border-color 상속.
   WSL2 emoji tofu 영구 해소. font-family 와 무관(● = U+25CF Black Circle,
   기본 system font 에 포함). 각 ds-chip variant 의 색은 strong 색 또는
   border-color 를 currentColor 로 가져와 통일된 시각 신호. */
.ds-chip .ds-chip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  font-size: 0;            /* 글자 ●의 폰트 의존 폭 제거 — 정원형 8×8 박스 */
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  margin-right: 4px;
  opacity: 0.85;
}
.ds-chip.tool_exec .ds-chip-dot { background: var(--sage); }
.ds-chip.thinking  .ds-chip-dot { background: var(--rust-soft); }
.ds-chip.input     .ds-chip-dot { background: #d29922; }
.ds-chip.idle      .ds-chip-dot { background: var(--text-secondary); }
.ds-chip.stuck     .ds-chip-dot { background: #f85149; }
.ds-chip.cost      .ds-chip-dot { background: #ffa657; }
.ds-chip.working   .ds-chip-dot { background: var(--accent-green); }
.ds-chip.working { border-color: var(--rust); }
.ds-chip.working strong { color: var(--accent-green); }
.ds-chip.tool_exec { border-color: var(--sage); }
.ds-chip.tool_exec strong { color: var(--sage); }
.ds-chip.thinking { border-color: var(--rust-soft); }
.ds-chip.thinking strong { color: var(--rust-soft); }
.ds-chip.input { border-color: #d29922; }
.ds-chip.input strong { color: #ffdf5d; }
.ds-chip.idle strong { color: var(--text-secondary); }
.ds-chip.stuck { border-color: var(--burgundy); background: rgba(107,44,31,0.12); }
.ds-chip.stuck strong { color: #f85149; }
.ds-chip.cost { border-color: #ffa657; }
.ds-chip.cost strong { color: #ffa657; }
.ds-chip.week { border-color: var(--accent-purple); }
.ds-chip.week strong { color: var(--accent-purple); }
.dash-divider { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }
.ds-chip.plan { border-color: var(--accent-blue); font-size: 10px; }
.ds-chip.plan strong { color: var(--accent-blue); }
.ds-chip.plan.warn { border-color: #ffa657; }
.ds-chip.plan.warn strong { color: #ffa657; }
.ds-chip.plan.danger { border-color: #f85149; }
.ds-chip.plan.danger strong { color: #f85149; }
.plan-bar { width: 80px; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.plan-bar-fill { height: 100%; border-radius: 3px; background: var(--accent-blue); transition: width 0.5s ease; }
.plan-bar-fill.warn { background: #ffa657; }
.plan-bar-fill.danger { background: #f85149; }
.dash-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.dash-actions button { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 11.5px; font-weight: 500; transition: border-color 0.15s ease, color 0.15s ease; }
.dash-actions button:hover { border-color: var(--border-warm); color: var(--text-primary); }

/* === Layout toggle (Board / Row) === */
.layout-toggle {
  display: inline-flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.layout-toggle button {
  background: transparent !important;
  border: none !important;
  color: var(--text-secondary);
  font-size: 11px !important;
  font-weight: 600;
  padding: 4px 10px !important;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.layout-toggle button:hover { color: var(--text-primary); background: rgba(255,255,255,0.04) !important; }
.layout-toggle button.active {
  background: var(--bg-secondary) !important;
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-warm) inset;
}
[data-theme="light"] .layout-toggle button:hover { background: rgba(0,0,0,0.04) !important; }

/* === Board layout (Kanban columns) === */
.team-board {
  display: flex;
  gap: 12px;
  padding: 0 20px 20px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: calc(100vh - 220px);
}
.team-board::-webkit-scrollbar { height: 10px; }
.team-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.team-board::-webkit-scrollbar-track { background: transparent; }
.team-column {
  flex: 0 0 auto;
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.team-column.team-drop-ready { border-color: var(--rust); box-shadow: 0 0 0 2px rgba(255,107,53,0.15); }
.team-column-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.team-column-name {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 6px;
}
.team-column-count {
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 1px 6px; border-radius: 999px;
}
.team-column-stats {
  font-size: 11px; color: var(--text-secondary);
  display: flex; gap: 8px; align-items: center;
}
.team-column-stats .col-cost { color: var(--rust-soft); font-family: var(--font-mono); font-weight: 600; }
.team-column-actions {
  display: flex; gap: 4px; margin-left: auto;
}
.team-column-actions button {
  background: transparent; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 12px; padding: 2px 4px; border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.team-column-actions button:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.team-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.team-column-body::-webkit-scrollbar { width: 8px; }
.team-column-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.team-column-body:empty::after {
  content: "비어있음 — 카드 드래그로 배치";
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
  padding: 20px 10px;
  opacity: 0.6;
}
/* In board mode, cards take full column width */
.team-column-body .card { width: 100%; max-width: 100%; min-width: 0; flex-shrink: 0; padding: 10px 12px 8px; font-size: 12px; }
.team-column-body .card .card-body { display: none; }
.team-column-body .card.expanded .card-body { display: block; }
.team-column-body .card .card-details { display: none; }
.team-column-body .card.expanded .card-details:not(.collapsed) { display: block; }
.team-column-body .card .footer { font-size: 10.5px; padding-top: 6px; }
.team-column-body .card .card-summary { padding: 4px 0; }
.team-column-body .card .card-summary .sum-narrative { -webkit-line-clamp: 2; }
.team-column-body .card .card-header-row1 { font-size: 12px; }
.team-column-body .card .card-header-row2 { font-size: 10px; gap: 4px; }
.team-column-body .card .work-log,
.team-column-body .card .files,
.team-column-body .card .tags { display: none; }
.team-column-body .card.expanded .work-log,
.team-column-body .card.expanded .files,
.team-column-body .card.expanded .tags { display: block; }

/* Add-team button at end of board */
.team-board .team-add-btn {
  flex: 0 0 auto;
  width: 200px;
  align-self: stretch;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 12px;
  padding: 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
  margin: 0;
}
.team-board .team-add-btn:hover { border-color: var(--rust); color: var(--rust); }

@media (max-width: 700px) {
  .team-board { padding: 0 12px 12px; }
  .team-column { width: 280px; }
}

/* === Card Collapse/Expand (#2) === */
.card-body { overflow: hidden; transition: max-height 0.3s ease, opacity 0.2s; max-height: 1061px; position: relative; }
/* 2026-05-17: 텍스트 바디 우측하단 "맨 아래로" 플로팅 투명 버튼 */
.chat-to-bottom-btn {
  position: absolute; right: 10px; bottom: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20,20,20,0.42); color: var(--text-secondary, #c9d1d9);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0.45; transition: opacity .15s ease, background .15s ease;
  z-index: 5;   /* 2026-05-17: backdrop-filter 제거 — 입력 시 reflow마다 GPU 블러 재계산 → 버벅임 회귀 해소 */
}
.chat-to-bottom-btn:hover, .chat-to-bottom-btn:active { opacity: 1; background: rgba(20,20,20,0.78); }
.card-body .chat { max-height: 460px; overflow-y: auto; }  /* 2026-05-17: 터미널 카드(card-view-term 460px)와 텍스트 바디 크기 통일 */
.card-body.card-chat-collapsed { max-height: 0; opacity: 0; overflow: hidden; }
/* 2026-05-03: Sessions 부서 컬럼 안 worker chip (Team 정합) */
.team-column-workers { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-bottom: 1px dashed var(--border, #30363d); margin-bottom: 6px; }
.worker-chip { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 5px; background: rgba(123, 104, 238, 0.06); border: 1px solid rgba(123, 104, 238, 0.20); font-size: 11px; }
.worker-chip.dormant { background: rgba(120, 120, 120, 0.04); border-color: rgba(120, 120, 120, 0.15); opacity: 0.7; }
.worker-chip-dot { color: var(--rust-deep); font-size: 10px; }
.worker-chip.dormant .worker-chip-dot { color: #8b949e; }
.worker-chip-name { font-weight: 500; flex: 1; color: var(--text, #c9d1d9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worker-chip-lbl { color: var(--text-secondary, #8b949e); font-size: 10px; }
.worker-chip-btn { padding: 1px 8px; font-size: 10px; border: none; border-radius: 3px; cursor: pointer; }
.worker-chip-btn.primary { background: #1f6feb; color: #fff; }
.worker-chip-btn.danger { background: #c93030; color: #fff; }

/* 2026-05-03: "지금 무슨 일" 활동 줄 — 카드 body 위에 항상 표시 */
.card-activity { display: flex; align-items: center; gap: 6px; padding: 4px 10px; margin: 4px 0; border-radius: 6px; font-size: 11px; font-family: 'JetBrains Mono', monospace; overflow: hidden; }
.card-activity.active { background: rgba(22, 163, 74, 0.12); border-left: 2px solid var(--accent); }
.card-activity.completed { background: rgba(100, 116, 139, 0.08); border-left: 2px solid #64748b; }
.card-activity .activity-icon { font-size: 12px; }
.card-activity .activity-tool { font-weight: 600; color: var(--text, #c9d1d9); }
.card-activity .activity-age { color: var(--text-secondary, #8b949e); }
.card-activity .activity-input { color: var(--text-secondary, #8b949e); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; opacity: 0.85; }

/* 2026-05-02: send-row 는 carded body 가 collapsed 여도 항상 보여야 함 (카드 입력 무반응 사고 복구) */
.send-row.send-row-always { display: flex; flex-direction: column; opacity: 1 !important; max-height: none !important; }

/* 2026-05-03: Team 페이지 워커카드 안 현재 세션 미니 카드 (Sessions·Office 정합) */
.team-card-session { margin-top: 8px; padding: 6px 8px; background: rgba(88, 166, 255, 0.06); border: 1px solid rgba(88, 166, 255, 0.25); border-radius: 5px; cursor: pointer; transition: background 0.15s; }
.team-card-session:hover { background: rgba(88, 166, 255, 0.12); }
.team-card-session-head { display: flex; align-items: center; gap: 6px; }
.team-card-session-status { font-size: 9px; padding: 1px 5px; border-radius: 6px; }
.team-card-session-title { font-size: 11px; font-weight: 500; color: var(--text, #c9d1d9); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-card-session-meta { display: flex; gap: 8px; font-size: 10px; color: var(--text-secondary, #8b949e); margin-top: 3px; }
.team-card-session-activity { color: var(--accent, #58a6ff); font-family: 'JetBrains Mono', monospace; }

/* 2026-05-02: Team 페이지 미분류 컬럼 (부서 옆에 추가) */
.team-col.team-col-orphan { border-left: 2px dashed #d29922; background: rgba(210, 153, 34, 0.04); }
.team-col-orphan .team-col-name { color: #d29922; }
.team-card.team-orphan-card { border-left: 3px dashed #d29922; }
.team-card.team-orphan-card .team-card-icon { color: #d29922; }
.team-card-head { display: flex; align-items: center; gap: 6px; }
.team-card-status { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--bg-soft, #1c2128); }
.team-card-meta { display: flex; gap: 12px; font-size: 11px; color: var(--text-secondary, #8b949e); margin-top: 4px; }
.team-card-actions { display: flex; gap: 6px; margin-top: 6px; }

/* 2026-05-02: Team 페이지 임시·좀비 섹션 */
.team-extra-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; }
.team-extra-col { background: var(--card-bg, #161b22); border: 1px solid var(--border, #30363d); border-radius: 8px; padding: 10px; min-height: 120px; }
.team-extra-head { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border, #30363d); }
.team-extra-title { font-weight: 600; color: var(--text, #c9d1d9); }
.team-extra-count { background: var(--accent, #58a6ff); color: #000; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.team-extra-hint { color: var(--text-secondary, #8b949e); font-size: 11px; margin-left: auto; }
.team-cleanup-btn { margin-left: auto; padding: 4px 10px; background: #c93030; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.team-cleanup-btn:hover { background: #a82020; }
.team-extra-body { padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.team-extra-empty { color: var(--text-secondary, #8b949e); font-size: 12px; padding: 12px; text-align: center; }
.team-extra-card { background: var(--bg, #0d1117); border: 1px solid var(--border, #30363d); border-radius: 6px; padding: 8px 10px; }
.team-extra-card-orphan { border-left: 3px dashed #d29922; }
.team-extra-card-zombie { border-left: 3px solid #c93030; }
.team-extra-card-head { display: flex; align-items: center; gap: 6px; }
.team-extra-card-title { font-weight: 500; flex: 1; color: var(--text, #c9d1d9); font-size: 13px; }
.team-extra-card-status { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--bg-soft, #1c2128); color: var(--text-secondary, #8b949e); }
.status-working { background: var(--rust-deep); color: #000; }
.status-input { background: #d29922; color: #000; }
.status-zombie, .status-aborted { background: #c93030; color: #fff; }
.team-extra-card-meta { display: flex; gap: 12px; font-size: 11px; color: var(--text-secondary, #8b949e); margin-top: 4px; }
.team-extra-card-actions { display: flex; gap: 6px; margin-top: 6px; }
.team-extra-btn { padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border, #30363d); background: var(--bg-soft, #1c2128); color: var(--text, #c9d1d9); cursor: pointer; font-size: 11px; }
.team-extra-btn-promote { background: #1f6feb; color: #fff; border-color: #1f6feb; }
.team-extra-btn-promote:hover { background: #388bfd; }
.team-extra-btn-kill:hover { background: #c93030; color: #fff; border-color: #c93030; }
.card-summary {
  font-size: 12px; color: var(--text-secondary); padding: 6px 0;
  line-height: 1.5;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
.card-summary:hover { color: var(--text-primary); }
.card-summary .sum-line {
  display: flex; align-items: baseline; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-summary .sum-label { flex-shrink: 0; font-size: 11px; opacity: 0.8; }
.card-summary .sum-topic { color: var(--text-primary); font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.card-summary .sum-recent-now { color: var(--accent); font-weight: 600; }
.card-summary .sum-recent-now em { color: #d29922; font-style: italic; font-weight: 500; font-size: 11px; }
.card-summary .sum-recent-past { color: var(--text-secondary); opacity: 0.7; font-size: 11px; }
.card-summary .sum-activity { color: #79c0ff; font-size: 10px; }
.card-summary .sum-tools { color: #ffa657; font-family: ui-monospace, monospace; font-size: 10px; opacity: 0.85; }
.card-summary .sum-stat { color: var(--text-secondary); font-size: 10px; opacity: 0.75; }
.card-summary .sum-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.card-summary .sum-narrative {
  color: var(--text-primary); font-size: 12px; line-height: 1.55;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-summary .sum-pulse {
  color: var(--accent);
  animation: sum-pulse-dot 1.3s ease-in-out infinite;
  font-size: 10px;
  margin-right: 3px;
}
@keyframes sum-pulse-dot { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
[data-theme="light"] .card-summary .sum-pulse { color: var(--rust-deep); }
[data-theme="light"] .card-summary .sum-recent-now { color: var(--rust-deep); }
[data-theme="light"] .card-summary .sum-recent-now em { color: #9a6700; }
[data-theme="light"] .card-summary .sum-activity { color: #0969da; }
.card-expand-icon { font-size: 10px; color: var(--text-secondary); cursor: pointer; transition: transform 0.2s; }
.card-expand-icon.open { transform: rotate(90deg); }

/* === Drag Card Sort (#3) === */
.card-header[draggable="true"] { cursor: grab; }
.card-header[draggable="true"]:active { cursor: grabbing; }
.card.drag-over { border-color: var(--accent-blue) !important; border-style: dashed; }

/* === Pin / Hide (#4) === */
.pin-btn, .hide-btn { background: none; border: none; cursor: pointer; font-size: 11px; opacity: 0.4; transition: opacity 0.2s; padding: 2px; }
.pin-btn:hover, .hide-btn:hover { opacity: 1; }
.pin-btn.pinned { opacity: 1; }
.card.pinned { border-top: 2px solid var(--accent-green); }
.card.card-hidden { opacity: 0.5; border-style: dashed; }
.unhide-btn { background: rgba(248,81,73,0.15); border: 1px solid rgba(248,81,73,0.3); color: #f85149; font-size: 10px; padding: 2px 8px; border-radius: 6px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.unhide-btn:hover { background: rgba(248,81,73,0.3); }

/* === Batch Prompt (#5) === */
.team-broadcast-btn { background: none; border: none; cursor: pointer; font-size: 12px; opacity: 0.5; transition: opacity 0.2s; }
.team-broadcast-btn:hover { opacity: 1; }

/* === Card Color (#6) === */
.color-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; flex-shrink: 0; display: inline-block; transition: transform 0.15s; }
.color-dot:hover { transform: scale(1.3); }

/* === Search Bar (#7) === */
.search-input {
  background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 6px; font-size: 12px; flex: 1; max-width: 300px; outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--text-secondary); }

/* === Keyboard Nav (#8) === */
.card-selected { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* === Input Warning (#9) === */
.wait-warning {
  font-size: 9px; color: #f85149; background: rgba(248,81,73,0.15);
  padding: 2px 6px; border-radius: 8px; font-weight: 600;
  animation: warn-pulse 1.5s ease-in-out infinite;
}
@keyframes warn-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === Mini Timeline (#10) === */
.mini-timeline { position: relative; height: 3px; background: var(--bg-tertiary); border-radius: 2px; margin: 6px 0 2px; overflow: hidden; }

/* === Light Theme Completion (#11) === */
[data-theme="light"] body { background: #f6f8fa; color: #1f2328; }
[data-theme="light"] .card { background: #fff; border-color: #d0d7de; }
[data-theme="light"] .card.working { border-color: var(--rust-deep); box-shadow: 0 0 0 1px var(--rust-deep) inset; }
[data-theme="light"] .card.input { border-color: #bf8700; box-shadow: 0 0 12px rgba(191,135,0,0.2); }
[data-theme="light"] .card.active { border-color: #0969da; }
[data-theme="light"] .card.idle { border-color: #d0d7de; opacity: 0.8; }
[data-theme="light"] .card.away { border-color: #d0d7de; opacity: 0.5; }
[data-theme="light"] .title-text { color: #1f2328; }
[data-theme="light"] .title-text.placeholder { color: #656d76; }
[data-theme="light"] .title-text:hover { color: var(--rust-deep); }
[data-theme="light"] .title-input { background: #f6f8fa; border-color: #0969da; color: #1f2328; }
[data-theme="light"] .msg-user { color: #1f2328; }
[data-theme="light"] .msg-user .who { color: var(--rust-deep); }
[data-theme="light"] .msg-asst { color: #656d76; }
[data-theme="light"] .msg-asst .who { color: #0969da; }
[data-theme="light"] .msg-tools { color: #bf8700; }
[data-theme="light"] .send-row { background: #f6f8fa; border-color: #d0d7de; }
[data-theme="light"] .send-row:focus-within { border-color: #0969da; }
[data-theme="light"] .send-textarea { color: #1f2328; }
[data-theme="light"] .send-textarea::placeholder { color: #656d76; }
[data-theme="light"] .send-hint { color: #656d76; }
[data-theme="light"] .send-hint kbd { background: #e1e4e8; color: #1f2328; }
[data-theme="light"] .badge { background: #e1e4e8; color: #656d76; }
[data-theme="light"] .badge.working { background: #dafbe1; color: var(--rust-deep); }
[data-theme="light"] .badge.input { background: #fff8c5; color: #9a6700; }
[data-theme="light"] .badge.active { background: #ddf4ff; color: #0969da; }
[data-theme="light"] .tag { background: #e1e4e8; color: #1f2328; border-color: #d0d7de; }
[data-theme="light"] .team-label { border-right-color: var(--rust-deep); }
[data-theme="light"] .team-label-name { color: var(--rust-deep); }
[data-theme="light"] .team-label-cost { color: #bf8700; }
[data-theme="light"] .team-row { border-bottom-color: #d0d7de; }
[data-theme="light"] .filter-row select { background: #f6f8fa; color: #1f2328; border-color: #d0d7de; }
[data-theme="light"] .title-row { border-bottom-color: #d0d7de; }
[data-theme="light"] .footer { color: #656d76; }
[data-theme="light"] .turn { border-bottom-color: #e1e4e8; }
[data-theme="light"] .sid { color: var(--rust-deep); }
[data-theme="light"] .files .label { color: #bf8700; }
[data-theme="light"] .work-log > .label { color: #bf8700; }
[data-theme="light"] .log-idx { color: var(--rust-deep); }
[data-theme="light"] .log-line { color: #1f2328; }
[data-theme="light"] .card-meta { border-top-color: #d0d7de; }
[data-theme="light"] .details-toggle { color: #0969da; }
[data-theme="light"] .search-input { background: #fff; color: #1f2328; border-color: #d0d7de; }
[data-theme="light"] h1 { color: var(--rust-deep); }

/* === Card Header (Top Identity Bar) === */
.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 8px;
  margin: -10px -12px 8px -12px;
  background: var(--bg-tertiary);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.card-header:hover { background: #2a3040; }
[data-theme="light"] .card-header { background: #f0f2f5; }
[data-theme="light"] .card-header:hover { background: #e4e8ec; }

/* === Status-tinted card headers (dark theme) === */
.card.working > .card-header {
  background: linear-gradient(135deg, rgba(35,134,54,0.22), rgba(35,134,54,0.08));
  border-bottom-color: rgba(35,134,54,0.4);
}
.card.working > .card-header:hover {
  background: linear-gradient(135deg, rgba(35,134,54,0.32), rgba(35,134,54,0.14));
}
/* INPUT — 사용자 입력 필요 → 강한 호박색 + 좌측 강조 띠 + soft pulse */
.card.input > .card-header {
  background: linear-gradient(135deg, rgba(255,179,71,0.45), rgba(255,143,0,0.18));
  border-bottom-color: rgba(255,159,28,0.7);
  box-shadow: inset 4px 0 0 #ffb347;
}
.card.input > .card-header:hover {
  background: linear-gradient(135deg, rgba(255,179,71,0.55), rgba(255,143,0,0.28));
}
.card.input { animation: input-glow 1.6s ease-in-out infinite; }
@keyframes input-glow {
  0%, 100% { box-shadow: 0 0 0 1px #d29922, 0 0 12px rgba(255,179,71,0.25); }
  50%      { box-shadow: 0 0 0 1px #ffb347, 0 0 22px rgba(255,179,71,0.55); }
}

/* IDLE — "일거리 대기" 강조: 차분한 파랑톤 + 좌측 띠로 "available" 시각화 */
.card.idle > .card-header {
  background: linear-gradient(135deg, rgba(88,166,255,0.20), rgba(88,166,255,0.06));
  border-bottom-color: rgba(88,166,255,0.4);
  box-shadow: inset 4px 0 0 #58a6ff;
}
.card.idle > .card-header:hover {
  background: linear-gradient(135deg, rgba(88,166,255,0.32), rgba(88,166,255,0.14));
}
.card.idle { opacity: 1; }

/* === Status-tinted card headers (light theme) === */
[data-theme="light"] .card.working > .card-header {
  background: linear-gradient(135deg, rgba(26,127,55,0.13), rgba(26,127,55,0.04));
  border-bottom-color: rgba(26,127,55,0.4);
}
[data-theme="light"] .card.working > .card-header:hover {
  background: linear-gradient(135deg, rgba(26,127,55,0.22), rgba(26,127,55,0.08));
}
[data-theme="light"] .card.input > .card-header {
  background: linear-gradient(135deg, rgba(255,184,77,0.55), rgba(241,164,0,0.25));
  border-bottom-color: rgba(191,135,0,0.7);
  box-shadow: inset 4px 0 0 #d68a00;
}
[data-theme="light"] .card.input > .card-header:hover {
  background: linear-gradient(135deg, rgba(255,184,77,0.65), rgba(241,164,0,0.35));
}
[data-theme="light"] .card.idle > .card-header {
  background: linear-gradient(135deg, rgba(9,105,218,0.16), rgba(9,105,218,0.05));
  border-bottom-color: rgba(9,105,218,0.4);
  box-shadow: inset 4px 0 0 #0969da;
}
[data-theme="light"] .card.idle > .card-header:hover {
  background: linear-gradient(135deg, rgba(9,105,218,0.26), rgba(9,105,218,0.10));
}
[data-theme="light"] .card.idle { opacity: 1; }
.card-header-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: -0.3px;
}
.card-header-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 20px;
}
.card-header-age {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
}
.title-input-inline {
  flex: 1; min-width: 0;
  background: var(--bg-primary); border: 1px solid var(--accent-blue); color: var(--text-primary);
  padding: 2px 8px; border-radius: 4px; font-size: 15px; font-weight: 700; outline: none;
}
.card-header-project {
  font-size: 10px;
  color: var(--accent-purple);
  font-family: ui-monospace, monospace;
  background: rgba(210,168,255,0.1);
  padding: 1px 6px;
  border-radius: 4px;
}
.card-header-sid {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
}

/* === World-style Status Badges === */
.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.idle-badge {
  background: rgba(248,81,73,0.15);
  color: #f85149;
  animation: badge-pulse 1.5s ease-in-out infinite;
}
.input-wait-badge {
  background: rgba(210,153,34,0.2);
  color: #ffdf5d;
  animation: badge-pulse 1.2s ease-in-out infinite;
}
.working-badge {
  background: rgba(35,134,54,0.2);
  color: var(--accent-green);
}
.active-badge {
  background: rgba(88,166,255,0.15);
  color: var(--accent-blue);
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
[data-theme="light"] .idle-badge { background: rgba(248,81,73,0.1); color: #d1242f; }
[data-theme="light"] .input-wait-badge { background: rgba(154,103,0,0.12); color: #9a6700; }
[data-theme="light"] .working-badge { background: rgba(26,127,55,0.1); color: var(--rust-deep); }
[data-theme="light"] .active-badge { background: rgba(9,105,218,0.1); color: #0969da; }

/* === Responsive (#12) === */
@media (max-width: 768px) {
  body { padding: 0; }
  h1 { font-size: 16px; left: 10px; }
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .chart-grid { grid-template-columns: 1fr; }
  .filter-row { flex-wrap: wrap; }
  .card { padding: 8px; }
  .stats-summary { grid-template-columns: repeat(2, 1fr); }
  .dash-header { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .dash-header::after { left: 12px; right: 12px; }
  .page-toolbar { padding: 8px 12px; }
  #grid { padding: 0 12px 12px; }
  .an-page { padding: 12px 12px; }
  .report-panel { margin: 0 12px 12px; }
  .dash-stats { gap: 4px; flex-wrap: wrap; }
  .dash-stat { padding: 3px 8px; min-width: 44px; }
  .dash-stat-val { font-size: 13px; }
  .team-row { flex-direction: column; }
  .team-label { width: 100%; border-right: none; border-bottom: 2px solid var(--accent-green); flex-direction: row; align-items: center; text-align: left; padding: 6px 0; }
  .team-cards { padding-left: 0; }
  .team-cards .card { width: 100%; }
  .search-input { max-width: 100% !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 2 — Kill/Restart/Spawn + Activity Stream
   ═══════════════════════════════════════════════════════════════════ */

/* ── Card action buttons (Kill / Restart) ─────────────────────── */
.card-action-btns {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}
.card-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
}
.card-action-btn:hover {
  border-color: var(--border-warm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.card-action-btn.kill:hover {
  border-color: rgba(239,68,68,0.5);
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}
.card-action-btn.restart:hover {
  border-color: rgba(96,165,250,0.5);
  background: rgba(96,165,250,0.12);
  color: var(--accent-blue);
}

/* ── Toast system ─────────────────────────────────────────────── */
#tw-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.tw-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-warm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  min-width: 220px;
  max-width: 380px;
  pointer-events: auto;
  animation: toast-in 0.22s cubic-bezier(0.16,1,0.3,1) both;
  transition: opacity 0.3s, transform 0.3s;
}
.tw-toast.toast-ok   { border-left: 3px solid var(--sage); }
.tw-toast.toast-err  { border-left: 3px solid #ef4444; }
.tw-toast.toast-info { border-left: 3px solid var(--accent-blue); }
.tw-toast.toast-out  { opacity: 0; transform: translateX(12px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── New Session modal ────────────────────────────────────────── */
.tw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease both;
}
@keyframes fade-in { from { opacity:0; } to { opacity:1; } }
.tw-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-primary);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modal-rise 0.2s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes modal-rise {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.tw-modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.tw-modal-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.tw-modal label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.tw-modal select,
.tw-modal input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.12s;
}
.tw-modal select:focus,
.tw-modal input[type="text"]:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(96,165,250,0.15);
}
.tw-modal-field { margin-bottom: 14px; }
.tw-modal-error {
  color: #ef4444;
  font-size: 11px;
  margin-top: 8px;
  min-height: 16px;
}
.tw-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.tw-btn-primary {
  flex: 1;
  padding: 9px 16px;
  background: var(--rust);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.tw-btn-primary:hover { background: var(--rust-soft); }
.tw-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.tw-btn-cancel {
  padding: 9px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.tw-btn-cancel:hover { border-color: var(--border-warm); color: var(--text-primary); }

/* ── New Session button in toolbar ───────────────────────────── */
.new-session-spawn-btn {
  padding: 6px 14px;
  background: var(--rust);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.new-session-spawn-btn:hover {
  background: var(--rust-soft);
  box-shadow: 0 0 0 2px rgba(255,107,53,0.25);
}

/* ── Activity Stream panel ────────────────────────────────────── */
#activity-stream-panel {
  margin: 0 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  overflow: hidden;
}
.activity-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  background: var(--bg-tertiary);
}
.activity-panel-header:hover { background: var(--bg-primary); }
.activity-panel-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  flex: 1;
}
.activity-panel-arrow {
  font-size: 10px;
  color: var(--text-faint);
  transition: transform 0.2s;
}
.activity-panel-arrow.open { transform: rotate(90deg); }
.activity-panel-count {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.activity-panel-body {
  display: none;
}
.activity-panel-body.open {
  display: block;
}
.activity-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.activity-filters select {
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  cursor: pointer;
}
.activity-filter-types {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.activity-filter-types label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

/* ── Phase 3: Live terminal modal ─────────────────────────────── */

/* Watch button on card — matches kill/restart styling */
.card-action-btn.watch {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.card-action-btn.watch:hover {
  color: #60a5fa;
  border-color: #60a5fa;
  background: rgba(96,165,250,0.08);
}

/* Overlay: full-screen backdrop, same base as tw-modal-overlay */
.tw-live-overlay {
  align-items: center;
  justify-content: center;
}

/* Modal box — wider + taller than spawn modal, resizable */
.tw-live-modal {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: var(--radius-lg);
  width: 900px;
  max-width: 96vw;
  height: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  animation: modal-rise 0.2s cubic-bezier(0.16,1,0.3,1) both;
  overflow: hidden;
  resize: both;
  min-width: 520px;
  min-height: 320px;
}

/* Header bar */
.tw-live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #111;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
  user-select: none;
}
.tw-live-title {
  font-size: 13px;
  font-weight: 600;
  color: #d4d4d4;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.tw-live-sid {
  color: #60a5fa;
  font-weight: 700;
}
.tw-live-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Live / Disconnected status pill */
.tw-live-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  font-family: var(--font-mono);
}
.tw-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tw-live-dot.live {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.7);
  animation: live-pulse 1.8s ease-in-out infinite;
}
.tw-live-dot.dead {
  background: #6b7280;
  box-shadow: none;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Header buttons */
.tw-live-stop-btn,
.tw-live-close-btn {
  background: transparent;
  border: 1px solid #333;
  border-radius: var(--radius-sm);
  color: #9ca3af;
  font-size: 11px;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  font-family: var(--font-mono);
}
.tw-live-stop-btn:hover  { color: #f87171; border-color: #f87171; }
.tw-live-close-btn:hover { color: #d4d4d4; border-color: #555; }
.tw-live-stop-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Terminal container — fills modal body */
.tw-live-term-wrap {
  flex: 1;
  overflow: hidden;
  background: #1e1e1e;
  /* xterm.js renders its own canvas here */
}
/* Let xterm canvas/viewport fill the wrapper fully */
.tw-live-term-wrap .xterm,
.tw-live-term-wrap .xterm-viewport {
  width: 100% !important;
  height: 100% !important;
}
/* 2026-05-17: .xterm-screen 은 height 강제 X — xterm 이 buffer 높이로 관리해야 스크롤 동작 */
.tw-live-term-wrap .xterm-screen { width: 100% !important; }
/* 2026-05-17: 터미널 스크롤 — viewport 스크롤 보장 + 터치 팬 + 체이닝 차단 + iOS 관성 */
.tw-live-term-wrap .xterm-viewport {
  overflow-y: auto !important;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.tw-live-term-wrap .xterm,
.tw-live-term-wrap .xterm-screen { touch-action: pan-y; }

/* Footer note */
.tw-live-footer {
  flex-shrink: 0;
  padding: 5px 14px;
  background: #111;
  border-top: 1px solid #2a2a2a;
  font-size: 10px;
  color: #4b5563;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.activity-filter-types input[type="checkbox"] {
  width: 12px;
  height: 12px;
  cursor: pointer;
  accent-color: var(--rust);
}
.activity-timeline {
  padding: 8px 0;
  max-height: 360px;
  overflow-y: auto;
}
.activity-timeline::-webkit-scrollbar { width: 6px; }
.activity-timeline::-webkit-scrollbar-thumb { background: var(--border-warm); border-radius: 3px; }
.activity-row {
  display: grid;
  grid-template-columns: 70px 72px auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-size: 11px;
  border-bottom: 1px solid rgba(38,38,43,0.6);
  transition: background 0.1s;
}
.activity-row:hover { background: var(--bg-tertiary); }
.activity-row:last-child { border-bottom: none; }
.activity-ts {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
}
.activity-sid {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge-PreToolUse    { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-PostToolUse   { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-Notification  { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-Stop          { background: rgba(113,113,122,0.2); color: #a1a1aa; }
.badge-UserPromptSubmit { background: rgba(167,139,250,0.15); color: #a78bfa; }
.badge-SessionStart  { background: rgba(255,107,53,0.15); color: var(--rust-soft); }
.activity-summary {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.activity-tool {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
}
.activity-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.activity-search-row { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.activity-search-row input[type="text"] { flex: 1; min-width: 120px; padding: 4px 8px; background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); border-radius: 3px; font-size: 13px; }
.activity-search-row input[type="text"]::placeholder { color: var(--text-faint); }
.activity-search-row select { padding: 4px 8px; background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); border-radius: 3px; font-size: 13px; }
.activity-row mark { background: #ffe27a !important; color: #000; padding: 0 2px; border-radius: 2px; }
[data-theme="light"] #activity-stream-panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .activity-panel-header { background: var(--bg-tertiary); }
[data-theme="light"] .activity-row:hover { background: var(--bg-tertiary); }

/* ─────────────────────────────────────────────
   Mobile responsive — viewport < 768px
   PWA + 휴대폰 Chrome/Safari 지원
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-header { padding: 8px; flex-wrap: wrap; }
  .dash-title { font-size: 16px; }
  .dash-header nav { width: 100%; order: 3; padding-top: 6px; gap: 4px; flex-wrap: wrap; }
  .dash-header nav a { font-size: 13px; padding: 4px 8px; }
  .dash-actions { flex-wrap: wrap; gap: 4px; }
  .layout-toggle { display: none; }
  .conn { font-size: 11px; }

  .kpi-bar.collapsed .kpi-summary { font-size: 12px; padding: 6px 8px; }
  .kpi-expanded { flex-direction: column; gap: 6px; padding: 8px; }
  .kpi-card { width: 100%; padding: 6px; }

  .page-toolbar { flex-wrap: wrap; gap: 6px; padding: 6px; }
  .search-input { flex: 1 1 100%; font-size: 16px; min-height: 36px; }
  .page-toolbar select { flex: 1 1 calc(50% - 4px); font-size: 14px; min-height: 36px; }
  .page-actions { width: 100%; flex-wrap: wrap; gap: 4px; }
  .page-actions button { flex: 1 1 calc(50% - 4px); font-size: 13px; min-height: 40px; }
  #ds-filter-btn, #ds-sort-btn { font-size: 12px; min-height: 36px; }

  #grid { grid-template-columns: 1fr !important; gap: 6px; padding: 6px; }
  .session-card { padding: 8px; }
  .card-header-row1 { flex-wrap: wrap; gap: 4px; }
  .card-action-btn { min-width: 44px; min-height: 44px; font-size: 16px; }

  .tw-live-overlay { padding: 0 !important; align-items: flex-start !important; }
  .tw-live-modal { width: 100vw !important; height: 100vh !important; max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
  .tw-live-header { padding: 8px; flex-wrap: wrap; gap: 4px; }
  .tw-live-header button { min-height: 40px; font-size: 13px; }
  .tw-live-body { flex: 1; min-height: 0; }

  .tw-modal { width: 90vw !important; max-width: 90vw !important; }
  .tw-modal input, .tw-modal select { font-size: 16px; min-height: 40px; }
  .tw-modal button { min-height: 44px; font-size: 14px; }

  #activity-stream-panel { margin: 0; border-radius: 0; }
  .activity-search-row { flex-wrap: wrap; gap: 4px; }
  .activity-search-row input[type="text"] { flex: 1 1 100%; font-size: 16px; min-height: 36px; }
  .activity-search-row select { flex: 1 1 calc(50% - 2px); font-size: 14px; min-height: 36px; }
  .activity-filters { flex-wrap: wrap; gap: 4px; }
  .activity-filter-types { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; }
  .activity-row { font-size: 12px; padding: 4px; }

  .tw-toast-container { left: 8px !important; right: 8px !important; bottom: 8px !important; }
  .tw-toast { width: 100% !important; }

  /* ── P0 모바일 UX (2026-05-17 시뮬레이션 기반) ─────────────────────
     근거: docs/10_아키텍처/CTW_anl_Session_PWA개선_v1.md (CTW 프로젝트 폴더)
     실측: 영구팀원 1566px·gridTop 1903px·가로오버플로 +134px @390 */

  /* 1) 영구 팀원 섹션 — 모바일에서 높이 캡 + 내부 스크롤 (1566px → ~42vh) */
  #workers-section .workers-grid {
    max-height: 42vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 2) 가로 오버플로 차단 — Board 부서 칼럼을 viewport 폭에 고정 (content 로 안 부풂) */
  #grid { width: 100%; max-width: 100vw; }
  #grid .team-column { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }

  /* 3) 가로 오버플로 차단 — 툴바·액션 영역 viewport 내 강제 */
  .page-toolbar, .page-actions { max-width: 100%; box-sizing: border-box; min-width: 0; }

  /* 4) 프롬프트 입력 — iOS focus 시 자동 확대 방지 (16px 미만이면 줌) */
  .card .send-textarea, .send-textarea, input[type="text"], textarea { font-size: 16px; }

  /* 5) 카드 바디 스크롤 안정화 — 체이닝(아래위 튕김)·대각(좌우 흔들림) 제거 */
  .card-body .chat, .chat {
    overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  /* 6) 펼친 카드 상단 작업내역 요약 제거 — 공간 최적화 (접힘 시엔 유지: 토글·미리보기) */
  .card.expanded .card-summary { display: none; }

  /* ── iPhone 15 Plus(430px) 등 폰 카드 보기 최적화 (2026-05-17 3차) ── */

  /* 7) 카드 폭 — 폰 viewport 에 맞춤 (데스크톱 624px 고정 해제 → 잘림 방지) */
  .team-cards .card, .team-column-body .card, #grid .card, .session-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex-shrink: 1 !important;
  }

  /* 8) 카드 바디 내용 줄바꿈 — 긴 명령·경로·내러티브가 카드 밖으로 안 넘침 */
  .card .chat, .card-summary, .card .work-log, .card-activity,
  .card .turn, .card .msg-user, .card .msg-asst, .card .log-line {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
  }

  /* 9) 인라인 터미널 — 카드 바디에선 헤더 없이 프롬프트 내용만 */
  .tw-live-overlay.tw-live-inline .tw-live-header { display: none; }

  /* 10) 프롬프트 입력창 — 1줄 구성 (textarea + 전송버튼 한 줄) + Enter 안내 제거 */
  .card .send-hint { display: none; }
  .card .send-row { padding: 6px 8px; flex-direction: row; align-items: center; gap: 6px; }
  .card .send-row .send-textarea { flex: 1 1 auto; min-width: 0; max-height: 30vh; }
  .card .send-bottom { flex: 0 0 auto; }

  /* 11) 카드 헤더 압축 — 차지 공간 최소화 */
  .card { padding: 8px 10px 8px; }
  .card-header-row1 { gap: 4px; margin-bottom: 2px; }
  .card-header-row1 .card-title, .card .title-text { font-size: 13px; }
  .card-header-row2 { font-size: 9.5px; gap: 4px; }
  .team-column-body .card .card-header-row1 { font-size: 11.5px; }

  body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}

/* Tablet — 769-1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  #grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Touch device — no hover */
@media (hover: none) {
  .card-action-btn { min-width: 44px; min-height: 44px; }
  .session-card { cursor: default; }
}

/* ═══════════════════════════════════════════════════════════════════
   Persistent Workers section (Phase 5.5)
   ═══════════════════════════════════════════════════════════════════ */
#workers-section {
  margin: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.workers-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--bg-tertiary);
  user-select: none;
  transition: background 0.12s ease;
}
.workers-header:hover { background: var(--border-warm); }
.workers-arrow { font-size: 10px; color: var(--text-secondary); transition: transform 0.15s ease; }
.workers-title { font-weight: 600; font-size: 14px; }
.workers-count { color: var(--text-secondary); font-size: 12px; margin-left: auto; }
.workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  padding: 8px;
}
.workers-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  grid-column: 1 / -1;
}
.worker-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease;
}
.worker-card:hover { border-color: var(--border-warm); }
.worker-card.alive  { border-left: 3px solid var(--sage); }
.worker-card.dormant { border-left: 3px solid var(--text-faint); opacity: 0.72; }
.worker-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}
.worker-id {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
}
.worker-status { color: var(--text-secondary); }
.worker-card.alive .worker-status { color: var(--sage); }
.worker-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.worker-role { font-size: 12px; color: var(--text-secondary); min-height: 16px; }
.worker-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  align-items: center;
}
.worker-team {
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.worker-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.worker-btn {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.worker-btn:hover { background: var(--border-warm); border-color: var(--border-warm); }
.worker-btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.worker-btn.primary:hover { background: var(--rust-soft); border-color: var(--rust-soft); }
.worker-btn.danger {
  background: transparent;
  color: var(--burgundy);
  border-color: var(--burgundy);
}
.worker-btn.danger:hover { background: rgba(239,68,68,0.08); }

/* Workers mobile */
@media (max-width: 768px) {
  .workers-grid { grid-template-columns: 1fr; }
  .worker-card { padding: 12px; }
  .worker-btn { min-height: 40px; font-size: 13px; }
}

/* ─────────────────────────────────────────────────────────────────────
   Phase 5.7 — 📜 이어 시작 (history modal)
   ───────────────────────────────────────────────────────────────────── */
.new-session-resume-btn {
  background: linear-gradient(135deg, #4a3aa6 0%, #6b54c4 100%);
  color: #fff;
  border: 1px solid #6b54c4;
}
.new-session-resume-btn:hover {
  background: linear-gradient(135deg, #5a4ab6 0%, #7b64d4 100%);
  border-color: #7b64d4;
}
.tw-history-overlay { z-index: 9000; }
.tw-history-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 80vw;
  max-width: 1400px;
  height: 80vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: modal-rise 0.2s cubic-bezier(0.16,1,0.3,1) both;
}
.tw-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card-deep, var(--card));
  flex: 0 0 auto;
}
.tw-history-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.tw-history-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tw-history-controls input[type="text"] {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 240px;
}
.tw-history-controls input[type="text"]:focus {
  border-color: var(--rust-soft);
  outline: none;
}
.tw-history-controls select {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}
.tw-history-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 25% 50% 25%;
  overflow: hidden;
  min-height: 0;
}
.tw-history-tree,
.tw-history-list,
.tw-history-preview {
  overflow-y: auto;
  padding: 10px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.tw-history-preview { border-right: none; }
.tw-history-empty {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 14px 8px;
  text-align: center;
}
.tw-history-tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background 0.12s;
}
.tw-history-tree-item:hover {
  background: var(--card-deep, rgba(255,255,255,0.03));
}
.tw-history-tree-item.active {
  background: var(--accent-bg, rgba(74,58,166,0.15));
  border-color: var(--accent, #6b54c4);
}
.tw-history-tree-label {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-history-tree-count {
  color: var(--text-secondary);
  font-size: 11px;
  background: var(--card-deep, rgba(255,255,255,0.06));
  padding: 1px 6px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.tw-history-list-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.tw-history-list-cwd {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: ui-monospace, "JetBrains Mono", monospace;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-history-card {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--card-deep, rgba(255,255,255,0.02));
  transition: border-color 0.12s, background 0.12s;
}
.tw-history-card:hover {
  border-color: var(--rust-soft, #b85a3e);
  background: var(--card-deep, rgba(255,255,255,0.05));
}
.tw-history-card.active {
  border-color: var(--accent, #6b54c4);
  background: var(--accent-bg, rgba(74,58,166,0.12));
}
.tw-history-card-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.tw-history-card-sid {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-secondary);
}
.tw-history-card-time {
  font-size: 11px;
  color: var(--text-secondary);
}
.tw-history-card-preview {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tw-history-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}
.tw-history-preview-section {
  margin-bottom: 12px;
}
.tw-history-preview-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.tw-history-preview-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}
.tw-history-preview-value.mono {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12px;
}
.tw-history-preview-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  background: var(--card-deep, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.tw-history-footer {
  flex: 0 0 auto;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-deep, var(--card));
}
.tw-history-hint {
  font-size: 12px;
  color: var(--text-secondary);
}
.card.history-highlight {
  animation: history-flash 1.2s ease-out 1;
  outline: 2px solid var(--accent, #6b54c4);
}
@keyframes history-flash {
  0%, 100% { box-shadow: 0 0 0 rgba(107,84,196,0); }
  30%      { box-shadow: 0 0 28px rgba(107,84,196,0.6); }
}

/* Mobile responsive — full screen, tabs */
@media (max-width: 768px) {
  .tw-history-modal { width: 100vw !important; height: 100vh !important; max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
  .tw-history-body { grid-template-columns: 1fr !important; grid-template-rows: auto auto auto; }
  .tw-history-tree, .tw-history-list, .tw-history-preview { border-right: none; border-bottom: 1px solid var(--border); max-height: 33vh; }
  .tw-history-controls input[type="text"] { min-width: 120px; }
  .tw-history-controls { flex-wrap: wrap; }
  .tw-history-header { flex-direction: column; align-items: stretch; }
  /* 2026-05-18: 풀스크린 모달이 iPhone 다이내믹 아일랜드/홈인디케이터에 가려
     ✕ 닫기·↩ 이어 시작 버튼이 탭 불가하던 버그 수정. 헤더/푸터 자체 배경이
     안전영역까지 덮도록 inset 만큼 패딩 가산 (Session(T) card-header 와 동일 패턴). */
  .tw-history-header { padding-top: calc(14px + env(safe-area-inset-top)); }
  .tw-history-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 5.6 — Team page (조직도 + 채용 풀 + drag-drop)
   ═══════════════════════════════════════════════════════════════════ */
.team-page-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin: 8px 8px 0 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.team-page-heading { display: flex; align-items: baseline; gap: 10px; }
.team-page-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.team-page-summary { font-size: 12px; color: var(--text-secondary); }
.team-page-actions { display: flex; gap: 6px; }

.team-page-layout {
  display: grid; grid-template-columns: 220px 1fr;
  gap: 8px; padding: 0 8px 8px 8px; min-height: calc(100vh - 160px);
}

/* Left pool */
.team-pool {
  background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 70px; align-self: start; max-height: calc(100vh - 90px); overflow-y: auto;
}
.team-pool-head { display: flex; align-items: center; justify-content: space-between; }
.team-pool-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.team-pool-hint { font-size: 11px; color: var(--text-faint); }
.team-pool-list { display: flex; flex-direction: column; gap: 6px; }
.team-pool-card {
  background: var(--bg-tertiary); border: 1px dashed var(--border-warm);
  border-radius: var(--radius-sm); padding: 10px; cursor: grab;
  display: flex; flex-direction: column; gap: 2px; transition: all 0.15s ease;
  user-select: none;
}
.team-pool-card:hover { border-color: var(--accent); background: var(--bg-primary); }
.team-pool-card.dragging { opacity: 0.5; cursor: grabbing; }
.team-pool-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.team-pool-card-desc { font-size: 11px; color: var(--text-secondary); }
.team-pool-card-drag { font-size: 11px; color: var(--text-faint); align-self: flex-end; }
.team-pool-card-custom { border-style: dotted; opacity: 0.85; }
.team-pool-card-custom:hover { opacity: 1; }

/* Org board */
.team-org-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr);
  gap: 8px; overflow-x: auto; align-items: start;
}
.team-loading { padding: 24px; color: var(--text-secondary); font-size: 13px; }

.team-col {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  min-height: 240px; transition: border-color 0.15s ease, background 0.15s ease;
}
.team-col.drop-ready { border-style: dashed; border-color: var(--text-faint); }
.team-col.drop-hover { border-color: var(--accent); background: rgba(255, 107, 53, 0.04); }
.team-col-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.team-col-icon { font-size: 14px; }
.team-col-name { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; outline: none; }
.team-col-name[contenteditable="true"] { background: var(--bg-primary); padding: 2px 4px; border-radius: 3px; }
.team-col-count { font-size: 11px; color: var(--text-faint); padding: 1px 6px; background: var(--bg-primary); border-radius: 8px; }
.team-col-menu-btn {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.team-col-menu-btn:hover { color: var(--text-primary); }
.team-col-body {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; flex: 1;
}
.team-col-empty {
  padding: 24px 8px; text-align: center; color: var(--text-faint);
  font-size: 12px; border: 1px dashed var(--border-warm); border-radius: var(--radius-sm);
}

/* Worker name plate inside dept */
.team-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-left: 3px solid var(--team-card-color, var(--text-faint));
  border-radius: var(--radius-sm);
  padding: 10px; cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.team-card:hover { border-color: var(--border-warm); transform: translateY(-1px); }
.team-card.dragging { opacity: 0.5; }
.team-card.dormant { opacity: 0.72; }
.team-card-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
.team-card-id { font-family: var(--font-mono); color: var(--accent); font-weight: 600; font-size: 11px; }
.team-card-menu-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; padding: 0 4px; }
.team-card-menu-btn:hover { color: var(--text-primary); }
.team-card-name { font-size: 13px; font-weight: 600; color: var(--text-primary); outline: none; }
.team-card-name[contenteditable="true"] { background: var(--bg-tertiary); padding: 1px 3px; border-radius: 3px; }
.team-card-role { font-size: 11px; color: var(--text-secondary); min-height: 14px; }
.team-card-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); }
.team-card-status.alive { color: var(--sage); }
.team-card-status.dormant { color: var(--text-faint); }

/* Phase 5.6: 인사 카드 액션 (📁 폴더 변경 / 🗑 해고) */
.team-card-actions { display: flex; gap: 4px; margin-top: 6px; }
.team-card-action {
  flex: 1;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--border, #30363d);
  background: var(--bg-soft, #1c2128);
  color: var(--text-secondary, #8b949e);
  cursor: pointer;
  font-size: 10px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.team-card-action:hover { background: var(--bg-tertiary, #2d333b); color: var(--text-primary, #c9d1d9); }
.team-card-action-cwd:hover { border-color: #1f6feb; color: #58a6ff; }
.team-card-action-dismiss:hover { background: #6e1c1c; color: #fff; border-color: #c93030; }

/* Add seat (+ 채용공고) carved button */
.team-add-seat {
  background: transparent;
  border: 1px dashed var(--border-warm);
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px; cursor: pointer;
  font-size: 12px; font-family: var(--font-body);
  transition: all 0.15s ease;
}
.team-add-seat:hover { border-color: var(--accent); color: var(--accent); }

/* Inline hire form (carved, in-column) */
.team-hire-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
  font-size: 12px;
}
.team-hire-form .thf-row { display: flex; align-items: center; gap: 6px; }
.team-hire-form .thf-radio-row { flex-direction: column; gap: 4px; align-items: flex-start; }
.team-hire-form .thf-label { font-weight: 600; color: var(--text-primary); }
.team-hire-form .thf-k { width: 60px; color: var(--text-secondary); font-size: 11px; }
.team-hire-form input[type="text"], .team-hire-form input[type="color"] {
  flex: 1; background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 3px; padding: 4px 6px;
  font-family: var(--font-body); font-size: 12px;
}
.team-hire-form .thf-checkbox { display: flex; align-items: center; gap: 4px; }
.team-hire-form .thf-actions { justify-content: flex-end; gap: 4px; }
.team-hire-form .thf-btn {
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--font-body);
}
.team-hire-form .thf-btn:hover { background: var(--border-warm); }
.team-hire-form .thf-btn.primary {
  background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600;
}
.team-hire-form .thf-btn.primary:hover { background: var(--rust-soft); }

/* Add-dept inline form (uses team-col shell) */
.team-add-dept-form { border-color: var(--accent) !important; }

/* Welcome overlay */
.team-welcome {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.team-welcome-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 32px;
  max-width: 480px; text-align: center; display: flex; flex-direction: column; gap: 12px;
}
.team-welcome-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.team-welcome-body { font-size: 13px; color: var(--text-secondary); }
.team-welcome-cta {
  display: flex; flex-direction: column; gap: 4px; padding: 14px;
  background: var(--bg-primary); border: 1px dashed var(--border-warm);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary);
  align-items: flex-start; text-align: left;
}
.team-welcome-cta-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.team-welcome-cta-hint { color: var(--accent); margin-top: 6px; align-self: center; }

/* Mobile bottom-sheet picker */
.team-mobile-sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.team-mobile-sheet .tms-card {
  background: var(--bg-secondary); width: 100%; max-width: 480px;
  border-top-left-radius: 12px; border-top-right-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  max-height: 70vh; overflow-y: auto;
}
.team-mobile-sheet .tms-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.team-mobile-sheet .tms-list { display: flex; flex-direction: column; gap: 4px; }
.team-mobile-sheet .tms-item, .team-mobile-sheet .tms-cancel {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; font-size: 13px; text-align: left; cursor: pointer;
  font-family: var(--font-body);
}
.team-mobile-sheet .tms-cancel { text-align: center; margin-top: 8px; }

/* Team-page mobile */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .team-page-layout { grid-template-columns: 1fr; min-height: 0; }
  .team-pool {
    position: relative; top: 0; max-height: none;
  }
  .team-pool-list {
    flex-direction: row; overflow-x: auto; padding-bottom: 4px;
    overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  }
  .team-pool-card { min-width: 160px; }
  .team-org-board {
    grid-auto-flow: row; grid-auto-columns: unset;
    grid-template-columns: 1fr; overflow-x: hidden;
  }
  /* ── P0 Team 모바일 UX (2026-05-17 시뮬레이션 기반) ────────────────
     근거: docs/10_아키텍처/CTW_anl_Team_Work_PWA개선_v1.md
     실측(개선 전 @390): header 121px·nav 2행 wrap 61px·toolbar 49px */
  /* 1) 툴바 — heading/actions 줄바꿈 (좁은 폭에서 actions 잘림 방지) */
  .team-page-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; margin: 8px; }
  .team-page-heading { flex-wrap: wrap; gap: 4px 8px; }
  .pt-spacer { display: none; }
  .team-page-actions { width: 100%; gap: 6px; }
  .team-page-actions .report-btn { flex: 1 1 calc(50% - 3px); min-height: 38px; }
  /* 2) 부서 칼럼 — 빈 칼럼 과도한 높이 축소 */
  .team-col { min-height: 120px; }
  .team-col-empty { padding: 14px 8px; }
  /* 3) 좀비/미니 패널 — 1칼럼 */
  .team-extra-row { grid-template-columns: 1fr; padding: 8px; }
  /* 4) 인사 카드 액션 — 터치 타깃 확대 */
  .team-card-action { min-height: 34px; font-size: 11px; }
  /* 5) 채용 폼 입력 — iOS focus 줌 방지 (16px 미만이면 줌) */
  .team-hire-form input[type="text"] { font-size: 16px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 5.6 — Worker side panel (Sessions + Team 공유)
   ═══════════════════════════════════════════════════════════════════ */
.tw-worker-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 350px; max-width: 95vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.3);
  z-index: 70; overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}
.tw-worker-panel.open { transform: translateX(0); }
.tw-wp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-secondary); z-index: 1;
}
.tw-wp-id-pill {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: #000; padding: 4px 10px; border-radius: 12px;
}
.tw-wp-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 18px; cursor: pointer; padding: 0 4px;
}
.tw-wp-close:hover { color: var(--text-primary); }
.tw-wp-section {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.tw-wp-h { font-size: 11px; font-weight: 600; color: var(--text-faint); margin: 0 0 4px 0; text-transform: uppercase; letter-spacing: 0.05em; }
.tw-wp-row {
  display: flex; gap: 8px; font-size: 12px; align-items: baseline;
}
.tw-wp-k { color: var(--text-secondary); min-width: 80px; flex-shrink: 0; }
.tw-wp-v { color: var(--text-primary); flex: 1; word-break: break-word; }
.tw-wp-mono { font-family: var(--font-mono); font-size: 11px; }
/* 2026-05-03: 워커 패널 인라인 편집 (name/role/cwd/persistence/auto_resume/label_prefix) */
.tw-wp-editable {
  cursor: text;
  border-bottom: 1px dashed transparent;
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 3px;
  transition: background 0.12s, border-color 0.12s;
}
.tw-wp-editable:hover {
  background: var(--bg-hover, rgba(255,255,255,0.05));
  border-bottom-color: var(--accent, #7B68EE);
}
.tw-wp-editable[contenteditable="true"] {
  background: var(--bg-input, rgba(123,104,238,0.12));
  border-bottom-color: var(--accent, #7B68EE);
  outline: none;
}
.tw-wp-select {
  background: var(--bg-input, rgba(255,255,255,0.06));
  color: var(--text-primary);
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
}
.tw-wp-mini-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border, rgba(255,255,255,0.2));
  border-radius: 3px;
  padding: 1px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-left: 6px;
}
.tw-wp-mini-btn:hover { background: var(--bg-hover, rgba(255,255,255,0.08)); color: var(--text-primary); }
.tw-wp-edit-hint { font-size: 11px; opacity: 0.6; margin-left: 4px; }

/* ============================================================
 * 2026-05-03: 카드 SSOT (cards.js) — Sessions·Team 양 페이지 공유
 * SSOT: docs/2026-05-03-card-action-ssot.md §1
 * ============================================================ */

/* SessionCard(compact) — Team 워커 카드 안 미니 세션 */
.ctw-mini-session {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-surface, rgba(255,255,255,0.04));
  border-radius: 6px;
  border-left: 3px solid var(--accent, #7B68EE);
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
.ctw-mini-session:hover {
  background: var(--bg-hover, rgba(123,104,238,0.10));
  transform: translateX(1px);
}
.ctw-mini-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font-size: 11px;
}
.ctw-mini-head .status-badge {
  font-size: 10px; padding: 2px 6px;
}
.ctw-mini-title {
  flex: 1; color: var(--text-primary); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px;
}
.ctw-mini-meta {
  display: flex; gap: 8px; font-size: 10px; color: var(--text-secondary);
  margin-bottom: 3px;
}
.ctw-mini-meta .ctw-mini-project {
  color: var(--accent, #7B68EE); font-weight: 500;
  max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ctw-mini-meta .ctw-mini-sid { font-family: var(--font-mono, monospace); opacity: 0.7; }
.ctw-mini-meta .ctw-mini-age { opacity: 0.7; }
.ctw-mini-narrative {
  font-size: 10.5px; color: var(--text-secondary);
  margin-top: 4px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}
.ctw-mini-session .card-activity {
  margin-top: 4px; padding: 3px 6px; font-size: 10px;
}

/* Sessions 카드 영구/ad-hoc 시각 구분 — 좌측 컬러 바 + 워커 라벨 chip */
.card.card-kind-persistent { /* 좌측 부서색 (border-left inline 설정) */ }
.card.card-kind-adhoc { /* 좌측 회색 점선 (border-left inline 설정) */ }
.card-worker-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  margin-right: 6px;
  transition: opacity 0.12s, transform 0.08s;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.card-worker-chip:hover { opacity: 0.85; transform: translateY(-1px); }
.card-worker-chip.card-worker-adhoc {
  background: rgba(128,128,128,0.18) !important;
  color: var(--text-secondary) !important;
  font-style: italic; font-weight: 500;
  cursor: default;
}
.card-worker-chip.card-worker-adhoc:hover { transform: none; opacity: 1; }

/* Cross-page focus flash — Team↔Sessions 점프 도착 시 카드 강조 (1.5초) */
@keyframes ctw-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 104, 238, 0); }
  20%, 60% { box-shadow: 0 0 0 4px rgba(123, 104, 238, 0.6), 0 0 18px rgba(123, 104, 238, 0.4); }
}
.ctw-flash-highlight {
  animation: ctw-flash 2s ease-in-out;
  position: relative;
  z-index: 5;
}

/* worker_panel.js — Team 컨텍스트 nav 버튼 (실제 발사 X, Sessions 점프) */
.tw-wp-btn.nav {
  background: rgba(123, 104, 238, 0.12);
  color: var(--accent, #7B68EE);
  border: 1px dashed var(--accent, #7B68EE);
}
.tw-wp-btn.nav:hover {
  background: rgba(123, 104, 238, 0.22);
}
.tw-wp-action-hint {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(123, 104, 238, 0.08);
  border-left: 2px solid var(--accent, #7B68EE);
  font-size: 11px;
  color: var(--text-secondary);
  border-radius: 3px;
  line-height: 1.4;
}

/* ============================================================
 * Phase 3: 비정상 상태 시각 강조 (운영원칙 §7-P3)
 * ============================================================ */
@keyframes ctw-pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.5); }
}
@keyframes ctw-pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
  50% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.5); }
}
/* 2026-05-03 Phase 0: chat 동거 — 인라인 라이브 tail 박스 (200px) 가 chat 밑에 부착 */
.tw-inline-term-slot {
  width: 100%;
  display: block;
  margin-top: 8px;
}
/* 2026-05-03 v2: chat ↔ xterm 토글 모드 — 카드에 .card-view-term 붙으면 chat 가리고 터미널 큰 박스로 */
.card.card-view-term .card-body > .chat,
.card.card-view-term .card-body > .send-status-bar {
  display: none !important;
}
.card.card-view-term .card-body .tw-inline-term-slot {
  margin-top: 0;
}
.card.card-view-term .tw-live-overlay.tw-live-inline {
  height: 460px;
}
.tw-live-overlay.tw-live-inline {
  position: relative;
  inset: auto;
  background: transparent;
  display: block;
  width: 100%;
  height: 220px;
  padding: 0;
  z-index: auto;
}
.tw-live-overlay.tw-live-inline .tw-live-modal {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
}
.tw-live-overlay.tw-live-inline .tw-live-header {
  padding: 4px 10px;
  font-size: 11.5px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  flex: 0 0 auto;
  min-height: auto;
}
.tw-live-overlay.tw-live-inline .tw-live-header .tw-live-title {
  font-size: 11px;
  opacity: 0.8;
}
.tw-live-overlay.tw-live-inline .tw-live-input-btn,
.tw-live-overlay.tw-live-inline .tw-live-stop-btn {
  font-size: 10.5px;
  padding: 2px 6px;
}
.tw-live-overlay.tw-live-inline .tw-live-term-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 4px 0;   /* 2026-05-17: 패딩 축소 — 터미널 정보 밀도 ↑ */
  background: #0f0f0f;
  overflow: hidden;   /* 2026-05-17: xterm 캔버스가 박스 밖(프롬프트창)으로 안 번지게 클립 */
}
/* 2026-05-17: 인라인 터미널 박스를 자기 영역에 가둠 — 아래 프롬프트 입력창과 겹침 방지 */
.tw-live-overlay.tw-live-inline { overflow: hidden; }
.card.card-view-term .card-body { display: flex; flex-direction: column; gap: 8px; }
.tw-live-overlay.tw-live-inline .tw-live-term-wrap .xterm,
.tw-live-overlay.tw-live-inline .tw-live-term-wrap .xterm-viewport {
  height: 100% !important;   /* .xterm-screen 은 제외 — xterm 이 buffer 높이로 관리(스크롤 보존) */
}
/* 2026-05-17: 인라인 터미널 푸터 숨김 — 정보 노출 행 +1~2 (조합 A) */
.tw-live-overlay.tw-live-inline .tw-live-footer { display: none; }
/* 작은 "전체 보기" 버튼 — 헤더 우측에 자리잡음 (모달로 펼치기) */
.tw-live-expand-btn {
  background: transparent;
  color: #aaa;
  border: 1px solid #444;
  padding: 2px 7px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10.5px;
  margin-right: 4px;
}
.tw-live-expand-btn:hover { background: #2a2a2a; color: #fff; }

/* stuck (도구 5분 무응답) — 노란 깜빡 */
.status-badge[style*="245, 158, 11"],
.status-badge[style*="#f59e0b"] {
  animation: ctw-pulse-warn 1.6s ease-in-out infinite;
}
/* awaiting_input (사용자 입력 장기 대기) — 빨간 깜빡 */
.status-badge[style*="220, 38, 38"],
.status-badge[style*="#dc2626"] {
  animation: ctw-pulse-danger 2s ease-in-out infinite;
}
.tw-wp-team-chip {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px;
  vertical-align: middle;
}
.tw-wp-status.alive { color: var(--sage); }
.tw-wp-status.dormant { color: var(--text-faint); }
.tw-wp-events { display: flex; flex-direction: column; gap: 4px; }
.tw-wp-empty { font-size: 12px; color: var(--text-faint); padding: 4px; }
.tw-wp-event {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 0;
}
.tw-wp-event-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.tw-wp-event-title { flex: 1; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-wp-event-when { color: var(--text-faint); font-size: 11px; }
.tw-wp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tw-wp-btn {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--font-body); transition: background 0.12s ease;
}
.tw-wp-btn:hover { background: var(--border-warm); }
.tw-wp-btn.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.tw-wp-btn.primary:hover { background: var(--rust-soft); }
.tw-wp-btn.danger { background: transparent; color: var(--burgundy); border-color: var(--burgundy); }
.tw-wp-btn.danger:hover { background: rgba(239,68,68,0.08); }
.tw-wp-foot {
  padding: 12px 16px; text-align: center;
}
.tw-wp-cross {
  font-size: 12px; color: var(--accent); text-decoration: none;
}
.tw-wp-cross:hover { text-decoration: underline; }

/* 세션 터미널 모드 — 폭 확장 + 스크롤 없음 (xterm 이 fill) */
.tw-worker-panel.tw-mode-session {
  width: min(600px, 90vw);
  overflow-y: hidden;
}
.tw-panel-term-slot {
  height: calc(100vh - 56px); /* 헤더(tw-wp-head) 56px 제외 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* 슬롯 안의 xterm overlay/modal 은 절대 좌표 대신 fill */
.tw-panel-term-slot .tw-modal-overlay.tw-live-inline {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
}
.tw-panel-term-slot .tw-live-modal {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
}
.tw-panel-term-slot .tw-live-term-wrap {
  flex: 1;
  overflow: hidden;
}

/* Mobile: bottom-sheet style */
@media (max-width: 768px) {
  .tw-worker-panel {
    top: auto; right: 0; bottom: 0; left: 0; width: 100%;
    max-height: 80vh; border-left: none; border-top: 1px solid var(--border);
    border-top-left-radius: 12px; border-top-right-radius: 12px;
    transform: translateY(100%);
  }
  .tw-worker-panel.open { transform: translateY(0); }
  .tw-worker-panel.tw-mode-session { width: 100%; max-height: 90vh; overflow-y: hidden; }
  .tw-panel-term-slot { height: calc(90vh - 56px); }
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 5.6 — Sessions worker card team-color stripe + ID badge
   ═══════════════════════════════════════════════════════════════════ */
.worker-card {
  --worker-team-color: var(--text-faint);
  position: relative;
}
.worker-card[data-team-color] { --worker-team-color: attr(data-team-color); }
.worker-card.team-styled {
  border-left: 3px solid var(--worker-team-color) !important;
}
.worker-id-badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 8px;
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   Phase 5.6 — Generic toast stack (page-local fallback)
   ═══════════════════════════════════════════════════════════════════ */
#toast-stack.toast-stack {
  position: fixed; bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 6px; z-index: 80;
  pointer-events: none;
}
#toast-stack .toast {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12px; box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out both;
  pointer-events: auto;
}
#toast-stack .toast.ok { border-left-color: var(--sage); }
#toast-stack .toast.error { border-left-color: var(--burgundy); }
#toast-stack .toast.info { border-left-color: var(--accent-blue); }
#toast-stack .toast.out { animation: toast-out 0.4s ease-in both; }
@keyframes toast-in {
  from { transform: translateX(8px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(8px); opacity: 0; }

}

/* ═══════════════════════════════════════════════════════════════════
   PWA / Mobile hamburger nav  (pwa-nav.js companion styles)
   Desktop (>768px): hamburger hidden, normal header nav stays.
   Mobile (≤768px):  header nav hidden, hamburger + popout shown.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Hamburger button — hidden on desktop ───────────────────────── */
#pwa-nav-btn {
  display: none;
}

/* ── Popout menu — hidden on desktop ───────────────────────────── */
#pwa-nav-menu {
  display: none;
}

@media (max-width: 768px) {
  /* Hide the horizontal nav inside .dash-header */
  header.dash-header > nav,
  .dash-header > nav {
    display: none !important;
  }

  /* ── Hamburger button ── */
  #pwa-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 6px);
    left: 8px;
    z-index: 200;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(30, 30, 30, 0.55);
    color: #d0d0d0;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 0;
  }
  #pwa-nav-btn:active {
    background: rgba(50, 50, 50, 0.75);
  }

  /* ── Popout nav menu ── */
  #pwa-nav-menu {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 6px);
    left: 8px;
    z-index: 199;
    min-width: 160px;
    background: rgba(22, 22, 28, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    padding: 6px 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
  }
  #pwa-nav-menu.pwa-nav-open {
    transform: translateY(44px); /* drop below the button */
    opacity: 1;
    pointer-events: auto;
  }
  #pwa-nav-menu a {
    display: block;
    padding: 11px 18px;
    min-height: 44px;
    box-sizing: border-box;
    color: #c9d1d9;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
    border-left: 3px solid transparent;
  }
  #pwa-nav-menu a:hover,
  #pwa-nav-menu a:focus {
    background: rgba(255, 255, 255, 0.06);
    color: #e6e6e6;
    outline: none;
  }
  #pwa-nav-menu a.pwa-nav-active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(126, 231, 135, 0.08);
  }
}

/* ── Phase F: Analytics 5-Section Headers ── */
.an-section {
  margin-bottom: 30px;
  padding-top: 8px;
}
.an-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid #1f2937;
}
.an-section-icon {
  font-size: 22px;
  line-height: 1;
}
.an-section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: #e1e7ef;
}
.an-section-desc {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
}
@media (prefers-color-scheme: light), [data-theme="light"] {
  .an-section-title { color: #1f2937; }
  .an-section-head { border-bottom-color: #e5e7eb; }
}

/* ═══════════════════════════════════════════════════════════════════
   PWA / 모바일 통합 미세조정 (2026-05-25 사이클 28)
   - 적용 대상: index.html / team.html / analytics.html / world.html /
     board.html / org.html / gate.html / login.html (session-t.html 제외)
   - docs.html 은 자체 인라인 모바일 블록 보유 (별도 작업)
   - 전역 text-size-adjust:100% 는 html,body 룰 (L96) 에서 처리
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* 공용 헤더 — 작은 폰에서 chip wrap + 폰트 축소 */
  .dash-stats { gap: 4px !important; flex-wrap: wrap !important; row-gap: 4px !important; }
  .dash-stat-group-title { font-size: 9px !important; }
  .ds-chip { font-size: 10px !important; padding: 2px 6px !important; }
  .ds-chip strong { font-size: 11px !important; }

  /* 페이지 툴바 (index.html / team.html / workflow) — 가로 wrap */
  .page-toolbar { flex-wrap: wrap !important; gap: 6px !important; padding: 8px !important; }
  .page-toolbar .search-input,
  .page-toolbar input[type="text"] { min-width: 0 !important; flex: 1 1 100% !important; font-size: 13px !important; }
  .page-toolbar select,
  .page-toolbar .report-btn,
  .page-toolbar .new-session-btn,
  .page-toolbar .cleanup-btn { font-size: 11.5px !important; padding: 4px 8px !important; }
  .page-actions { flex-wrap: wrap !important; gap: 4px !important; }

  /* KPI 바 — 모바일에서 1열 스택 */
  .kpi-bar .kpi-expanded { flex-wrap: wrap !important; gap: 6px !important; }
  .kpi-card { min-width: calc(50% - 4px) !important; padding: 8px !important; }
  .kpi-card-title { font-size: 10px !important; }
  .kpi-sum-text { font-size: 11px !important; }

  /* 영구 워커 그리드 */
  .workers-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important; }
  .workers-title { font-size: 12px !important; }

  /* Activity Stream 패널 */
  .activity-search-row { flex-wrap: wrap !important; gap: 4px !important; }
  .activity-search-row select,
  .activity-search-row input { font-size: 11px !important; flex: 1 1 auto !important; }
  .activity-filter-types { gap: 6px !important; font-size: 11px !important; }

  /* analytics: select 인라인 폰트 강제 축소 */
  .an-card-head select { font-size: 10.5px !important; padding: 1px 4px !important; }
  .an-card-head { font-size: 12px !important; }
  .an-section-title { font-size: 16px !important; }
  .an-section-desc { font-size: 11px !important; }

  /* analytics: 차트 캔버스 — 가로 풀폭 + 높이 축소 */
  .an-card canvas { max-height: 200px !important; }
  .an-card-wide canvas { max-height: 240px !important; }
  .an-table-wrap { overflow-x: auto !important; font-size: 11px !important; }
  .an-modal { max-width: 95vw !important; max-height: 90vh !important; }

  /* board / org — 본문 패딩 축소 */
  body { font-size: 13px; }
}

/* PWA standalone (홈화면 실행) — 작은 폰에서 더 촘촘하게 */
@media all and (display-mode: standalone) and (max-width: 768px) {
  .page-toolbar { padding: 6px 8px !important; }
  .an-page { padding: 8px 6px !important; }
  body { font-size: 12.5px; }
}

/* Session(T) 메뉴 — PWA 전용 (브라우저에서는 숨김, 홈화면 실행 시만 표시).
   2026-05-27: 데스크탑 nav 의 /session-t 링크는 PWA standalone 모드에서만 노출.
   햄버거 nav (pwa-nav.js) 의 동일 항목은 영향 없음. */
.dash-header nav a[href="/session-t"] { display: none !important; }
@media all and (display-mode: standalone) {
  .dash-header nav a[href="/session-t"] { display: inline-flex !important; }
}
