@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark Theme (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.35);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-primary-glow: rgba(99, 102, 241, 0.25);

  --color-stock: #3b82f6;
  --color-deposit: #10b981;
  --color-cash: #f59e0b;
  
  --profit-up: #ef4444; /* 한국식 주식 상승 레드 */
  --profit-down: #3b82f6; /* 한국식 주식 하락 블루 */
  --profit-up-soft: rgba(239, 68, 68, 0.15);
  --profit-down-soft: rgba(59, 130, 246, 0.15);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);
}

[data-theme='light'] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(0, 0, 0, 0.03);
  --border-color: rgba(0, 0, 0, 0.09);
  --border-highlight: rgba(99, 102, 241, 0.45);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  overflow-x: clip;
  width: 100%;
  max-width: 100vw;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  min-width: 0;
}

/* ========================================================
   상단 고정 네비게이션 래퍼 (Fixed + Glassmorphism + Animation)
   ======================================================== */
.navbar-fixed-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-sizing: border-box;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: background, backdrop-filter, box-shadow, padding;
}

/* fixed 네비게이션으로 인한 상단 본문 밀림 방지 플레이스홀더 */
.navbar-fixed-placeholder {
  height: 104px; /* 데스크탑: Navbar(56px) + TabsBar(48px) */
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* 스크롤 시 상단 플로팅 + 세련된 반투명 블러 배경 + 드롭다운 슬라이드 인 애니메이션 */
.navbar-fixed-wrapper.is-scrolled,
.navbar-fixed-wrapper.floating {
  background: rgba(11, 15, 25, 0.76) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 12px 35px -8px rgba(0, 0, 0, 0.65), 0 1px 3px rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  animation: navFloatIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes navFloatIn {
  0% {
    transform: translateY(-6px);
    opacity: 0.9;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

[data-theme='light'] .navbar-fixed-wrapper {
  background: var(--bg-primary);
}

[data-theme='light'] .navbar-fixed-wrapper.is-scrolled,
[data-theme='light'] .navbar-fixed-wrapper.floating {
  background: rgba(248, 250, 252, 0.82) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Navbar (상단 브랜드 & 액션 행) */
.navbar {
  position: relative;
  background: transparent;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 스크롤 시 상단 헤더 패딩이 부드럽게 컴팩트해지는 미세 애니메이션 */
.navbar.is-scrolled {
  padding: 0.5rem 1.5rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border-radius: 6px;
  font-weight: 600;
}

/* Member Selector Pills & Carousel */
.member-carousel-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 700px;
  position: relative;
  min-width: 0;
}

.member-pills-scroll {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-glass);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  scroll-behavior: smooth;
  flex: 1;
}

.member-pills-scroll::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.member-scroll-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  padding: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.member-scroll-btn:hover:not(:disabled) {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  transform: scale(1.08);
}

.member-scroll-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  transform: none;
}

.member-pills {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-glass);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.member-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.member-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.member-pill.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.member-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.desktop-actions {
  display: flex;
}

.mobile-header-actions {
  display: none;
}

.icon-only-btn {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

/* 모바일 아이콘 클릭 시 펼쳐지는 Glassmorphism 드롭다운 메뉴 */
.mobile-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 10px;
  right: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-highlight);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  animation: mobileMenuSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mobileMenuSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.mobile-menu-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.mobile-menu-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.mobile-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 2px 0;
}

.mobile-menu-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #F87171;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-logout-btn:hover {
  background: rgba(239, 68, 68, 0.22);
}

.fx-rate-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

/* Tab Navigation */
.tabs-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.45rem 1.5rem;
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: none;
  overflow-x: auto;
  white-space: nowrap;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tabs-bar.is-scrolled {
  padding: 0.32rem 1.5rem;
}

[data-theme='light'] .tabs-bar {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.tabs-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.tab-btn.active {
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1440px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0 auto;
}

/* Cards & Glassmorphism */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.glass-card:hover {
  border-color: var(--border-highlight);
}

/* Metric Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.metric-sub {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-profit {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-profit.up {
  color: var(--profit-up);
  background: var(--profit-up-soft);
}
.badge-profit.down {
  color: var(--profit-down);
  background: var(--profit-down-soft);
}

/* Dashboard Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }

@media (max-width: 1024px) {
  .col-8, .col-4, .col-6 {
    grid-column: span 12;
  }
}

.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Tables */
.modern-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.modern-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.modern-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  white-space: nowrap;
}

.modern-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px var(--accent-primary-glow);
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Loading Modal & Overlay */
.loading-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: loadingFadeIn 0.25s ease-out;
  user-select: none;
}

.loading-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2.2rem 2.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 35px rgba(99, 102, 241, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  min-width: 290px;
  max-width: 360px;
  animation: loadingScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.loading-modal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
  animation: loadingShimmer 2s infinite linear;
  background-size: 200% 100%;
}

.loading-spinner-wrapper {
  position: relative;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #6366f1;
  border-right-color: #a855f7;
  animation: loadingSpin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

.loading-spinner-ring-outer {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed rgba(168, 85, 247, 0.35);
  animation: loadingSpinReverse 3s linear infinite;
}

.loading-spinner-icon {
  color: #818cf8;
  animation: loadingPulse 1.6s ease-in-out infinite;
}

.loading-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.loading-modal-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.loading-dots span {
  animation: loadingDotBlink 1.4s infinite;
  opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.25s; }
.loading-dots span:nth-child(3) { animation-delay: 0.5s; }

@keyframes loadingFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes loadingScaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes loadingSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes loadingSpinReverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes loadingPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
}

@keyframes loadingDotBlink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

@keyframes loadingShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ========================================================
   Device Visibility Utilities (데스크탑/모바일 분기)
   ======================================================== */
.mobile-only {
  display: none !important;
}
.desktop-only {
  display: block;
}
nav.desktop-only {
  display: flex !important;
}

