/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface-hover: #f1f3f5;
  --border: #e9ecef;
  --text: #1a1a1a;
  --text-muted: #6c757d;
  --accent: #1f6b54;
  --accent-light: rgba(31,107,84,0.08);
  --up: #0f7b5f;
  --up-bg: rgba(15,123,95,0.07);
  --down: #c92a2a;
  --down-bg: rgba(201,42,42,0.06);
  --warn: #e67700;
  --warn-bg: rgba(230,119,0,0.08);
  --new: #868e96;
  --radius: 10px;
  --radius-sm: 6px;
  --max-w: 1040px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* === Header === */
.header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
}
.header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header__link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.15s;
}
.header__link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.header__sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 1.25rem 0 0.75rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* === Content === */
.content {
  padding-bottom: 2rem;
  min-height: 300px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  padding: 4rem 0;
  font-size: 0.9rem;
}
.loading__spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Panel === */
.panel { animation: fadeIn 0.2s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.panel__title {
  font-size: 1.1rem;
  font-weight: 600;
}
.panel__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.badge--time {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge--degraded, .badge--stale {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(230,119,0,0.2);
}
.badge--ok {
  background: var(--up-bg);
  color: var(--up);
  border: 1px solid rgba(15,123,95,0.15);
}

/* === Item List === */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.item-card:hover { background: var(--surface); text-decoration: none; }
.item-card[href] { cursor: pointer; }

.item-rank {
  flex-shrink: 0;
  width: 1.8rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.item-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1rem;
  overflow: hidden;
}
.item-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.item-icon__initial {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 1;
}

.item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.item-name {
  font-size: 0.88rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-chip {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}

.item-value {
  flex-shrink: 0;
  text-align: right;
  min-width: 70px;
}
.item-value__num {
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.item-value__change {
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 0.1rem;
}
.item-value__change.up { color: var(--up); }
.item-value__change.down { color: var(--down); }
.item-value__change.neutral { color: var(--new); }

/* Keyword-only row (google_trends) */
.item-card--keyword { padding-left: 0; }
.item-card--keyword .item-info--keyword {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

/* === Radar Toggle === */
.radar-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-left: 0.5rem;
}
.radar-toggle__btn {
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.radar-toggle__btn:first-child { border-right: 1px solid var(--border); }
.radar-toggle__btn.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* === Insight Section === */
.insight-list { display: flex; flex-direction: column; }
.insight-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.insight-item:last-child { border-bottom: none; }
.insight-item__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.insight-item__type {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
}
.insight-item__date {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.insight-item__title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.5;
}
.insight-item__body {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 0.3rem;
  white-space: pre-line;
}

/* === YouTube Inline Thumbnail === */
.item-thumb {
  flex-shrink: 0;
  width: 88px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state__icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}
.empty-state__msg {
  font-size: 0.88rem;
}

/* News items */
.news-list { display: flex; flex-direction: column; }
.news-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.news-item:last-child { border-bottom: none; }
.news-item__source {
  flex-shrink: 0;
  font-size: 0.68rem; font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  min-width: 52px;
  text-align: center;
}
.news-item__body { flex: 1; min-width: 0; }
.news-item__title { font-size: 0.85rem; font-weight: 500; line-height: 1.4; }
.news-item__title a { color: var(--text); text-decoration: none; }
.news-item__title a:hover { color: var(--accent); }
.news-item__time { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }

/* === Footer === */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  margin-top: 2rem;
}
.footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  text-align: center;
}
.footer__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.8rem;
  margin-bottom: 0.6rem;
}
.footer__links a { color: var(--text-muted); }
.footer__links a:hover { color: var(--accent); }
.footer__copy { font-size: 0.72rem; color: var(--text-muted); }

/* === Responsive === */
@media (max-width: 640px) {
  .header { padding: 1rem; }
  .header__title { font-size: 1.25rem; }
  .header__nav { gap: 0.3rem; }
  .header__link { font-size: 0.72rem; padding: 0.3rem 0.55rem; }
  .wrap { padding: 0 0.75rem; }
  .tabs { gap: 0.3rem; padding: 1rem 0 0.5rem; }
  .tab-btn { padding: 0.45rem 0.75rem; font-size: 0.78rem; }
  .item-card { padding: 0.65rem 0.75rem; gap: 0.6rem; }
  .item-icon { width: 24px; height: 24px; font-size: 0.85rem; }
  .item-rank { width: 1.5rem; font-size: 0.72rem; }
  .item-name { font-size: 0.82rem; }
  .item-value { min-width: 56px; }
  .item-value__num { font-size: 0.82rem; }
  .item-thumb { width: 64px; height: 36px; }
  .panel__header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .panel__meta { margin-left: 0; }
}

/* === Trust pages === */
.page { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem; }
.page h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1rem; color: var(--accent); }
.page h2 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.page p, .page li { font-size: 0.9rem; line-height: 1.7; color: var(--text); margin-bottom: 0.5rem; }
.page ul { padding-left: 1.2rem; }
.page a { color: var(--accent); }
