/* VibeCrew app.css 분해 (보비·2026-05-30·비비 R3). cascade 순서 보존·shell→views */

/* ================================================================
   VibeCrew Dashboard — app.css v2
   디자인 토큰: design_tokens.css (--vc-* 변수)
   ================================================================ */

/* ==== Reset & Base ==== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow-x: hidden; }
body {
  background: var(--vc-bg);
  color: var(--vc-text);
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Pretendard',
               'Apple SD Gothic Neo', 'Segoe UI', sans-serif;
  font-size: var(--vc-fs-md);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
::selection { background: var(--vc-blue-20); color: var(--vc-text); }
:focus-visible { outline: 2px solid var(--vc-blue); outline-offset: 2px; border-radius: var(--vc-r-1); }
button, [role="button"], input, textarea, select { font-family: inherit; }
#app { min-width: 0; max-width: 100vw; overflow-x: hidden; }

/* ==== Scrollbar ==== */
* { scrollbar-width: thin; scrollbar-color: var(--vc-white-08) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--vc-white-05); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--vc-white-18); }

/* ==== Header ==== */
header {
  height: 56px;
  padding: 0 20px;
  background: var(--vc-bg);
  border-bottom: 1px solid var(--vc-line);
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: visible;
}
h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0; cursor: pointer; color: var(--vc-text); }
.logo { font-weight: 700; font-size: 16px; letter-spacing: 0; flex-shrink: 0; }
/* 로고 마크 — 30px 정사각형 그라디언트 버튼 (헤더에서 .logo-mark 사용) */
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--vc-blue), var(--vc-purple));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; color: var(--vc-on-accent); cursor: pointer;
  box-shadow: 0 2px 8px var(--vc-blue-30);
  transition: opacity var(--vc-fast);
}
.logo-mark:hover { opacity: 0.85; }
/* usage 뱃지 (헤더 우측) */
.usage-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--vc-r-pill);
  background: var(--vc-amber-10);
  border: 1px solid var(--vc-amber-25);
  color: var(--vc-amber-2);
  font-size: var(--vc-fs-xs); font-weight: 600;
  cursor: pointer;
  transition: background var(--vc-fast);
}
.usage-badge:hover { background: var(--vc-amber-15); }

/* header 안의 project-tabs: Rail 생긴 후 헤더에선 숨김 */
header .project-tabs { display: none; }

/* header spacer */
header .header-spacer { flex: 1; }

/* header-actions */
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: nowrap; overflow: hidden; }

/* ==== Mobile hamburger ==== */
.mobile-only { display: none; }
.nav-toggle {
  width: var(--vc-touch); height: var(--vc-touch);
  display: none; align-items: center; justify-content: center;
  background: none; border: none; color: var(--vc-text); cursor: pointer; padding: 0;
}
.nav-toggle svg { width: 22px; height: 22px; }

/* ==== Layout: 3-pane (rail + list + main) ==== */
.layout {
  display: grid;
  grid-template-columns: 60px 280px 1fr;
  height: calc(100svh - 52px);
  min-width: 0;
  max-width: 100vw;
  overflow: hidden;
}