/* ========================================================
   모바일 최적화 반응형 레이아웃 (max-width: 768px)
   * PC(769px 이상)의 기존 레이아웃은 100% 그대로 보존됨
   ======================================================== */
@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
  .mobile-only-flex,
  nav.mobile-only {
    display: flex !important;
  }
  .desktop-only,
  nav.desktop-only {
    display: none !important;
  }

  /* 1. 상단 네비게이션 바 (Navbar): 모바일 단일 행(높이 54px) 및 슬림 트랜지션 */
  .navbar-fixed-placeholder {
    height: 54px !important;
  }

  .navbar {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.5rem 12px !important;
    height: 54px !important;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    position: relative !important;
    background: transparent !important;
    transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1), padding 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .navbar.is-scrolled {
    height: 48px !important;
    padding: 0.35rem 12px !important;
  }

  .brand-section {
    flex-shrink: 0;
    gap: 0.5rem;
  }

  .brand-name {
    font-size: 1.15rem;
  }

  .logo-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  /* 모바일에서는 데스크탑용 다중 액션을 숨기고 아이콘 토글 액션만 단정하게 표시 */
  .desktop-actions {
    display: none !important;
  }

  .mobile-header-actions {
    display: flex !important;
    align-items: center;
    gap: 8px;
  }

  .mobile-header-actions .icon-only-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .mobile-header-actions .icon-only-btn.active {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
  }

  /* 2. 모바일 하단 내비게이션 바 (Bottom Navigation Bar): 작은 폰 및 safe-area 완벽 대응 */
  .bottom-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 2px 2px calc(4px + env(safe-area-inset-bottom, 0px)) 2px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    overflow: hidden;
  }

  .bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: clamp(0.6rem, 2.3vw, 0.72rem);
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 3px 1px;
    border-radius: 8px;
    transition: all 0.15s ease;
    user-select: none;
    box-sizing: border-box;
  }

  .bottom-nav-item svg {
    width: 18px;
    height: 18px;
  }

  .bottom-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
    line-height: 1.2;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item.active {
    color: var(--accent-primary);
  }

  .bottom-nav-item.active {
    font-weight: 700;
  }

  .bottom-nav-item.active svg {
    transform: scale(1.08);
    filter: drop-shadow(0 0 6px var(--accent-primary-glow));
  }

  /* 3. 메인 컨텐츠 영역 여백 (하단 내비바 및 플로팅 위젯에 가려지지 않도록 충분한 하단 간격 확보) */
  .main-content {
    padding: 0.75rem 12px calc(76px + env(safe-area-inset-bottom, 12px)) 12px !important;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  /* 4. 대시보드 2x2 메트릭 요약 그리드 */
  .summary-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
  }

  .metric-card {
    padding: 0.75rem 0.65rem;
    gap: 0.3rem;
  }

  .metric-header {
    font-size: 0.72rem;
  }

  .metric-value {
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metric-sub {
    font-size: 0.7rem;
    flex-wrap: wrap;
    gap: 0.2rem;
  }

  /* 5. 카드 및 차트 그리드 모바일 정돈 */
  .glass-card {
    padding: 0.85rem;
    border-radius: var(--radius-md);
  }

  .charts-grid {
    gap: 0.75rem;
    margin-bottom: 0.85rem;
  }

  .card-title {
    font-size: 0.95rem;
  }

  /* 차트 모바일 높이 최적화 (스크롤 압박 완화 및 가독성 향상) */
  .dashboard-chart-treemap {
    height: 250px !important;
  }
  .dashboard-chart-pie {
    height: 220px !important;
  }
  .dashboard-chart-bar {
    height: 220px !important;
  }
  .asset-trend-echarts {
    height: 210px !important;
  }

  /* 6. 모달 팝업 & 폼 모바일 맞춤 */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 1.1rem;
    max-height: 85vh;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  /* 7. 모바일 전용 주식 카드 리스트 스타일 */
  .stock-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  .stock-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s;
  }

  .stock-mobile-card:hover {
    border-color: var(--border-highlight);
  }

  .stock-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  .stock-mobile-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .stock-mobile-sub {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-family: var(--font-mono);
  }

  .stock-mobile-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
  }

  .stock-mobile-body-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .stock-mobile-body-label {
    font-size: 0.7rem;
    color: var(--text-muted);
  }

  .stock-mobile-body-val {
    font-family: var(--font-mono);
    font-weight: 700;
  }

  .stock-mobile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    font-size: 0.78rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* 8. 거래내역 모바일 카드 */
  .tx-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .tx-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  /* 9. 반응형 그리드 (저축, 계좌, 구성원 카드) */
  .responsive-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* 10. 모바일 차트 및 탭 텍스트 겹침 방지 */
  .echarts-for-react {
    overflow: visible;
  }

  .glass-card {
    padding: 1rem !important;
  }
}

/* ========================================================
   중간 해상도 (태블릿 및 소형 PC: 769px ~ 1250px) 상단 메뉴 넘침 방지
   ======================================================== */
@media (min-width: 769px) and (max-width: 1250px) {
  .navbar {
    padding: 0.65rem 1rem;
    gap: 0.5rem;
  }
  .member-carousel-wrapper {
    max-width: 360px;
  }
  .user-name-text {
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
  .fx-rate-chip {
    font-size: 0.75rem;
    padding: 3px 6px;
  }
}

/* ========================================================
   전역 컨텐츠 동적 반응형 및 디스플레이 영역 잘림 방지 규칙
   ======================================================== */
img, svg, canvas {
  max-width: 100%;
}

.echarts-for-react {
  max-width: 100% !important;
  width: 100% !important;
}

/* 모든 그리드 컨테이너의 자식이 컨테이너를 뚫지 않도록 min-width: 0 보장 */
.summary-grid > *,
.charts-grid > *,
.responsive-grid > * {
  min-width: 0;
}

/* ========================================================
   시장 (Market) 지표 & ETF 순위 뷰 스타일링
   ======================================================== */
.market-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.market-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.market-title-area {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.market-title-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.market-icon {
  color: var(--accent-primary);
}

.market-title-badge h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.market-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 720px;
  line-height: 1.45;
}

.market-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.market-last-updated {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* 범용 카드 및 시장 섹션 패널 스타일 (투명 배경 방지 및 시각적 계층화) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.market-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.market-section.card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.market-badge-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.12);
  color: #818CF8;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.timeline-pills {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 8px;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* 1. Fear & Greed Section */
.fg-section {
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.fg-content-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 2rem;
  align-items: center;
  margin-top: 1rem;
}

.fg-gauge-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fg-gauge-container {
  position: relative;
  width: 240px;
  text-align: center;
}

.fg-gauge-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.fg-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -15px;
}

