:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-active: #6366f1;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-primary: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --color-up: #ef4444;
  --color-down: #3b82f6;
  --color-same: #94a3b8;
  --color-new: #10b981;
  --color-hot: #f59e0b;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Pretendard", "Noto Sans KR", sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -3px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  animation: none;
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.brand-text p {
  font-size: 13px;
  color: var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Language Selector */
.lang-selector-wrapper {
  position: relative;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.lang-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 200px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lang-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.lang-dropdown-header {
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lang-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.lang-option:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.lang-option.active {
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent-primary);
  font-weight: 700;
}

.lang-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.lang-ext-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-size: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.lang-ext-link:hover {
  background: rgba(99, 102, 241, 0.06);
}

/* Hide Google Translate top banner if loaded */
.goog-te-banner-frame { display: none !important; }
body { top: 0px !important; }

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
  animation: blink 2s infinite;
}

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

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-refresh:active {
  transform: translateY(0);
}

.btn-refresh.loading svg {
  animation: spin 1s linear infinite;
}

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

/* Info Bar & Quick Stats */
.hero-banner {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-left h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.hero-left p {
  font-size: 13px;
  color: var(--text-muted);
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 24px;
}

.stat-item {
  text-align: right;
}

.stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search & Tabs Controls */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.search-input::placeholder {
  color: var(--text-dim);
}

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

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* Platform Nav Tabs */
.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.tab-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.tab-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

/* Grid layout for Platforms & Trends */
.trends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.platform-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.platform-card:hover {
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.platform-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.platform-icon {
  font-size: 20px;
}

.platform-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.platform-tag {
  font-size: 11px;
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Trend List */
.trend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.trend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-main);
  transition: var(--transition);
  position: relative;
}

.trend-item:hover {
  background: #f8fafc;
  border-color: var(--border-subtle);
  transform: translateX(3px);
}

.trend-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.rank-badge {
  font-size: 12px;
  font-weight: 800;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--text-muted);
  flex-shrink: 0;
}

.trend-item:nth-child(1) .rank-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}
.trend-item:nth-child(2) .rank-badge {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
}
.trend-item:nth-child(3) .rank-badge {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

.trend-keyword {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.trend-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.traffic-pill {
  font-size: 11px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.state-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.state-up {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.08);
}
.state-down {
  color: #2563eb;
  background: rgba(59, 130, 246, 0.08);
}
.state-new {
  color: #059669;
  background: rgba(16, 185, 129, 0.08);
}
.state-hot {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
}
.state-same {
  color: var(--text-dim);
}

/* Quick Copy Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 0.3s ease;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Sources Section */
.sources-card {
  margin-top: 40px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.sources-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sources-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.sources-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.sources-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 20px;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.source-item {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: var(--transition);
}

.source-item:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.link-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.link-card:hover {
  transform: translateY(-2px);
  background: #f1f5f9;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-card-hover);
}

.source-icon {
  font-size: 20px;
  line-height: 1;
}

.source-item h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

.source-item p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.sources-disclaimer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* Footer */
footer {
  margin-top: 48px;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 13px;
}

@media (max-width: 768px) {
  .hero-stats {
    width: 100%;
    justify-content: space-between;
  }
  .trends-grid {
    grid-template-columns: 1fr;
  }
}
