/* Left Panel */
.left-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--left-width);
    /* 100vh fallback, 100dvh 는 iOS Safari 주소창 펼침/접힘 시 자동 보정 */
    height: 100vh;
    height: 100dvh;
    background: var(--left-bg);
    border-right: 1px solid var(--left-border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform var(--transition);
}

.left-panel.active {
    transform: translateX(0);
}

@media (min-width: 768px) {
    .left-panel {
        transform: translateX(0);
    }
}

.left-header {
    display: flex;
    align-items: center;
    justify-content: center;       /* 로고 가운데 정렬 (close btn 은 absolute 로 분리) */
    position: relative;
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
    height: 3rem;
}

.logo-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.025em;
    text-align: center;
    flex: 1;
}

.logo-text:hover {
    text-decoration: none;
    color: var(--color-text);
}

.close-left-panel {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all var(--transition);
    /* 로고를 가운데로 보내기 위해 close btn 은 absolute 로 빼냄 (모바일에서만 보임) */
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.close-left-panel:hover {
    background: var(--left-hover);
    color: var(--color-text);
}

@media (max-width: 767px) {
    .close-left-panel {
        display: flex;
    }

    /* 모바일에서 닫힌(슬라이드아웃) 패널은 비상호작용 — 화면 밖이라 평소엔
       무해하지만 transition 중·상태 꼬임 시 탭 가로채기를 막는 안전망.
       데스크탑(≥768px)은 .active 없이도 항상 보이므로 이 가드를 적용하지 않음. */
    .left-panel:not(.active) {
        pointer-events: none;
    }
}

/* Tabs (Chat / Studio) */
.left-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    margin-bottom: 1rem;
    background: var(--color-bg-tertiary, #f1f5f9);
    border-radius: 0.375rem;
    flex-shrink: 0;
}

.left-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.25;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    text-align: center;
    text-decoration: none;
}

.left-tab svg {
    flex-shrink: 0;
    display: block;
}

.left-tab-icon-toolbox {
    transform: translateY(1px);
}

.left-tab span {
    display: inline-block;
    line-height: 1;
}

.left-tab:hover {
    color: var(--color-text);
    text-decoration: none;
}

.left-tab.active {
    background: var(--color-bg, #ffffff);
    color: var(--color-text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Menu */
.menu-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    overflow-y: auto;
    min-height: 0;
}

/* Tab panes — only the active pane is visible */
.left-tab-pane {
    display: none;
    flex-direction: column;
    gap: 0.125rem;
}

.menu-list[data-active="chat"] .left-tab-pane[data-pane="chat"],
.menu-list[data-active="studio"] .left-tab-pane[data-pane="studio"],
.menu-list[data-active="settings"] .left-tab-pane[data-pane="settings"] {
    display: flex;
}


.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--left-hover);
    color: var(--color-text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--slate-800);
    color: white;
}

.nav-item.active:hover {
    background: var(--slate-700);
}

.nav-item svg {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    color: var(--color-text-secondary);
    transition: color var(--transition);
}

.nav-item:hover svg { color: var(--color-text); }
.nav-item.active svg { color: white; }

/* 메인(지식) — 클러스터와 대비를 키우려 한 단계 더 진한 톤 + 굵게.
   (새 채팅은 이미 solid pill 강조라 손대지 않음. 클러스터는 AA 하한이라 더 못 흐리므로 메인을 올려 격차 확보.) */
.nav-item--pillar { color: var(--color-text); font-weight: 600; }
.nav-item--pillar svg { color: var(--color-text); }

/* 마켓 클러스터(뉴스/주식/성장/지표/RSI/내 피드백) — 지식 아래 옅은 톤으로 묶는다.
   들여쓰기·헤더 없이 색만 한 단계 더 죽여(secondary→muted) 메인(채팅/지식)과 위계를 만든다.
   '비활성'으로 오독되지 않게 hover/active 시 정상 톤으로 복귀. */
