/* Enhanced black & white theme for SPA */
:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #e5e5e5;
  --surface: #fafafa;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  max-width: 1200px;
  margin: 0 auto 24px;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

main {
  max-width: 1200px;
  margin: 0 auto;
}

/* Source Toggle */
.source-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--surface);
  border-radius: 12px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.toggle-container {
  position: relative;
  cursor: pointer;
}

.toggle-container input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-label {
  display: block;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 200ms ease;
  color: var(--muted);
}

.toggle-container input[type="radio"]:checked + .toggle-label {
  background: var(--text);
  color: white;
}

/* Search Container */
.search-container {
  position: relative;
  max-width: 500px;
  margin: 0 auto 32px;
}

#search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  transition: all 200ms ease;
  outline: none;
}

#search-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.1);
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
}

.search-dropdown.hidden {
  display: none;
}

.dropdown-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f2f2f2;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--surface);
}

.dropdown-item-term {
  font-weight: 500;
  margin-bottom: 2px;
}

.dropdown-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.dropdown-no-results {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* Content Area */
#content-area {
  min-height: 400px;
}

.welcome-message {
  text-align: center;
  margin-top: 60px;
  padding: 40px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.welcome-message h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
}

.welcome-message p {
  margin: 8px 0;
  color: var(--muted);
}

/* Loading indicator */
.loading {
  text-align: center;
  margin: 40px 0;
}

.loading.hidden {
  display: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Compare layout (when loaded dynamically) */
.term-header {
  text-align: center;
  margin-bottom: 10px;
  padding: 16px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.term-header h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
}

.term-meta {
  color: var(--muted);
  font-size: 14px;
}

/* Viewing Options */
.viewing-options {
  margin: 8px auto 16px;
  padding: 6px 16px;
  background: transparent;
  border-radius: 8px;
  max-width: 1200px;
}

.option-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sync-toggle-container {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  flex-direction: row-reverse;
}

.sync-toggle-container input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sync-toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #e5e5e5;
  border-radius: 12px;
  transition: background-color 200ms ease;
}

.sync-toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sync-toggle-container input[type="checkbox"]:checked + .sync-toggle-slider {
  background: var(--text);
}

.sync-toggle-container input[type="checkbox"]:checked + .sync-toggle-slider::before {
  transform: translateX(20px);
}

.sync-toggle-container input[type="checkbox"]:disabled + .sync-toggle-slider {
  background: #f0f0f0;
  cursor: not-allowed;
}

.sync-toggle-container input[type="checkbox"]:disabled + .sync-toggle-slider::before {
  background: #d0d0d0;
}

.sync-toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.sync-toggle-container input[type="checkbox"]:disabled ~ .sync-toggle-label {
  color: var(--muted);
  cursor: not-allowed;
}

.term-actions {
  margin-top: 12px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 4px;
  font-size: 13px;
  border: 1px solid var(--text);
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 150ms ease;
}

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

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 10px;
}

.viewer-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.viewer-header {
  padding: 16px;
  background: var(--surface);
  font-weight: 600;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}

.canvas-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f8f9fa;
}

.viewer-card canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-info {
  padding: 12px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.coordinates {
  padding: 8px 16px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  min-height: 20px;
}

.download-row {
  padding: 12px 16px;
  text-align: center;
}

.download-btn {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--text);
  color: white;
  cursor: pointer;
  transition: all 150ms ease;
}

.download-btn:hover {
  background: #000000;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }
  
  .source-toggle {
    flex-direction: column;
    width: 100%;
  }
  
  .toggle-label {
    text-align: center;
  }
  
  .compare-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .welcome-message {
    padding: 24px;
    margin-top: 40px;
  }
}