.fg-score-number {
  font-size: 2.75rem;
  font-weight: 900;
  font-family: var(--font-mono);
  line-height: 1;
}

.fg-score-label {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 4px;
}

.fg-scale-legend {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding: 0 4px;
}

.fg-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.fg-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.fg-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.fg-stat-val {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-top: 2px;
}

/* 7대 세부 지표 */
.fg-indicators-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.fg-indicators-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.fg-indicators-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.fg-indicator-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fg-ind-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.fg-ind-name {
  color: var(--text-primary);
  font-weight: 500;
}

.fg-ind-score-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.fg-ind-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.fg-ind-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease-out;
}

/* 2. 주요 주가지수 그리드 */
.indices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.index-card {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.index-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border-color: var(--border-highlight);
}

.index-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.index-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.index-symbol {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.index-change-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.index-change-badge.up {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.index-change-badge.down {
  background: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
}

.index-price-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.index-current-price {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.index-change-val {
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.text-up {
  color: #EF4444;
}

.text-down {
  color: #3B82F6;
}

.index-sparkline-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 36px;
}

.index-range-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.index-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.index-range-track {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.index-range-bar {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 999px;
}

/* 3. 환율 및 원자재 그리드 */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.asset-card {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  border-color: var(--border-highlight);
}

.asset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.asset-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.asset-pct-chip {
  font-size: 0.75rem;
  font-weight: 700;
}

.asset-pct-chip.up {
  color: #EF4444;
}

.asset-pct-chip.down {
  color: #3B82F6;
}

.asset-val-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.asset-val {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.asset-spark {
  display: flex;
  align-items: center;
}

/* 4. 시가총액 히트맵 */
.heatmap-wrapper {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.heatmap-treemap-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-auto-rows: 65px;
  gap: 6px;
  width: 100%;
}

.heatmap-cell {
  border-radius: 8px;
  border: 1px solid;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.heatmap-cell:hover {
  transform: scale(1.02);
  z-index: 2;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.heatmap-cell-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
}

.heatmap-cell-ticker {
  font-size: 0.82rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-cell-name {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-cell-bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
}

.heatmap-cell-rate {
  font-size: 0.88rem;
  font-weight: 900;
  font-family: var(--font-mono);
}

.heatmap-cell-price {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-gradient {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #3B82F6 0%, rgba(255,255,255,0.1) 50%, #EF4444 100%);
}

.market-toggle-group {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 8px;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* 5. 순위 & ETF 섹션 */
.ranking-section {
  padding: 1.5rem;
}

.ranking-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

@media (min-width: 900px) {
  .ranking-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.ranking-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 10px;
}

.rank-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.rank-tab-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rank-tab-btn.etf-highlight-tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
  color: #A5B4FC;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.ranking-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.market-scope-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.segmented-control {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2px;
  border-radius: 8px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.etf-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.etf-chip {
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.etf-chip.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: #6366F1;
  color: #818CF8;
}

.ranking-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 240px;
}

.ranking-search-box input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

/* 순위 테이블 스타일 */
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ranking-table th {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.ranking-row {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s;
}

.ranking-row:hover {
  background: var(--bg-secondary);
}

.ranking-row td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.rank-badge.rank-1 {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

.rank-badge.rank-2 {
  background: linear-gradient(135deg, #94A3B8, #64748B);
  color: #ffffff;
}

.rank-badge.rank-3 {
  background: linear-gradient(135deg, #B45309, #78350F);
  color: #ffffff;
}

.ranking-stock-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stock-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stock-name {
  font-weight: 700;
  color: var(--text-primary);
}

.market-tag-pill {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
}

.market-tag-pill.kr {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

.market-tag-pill.us {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
}

.stock-sub-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stock-ticker {
  font-family: var(--font-mono);
}

.stock-issuer-chip, .stock-cat-chip {
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.stock-price {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.stock-rate-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 8px;
  border-radius: 6px;
}

.stock-rate-chip.up {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.stock-rate-chip.down {
  background: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
}

.stock-volume-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-mono);
}

.volume-val {
  font-weight: 600;
  color: var(--text-primary);
}

.volume-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.stock-aum {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-secondary);
}

.dividend-yield-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  font-family: var(--font-mono);
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
}

.market-loading-box, .market-empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 데스크탑 기본: 모바일 전용 칩 숨김 */
.stock-aum-chip-mobile {
  display: none;
}

/* ========================================================
   모바일 모드 최적화 (첨부 이미지 레이아웃 반영)
   ======================================================== */
@media (max-width: 768px) {
  .market-container {
    gap: 1rem;
  }

  .market-header {
    gap: 0.5rem;
  }

  .market-title-badge h1 {
    font-size: 1.25rem;
  }

  .market-subtitle {
    font-size: 0.8rem;
  }

  .market-section.card,
  .fg-section,
  .ranking-section {
    padding: 0.9rem 0.75rem;
    border-radius: var(--radius-md);
  }

  /* 1. Fear & Greed Section 모바일 */
  .fg-content-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .fg-gauge-container {
    width: 220px;
    margin: 0 auto;
  }

  .fg-score-number {
    font-size: 2.2rem;
  }

  .fg-score-label {
    font-size: 0.95rem;
  }

  .fg-stats-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
  }

  .fg-stat-box {
    padding: 0.35rem 0.2rem;
  }

  .fg-stat-val {
    font-size: 0.85rem;
  }

  .fg-stat-label {
    font-size: 0.62rem;
  }

  .fg-indicators-wrapper {
    padding: 0.85rem;
    gap: 0.65rem;
  }

  /* 2. 주요 주가지수 & 환율 모바일 (이미지처럼 좌/우 2열 그리드) */
  .indices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
  }

  .index-card {
    padding: 0.75rem 0.6rem;
    gap: 0.45rem;
    border-radius: 10px;
  }

  .index-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .index-symbol {
    font-size: 0.65rem;
  }

  .index-current-price {
    font-size: 1.05rem;
  }

  .index-change-val {
    font-size: 0.75rem;
  }

  .index-change-badge {
    font-size: 0.7rem;
    padding: 2px 5px;
  }

  .index-price-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .index-sparkline-row {
    height: 24px;
  }

  /* 3. 환율 및 원자재 모바일 (좌/우 2열 그리드) */
  .assets-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
  }

  .asset-card {
    padding: 0.7rem 0.6rem;
    gap: 0.35rem;
    border-radius: 10px;
  }

  .asset-name {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .asset-val {
    font-size: 0.95rem;
  }

  .asset-pct-chip {
    font-size: 0.7rem;
  }

  /* 4. 시가총액 히트맵 모바일 */
  .heatmap-treemap-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 56px;
    gap: 4px;
  }

  .heatmap-cell {
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
  }

  .heatmap-cell-name {
    display: none;
  }

  .heatmap-cell-ticker {
    font-size: 0.75rem;
  }

  .heatmap-cell-rate {
    font-size: 0.78rem;
  }

  .heatmap-cell-price {
    font-size: 0.65rem;
  }

  /* 5. 실시간 시장 랭킹 테이블 모바일 최적화 (가로 잘림 방지) */
  .ranking-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .ranking-search-box {
    width: 100%;
    min-width: 0;
  }

  .market-scope-filters {
    justify-content: space-between;
    gap: 0.5rem;
  }

  .ranking-category-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .ranking-category-tabs::-webkit-scrollbar {
    display: none;
  }

  .rank-tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 5px 10px;
  }

  /* 모바일에서 넓은 보조 컬럼 숨김 (화면 핏팅) */
  .col-hide-mobile {
    display: none !important;
  }

  .stock-aum-chip-mobile {
    display: inline-block;
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
  }

  .ranking-table th,
  .ranking-table td {
    padding: 0.65rem 0.45rem;
  }

  .stock-name {
    font-size: 0.82rem;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stock-price {
    font-size: 0.88rem;
  }

  .stock-rate-chip {
    font-size: 0.75rem;
    padding: 2px 5px;
  }
}

@media (max-width: 480px) {
  .stock-name {
    max-width: 110px;
  }

  .indices-grid,
  .assets-grid {
    gap: 0.45rem !important;
  }

  .index-card,
  .asset-card {
    padding: 0.65rem 0.5rem;
  }
}
/* ========================================================
   스택온(Stackon) 스타일 네비게이션 & UI 시스템 확장
   ======================================================== */

/* 1. PC 상단 중앙 4대 메인 네비게이션 (홈, 추이, 자산, 시장) */
.desktop-main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-glass);
  padding: 4px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.main-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.main-nav-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

[data-theme='light'] .main-nav-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme='light'] .main-nav-btn.active {
  color: #ffffff;
}

/* 2. 상단 서브 칩 바 (Sub-Navbar Strip) - 슬림 & 조화로운 스타일 */
.sub-navbar-strip {
  width: 100%;
  background: rgba(11, 15, 25, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding: 4px 12px;
  box-sizing: border-box;
  position: relative;
}

[data-theme='light'] .sub-navbar-strip {
  background: rgba(248, 250, 252, 0.6);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.sub-navbar-relative-wrapper {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.sub-chips-scroll-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  padding: 2px 2px;
  scroll-behavior: smooth;
}

.sub-chips-scroll-container::-webkit-scrollbar {
  display: none;
}

/* 스크롤 방향 안내 화살표 인디케이터 */
.sub-chip-scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

[data-theme='light'] .sub-chip-scroll-arrow {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sub-chip-scroll-arrow.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.sub-chip-scroll-arrow.left {
  left: -4px;
}

.sub-chip-scroll-arrow.right {
  right: -4px;
}

.sub-chip-scroll-arrow:hover {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
  background: var(--bg-tertiary);
}

.sub-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

[data-theme='light'] .sub-chip-btn {
  background: rgba(0, 0, 0, 0.02);
}

.sub-chip-btn:hover {
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

.sub-chip-btn.active {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.38);
  font-weight: 700;
  box-shadow: none;
}

[data-theme='light'] .sub-chip-btn.active {
  color: #4338ca;
  background: rgba(99, 102, 241, 0.09);
  border-color: rgba(99, 102, 241, 0.28);
}

.navbar-fixed-placeholder.has-subbar {
  height: 90px;
}

@media (max-width: 768px) {
  .navbar-fixed-placeholder.has-subbar {
    height: 84px !important;
  }
}

/* 2-1. 본문 내 컴팩트 세그먼트 탭 스타일 (보유종목, 매수/매도 이력 등) */
.compact-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.compact-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.compact-tab-btn:hover {
  color: var(--text-primary);
}

.compact-tab-btn.active {
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  font-weight: 700;
}

[data-theme='light'] .compact-tab-btn.active {
  background: #ffffff;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 3. 모바일 하단 5대 고정 네비게이션 바 (Bottom Navigation) */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme='light'] .bottom-nav-bar {
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 4px 0;
}

.bottom-nav-item span {
  font-size: 0.72rem;
  font-weight: 600;
}

.bottom-nav-item.active {
  color: #38BDF8;
}

.bottom-nav-item:hover {
  color: var(--text-primary);
}

/* 4. 추이 & 분석 (Analytics) 전용 레이아웃 & PC 우측 사이드 패널 */
.analytics-layout-container {
  display: flex;
  gap: 1.5rem;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  position: relative;
  align-items: flex-start;
}

.analytics-main-content {
  flex: 1;
  min-width: 0;
}

/* PC 우측 사이드 패널 */
.analytics-side-nav {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 0.85rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
}

.side-nav-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #818CF8;
  padding: 0 0.5rem 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.side-nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-align: left;
}

.side-nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.side-nav-item.active {
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
}

.side-nav-item .active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38BDF8;
  margin-left: auto;
  box-shadow: 0 0 8px #38BDF8;
}

/* 5. 분석 헤더 & 필터 바 */
.analytics-header-section {
  margin-bottom: 1.5rem;
}

.analytics-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.analytics-view-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.analytics-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.analytics-view-mode-toggle {
  display: flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.mode-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.analytics-preset-filter-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.analytics-preset-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  scroll-behavior: smooth;
  width: 100%;
  padding: 4px 2px;
}

.analytics-preset-filter-row::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.preset-chip-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.preset-chip-btn:hover {
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--bg-card-hover);
}

.preset-chip-btn.active {
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 700;
}

[data-theme='light'] .preset-chip-btn.active {
  background: rgba(99, 102, 241, 0.1);
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.3);
}

/* 6. 2열 분석 카드 그리드 (스택온 2번째 화면 벤치마킹) */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

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

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.analytics-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-arrow {
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.card-arrow:hover {
  transform: translateX(3px);
  color: #38BDF8;
}

.analytics-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

/* AI 리포트 정밀 진단 전용 스타일 */
.ai-report-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ========================================================
   AI 보고서 상세 화면 상단 툴바
   ======================================================== */
.ai-report-detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}

.detail-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.report-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.report-back-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #818CF8;
}

.report-target-pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 6px;
}

.detail-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  color: #EF4444;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.report-delete-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
}

/* ========================================================
   AI 보고서 목록 화면 툴바 & 컨트롤
   ======================================================== */
.ai-report-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.toolbar-select {
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.toolbar-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 10px;
  flex: 1;
  max-width: 260px;
  min-width: 140px;
}

.toolbar-search-wrap .search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.toolbar-search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  width: 100%;
}

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-toggle-group {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-mode-btn.active {
  background: #6366F1;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.4);
}

/* ========================================================
   AI 보고서 카드 뷰 (그리드 형태 기본)
   ======================================================== */
.ai-report-cards-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.report-catalog-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.15rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.report-catalog-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.catalog-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.75rem;
}

.catalog-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-month {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #818CF8;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill-member {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
}

.catalog-score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10B981;
  border-radius: 12px;
  flex-shrink: 0;
}

