:root {
  --primary-color: #2196f3;
  --secondary-color: #1976d2;
  --background-color: #f5f5f5;
  --card-background: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --border-radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --container-padding: 1rem;
  --section-margin: 1.5rem;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%);
  --card-hover-transform: translateY(-3px);
  --animation-duration: 0.3s;
  --glass-effect: backdrop-filter: blur(12px);
  --hover-transform: translateY(-8px) scale(1.02);
  --animation-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --border-glow: 0 0 20px rgba(99, 102, 241, 0.15);
  --header-height: 60px;
  --content-max-width: 1400px;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui,
    Roboto, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.theme-transition * {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease, 
              box-shadow 0.3s ease !important;
}

/* 헤더 스타일 */
.header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: var(--glass-effect);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  padding: 0.5rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: slideDown 0.5s var(--animation-timing);
}

.header-content {
  max-width: var(--content-max-width);
  height: 100%;
  margin: 0 auto;
  display: flex; 
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
}

.header-content h1 {
  font-size: 1.25rem;
  margin: 0;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  animation: pulse 2s infinite;
}

/* 카테고리 버튼 컨테이너 */
.category-buttons {
  position: sticky;
  top: calc(var(--header-height) + 16px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: var(--glass-effect);
  z-index: 89;
  padding: 1rem;
  margin: 0;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center; /* 가운데정렬 */
  align-items: center;
  max-width: 100vw;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 스크롤바 숨기기 */
.category-buttons::-webkit-scrollbar {
  display: none;
}

.category-button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 50px;
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.5;
  transition: all 0.3s var(--animation-timing);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.category-button i {
  font-size: 0.9em;
}

.category-button:hover {
  opacity: 0.8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.category-button.active {
  opacity: 1;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* 다크모드 대응 */
.dark-mode .category-buttons {
  background: rgba(30, 30, 30, 0.95);
}

/* 모바일 대응 */
@media (max-width: 768px) {
  .category-buttons {
    padding: 0.75rem 0.5rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .category-button {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }
}

/* 트렌드 섹션 여백 조정 */
.trending-section {
  max-width: var(--content-max-width);
  padding: 1.5rem 2rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trend-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.trend-header h2 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-primary);
}

.trend-btn {
  background: var(--card-background);
  color: var(--text-primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  margin: 0.25rem;
  cursor: pointer;
  transition: all 0.3s var(--animation-timing);
}

.trend-btn:hover {
  background: var(--primary-gradient);
  color: white;
  transform: translateY(-2px);
}

.trend-btn .count {
  background: var(--primary-color);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* 뉴스 컨테너 */
.news-container {
  max-width: var(--content-max-width);
  padding: 0 2rem 2rem;
  margin: var(--section-margin) auto;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  padding-bottom: 2rem;
}

.news-item {
  background: var(--card-background);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  margin: 0;
  margin-bottom: 1rem;
  position: relative;
  padding-top: 2rem;
  border: 1px solid rgba(99, 102, 241, 0.1);
  transition: all 0.4s var(--animation-timing);
  animation: fadeInUp 0.6s var(--animation-timing);
  position: relative;
  overflow: hidden;
}

.news-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    45deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.news-item:hover::before {
  transform: translateX(100%);
}

.news-item:hover {
  transform: var(--hover-transform);
  box-shadow: var(--border-glow);
}

.news-category {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  color: white;
  font-size: 0.8rem;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.news-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1rem 0;
  cursor: pointer;
}

.news-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 1rem 0;
  line-height: 1.7;
}

.news-time {
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.news-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  margin: 0;
  display: flex;
  gap: 0.5rem;
}

.news-actions button {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.news-actions button:hover {
  color: var(--primary-color);
  background: rgba(0, 0, 0, 0.05);
}

.dark-mode .news-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* 로딩 & 알림 */
.loading-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.web-notification {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--card-background);
  color: var(--text-primary);
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  max-width: 300px;
  animation: slideIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.web-notification i {
  font-size: 1.1em;
}

.web-notification span {
  line-height: 1.2;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .news-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .category-buttons {
    padding: 0.5rem;
  }

  .category-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  :root {
    --container-padding: 0.75rem;
    --section-margin: 1rem;
  }

  .header-actions button {
    width: 2rem;
    height: 2rem;
  }

  :root {
    --content-max-width: 100%;
  }

  .header-content,
  .category-buttons,
  .trending-section,
  .news-container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

@media (min-width: 769px) {
  .news-container {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }
}

/* 가상화폐 가격 스타일 */
.crypto-prices {
  display: flex;
  gap: 0.75rem;
  margin-right: 1rem;
}

.crypto-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
}

.crypto-item::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 0.8rem;
  background: var(--card-background);
  color: var(--text-primary);
  font-size: 0.8rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 1000;
}

.crypto-item:hover::before {
  opacity: 1;
  visibility: visible;
}

/* 스크롤 버튼 스타일 */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary-color);
  color: white;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: none;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
  z-index: 1000;
}

.scroll-to-top:hover {
  transform: translateY(-2px);
  background: var(--secondary-color);
}

/* 새로고침 카운트다운 스타일 개선 */
.refresh-countdown {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-background);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  z-index: 1000;
}

/* 필터 태그 스일 수정 */
.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-gradient);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  margin-left: auto;
  height: fit-content;
}

