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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #222;
  line-height: 1.5;
}

.container {
  max-width: 620px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* 상단 바 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

/* 입력 섹션 */
.input-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* 수집 옵션 체크박스 */
.collect-options {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
  flex-wrap: nowrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: #555;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #222;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* 공통 카드 */
.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
}

input[type="text"],
input[type="password"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

button {
  padding: 0.5rem 1.25rem;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: #444;
}

button:disabled {
  background: #999;
  cursor: not-allowed;
}

/* 프로그레스 */
#progress-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #222;
  width: 0%;
  transition: width 0.2s;
}

.progress-text {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.4rem;
}

/* 결과 */

.summary {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.8;
}

.summary strong {
  font-size: 1.1rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th, td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fafafa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
}

th.sortable:hover {
  background: #f0f0f0;
}

.sort-arrow {
  color: #2563eb;
  font-size: 0.75em;
  margin-left: 2px;
}

tr:hover td {
  background: #fafafa;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th:nth-child(2),
th:nth-child(3) {
  text-align: right;
  width: 8.2rem;
}
th:nth-child(4) {
  text-align: right;
  width: 3.5rem;
}
th:nth-child(5) {
  text-align: right;
  width: 3rem;
}

/* 헤더 서브텍스트 */
th:has(.th-sub) {
  white-space: normal;
}

.th-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: #888;
}

/* CTR 서브텍스트 */
.ctr-sub {
  font-size: 0.68rem;
  font-weight: 700;
  color: #e53e3e;
  line-height: 1.2;
  margin-top: 1px;
}

/* 경쟁도 5단계 */
.comp-highest, .comp-high, .comp-mid, .comp-low, .comp-lowest { font-weight: 600; font-size: 0.72rem; }
.comp-highest { color: #e53e3e; }
.comp-high { color: #dd6b20; }
.comp-mid { color: #d69e2e; }
.comp-low { color: #48bb78; }
.comp-lowest { color: #2b6cb0; }

/* 키워드 셀 말줄임 */
td:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 키워드 드릴다운 링크 */
.kw-link {
  color: #0066cc;
  cursor: pointer;
  text-decoration: none;
}

.kw-link:hover {
  text-decoration: underline;
}

.naver-link {
  font-size: 0.7rem;
  text-decoration: none;
  margin-left: 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.naver-link:hover {
  opacity: 1;
}

/* 탐색 이력 breadcrumb */
.breadcrumb {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.8;
}

.crumb-link {
  color: #0066cc;
  cursor: pointer;
}

.crumb-link:hover {
  text-decoration: underline;
}

.crumb-current {
  font-weight: 600;
  color: #222;
}

.crumb-sep {
  margin: 0 0.3rem;
  color: #aaa;
}

/* DataLab 트렌드 섹션 */

.filter-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  margin-right: 0.2rem;
}

.filter-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  background: #f5f5f5;
  color: #555;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: #eee;
  color: #222;
}

.filter-btn.active {
  background: #222;
  color: #fff;
  border-color: #222;
}

.chart-area {
  width: 100%;
  height: 200px;
  position: relative;
}

.chart-area canvas {
  width: 100%;
  height: 100%;
}

.datalab-status {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.4rem;
  text-align: center;
}

.ctr-footnote {
  color: #aaa;
  font-size: 0.78rem;
  margin-top: 0.75rem;
}

.copyright {
  text-align: center;
  color: #999;
  font-size: 0.75rem;
  padding: 2rem 0 1rem;
}

/* 자동완성 드롭다운 */
.ac-wrapper {
  position: relative;
  flex: 1;
}

.ac-wrapper input {
  width: 100%;
}

.ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ac-dropdown li {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ac-dropdown li::before {
  content: "🔍";
  font-size: 0.75rem;
  opacity: 0.4;
}

.ac-dropdown li:hover,
.ac-dropdown li.ac-active {
  background: #f0f4ff;
}


.hidden {
  display: none;
}

/* related-section은 이제 독립 .card */

.related-hashtags {
  color: #aaa;
  font-size: 0.78rem;
  margin-top: 0.5rem;
  line-height: 1.8;
}

@keyframes row-flash-anim {
  0%   { background: #fff9c4; }
  100% { background: transparent; }
}

.row-flash {
  animation: row-flash-anim 1.5s ease-out forwards;
}

/* 출처 범례 */
.src-legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: #666;
  margin-top: 0.4rem;
}

.src-filter {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}

.src-filter:hover {
  opacity: 0.7;
}