.catalog-score-badge .score-val {
  font-size: 0.92rem;
  font-weight: 800;
}

.catalog-score-badge .score-unit {
  font-size: 0.68rem;
  font-weight: 600;
}

.catalog-card-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.catalog-card-summary {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.catalog-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  font-size: 0.74rem;
  color: var(--text-muted);
}

.catalog-card-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.catalog-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.catalog-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  transition: all 0.15s ease;
}

.catalog-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.catalog-view-link {
  font-size: 0.78rem;
  font-weight: 700;
  color: #818CF8;
  transition: color 0.15s ease;
}

.report-catalog-card:hover .catalog-view-link {
  color: #A5B4FC;
}

/* ========================================================
   AI 보고서 리스트 뷰 (행 테이블 형태)
   ======================================================== */
.ai-report-table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.ai-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.ai-report-table th {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.ai-report-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.05));
  vertical-align: middle;
}

.report-table-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.report-table-row:hover {
  background: rgba(99, 102, 241, 0.06);
}

.col-title-summary {
  max-width: 320px;
}

.table-report-title {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.table-report-summary {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-score-pill {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10B981;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.76rem;
}

.table-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-action-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}

.table-action-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.table-action-view {
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818CF8;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.table-action-view:hover {
  background: #6366F1;
  color: #ffffff;
}

/* ========================================================
   페이지네이션 바
   ======================================================== */
.ai-report-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 0.25rem 0.5rem;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-info strong {
  color: var(--text-primary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.page-nav-btn:hover:not(:disabled) {
  border-color: #6366F1;
  color: #818CF8;
}

.page-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-num-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.page-num-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.page-num-btn.active {
  background: #6366F1;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.ai-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ai-generate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
}

.ai-generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .ai-report-list-toolbar {
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }
  .toolbar-left {
    width: 100%;
  }
  .toolbar-search-wrap {
    max-width: none;
    flex: 1;
  }
  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .ai-report-cards-list-grid {
    grid-template-columns: 1fr;
  }
  .ai-report-pagination {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  .desktop-text {
    display: none;
  }
  .ai-generate-btn {
    padding: 5px 11px;
    font-size: 0.78rem;
    gap: 5px;
    border-radius: 6px;
  }
}

/* ========================================================
   AI 보고서 작성 모달 (새 창 다이얼로그)
   ======================================================== */
.ai-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 1rem;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #1e2230);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(99, 102, 241, 0.15);
  overflow: hidden;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.ai-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.ai-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-modal-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  flex-shrink: 0;
}

.ai-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
}

.ai-modal-sub {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: var(--text-muted, #9ca3af);
  line-height: 1.35;
}

.ai-modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #9ca3af);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ai-modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
}

.ai-modal-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #d1d5db);
}

.modal-label-with-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-hint {
  font-size: 0.72rem;
  color: var(--text-muted, #9ca3af);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

.modal-period-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.modal-period-tab {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #9ca3af);
  cursor: pointer;
  transition: all 0.18s ease;
}

.modal-period-tab.active {
  background: #6366F1;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.modal-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  color: var(--text-primary, #ffffff);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.modal-input:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-input option {
  background: var(--bg-card, #1e2230);
  color: var(--text-primary, #ffffff);
}

.modal-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-range-sep {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted, #9ca3af);
}

.modal-textarea {
  width: 100%;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  color: var(--text-primary, #ffffff);
  font-size: 0.83rem;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-textarea:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.ai-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.modal-btn-cancel {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: 8px;
  color: var(--text-secondary, #d1d5db);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.06);
}

.modal-btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
}

.modal-btn-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
}

.modal-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-report-meta-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.meta-saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10B981;
  border-radius: 12px;
  font-size: 0.74rem;
  font-weight: 600;
}

.ai-report-error-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #EF4444;
  border-radius: 8px;
  font-size: 0.88rem;
}

.ai-report-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  text-align: center;
}

.pulse-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366F1;
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 1.25rem;
}

.ai-report-loading-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.ai-report-loading-state p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 500px;
}

.ai-report-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.015);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-color);
}

