:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1a1f2c;
  --muted: #65708b;
  --primary: #3182f6;
  --border: #e8ecf4;
  --chip-bg: #ffffff;
  --tag-bg: #f0f3f9;
  --tag-text: #42506d;
  --shadow: 0 8px 20px rgba(22, 34, 58, 0.05);
  --watch-bg: #ff3b30;
  --watch-hover: #e02d23;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #111827;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --border: #1f2937;
  --chip-bg: #0b1220;
  --tag-bg: #172033;
  --tag-text: #dbeafe;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  --watch-bg: #ef4444;
  --watch-hover: #dc2626;
}

:root[data-theme="pink"] {
  color-scheme: light;
  --bg: #fff1f7;
  --card: #ffffff;
  --text: #4a1630;
  --muted: #8c4d69;
  --primary: #e75480;
  --border: #f7c8da;
  --chip-bg: #fff7fb;
  --tag-bg: #ffe0ec;
  --tag-text: #8c2f58;
  --shadow: 0 10px 24px rgba(231, 84, 128, 0.16);
  --watch-bg: #ff4f87;
  --watch-hover: #eb3c75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  color: var(--text);
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero-card,
.toolbar-card,
.detail-card,
.rank-card {
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 20px;
  margin-bottom: 16px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.platform-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.platform-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.platform-button.active {
  background: color-mix(in srgb, var(--primary) 16%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
  color: var(--primary);
}

h1 {
  margin: 8px 0;
  font-size: 28px;
  line-height: 1.2;
}

.subcopy {
  margin: 0;
  color: var(--muted);
}

.hero-card .subcopy + .subcopy {
  margin-top: 8px;
}

.toolbar-card {
  padding: 16px;
  margin-bottom: 20px;
}

.toolbar-block + .toolbar-block {
  margin-top: 14px;
}

.toolbar-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-toggle {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
}

.search-button {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--text);
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.chip.active,
.search-button {
  background: color-mix(in srgb, var(--primary) 16%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
  color: var(--primary);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
}

#result-count {
  color: var(--muted);
  font-size: 14px;
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.rank-card {
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rank-card:hover,
.rank-card.active {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(24, 35, 56, 0.08);
}

.rank-card.active {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

.rank-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.rank-no {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.growth {
  color: #109769;
  font-weight: 800;
}

.rank-meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  font-weight: 600;
}

.detail-card {
  padding: 20px;
}

.inline-detail {
  margin-top: -2px;
  margin-bottom: 12px;
}

.placeholder {
  margin: 0;
  color: var(--muted);
}

.insight-copy {
  margin: 14px 0 0;
  color: var(--text);
  line-height: 1.5;
}

.watch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--watch-bg);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.watch-button:hover {
  background: var(--watch-hover);
}

.growth-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.growth-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.growth-head h3 {
  margin: 0;
  font-size: 16px;
}

.growth-note {
  color: var(--muted);
  font-size: 12px;
}

.growth-bars {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.growth-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.growth-step strong {
  color: var(--text);
  font-size: 12px;
}

.growth-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 999px 999px 8px 8px;
  background: linear-gradient(180deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 50%, var(--card)) 100%);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.kpi {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  margin: 4px 0 0;
  font-weight: 700;
}

@media (max-width: 640px) {
  .hero-top {
    flex-direction: column;
  }

  .search-form {
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .growth-head {
    flex-direction: column;
  }
}
