/* ============================================================
   kafka — clean, minimal search UI
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f5;
  --border: #e9ecef;
  --border-focus: #cad1d8;
  --text-primary: #1a1a1a;
  --text-secondary: #5c6370;
  --text-muted: #8b929e;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #f0fdfa;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #242424;
  --border: #2e2e2e;
  --border-focus: #404040;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #6b7280;
  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-soft: #134e4a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Header
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
}

.site-logo-mark {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.site-name {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.settings-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.settings-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ============================================================
   Main Layout
   ============================================================ */

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ============================================================
   Homepage
   ============================================================ */

.page-home {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
}

.home-container {
  width: 100%;
  max-width: 640px;
  text-align: center;
}

.home-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.home-logo svg {
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.home-logo-text {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.home-tagline {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ============================================================
   Search Form
   ============================================================ */

.search-form {
  width: 100%;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input[type="text"] {
  width: 100%;
  padding: 1rem 3.5rem 1rem 1.25rem;
  font-size: 1.05rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.search-box input[type="text"]::placeholder {
  color: var(--text-muted);
}

.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

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

/* ============================================================
   Results Page
   ============================================================ */

.page-results {
  padding-top: 1.5rem;
}

.results-container {
  max-width: 768px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 56px;
  background: var(--bg);
  padding: 0.75rem 0;
  z-index: 50;
}

.results-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
}

.results-logo svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.results-logo span {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
}

.header-search {
  flex: 1;
}

.header-search .search-box input {
  padding: 0.65rem 2.5rem 0.65rem 1rem;
  font-size: 0.95rem;
}

.header-search .search-btn {
  width: 34px;
  height: 34px;
}

/* ============================================================
   Category Tabs
   ============================================================ */

.category-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.category-tab {
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.category-tab:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.category-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   Results Meta
   ============================================================ */

.results-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ============================================================
   Result Cards
   ============================================================ */

.result {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.result:last-child {
  border-bottom: none;
}

.result_header {
  margin-bottom: 0.2rem;
}

.result_header a {
  font-size: 1rem;
  font-weight: 500;
  color: #2563eb;
  text-decoration: none;
  line-height: 1.4;
}

.result_header a:hover {
  text-decoration: underline;
}

.result_url {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.result-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.result_url a {
  color: var(--text-muted);
  text-decoration: none;
}

.result_url a:hover {
  color: var(--accent);
}

.engine-badge {
  flex-shrink: 0;
  padding: 0.1rem 0.35rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.result_content {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ============================================================
   No Results
   ============================================================ */

.no-results {
  text-align: center;
  padding: 4rem 2rem;
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.no-results h2 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.no-results p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
  flex-wrap: wrap;
}

.pagination button,
.pagination form {
  display: inline-flex;
}

.pagination button {
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pagination button:hover {
  background: var(--bg-secondary);
  border-color: var(--border-focus);
}

.page-current {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

/* ============================================================
   Footer
   ============================================================ */

footer {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ============================================================
   Corrections
   ============================================================ */

.correction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

/* ============================================================
   Image Grid
   ============================================================ */

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.image-result {
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.image-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-meta {
  padding: 0.5rem;
}

.image-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-source {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ============================================================
   Video Results
   ============================================================ */

.video-result {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.video-result .result_thumbnail {
  flex-shrink: 0;
  width: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
}

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

/* ============================================================
   Back to Top
   ============================================================ */

.back-to-top {
  text-align: center;
  padding: 1rem;
}

.back-to-top a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.back-to-top a:hover {
  text-decoration: underline;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 600px) {
  .results-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .results-logo {
    display: none;
  }

  .category-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .category-tabs::-webkit-scrollbar {
    display: none;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
  }
}

/* ============================================================
   Preferences Page
   ============================================================ */

.preferences-container {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.preferences-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.preferences-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.pref-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.pref-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.pref-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.pref-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pref-row label:first-child {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.pref-row-info {
  flex: 1;
}

.pref-row-info label {
  font-weight: 500;
}

.pref-row select {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 120px;
}

.pref-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.theme-buttons {
  display: flex;
  gap: 0.5rem;
}

.theme-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn:hover {
  background: var(--bg-secondary);
}

.theme-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.engine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.engine-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.engine-toggle:hover {
  background: var(--bg-tertiary);
}

.engine-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.engine-toggle span {
  color: var(--text-secondary);
}

.pref-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .engine-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pref-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .pref-row select {
    width: 100%;
  }

  .pref-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    text-align: center;
  }
}