.empty-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.ai-report-empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.ai-report-empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 540px;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.ai-generate-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
}

.ai-generate-hero-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.6);
}

/* 상단 핵심 총평 Hero 카드 */
.ai-summary-hero-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(56, 189, 248, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.hero-score-wrap {
  flex-shrink: 0;
}

.score-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, rgba(17, 24, 39, 0.8) 100%);
  border: 3px solid #6366F1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.score-num {
  font-size: 1.8rem;
  font-weight: 900;
  color: #818CF8;
  line-height: 1;
}

.score-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

.hero-text-wrap {
  flex: 1;
}

.hero-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.hero-summary {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 카드 그리드 */
.ai-report-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.ai-insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}

.ai-insight-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.card-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-badge-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.card-badge-pill.positive {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.card-badge-pill.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.card-badge-pill.highlight {
  background: rgba(99, 102, 241, 0.15);
  color: #818CF8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.card-badge-pill.info {
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.card-heading {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.card-body-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
  flex: 1;
}

.card-body-text p {
  margin-bottom: 6px;
}

.card-metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.metric-chip {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text-primary);
}

.card-recommendation-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.rec-icon {
  flex-shrink: 0;
  color: #818CF8;
  margin-top: 1px;
}

.rec-content {
  line-height: 1.45;
}

.rec-content strong {
  color: #818CF8;
}

/* 거래 타임라인 */
.transaction-timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.tx-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* 7. 마이 뷰 (MyView) 전용 스타일 */
.my-view-container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 40px;
}

