:root {
  --bg-primary: #0f1219;
  --bg-secondary: #161b26;
  --bg-card: #1a2030;
  --bg-card-hover: #1e2538;
  --bg-input: #1a2030;
  --border: #252d3d;
  --border-light: #2a3348;
  --text-primary: #e2e8f0;
  --text-secondary: #8892a6;
  --text-muted: #5a6478;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim: rgba(59, 130, 246, 0.15);
  --orange: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --brave-orange: #fb542b;
  --json-key: #7dd3fc;
  --json-string: #fbbf24;
  --json-number: #a78bfa;
  --json-bool: #f87171;
  --json-null: #5a6478;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  height: 56px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.logo-dots {
  display: flex;
  gap: 3px;
}

.logo-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.logo-dots span:nth-child(1) { background: #3b82f6; }
.logo-dots span:nth-child(2) { background: #f59e0b; }
.logo-dots span:nth-child(3) { background: #10b981; }
.logo-dots span:nth-child(4) { background: #ef4444; }

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

.engine-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.engine-pill.brave_json { background: rgba(251, 84, 43, 0.12); color: #fb8c6b; }
.engine-pill.brave_html { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.engine-pill.bing { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; }

.timing {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.timing strong {
  color: var(--accent);
}

/* ===== TABS ===== */
.tab-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-item:hover {
  color: var(--text-secondary);
}

.tab-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-icon {
  font-size: 14px;
  opacity: 0.7;
}

.tab-item.active .tab-icon {
  opacity: 1;
}

.tab-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.tab-item.active .tab-count {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ===== SEARCH BAR ===== */
.search-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 560px;
}

.search-input-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

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

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

.search-btn {
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-btn:hover { background: var(--accent-hover); }

.search-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== MAIN SPLIT LAYOUT ===== */
.main {
  display: flex;
  height: calc(100vh - 56px - 46px - 56px);
  overflow: hidden;
}

.panel {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel-results {
  flex: 1;
  padding: 20px 28px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.panel-json {
  flex: 1;
  padding: 16px 20px;
  background: var(--bg-secondary);
  min-width: 0;
}

/* ===== RESULT CARDS ===== */
.result-card {
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.result-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.result-favicon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-weight: 600;
}

.result-url-block {
  min-width: 0;
}

.result-site {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
}

.result-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-title {
  font-size: 15px;
  font-weight: 600;
  color: #7bb8ff;
  line-height: 1.4;
  margin-bottom: 6px;
  cursor: pointer;
}

.result-title:hover {
  text-decoration: underline;
}

.result-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-rank {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-primary);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  right: 8px;
}

.result-card {
  position: relative;
}

/* ===== NEWS CARD ===== */
.news-card {
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  gap: 14px;
  transition: background 0.15s;
}

.news-card:hover { background: var(--bg-card-hover); }

.news-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: var(--border);
  flex-shrink: 0;
  object-fit: cover;
}

.news-body { min-width: 0; flex: 1; }

.news-title {
  font-size: 14px;
  font-weight: 600;
  color: #7bb8ff;
  line-height: 1.4;
  margin-bottom: 4px;
}

.news-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.news-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-source {
  color: var(--orange);
  font-weight: 600;
}

/* ===== VIDEO CARD ===== */
.video-card {
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  gap: 14px;
  transition: background 0.15s;
}

.video-card:hover { background: var(--bg-card-hover); }

.video-thumb-wrap {
  position: relative;
  width: 120px;
  height: 68px;
  flex-shrink: 0;
}

.video-thumb {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: var(--border);
  object-fit: cover;
}

.video-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
}

.video-body { min-width: 0; flex: 1; }

.video-title {
  font-size: 14px;
  font-weight: 600;
  color: #7bb8ff;
  line-height: 1.4;
  margin-bottom: 4px;
}

.video-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.video-creator {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== JSON PANEL ===== */
.json-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.json-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.json-copy {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.json-copy:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.json-view {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.json-view .key { color: var(--json-key); }
.json-view .string { color: var(--json-string); }
.json-view .number { color: var(--json-number); }
.json-view .bool { color: var(--json-bool); }
.json-view .null { color: var(--json-null); }

/* ===== SKELETON ===== */
.skeleton-card {
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.skeleton-line {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  margin-bottom: 10px;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.w40 { width: 40%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w100 { width: 100%; }
.skeleton-line.title { height: 14px; background: rgba(59, 130, 246, 0.15); }
.skeleton-line.url { height: 8px; margin-bottom: 12px; }

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

.skeleton-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
  padding: 40px;
}

.empty-state svg {
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
  text-align: center;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main { flex-direction: column; }
  .panel-results { border-right: none; border-bottom: 1px solid var(--border); }
}