/* ==== Rail (좌측 아이콘 바) ==== */
.rail {
  background: var(--vc-bg-2);
  border-right: 1px solid var(--vc-line);
  padding: 12px 8px;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.rail-item {
  width: 40px; height: 40px; border-radius: var(--vc-r-3);
  display: flex; align-items: center; justify-content: center;
  color: var(--vc-text-2); cursor: pointer;
  border: 1px solid transparent;
  font-weight: 700; font-size: 13px;
  transition: all var(--vc-fast);
  background: none;
}
.rail-item:hover { background: var(--vc-surface); }
.rail-item.active {
  background: var(--vc-blue-10);
  border-color: var(--vc-blue-35);
  color: var(--vc-blue-2);
}
.rail-item.bibi {
  background: linear-gradient(135deg, var(--vc-purple-10), var(--vc-blue-10));
  border-color: var(--vc-purple-30);
}

/* ==== 워커 리스트 패널 ==== */
.list {
  background: var(--vc-bg-2);
  border-right: 1px solid var(--vc-line);
  overflow-y: auto;
  padding: 12px;
  min-width: 0;
}
.list h2 {
  font-size: 15px; font-weight: 700; letter-spacing: 0;
  margin: 4px 4px 12px; color: var(--vc-text);
}
.list-backdrop { display: none; }

/* ==== Item (워커 카드 · 워커 행) ==== */
.item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--vc-r-4);
  cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all var(--vc-fast);
  position: relative;
}
.item:hover:not(.disabled) { background: var(--vc-surface); border-color: var(--vc-line-2); }
.item:focus-visible { outline-offset: 0; }
.item.disabled { cursor: not-allowed; opacity: 0.55; }
.item.active {
  background: var(--vc-blue-10);
  border-color: var(--vc-blue-35);
}
.item.busy {
  border-color: var(--vc-amber-35);
}
.item.busy.active {
  background: var(--vc-blue-10);
  border-color: var(--vc-amber-45);
}
.item.busy .dot {
  background: var(--vc-amber);
  box-shadow: 0 0 0 2px var(--vc-amber-30);
  animation: dot-pulse 1.8s ease-in-out infinite;
}
.item.unread:not(.busy) {
  border-color: var(--vc-blue-40);
}
.item.supervisor {
  background: linear-gradient(180deg, var(--vc-blue-10) 0%, var(--vc-blue-04) 100%);
  border-color: var(--vc-blue-30);
}
.item.supervisor.active { background: var(--vc-blue-20); }
.item.supervisor.busy,
.item.supervisor.busy.active {
  border-color: var(--vc-amber-35);
}
.item.supervisor.busy { background: linear-gradient(180deg, var(--vc-blue-10) 0%, var(--vc-blue-04) 100%); }
.item.supervisor.busy.active {
  background: var(--vc-blue-20);
  border-color: var(--vc-amber-45);
}
.item-content { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: var(--vc-fs-md); padding-right: 20px; color: var(--vc-text); }
.item .subname { font-size: var(--vc-fs-xs); color: var(--vc-muted); margin-top: 1px; font-family: var(--vc-mono); }
.item .name .placeholder { color: var(--vc-muted); font-weight: 500; font-style: italic; }
.item .name .warn-icon { color: var(--vc-red); margin-right: 2px; }
.item .role { font-size: var(--vc-fs-xs); color: var(--vc-text-2); margin: 4px 0 6px; line-height: 1.35; }
.item .meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--vc-fs-xs); }
.item .meta .activity-time { color: var(--vc-muted); font-size: var(--vc-fs-xs); }
.item .seq {
  display: inline-block; min-width: 22px; padding: 1px 5px; margin-right: 5px;
  background: var(--vc-white-07); border-radius: var(--vc-r-1);
  font-size: var(--vc-fs-xs); font-weight: 600; color: var(--vc-muted);
  font-family: var(--vc-mono); vertical-align: middle;
}
.item.supervisor .seq { background: var(--vc-blue-20); color: var(--vc-blue-2); }
.sup-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: var(--vc-r-pill); background: var(--vc-blue-20); color: var(--vc-blue-2);
  font-size: 9px; font-weight: 600; vertical-align: middle;
}
.autonomy-badge {
  display: inline-block; margin-left: 4px; padding: 1px 5px;
  border-radius: var(--vc-r-pill); background: var(--vc-white-06); color: var(--vc-muted);
  border: 1px solid var(--vc-line-2); font-size: 9px; font-weight: 700;
  font-family: var(--vc-mono); vertical-align: middle; letter-spacing: 0.03em;
}
.autonomy-badge.l3 { background: var(--vc-red-10); color: var(--vc-red-2); border-color: var(--vc-red-10); }
.autonomy-badge.l0 { background: var(--vc-amber-10); color: var(--vc-amber); border-color: var(--vc-amber-15); }
.kpi-badge {
  display: inline-block; margin-left: 4px; padding: 1px 5px;
  border-radius: var(--vc-r-pill); background: var(--vc-green-10); color: var(--vc-green);
  border: 1px solid var(--vc-green-15); font-size: 9px; font-weight: 700;
  font-family: var(--vc-mono); vertical-align: middle;
}
.runner-badge {
  display: inline-block; margin-left: 4px; padding: 1px 6px;
  border-radius: var(--vc-r-pill); background: var(--vc-white-055); color: var(--vc-muted);
  border: 1px solid var(--vc-line-2); font-size: 9px; font-weight: 700;
  vertical-align: middle;
}
.runner-badge.codex { background: var(--vc-blue-20); color: var(--vc-blue-2); border-color: var(--vc-blue-28); }
.op-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--vc-s-1);
  margin-left: var(--vc-s-1);
  padding: 0 var(--vc-s-2);
  border-radius: var(--vc-r-pill);
  border: 1px solid var(--vc-line-2);
  background: var(--vc-white-04);
  color: var(--vc-muted);
  font-size: var(--vc-fs-xs);
  font-weight: 700;
  vertical-align: middle;
  white-space: nowrap;
}
.op-status-dot {
  width: var(--vc-s-2);
  height: var(--vc-s-2);
  border-radius: var(--vc-r-pill);
  background: currentColor;
  flex-shrink: 0;
}
.op-status-badge.status-active,
.oh-health-kpi.status-active,
.oh-health-row.status-active {
  color: var(--vc-green-2);
  border-color: var(--vc-green-22);
  background: var(--vc-green-10);
}
.op-status-badge.status-idle,
.oh-health-kpi.status-idle,
.oh-health-row.status-idle {
  color: var(--vc-text-2);
  border-color: var(--vc-line-2);
  background: var(--vc-white-04);
}
.op-status-badge.status-stale,
.oh-health-kpi.status-stale,
.oh-health-row.status-stale {
  color: var(--vc-amber-2);
  border-color: var(--vc-amber-28);
  background: var(--vc-amber-10);
}
.op-status-badge.status-error,
.op-status-badge.status-ghost,
.oh-health-row.status-error,
.oh-health-row.status-ghost {
  color: var(--vc-red-2);
  border-color: var(--vc-red-30);
  background: var(--vc-red-10);
}
.op-status-badge.status-config_issue,
.oh-health-row.status-config_issue {
  color: var(--vc-purple-2);
  border-color: var(--vc-purple-30);
  background: var(--vc-purple-10);
}
.op-status-badge.status-deferred,
.oh-health-kpi.status-deferred,
.oh-health-row.status-deferred {
  color: var(--vc-blue-2);
  border-color: var(--vc-blue-30);
  background: var(--vc-blue-10);
}

