/* === MATRXIA — Design System === */
:root {
  --bg: #e8e8e8;
  --surface: #f2f2f2;
  --border: #e2e2de;
  --border-hover: #c4c4be;
  --text-primary: #1a1a18;
  --text-secondary: #5a5a56;
  --text-muted: #9a9a94;
  --accent: #1a56e8;
  --accent-light: #eef2ff;
  --accent-hover: #1446d0;
  --green: #059669;
  --green-light: #ecfdf5;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --red: #dc2626;
  --logo-m: #1a56e8;
  --logo-a: #1a56e8;
  --logo-t: #ffffff;
  --logo-r: #ffffff;
  --logo-x: #ef4444;
  --logo-i: #ef4444;
  --logo-a2: #0055A4;
  --radius: 24px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.06);
}

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

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* === HOMEPAGE === */

.home-page { display: flex; flex-direction: column; min-height: 100vh; }

.home-header { padding: 16px 24px; }

.top-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
}

.top-nav .nav-links { display: flex; gap: 16px; }

.top-nav a {
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.top-nav a:hover { color: var(--text-primary); }

.btn-sign {
  padding: 8px 20px;
  background: var(--accent);
  color: white !important;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}

.btn-sign:hover { background: var(--accent-hover) !important; transform: translateY(-1px); }

.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  margin-top: -60px;
}

/* Logo */
.logo-wrap { text-align: center; margin-bottom: 32px; }

.logo-mark {
  font-family: 'Syne', sans-serif;
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  display: inline-block;
  user-select: none;
  animation: logoReveal 0.8s ease-out both;
}

@keyframes logoReveal {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-mark span {
  display: inline-block;
  transition: transform 0.2s;
}

.logo-mark:hover span { animation: letterBounce 0.4s ease forwards; }
.logo-mark span:nth-child(1) { animation-delay: 0.05s; }
.logo-mark span:nth-child(2) { animation-delay: 0.1s; }
.logo-mark span:nth-child(3) { animation-delay: 0.15s; }

.m1 { color: var(--logo-m); }
.a1 { color: var(--logo-a); }
.t1 { color: var(--logo-t); }
.r1 { color: var(--logo-r); }
.x1 { color: var(--logo-x); }
.i1 { color: var(--logo-i); }
.a2 { color: var(--logo-a2); }

.tagline {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 300;
  letter-spacing: 0.02em;
  animation: fadeIn 1s ease-out 0.3s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Search Form */
.search-form {
  width: 100%;
  max-width: 584px;
  animation: fadeIn 0.6s ease-out 0.2s both;
}

.search-container {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 20px;
  height: 52px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.search-container:focus-within {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}

.search-icon { color: var(--text-muted); flex-shrink: 0; display: flex; }

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--text-primary);
}

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

.voice-icon {
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
}

.voice-icon:hover { background: var(--accent-light); }

/* Suggestions */
.suggestions-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-top: -8px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.1s;
}

.suggestion-item:hover { background: var(--bg); }

/* Search Buttons */
.search-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}

.btn-search {
  padding: 10px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.btn-search:hover {
  background: #f0f0ec;
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

.btn-secondary { }

/* Recent */
.recent-searches {
  margin-top: 36px;
  text-align: center;
}

.recent-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.recent-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.recent-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.recent-item:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Footer Home */
.home-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
}

.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-secondary); transition: color 0.15s; }
.footer-links a:hover { color: var(--text-primary); }

/* === RESULTS PAGE === */

.results-page { background: var(--bg); }

.results-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
}

.results-logo {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #1a56e8, #8b5cf6, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.results-search-form { flex: 1; max-width: 640px; }

.results-search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 0 16px;
  height: 44px;
  gap: 10px;
  transition: all 0.2s;
}

.results-search-wrap:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.search-icon-sm { color: var(--text-muted); display: flex; flex-shrink: 0; }

.results-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
}

.results-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.results-search-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

.header-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.tool-link { font-size: 13px; color: var(--text-secondary); transition: color 0.15s; }
.tool-link:hover { color: var(--text-primary); }

