/* ================================================================
   곡소리 매매법 - 메인 스타일시트
   다크 금융 테마 | 반응형
   ================================================================ */

/* ── 변수 ───────────────────────────────────────────────── */
:root {
  --bg-base: #0d0f14;
  --bg-card: #141820;
  --bg-card-hover: #1c2230;
  --bg-header: #0a0c10;
  --bg-modal: #161b26;

  --border: #2a3040;
  --border-light: #3a4560;

  --text-primary: #e8eaf0;
  --text-secondary: #8890a8;
  --text-muted: #545c70;

  --accent: #4f8ef7;
  --accent-glow: rgba(79, 142, 247, 0.2);

  --positive: #f05060;
  --positive-bg: rgba(240, 80, 96, 0.12);
  --negative: #26d97f;
  --negative-bg: rgba(38, 217, 127, 0.12);
  --neutral: #f5a623;
  --neutral-bg: rgba(245, 166, 35, 0.12);

  --grade-a: #26d97f;
  --grade-b: #4f8ef7;
  --grade-c: #f5a623;
  --grade-d: #f07030;
  --grade-e: #f05060;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --transition: 0.18s ease;

  --header-h: 64px;
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', -apple-system, sans-serif;
}

/* ── 리셋 ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

img {
  max-width: 100%;
}

/* ── 헤더 ───────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 1.4rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-accent {
  color: var(--accent);
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid transparent;
}

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

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.search-wrap {
  position: relative;
}

.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 36px 7px 14px;
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 200px;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  width: 260px;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
}

.update-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.update-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}

/* ── 광고 영역 ──────────────────────────────────────────── */
.ad-wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 8px 20px;
}

/* ── 통계 바 ────────────────────────────────────────────── */
.stats-bar {
  max-width: 1600px;
  margin: 12px auto;
  padding: 0 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
  flex: 1;
}

.stat-item.hot {
  border-color: rgba(255, 100, 50, 0.4);
  background: rgba(255, 100, 50, 0.06);
}