/* ==== Avatar ==== */
.avatar {
  display: inline-block; width: 38px; height: 38px; border-radius: 50%;
  background-size: cover; background-position: center; vertical-align: middle; flex-shrink: 0;
}
.avatar.fallback {
  background: var(--vc-avatar-fallback); color: var(--vc-text-2);
  font-weight: 700; font-size: var(--vc-fs-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
/* seed 기반 그라디언트 아바타 — JS에서 style 인라인 적용 */
.avatar.fallback[data-seed] { background: var(--avatar-grad, var(--vc-avatar-fallback)); }
.avatar.sm { width: 24px; height: 24px; font-size: var(--vc-fs-xs); }
.avatar.lg { width: 48px; height: 48px; }
.avatar.xl { width: 72px; height: 72px; font-size: 18px; cursor: pointer; transition: box-shadow var(--vc-fast); }
.avatar.xl:hover { box-shadow: 0 0 0 2px var(--vc-blue); }

/* ==== Dot (상태 인디케이터) ==== */
.dot {
  position: absolute; top: 12px; right: 12px;
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--vc-green);
  box-shadow: 0 0 0 2px var(--vc-green-25);
}
.dot.idle { background: var(--vc-muted); box-shadow: none; }
.dot.busy {
  background: var(--vc-amber);
  box-shadow: 0 0 0 2px var(--vc-amber-30);
  animation: dot-pulse 1.8s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--vc-amber-30); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* ==== Tags / Badges ==== */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--vc-r-pill);
  font-size: var(--vc-fs-xs); font-weight: 600;
}
.tag.cron { background: var(--vc-green-10); color: var(--vc-green-2); border: 1px solid var(--vc-green-22); }
/* on-demand 뱃지 — 소형 칩 */
.tag.ondemand {
  background: var(--vc-white-05);
  color: var(--vc-muted);
  border: 1px solid var(--vc-line-2);
  font-size: 10px; padding: 1px 7px;
}
.stale-warn { color: var(--vc-amber); font-size: var(--vc-fs-xs); margin-left: 6px; }
.health-bar { display: inline-flex; gap: 2px; margin-left: 6px; }
.health-bar span { width: 6px; height: 8px; border-radius: 1px; background: var(--vc-white-10); }
.health-bar span.ok { background: var(--vc-green); }
.health-bar span.fail { background: var(--vc-red); }

