:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --secondary-color: #8b5cf6;
  --accent-color: #ec4899;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --dark-bg: #0f172a;
  --dark-bg-secondary: #1e293b;
  --dark-bg-tertiary: #334155;
  --card-bg: #1e293b;
  --card-bg-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #334155;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
}

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html,
body,
.page-wrapper {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--dark-bg);
  color: var(--text-primary);
  line-height: 1.6;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
}

.container.main-content {
  flex: 1;
  max-width: 95%;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  padding: 1rem;
  overflow: hidden;
  box-sizing: border-box;
}

main {
  height: 100%;
}

h1 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.2;
}

.btn {
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-size: 1rem;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  color: white;
}

.btn:focus,
.form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
  outline: none;
}

.card {
  background: var(--card-bg);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.form-control {
  border-radius: 0.5rem;
  border: 2px solid var(--border-color);
  padding: 0.75rem 1rem;
  background: var(--dark-bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--primary-color);
  background: var(--dark-bg-tertiary);
  color: var(--text-primary);
}

.form-control::placeholder {
  color: #64748b;
}

.search-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  height: 100%;
  min-height: 0;
}

.search-left {
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  padding-right: 0.25rem;
}

.search-right {
  min-height: 0;
  height: 100%;
}

.search-panel {
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.search-panel:hover,
.search-pdf-pane:hover,
.search-hit:hover {
  transform: none;
}

.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.search-bar .form-control {
  flex: 1;
}

.search-bar .btn {
  white-space: nowrap;
  min-width: 8rem;
}

.search-status {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.search-status.error {
  color: var(--danger-color);
}

.search-hit {
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.search-hit.selected {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
}

.search-hit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.search-hit-meta span {
  background: var(--dark-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.search-hit-score {
  background: var(--primary-color) !important;
  color: white !important;
  border-color: var(--primary-color) !important;
}

.search-hit-content {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.search-hit-path {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.search-pdf-pane {
  height: 100%;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

.pdf-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.search-pdf-pane.has-pdf .pdf-placeholder {
  display: none !important;
}

.search-pdf-pane iframe {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--dark-bg);
}

.search-pdf-pane.has-pdf iframe {
  display: block;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--dark-bg-tertiary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .search-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 45vh;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-right {
    height: 45vh;
  }

  .search-panel {
    padding: 1.25rem;
  }
}