.nav-item--muted { color: var(--color-text-muted); font-weight: 500; }
.nav-item--muted svg { color: var(--color-text-muted); }
.nav-item--muted:hover { color: var(--color-text); }
.nav-item--muted:hover svg { color: var(--color-text); }
.nav-item--muted.active { color: white; }
.nav-item--muted.active svg { color: white; }

/* 지식 ↔ 마켓 클러스터 사이 여백 — 들여쓰기/구분선 없이 근접성(gap)만으로 '한 묶음' 신호. */
.nav-cluster-top { margin-top: 0.5rem; }

/* Sub-menu tree */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-children {
    display: none;
    flex-direction: column;
    padding-left: 1rem;
    gap: 0.125rem;
}

.nav-group.expanded > .nav-children {
    display: flex;
}

.nav-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    transition: all var(--transition);
}

.nav-arrow:hover {
    color: var(--color-text);
    background: var(--left-hover);
}

.nav-child {
    padding-left: 0.5rem;
}

/* New Chat */
.nav-new-chat {
    color: var(--color-primary);
    font-weight: 600;
}

.nav-new-chat svg {
    color: var(--color-primary);
}

.nav-new-chat:not(.active):hover {
    background: var(--color-bg-tertiary);
    color: var(--color-primary-hover);
}

.nav-new-chat:not(.active):hover svg {
    color: var(--color-primary-hover);
}

/* Separator */
.nav-separator {
    border-top: 1px solid var(--color-border);
    margin: 0.875rem 0;
}

/* Section title */
.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 0.5rem 0.75rem 0.25rem;
    flex-shrink: 0;
}

/* 두 section (favorites → recent) 사이 시각 분리 — chat-list 다음에 오는
   section-title 은 위쪽 간격을 더 주고 살짝의 디바이더 라인으로 그룹 경계 강조.
   다만 즐겨찾기가 0개여서 chatSectionSeparator 가 이미 그룹 경계 라인을 그리는
   경우엔 라인이 두 개 가까이 붙어 보이는 중복 문제가 생기므로, left.js 가
   recentChatsTitle 에 `.no-fav-divider` 를 달 때 이 룰을 끈다. */