/* ==== Badge (상태 배지) ==== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--vc-r-pill);
  font-size: var(--vc-fs-xs); font-weight: 600;
}
.badge-green { background: var(--vc-green-10); color: var(--vc-green-2); }
.badge-blue { background: var(--vc-blue-10); color: var(--vc-blue-2); }
.badge-amber { background: var(--vc-amber-10); color: var(--vc-amber-2); }
.badge-red { background: var(--vc-red-10); color: var(--vc-red-2); }

/* ==== Tabs (상단 탭) ==== */
.detail-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--vc-line);
  background: var(--vc-bg);
  min-height: 48px;
  min-width: 0;
  overflow: hidden;
}
.tabs {
  display: flex; align-items: center; gap: 2px; flex: 1 1 auto;
  min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.detail-actions {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.detail-actions::-webkit-scrollbar { display: none; }
.tab {
  min-height: 48px; padding: 0 14px; font-size: var(--vc-fs-sm); font-weight: 600;
  color: var(--vc-muted); border-bottom: 2px solid transparent;
  cursor: pointer; transition: all var(--vc-fast);
  background: none; border-top: none; border-left: none; border-right: none;
  white-space: nowrap;
}
.tab:hover { color: var(--vc-text-2); }
.tab.active { color: var(--vc-text); border-bottom-color: var(--vc-blue); }
.detail-action-btn {
  min-height: 32px; padding: 6px 11px;
  border: 1px solid var(--vc-line-2); border-radius: var(--vc-r-3);
  background: var(--vc-white-04); color: var(--vc-text-2);
  font-size: var(--vc-fs-xs); font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: background var(--vc-fast), color var(--vc-fast), border-color var(--vc-fast);
}
.detail-action-btn:hover { background: var(--vc-blue-10); color: var(--vc-text); border-color: var(--vc-blue-30); }
.worker-state-chip {
  min-height: 28px; padding: 4px 10px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--vc-line-2); border-radius: var(--vc-r-pill);
  color: var(--vc-muted); background: var(--vc-white-025);
  font-size: var(--vc-fs-xs); white-space: nowrap;
}
.worker-state-chip.warn { color: var(--vc-amber-2); border-color: var(--vc-amber-28); background: var(--vc-amber-10); }
.worker-state-dot {
  width: 7px; height: 7px; border-radius: var(--vc-r-pill);
  background: var(--vc-red); flex-shrink: 0;
}
.worker-state-dot.on { background: var(--vc-green); }
.worker-state-dot.off { background: var(--vc-red); }
.detail-menu-wrap { position: relative; flex-shrink: 0; }

/* ==== Project Tabs ==== */
.project-tabs {
  display: flex; gap: 4px; padding: 10px 20px;
  border-bottom: 1px solid var(--vc-line); flex-wrap: wrap;
  background: var(--vc-bg);
}
.project-tab {
  padding: 6px 12px; border-radius: var(--vc-r-3);
  font-size: var(--vc-fs-sm); cursor: pointer;
  color: var(--vc-muted); border: 1px solid transparent;
  background: none; transition: all var(--vc-fast);
}
.project-tab.active {
  background: var(--vc-blue-10); color: var(--vc-text);
  border-color: var(--vc-blue-40);
}
.project-tab:hover { background: var(--vc-white-04); color: var(--vc-text-2); }
.project-tab.add { color: var(--vc-green-2); border-style: dashed; border-color: var(--vc-green-30); }

/* ==== Buttons (통합) ==== */
.btn {
  padding: 8px 16px; border-radius: var(--vc-r-3); font-size: var(--vc-fs-sm);
  font-weight: 600; cursor: pointer; border: 1px solid var(--vc-line-2);
  background: var(--vc-white-04); color: var(--vc-text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--vc-fast); min-height: var(--vc-touch);
}
.btn:hover:not(:disabled) { background: var(--vc-white-08); color: var(--vc-text); border-color: var(--vc-line-3); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--vc-blue), var(--vc-blue-h));
  border-color: var(--vc-blue-50); color: var(--vc-on-accent);
  box-shadow: 0 4px 12px var(--vc-blue-30);
}
.btn.primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--vc-blue), var(--vc-blue-h));
  border-color: var(--vc-blue-50); color: var(--vc-on-accent);
  box-shadow: 0 4px 12px var(--vc-blue-30);
}
.btn.danger { background: transparent; border-color: var(--vc-red-40); color: var(--vc-red-2); }
.btn.danger:hover:not(:disabled) { background: var(--vc-red-10); border-color: var(--vc-red); }
.btn.sm { padding: 4px 10px; min-height: 32px; font-size: var(--vc-fs-xs); }
.btn.icon { width: var(--vc-touch); height: var(--vc-touch); padding: 0; }
.btn.icon.sm { width: 32px; height: 32px; }
.btn.ghost { background: none; border-color: transparent; color: var(--vc-text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--vc-white-05); color: var(--vc-text); }
.btn-ghost {
  background: var(--vc-white-04); border: 1px solid var(--vc-line-2); color: var(--vc-text-2);
  padding: 8px 16px; border-radius: var(--vc-r-3); font-size: var(--vc-fs-sm);
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--vc-fast);
}
.btn-ghost:hover { background: var(--vc-white-08); color: var(--vc-text); }
.btn-menu {
  width: 32px; height: 32px; padding: 0;
  background: none; border: 1px solid var(--vc-line-2); color: var(--vc-muted);
  border-radius: var(--vc-r-3); cursor: pointer; font-size: 14px; line-height: 1;
  transition: all var(--vc-fast); display: inline-flex; align-items: center; justify-content: center;
}
.btn-menu:hover { color: var(--vc-text); border-color: var(--vc-blue); }
.send-btn {
  width: 36px; height: 36px; border-radius: var(--vc-r-3); border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--vc-blue), var(--vc-purple));
  color: var(--vc-on-accent); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity var(--vc-fast);
}
.send-btn:disabled { opacity: 0.4; }

