:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --border-color: #334155;
  --success: #22c55e;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --border-color: #e2e8f0;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Styling */
#sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  transition: all 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2rem;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.nav-item {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: 0.2s;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent);
}

.history-section {
  flex: 1;
  overflow-y: auto;
}

.history-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background-color: var(--border-color);
  color: var(--text-main);
}

/* Main Content Workspace */
#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

header {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background-color: var(--bg-secondary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle, .btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

/* Container & Search */
.container {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
}

.search-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
}

.search-input-wrapper {
  display: flex;
  gap: 1rem;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 1rem;
  resize: none;
  height: 60px;
}

.search-filters {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

select {
  background-color: var(--bg-primary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* Research Content Output */
.results-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--card-shadow);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.source-card {
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 8px;
  background-color: var(--bg-primary);
}

.source-card a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  border-radius: 4px;
  margin-top: 0.5rem;
}

/* Progress Spinner */
.loader-container {
  display: none;
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Timeline Layout */
.timeline {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  margin-left: 0.5rem;
}

.timeline-event {
  margin-bottom: 1.5rem;
  position: relative;
}

.timeline-event::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  left: -1.4rem;
  top: 6px;
}

/* Responsive Styles */
@media (max-width: 768px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
  #workspace { height: 100vh; }
}