/* Filters Bar */
.filters-bar {
  border-top: 1px solid var(--border);
  padding: 0 24px 0 calc(24px + 26px + 24px + 640px + 24px);
  overflow-x: auto;
}

.filters-inner { display: flex; gap: 0; min-width: max-content; }

.filter-tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-tab:hover { color: var(--accent); }
.filter-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* Results Layout */
.results-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  gap: 40px;
}

.results-main { flex: 1; min-width: 0; max-width: 660px; }

/* Skeleton Loading */
.skeleton-summary {
  height: 100px;
  background: linear-gradient(90deg, #e8e8e4 25%, #f0f0ec 50%, #e8e8e4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.results-meta-skeleton {
  height: 16px;
  width: 200px;
  background: linear-gradient(90deg, #e8e8e4 25%, #f0f0ec 50%, #e8e8e4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  margin-bottom: 24px;
}

.skeleton-card { margin-bottom: 28px; }

.sk-line {
  height: 14px;
  background: linear-gradient(90deg, #e8e8e4 25%, #f0f0ec 50%, #e8e8e4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 7px;
  margin-bottom: 8px;
}

.sk-url { width: 30%; height: 12px; }
.sk-title { width: 80%; height: 18px; }
.sk-desc { width: 100%; }
.sk-short { width: 60%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* AI Summary */
.ai-summary {
  background: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.ai-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.65;
  margin-bottom: 10px;
}

.ai-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-points li {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.ai-points li::before {
  content: '→';
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 600;
  margin-top: 1px;
}

/* Meta */
.results-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.meta-time { font-style: italic; }

/* Result Items */
.result-item {
  margin-bottom: 28px;
  animation: resultIn 0.3s ease-out both;
}

@keyframes resultIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-item:nth-child(2) { animation-delay: 0.05s; }
.result-item:nth-child(3) { animation-delay: 0.1s; }
.result-item:nth-child(4) { animation-delay: 0.15s; }
.result-item:nth-child(5) { animation-delay: 0.2s; }
.result-item:nth-child(6) { animation-delay: 0.25s; }

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

.favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.source-info { display: flex; flex-direction: column; line-height: 1.2; }

.source-domain {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

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

.more-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 50%;
  transition: background 0.15s;
  display: none;
}

.result-item:hover .more-btn { display: block; }
.more-btn:hover { background: var(--bg); }

.result-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.35;
}

.result-title a { color: #1558d6; transition: color 0.15s; }
.result-title a:hover { color: var(--accent-hover); text-decoration: underline; }

.result-snippet {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-tags { display: flex; gap: 6px; }

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: capitalize;
}

.badge-green { background: var(--green-light); color: var(--green); }
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-gray { background: #f0f0ec; color: var(--text-muted); }
.tag-cat { background: #f5f5f1; color: var(--text-muted); }

/* No Results */
.no-results {
  text-align: center;
  padding: 60px 24px;
}

.no-results-icon { font-size: 48px; margin-bottom: 16px; }

.no-results h3 {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.no-results p { font-size: 14px; color: var(--text-secondary); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
  padding: 20px 0;
}

.page-btn {
  padding: 10px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--accent);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.page-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

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

/* Knowledge Card (Aside) */
.results-aside { width: 300px; flex-shrink: 0; padding-top: 4px; }

.knowledge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 120px;
}

.knowledge-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.knowledge-img-placeholder {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, var(--accent-light), #f0fdf4);
  border-radius: 12px;
  margin-bottom: 12px;
}

.knowledge-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 16px;
}

.knowledge-facts { border-top: 1px solid var(--border); padding-top: 12px; }

.fact-row {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.fact-row:last-child { border-bottom: none; }

.fact-key {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

.fact-val { color: var(--text-primary); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Responsive */
@media (max-width: 768px) {
  .logo-mark { font-size: 52px; }
  .results-aside { display: none !important; }
  .results-layout { padding: 16px; }
  .header-tools { display: none; }
  .filters-bar { padding-left: 24px; }
  .filters-inner { gap: 0; }
  .filter-tab { padding: 10px 12px; font-size: 13px; }
  .home-footer { flex-direction: column; gap: 12px; text-align: center; }
}