.clear-filter {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 1rem;
}

.clear-filter:hover {
  opacity: 0.8;
}

#trending-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* 다크 모드 지원 */
.dark-mode {
  --background-color: #1a1a1a;
  --card-background: rgba(30, 30, 30, 0.8);
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --glass-effect: backdrop-filter: blur(12px);
  --border-glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

@media (max-width: 768px) {
  .crypto-prices {
    display: none; /* 모바일에서는 가상화폐 가격 숨김 */
  }

  .scroll-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* 헤더 액션 버튼 스타일 개선 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-actions button {
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-primary);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}

.header-actions button:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}

.header-actions button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 필터 태그 위치 수정 */
#active-filter-display {
  max-width: 1200px;
  margin: 0;
  display: inline-flex;
}

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

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

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

/* 로딩 애니메이션 개선 */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

.loading-message i {
  animation: pulse 1.5s infinite;
}

/* 새로운 기능: 뉴스 카드 북마크 버튼 */
.bookmark-btn {
  position: absolute;
  top: 0.75rem;
  right: 3rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  transition: all var(--animation-duration) ease;
}

.bookmark-btn.active {
  color: #fbbf24;
}

/* 새로�� 기능: 읽음 표시 */
.news-item.read {
  opacity: 0.7;
}

.news-item.read::after {
  content: "읽음";
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--card-background);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* 애니메이션 정의 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* 반응형 애니메이션 최적화 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 새로운 기능: 스크롤 프로그레스 바 */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary-gradient);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 1000;
}

/* 새로운 기능: 미지 프리뷰 */
.news-preview {
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  margin: -1.5rem -1.5rem 1rem;
}

.highlight {
  background-color: rgba(99, 102, 241, 0.2);
  padding: 0.1em 0.2em;
  border-radius: 3px;
  color: var(--primary-color);
  font-weight: 600;
}

.dark-mode .highlight {
  background-color: rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

.dark-mode .header {
  background: rgba(30, 30, 30, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-mode .header-actions button {
  border-color: var(--text-secondary);
}

.dark-mode .header-actions button:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

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

.skeleton {
  background: linear-gradient(
    90deg,
    var(--card-background) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    var(--card-background) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-title {
  height: 24px;
  width: 80%;
  margin-bottom: 1rem;
}

.skeleton-description {
  height: 16px;
  width: 100%;
  margin-bottom: 0.5rem;
}

.category-transition {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.category-enter {
  transform: translateY(20px);
  opacity: 0;
}

.category-enter-active {
  transform: translateY(0);
  opacity: 1;
}