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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #252836;
  --border: #2e3144;
  --text: #e4e4e7;
  --text-dim: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Auth Page */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 400px;
  max-width: 90vw;
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

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

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

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

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-bar-left {
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.top-bar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.import-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-right: 4px;
}

.processing-status {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 12px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.usage-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.usage-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* Progress bar for processing */
.progress-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-title {
  font-size: 14px;
  font-weight: 500;
}

.progress-count {
  font-size: 13px;
  color: var(--text-dim);
}

.progress-bar-bg {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-status {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-status .spinner {
  width: 12px;
  height: 12px;
}

/* PDF Processing Indicator */
.pdf-processing-indicator {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pdf-processing-indicator .spinner-large {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.pdf-processing-indicator .pdf-status-text {
  flex: 1;
}

.pdf-processing-indicator .pdf-status-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.pdf-processing-indicator .pdf-status-subtitle {
  font-size: 12px;
  color: var(--text-dim);
}

/* Mind map toggle */
.mindmap-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.toggle-btn.active {
  background: var(--accent);
  color: white;
}

.toggle-btn svg {
  flex-shrink: 0;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-bottom: 10px;
}

.search-input:focus {
  border-color: var(--accent);
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sort-select {
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.sort-select:focus {
  border-color: var(--accent);
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.page-btn {
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: 12px;
  color: var(--text-dim);
}

.article-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.article-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.article-item:hover {
  background: var(--surface2);
}

.article-item.selected {
  background: var(--surface2);
  border-color: var(--accent);
}

.article-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.article-title {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.relevance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.relevance-dot.relevant { background: var(--green); }
.relevance-dot.not_relevant { background: var(--red); }
.relevance-dot.unreviewed { background: var(--text-dim); opacity: 0.4; }

.relevance-btns {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.rel-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}

.rel-btn:hover { border-color: var(--text-dim); }
.rel-btn.active-green { background: var(--green); border-color: var(--green); color: white; }
.rel-btn.active-red { background: var(--red); border-color: var(--red); color: white; }
.rel-btn.del-btn { font-size: 14px; }
.rel-btn.del-btn:hover { border-color: var(--red); color: var(--red); }

.article-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.article-btns {
  display: flex;
  gap: 4px;
}

.small-btn {
  padding: 3px 8px;
  font-size: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.small-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
}

.pdf-indicator {
  margin-left: auto;
  font-size: 12px;
}

/* Mind Map Area */
.mindmap-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.mindmap-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 15px;
}

#mindmap-svg {
  width: 100%;
  height: 100%;
}

.node text {
  font-size: 13px;
  fill: var(--text);
}

.node circle {
  stroke-width: 2px;
}

.link {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5px;
}

/* Legend */
.legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
}

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

.legend-item:last-child { margin-bottom: 0; }

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Markmap controls */
.markmap-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.markmap-controls .btn {
  padding: 4px 10px;
  font-size: 11px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: flex;
}

/* Welcome / Import / Processing screens */
.center-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 500px;
  max-width: 90vw;
  text-align: center;
}

.card h2 {
  margin-bottom: 8px;
}

.card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 20px;
}

.source-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.source-btn {
  padding: 12px 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.source-btn:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.warning-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: var(--yellow);
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 20px;
}

.preview-list {
  text-align: left;
  max-height: 250px;
  overflow-y: auto;
  margin: 16px 0;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius);
  font-size: 13px;
}

.preview-list li {
  padding: 4px 0;
  list-style: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

.preview-list li:last-child { border-bottom: none; }

/* Processing screen */
.progress-list {
  text-align: left;
  margin: 16px 0;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

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

.status-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-counter {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 16px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Hidden file input */
.hidden-input {
  display: none;
}