.my-profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.profile-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.profile-info-block {
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-name-row h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-pill {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.25);
  color: #93C5FD;
  border-radius: 4px;
}

.profile-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.my-settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding-left: 4px;
}

.settings-item-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-card);
}

.settings-item-card.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-item-card.clickable:hover {
  border-color: var(--border-highlight);
  background: var(--bg-card-hover);
}

.item-icon-col {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-text-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-text-col strong {
  font-size: 0.92rem;
  color: var(--text-primary);
}

.item-text-col span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toggle-action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-action-btn.public {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34D399;
}

.toggle-action-btn.private {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #FBBF24;
}

.theme-switch-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.rate-value-pill {
  font-size: 0.92rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
}

.admin-group {
  margin-top: 10px;
}

.admin-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.admin-panel-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #60A5FA;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-embedded-wrapper {
  background: var(--bg-card);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.my-logout-section {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.my-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #F87171;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.my-logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Floating Add Action Button Styles (Placed above AI Assistant FAB) */

.floating-add-wrapper {
  position: fixed;
  bottom: 88px; /* AI 비서 52px + 바닥 24px + 간격 12px */
  right: 24px;
  z-index: 998; /* AI 비서 챗봇 창(9999) 아래, 일반 요소 위 */
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none; /* 래퍼 자체는 클릭 통과 */
}

/* AI 비서가 비활성화된 경우 하단 위치 조정 */
.floating-add-wrapper.no-ai-chat {
  bottom: 24px;
}

/* 플로팅 버튼 공통 (반투명 글래스모피즘 적용으로 컨텐츠 투과) */
.floating-add-btn {
  pointer-events: auto; /* 버튼 영역만 클릭 허용 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.72; /* 평상시 컨텐츠를 가리지 않는 부드러운 반투명 */
}

/* 호버 또는 스크롤 진행 중일 때 완전 불투명 및 선명한 상태로 전환 */
.floating-add-btn:hover,
.floating-add-btn.is-scrolling {
  opacity: 1;
}

/* 1. 주식 (Stock) 테마: 모던 인디고-오션블루 반투명 글래스 */
.floating-add-btn.variant-stock {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.65) 0%, rgba(59, 130, 246, 0.65) 50%, rgba(2, 132, 199, 0.65) 100%);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}
.floating-add-btn.variant-stock:hover,
.floating-add-btn.variant-stock.is-scrolling {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95) 0%, rgba(59, 130, 246, 0.95) 50%, rgba(2, 132, 199, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.58), 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

/* 2. 저축 (Deposit) 테마: 에메랄드-민트그린 반투명 글래스 */
.floating-add-btn.variant-deposit {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.65) 0%, rgba(16, 185, 129, 0.65) 50%, rgba(13, 148, 136, 0.65) 100%);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}
.floating-add-btn.variant-deposit:hover,
.floating-add-btn.variant-deposit.is-scrolling {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.95) 0%, rgba(16, 185, 129, 0.95) 50%, rgba(13, 148, 136, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.58), 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