.chat-list + .nav-section-title {
    margin-top: 0.625rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border, #e2e8f0);
}
.chat-list + .nav-section-title.no-fav-divider {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.nav-section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* 메인의 "전체 뉴스 보기 →"(.home-news-summary-link)와 동일한 스타일 — 그게 기준.
   단, 크기만 좌측 메뉴 기존 크기(0.6875rem) 유지. */
.nav-section-action {
    font-size: 0.6875rem;
    color: var(--color-primary, #2563eb);
    text-decoration: none;
}

.nav-section-action:hover { text-decoration: underline; }

/* Chat list */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.chat-list-item {
    position: relative; /* 호버 케밥(.chat-list-kebab) absolute 기준 */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* 우측 padding 최소화 — 제목이 최대한 길게 표시되도록. 호버 시 노출되는
       케밥은 absolute 라 레이아웃 폭을 먹지 않고 제목 위에 떠 있다. */
    padding: 0.375rem 0.25rem 0.375rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: all var(--transition);
    cursor: pointer;
}

.chat-list-item:hover {
    background: var(--left-hover);
    color: var(--color-text);
    text-decoration: none;
}

.chat-list-item.active {
    background: var(--left-active);
    color: var(--color-text);
}

.chat-list-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 케밥(삼점) 메뉴 — 평소 숨김, 행 호버(또는 메뉴 열림) 시 우측끝에 노출.
   왼쪽 ~3글자 폭을 transparent→행 배경(--left-hover) 그라데이션으로 덮어
   제목 끝과 겹쳐도 삼점이 또렷하게 보이도록. absolute 라 제목 폭은 안 먹음. */
.chat-list-kebab {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 0; /* stacking context — ::before(z-index:-1) 를 점 뒤·제목 위에 가둠 */
    display: none;
    align-items: center;
    justify-content: center;
    /* 실제 클릭 영역은 점 주변(우측)만. 넓은 좌측 그라데이션은 ::before 로 그려
       pointer-events:none 으로 클릭이 행(<a>)에 통과되게 한다 — 흐린 영역 클릭=채팅 이동. */
    padding: 0 0.5rem;
    border: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    background: none;
}
/* 넓은 좌측 그라데이션 — 시각 효과만, 클릭은 통과(pointer-events:none).
   opacity 는 점(svg)에만 걸어 제목 호버/삼점 호버 양쪽에서 글자 가려짐이 동일.
   세점에 가까운 우측은 완전 불투명(3.5rem 부터), 왼쪽 0~3.5rem 만 페이드. */
.chat-list-kebab::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 5.5rem;
    z-index: -1;
    pointer-events: none;
    border-radius: 0 0.375rem 0.375rem 0;
    background: linear-gradient(to right, transparent, var(--left-hover) 3.5rem);
}
.chat-list-item:hover .chat-list-kebab,
.chat-list-item.menu-open .chat-list-kebab {
    display: flex;
}
/* 메뉴가 열린 동안은 마우스가 행을 벗어나도 행·케밥 하이라이트 유지 */
.chat-list-item.menu-open {
    background: var(--left-hover);
    color: var(--color-text);
}
.chat-list-kebab:hover { color: var(--color-text); }
.chat-list-kebab svg { width: 13px; height: 13px; display: block; opacity: 0.6; }
.chat-list-kebab:hover svg { opacity: 1; }

/* 익명 사용자에게 보이는 sample chat — 실제 데이터 없음 표시용 살짝 dim */
.chat-list-item-sample { opacity: 0.78; }
.chat-list-item-sample:hover { opacity: 1; }

/* 진행 중 채팅 — 항목 좌측에 작은 펄스 dot. chat.js setStreamingState 가 토글. */
.chat-list-item-streaming {
    position: relative;
    padding-left: 1.25rem;
}
.chat-list-item-streaming::before {
    content: "";
    position: absolute;
    left: 0.45rem;
    top: 50%;
    width: 0.5rem;
    height: 0.5rem;
    margin-top: -0.25rem;
    border-radius: 50%;
    background: #22c55e; /* emerald-500 */
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    animation: chat-streaming-pulse 1.4s ease-out infinite;
}
@keyframes chat-streaming-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
    70%  { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);    }
    100% { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0);    }
}

/* ── Profile chip (사이드바 하단 sticky footer) ───────────────────────────
   .menu-list { flex:1 } 이 위쪽 공간 모두 흡수하므로 chip 은 자연히 바닥에 위치.
   iOS Safari 하단 bar 가림 대응: padding-bottom 에 env(safe-area-inset-bottom)
   를 더해 chip 이 항상 안전 영역 위로 떠 있음. 데스크탑·안드로이드는 env() = 0px 이라 영향 없음.
   .left-panel 의 1rem 좌우 padding 을 상쇄하려고 chip 자체 음수 margin 사용 → 풀폭 행. */
.left-profile-chip {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0.75rem -1rem 0;            /* 위쪽 여유 + 좌우 padding 상쇄 */
    padding: 0.625rem 0.875rem;
    padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--left-border);
    background: var(--left-bg);
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
    min-height: 44px;                    /* iOS 최소 터치 타겟 */
    transition: background var(--transition);
}
.left-profile-chip:hover {
    background: var(--left-hover);
    text-decoration: none;
    color: var(--color-text);
}
.left-profile-chip.active {
    background: var(--left-active);
    font-weight: 600;
}
.left-profile-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--slate-700);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}
.left-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.left-profile-name {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.left-profile-icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

/* ── 익명 로그인 슬롯 — 미인증 시 프로필 chip 대신 노출 ────────────── */
.left-anon-login {
    margin: 0.75rem -1rem 0;
    padding: 0.875rem 1rem;
    padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--left-border);
    background: var(--left-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.left-anon-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: center;
}
.left-anon-google {
    display: flex;
    justify-content: center;
    min-height: 40px;
}