.stat-item.cold {
  border-color: rgba(79, 142, 247, 0.4);
  background: rgba(79, 142, 247, 0.06);
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── 메인 그리드 ─────────────────────────────────────────── */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.grid-header {
  display: grid;
  grid-template-columns: 1.8fr 1.2fr 1.8fr 0.4fr;
  padding: 8px 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* 로딩 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 0;
  color: var(--text-muted);
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 종목 그리드 */
.stock-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ── 종목 카드 (한 행) ───────────────────────────────────── */
.stock-row {
  display: grid;
  grid-template-columns: 1.8fr 1.2fr 1.8fr 0.4fr;
  align-items: center;
  padding: 11px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stock-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: var(--transition);
}

.stock-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateX(2px);
}

.stock-row:hover::before {
  background: var(--accent);
}

.stock-row.rank-1::before {
  background: #ffd700;
}

.stock-row.rank-2::before {
  background: #c0c0c0;
}

.stock-row.rank-3::before {
  background: #cd7f32;
}

/* 순위/종목명 컬럼 */
.col-stock {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-badge {
  width: 24px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.stock-emoji {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stock-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stock-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.stock-code {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* 점수 컬럼 */
.col-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-num {
  font-size: 1.1rem;
  font-weight: 700;
}

.score-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* 추세/등급 컬럼 */
.col-trend {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trend-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.trend-up {
  background: var(--positive-bg);
  color: var(--positive);
}

.trend-down {
  background: var(--negative-bg);
  color: var(--negative);
}

.trend-neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

.grade-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.grade-A {
  background: var(--positive-bg);
  color: var(--grade-a);
}

.grade-B {
  background: var(--accent-glow);
  color: var(--grade-b);
}

.grade-C {
  background: var(--neutral-bg);
  color: var(--grade-c);
}

.grade-D {
  background: rgba(240, 112, 48, 0.12);
  color: var(--grade-d);
}

.grade-E {
  background: var(--negative-bg);
  color: var(--grade-e);
}

.change-badge {
  font-size: 0.75rem;
}

.change-pos {
  color: var(--positive);
}

.change-neg {
  color: var(--negative);
}

/* 공유 컬럼 */
.col-share {
  display: flex;
  justify-content: flex-end;
}

.share-mini-btn {
  padding: 5px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.share-mini-btn:hover {
  background: #fee500;
  color: #3c1e1e;
  border-color: #fee500;
}

/* ── 색상 분기 ─────────────────────────────────────────── */
.score-color-high {
  color: var(--positive);
}

.score-color-mid {
  color: var(--neutral);
}

.score-color-low {
  color: var(--negative);
}

.bar-color-high {
  background: var(--positive);
}

.bar-color-mid {
  background: var(--neutral);
}

.bar-color-low {
  background: var(--negative);
}

/* ── 페이지네이션 ─────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 0;
}

.page-btn {
  padding: 8px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

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

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

/* ── 모달 ────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg-modal);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: min(680px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-emoji {
  font-size: 1.8rem;
  margin-right: 10px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-code {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 8px;
  font-family: monospace;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--negative-bg);
  color: var(--negative);
}

/* 탭 */
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: var(--transition);
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.tab-content {
  display: none;
  padding: 20px 24px;
}

.tab-content.active {
  display: block;
}

/* 개요 탭 */
.score-display {
  text-align: center;
  padding: 16px 0;
}

.score-big {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
}

.score-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.ov-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.ov-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ov-val {
  font-size: 1rem;
  font-weight: 700;
}

.ov-val.positive {
  color: var(--positive);
}

.ov-val.negative {
  color: var(--negative);
}

/* 미니 바 */
.mini-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
}

.mini-bar-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.mini-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.7s ease;
}

.mini-bar-fill.positive {
  background: var(--positive);
}

.mini-bar-fill.negative {
  background: var(--negative);
}

.mini-bar-fill.neutral {
  background: var(--neutral);
}

/* 댓글 탭 */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: var(--radius);
  padding: 10px 14px;
}

.comment-item.positive {
  border-left-color: var(--positive);
}

.comment-item.negative {
  border-left-color: var(--negative);
}

.comment-item.neutral {
  border-left-color: var(--neutral);
}

.comment-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* 차트 탭 */
#scoreChart {
  max-height: 220px;
}

/* DART 탭 */
.dart-info p {
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.dart-frame {
  width: 100%;
  height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dart-external-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.85rem;
  transition: var(--transition);
}

.dart-external-btn:hover {
  background: var(--accent);
  color: white;
}

/* 모달 푸터 */
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.share-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

.kakao-btn {
  background: #fee500;
  color: #3c1e1e;
}

.kakao-btn:hover {
  background: #f0d800;
}

.link-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.naver-btn {
  background: #03c75a;
  color: white;
}

.naver-btn:hover {
  background: #02b04e;
}

/* ── 푸터 ────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  margin-top: 20px;
}

.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

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

.footer-lang {
  display: flex;
  gap: 8px;
}

.lang-btn {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: var(--transition);
}

.lang-btn.active,
.lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── 시장 공포-탐욕 게이지 ────────────────────────────── */
.market-gauge-section {
  max-width: 1600px;
  margin: 0 auto 20px;
  padding: 0 20px;
}

.gauge-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.gauge-header {
  text-align: center;
  margin-bottom: 20px;
}

.gauge-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.gauge-subtitle {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.gauge-body {
  position: relative;
  width: 320px;
  height: 180px;
}

#marketGauge {
  width: 100% !important;
  height: 100% !important;
}

.gauge-value-center {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#marketIndexVal {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.gauge-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.gauge-legend {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  margin-top: 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0 10px;
}

/* ── 반응형 ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-header {
    grid-template-columns: 1fr 1fr;
  }

  .grid-header .col-header:nth-child(3),
  .grid-header .col-header:nth-child(4) {
    display: none;
  }

  .stock-row {
    grid-template-columns: 1fr 1fr;
  }

  .col-trend,
  .col-share {
    display: none;
  }

  .header-nav {
    display: none;
  }

  .logo-sub {
    display: none;
  }
}

@media (max-width: 600px) {
  .stats-bar {
    gap: 8px;
  }

  .stat-item {
    min-width: 80px;
    padding: 8px 12px;
  }

  .stat-val {
    font-size: 1.1rem;
  }

  .search-input {
    width: 140px;
  }

  .search-input:focus {
    width: 180px;
  }

  .modal-box {
    border-radius: var(--radius);
  }

  .overview-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 히어로 섹션 ──────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, rgba(79, 142, 247, 0.15) 0%, rgba(38, 217, 127, 0.08) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  margin: 20px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(79, 142, 247, 0.1);
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--positive) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.3;
}

.hero-subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-style: italic;
}

.hero-english {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.hero-accent {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── 토스트 알림 ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 스크롤바 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}