/* 3. 계좌 (Account) 테마: 인디고-바이올렛 반투명 글래스 */
.floating-add-btn.variant-account {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.65) 0%, rgba(99, 102, 241, 0.65) 50%, rgba(139, 92, 246, 0.65) 100%);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}
.floating-add-btn.variant-account:hover,
.floating-add-btn.variant-account.is-scrolling {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.95) 0%, rgba(99, 102, 241, 0.95) 50%, rgba(139, 92, 246, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.58), 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

/* 호버 & 액티브 모션 효과 */
.floating-add-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

.floating-add-btn:active {
  transform: translateY(0) scale(0.96);
}

/* 아이콘 감싸는 글래스 서클 */
.floating-add-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-add-btn:hover .floating-add-icon-wrap {
  transform: rotate(90deg);
}

.floating-add-icon {
  color: #ffffff;
  stroke-width: 2.3;
}

/* 텍스트 라벨 (평소 숨김, 호버 또는 스크롤 시 부드럽게 펼쳐짐) */
.floating-add-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  margin-left: 0;
  transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              margin-left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 스크롤 진행 중이거나 마우스 호버 시 알약(Pill) 형태로 텍스트 확장 */
.floating-add-btn.is-scrolling,
.floating-add-btn:hover {
  width: auto;
  border-radius: 9999px;
  padding: 8px 18px 8px 10px;
}

.floating-add-btn.is-scrolling .floating-add-label,
.floating-add-btn:hover .floating-add-label {
  max-width: 140px;
  opacity: 1;
  margin-left: 8px;
}

.floating-add-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.floating-add-sub {
  font-size: 10px;
  opacity: 0.9;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.2;
}

/* 모바일 화면 대응 (768px 이하) */
@media (max-width: 768px) {
  .floating-add-wrapper {
    bottom: 126px; /* AI 비서 48px + 하단 내비 68px + 간격 10px */
    right: 12px;
  }

  .floating-add-wrapper.no-ai-chat {
    bottom: 68px;
  }

  .floating-add-btn {
    width: 48px;
    height: 48px;
    padding: 0;
  }

  .floating-add-icon-wrap {
    width: 32px;
    height: 32px;
  }

  .floating-add-btn.is-scrolling {
    width: auto;
    padding: 6px 14px 6px 8px;
  }

  .floating-add-btn.is-scrolling .floating-add-label {
    max-width: 125px;
    margin-left: 6px;
  }

  .floating-add-title {
    font-size: 12px;
  }

  .floating-add-sub {
    font-size: 9px;
  }
}
/* AI Chat Float & Widget Styles */

.ai-float-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: inherit;
}

/* 플로팅 트리거 버튼 (FAB) - 평소 아이콘만 표시 및 반투명으로 컨텐츠 가림 방지, 호버/스크롤 시 선명하게 확장 */
.ai-fab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.65) 0%, rgba(139, 92, 246, 0.65) 50%, rgba(236, 72, 153, 0.65) 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0.72; /* 평상시 컨텐츠를 가리지 않는 부드러운 반투명 */
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.ai-fab-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

.ai-fab-btn:active {
  transform: translateY(0) scale(0.96);
}