/* ==== Menu Popup ==== */
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--vc-surface);
  border: 1px solid var(--vc-line-2);
  border-radius: var(--vc-r-4);
  box-shadow: var(--vc-elev-2);
  min-width: 200px; padding: 4px; z-index: 100;
}
.menu-item {
  display: block; width: 100%; padding: 8px 12px;
  background: none; border: none; color: var(--vc-text);
  text-align: left; cursor: pointer; font-size: var(--vc-fs-sm);
  border-radius: var(--vc-r-2); min-height: 36px;
}
.menu-item:hover:not(:disabled) { background: var(--vc-blue-10); color: var(--vc-text); }
.menu-item:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-item.danger { color: var(--vc-red-2); }
.menu-item.danger:hover { background: var(--vc-red-10); color: var(--vc-red-2); }

/* ==== Crop ==== */
.crop-area {
  width: 260px; height: 260px; margin: 0 auto;
  border-radius: var(--vc-r-pill); overflow: hidden; position: relative;
  background: var(--vc-ink); cursor: grab; user-select: none;
  border: 2px solid var(--vc-line-2);
}
.crop-area:active { cursor: grabbing; }
.crop-area img {
  position: absolute; top: 50%; left: 50%;
  transform-origin: center; will-change: transform;
  pointer-events: none; max-width: none;
}
.crop-zoom { width: 100%; margin-top: 16px; }

/* ==== Detail (메인 패널) ==== */
.detail {
  display: flex; flex-direction: column;
  background: var(--vc-bg);
  height: 100%; overflow: hidden; min-width: 0;
}

/* ==== Mobile Tab Bar ==== */
.mobile-tabbar {
  display: none;
}