.ai-fab-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.ai-fab-pulse {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  animation: ai-fab-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

@keyframes ai-fab-ping {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  70%, 100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* 라벨 텍스트: 기본적으로 숨김 (아이콘만 표시) */
.ai-fab-label {
  letter-spacing: -0.2px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  margin-left: 0;
  transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease,
              margin-left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 스크롤 진행 중이거나 마우스 호버 시 부드럽게 텍스트 확장 및 선명도 100% 전환 */
.ai-fab-btn.is-scrolling,
.ai-fab-btn:hover {
  opacity: 1;
  width: auto;
  border-radius: 9999px;
  padding: 8px 18px 8px 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.95) 0%, rgba(139, 92, 246, 0.95) 50%, rgba(236, 72, 153, 0.95) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.55), 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.ai-fab-btn.is-scrolling .ai-fab-label,
.ai-fab-btn:hover .ai-fab-label {
  max-width: 140px;
  opacity: 1;
  margin-left: 8px;
}

.ai-fab-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
}

.ai-fab-sub {
  font-size: 10px;
  opacity: 0.9;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
}

/* 챗 윈도우 컨테이너 */
.ai-chat-window {
  width: 410px;
  height: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  background: var(--bg-card, #181920);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(20px);
}

@keyframes ai-slide-up {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 윈도우 헤더 */
.ai-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.08) 100%);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.ai-header-titles {
  display: flex;
  flex-direction: column;
}

.ai-header-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.ai-header-sub {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-tag-linked {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 600;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
}

.ai-icon-btn.active {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

/* 설정 오버레이 패널 */
.ai-settings-panel {
  padding: 16px;
  background: var(--bg-secondary, #20222b);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
  animation: ai-fade-in 0.2s ease;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-setting-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-setting-label {
  font-weight: 600;
  color: var(--text-secondary, #cbd5e1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-setting-input,
.ai-setting-select {
  background: var(--bg-card, #14151b);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  color: var(--text-primary, #ffffff);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}

.ai-setting-input:focus,
.ai-setting-select:focus {
  border-color: #6366f1;
}

.ai-setting-help {
  font-size: 10.5px;
  color: var(--text-muted, #94a3b8);
  line-height: 1.35;
}

.ai-setting-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ai-btn-sm {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-btn-primary {
  background: #6366f1;
  color: #fff;
  border: none;
}
.ai-btn-primary:hover {
  background: #4f46e5;
}

.ai-btn-outline {
  background: transparent;
  color: var(--text-secondary, #cbd5e1);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}
.ai-btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* 메시지 스크롤 영역 */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 웰컴 인트로 */
.ai-welcome-card {
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.04) 100%);
  border: 1px dashed rgba(99, 102, 241, 0.25);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-welcome-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-welcome-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
}

.ai-welcome-text {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
}

.ai-welcome-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-chip-btn {
  background: var(--bg-secondary, #232530);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  color: var(--text-secondary, #cbd5e1);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chip-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  transform: translateX(3px);
}

/* 메시지 버블 */
.ai-message-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.ai-message-row.user {
  justify-content: flex-end;
}

.ai-message-row.assistant {
  justify-content: flex-start;
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  font-size: 12px;
  margin-top: 2px;
}

.ai-msg-content-wrap {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.ai-message-row.user .ai-msg-content-wrap {
  align-items: flex-end;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-word;
}

.ai-message-row.user .ai-msg-bubble {
  background: #6366f1;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.ai-message-row.assistant .ai-msg-bubble {
  background: var(--bg-secondary, #22242f);
  color: var(--text-primary, #e2e8f0);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-bottom-left-radius: 4px;
}

.ai-msg-meta {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 마크다운 렌더링 스타일 */
.ai-markdown {
  white-space: pre-wrap;
}

.ai-markdown p {
  margin: 0 0 8px 0;
}
.ai-markdown p:last-child {
  margin-bottom: 0;
}

.ai-markdown strong {
  font-weight: 700;
  color: #a5b4fc;
}

.ai-message-row.user .ai-markdown strong {
  color: #ffffff;
}

.ai-markdown ul,
.ai-markdown ol {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.ai-markdown li {
  margin-bottom: 4px;
}

.ai-markdown table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 11px;
}

.ai-markdown th,
.ai-markdown td {
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  padding: 5px 8px;
  text-align: left;
}

.ai-markdown th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

/* 에러 알림 카드 */
.ai-error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 12px;
  color: #fca5a5;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.45;
}

.ai-error-title {
  font-weight: 700;
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 타이핑 인디케이터 */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--bg-secondary, #22242f);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #818cf8;
  animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* 하단 영역: 토큰 프로그레스 바 & 인풋 */
.ai-chat-footer {
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  background: var(--bg-secondary, #1b1c24);
  padding: 10px 14px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* 토큰 사용량 & 남은량 프로그레스 바 카드 */
.ai-token-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-token-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.ai-token-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text-secondary, #cbd5e1);
}

.ai-token-badge-free {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.ai-token-counts {
  color: var(--text-muted, #94a3b8);
  font-variant-numeric: tabular-nums;
}

.ai-token-current {
  font-weight: 700;
  color: var(--text-primary, #ffffff);
}

/* 프로그레스 바 */
.ai-progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.ai-progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
}

.ai-progress-bar.tier-safe {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.ai-progress-bar.tier-warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.ai-progress-bar.tier-danger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.ai-token-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
}

.ai-token-percent {
  font-weight: 600;
}

.ai-token-remaining {
  color: #34d399;
}

/* 입력 바 영역 */
.ai-input-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-card, #14151b);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  padding: 6px 8px 6px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-input-box:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.ai-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary, #ffffff);
  font-size: 12.5px;
  line-height: 1.45;
  resize: none;
  max-height: 90px;
  outline: none;
  padding: 4px 0;
  font-family: inherit;
}

.ai-textarea::placeholder {
  color: var(--text-muted, #64748b);
}

.ai-send-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.ai-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-input-bottom-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 10px;
  color: var(--text-muted, #64748b);
  padding: 0 4px;
}

.ai-shortcut-hint {
  font-size: 10.5px;
  color: var(--text-muted, #64748b);
}

/* 백드롭 및 모바일 핸들 바 기본 (데스크탑 숨김) */
.ai-chat-backdrop {
  display: none;
}

.ai-mobile-handle-bar {
  display: none;
}

/* 모바일 반응형: 바텀시트 모달 레이아웃 (닫기 용이 & 화면 높이 최적화) */
@media (max-width: 768px) {
  /* 배경 딤 오버레이: 바깥 영역 터치 시 즉시 닫힘 */
  .ai-chat-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    animation: ai-fade-in 0.25s ease forwards;
  }

  @keyframes ai-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .ai-float-wrapper {
    bottom: 68px;
    right: 12px;
    z-index: 9999;
  }

  /* 챗 윈도우가 열렸을 때 모바일 하단에 딱 붙는 바텀시트 컨테이너로 전환 */
  .ai-float-wrapper.is-open {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100vw;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
  }

  .ai-fab-btn {
    width: 48px;
    height: 48px;
    padding: 0;
  }
  .ai-fab-btn.is-scrolling {
    width: auto;
    padding: 6px 14px 6px 8px;
  }
  .ai-fab-btn.is-scrolling .ai-fab-label {
    max-width: 125px;
    margin-left: 6px;
  }
  .ai-fab-icon-wrap {
    width: 32px;
    height: 32px;
  }
  .ai-fab-title {
    font-size: 12px;
  }
  .ai-fab-sub {
    font-size: 9px;
  }

  /* 모바일 바텀시트 윈도우 */
  .ai-chat-window {
    width: 100vw;
    max-width: 100vw;
    height: min(72vh, 520px);
    max-height: 78vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.7);
    margin: 0;
    animation: ai-sheet-up 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes ai-sheet-up {
    from {
      transform: translateY(100%);
      opacity: 0.7;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* 상단 모바일 핸들 바 */
  .ai-mobile-handle-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0 4px;
    cursor: pointer;
    background: transparent;
    user-select: none;
    touch-action: manipulation;
  }

  .ai-mobile-handle-pill {
    width: 36px;
    height: 4.5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.2s;
  }

  .ai-mobile-handle-bar:active .ai-mobile-handle-pill {
    background: rgba(255, 255, 255, 0.6);
  }

  /* 헤더 패딩 및 닫기 버튼 터치 타겟 강화 */
  .ai-chat-header {
    padding: 4px 14px 10px;
  }

  .ai-close-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #f1f5f9;
  }

  .ai-chat-body {
    padding: 10px 14px;
  }

  .ai-chat-footer {
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
