:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --success: #22c55e;
  --danger: #ef4444;
  --bg: #0b1117;
  --surface: #161b22;
  --surface-2: #1f2937;
  --border: #2a313c;
  --text: #f9fafb;
  --text-secondary: #9ca3af;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.container-xl {
  position: relative;
  z-index: 1;
  max-width: 1400px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

.user-badge {
  padding: 0.5rem 1rem;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.auth-section {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

.auth-tab:not(.active):hover {
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 0.875rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.form-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.form-hint,
.form-error {
  margin: 0;
  font-size: 0.8125rem;
}

.form-hint {
  color: var(--text-secondary);
}

.form-error {
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 8px;
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger:hover {
  color: var(--danger);
}

.btn-icon.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.workspace {
  padding: 0;
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.breadcrumb-item {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.breadcrumb-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.breadcrumb-item.active {
  background: var(--primary);
  color: white;
}

.breadcrumb-sep {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.view-section {
  animation: fadeIn 0.3s ease;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.view-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.view-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.create-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.create-form h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.import-status {
  margin: 1rem 0 0;
  color: var(--text-secondary);
}

.form-hint {
  margin: 1rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.upload-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.analysis-methods-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.analysis-methods-title {
  margin-right: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
}

.method-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
  user-select: none;
}

.method-chip input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.05);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-content svg {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.upload-text {
  font-weight: 600;
  font-size: 1rem;
}

.upload-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.files-count {
  padding: 0.875rem 1rem;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--text-secondary);
  text-align: center;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.project-card,
.task-card,
.solution-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.project-card:hover,
.task-card:hover,
.solution-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.solution-card.selected {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  cursor: pointer;
}

.card-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--primary);
}

.card-content {
  flex: 1;
  min-width: 0;
}

.card-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-content p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-content .date {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.card-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.empty-state span {
  font-size: 0.875rem;
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.results-toolbar label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.results-toolbar select {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.results-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.summary-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.summary-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.summary-card.high .summary-value { color: var(--danger); }
.summary-card.medium .summary-value { color: #f59e0b; }
.summary-card.low .summary-value { color: var(--success); }

.result-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  transition: all 0.2s;
}

.result-card:hover {
  transform: translateX(4px);
}

.result-card.high { border-left-color: var(--danger); }
.result-card.medium { border-left-color: #f59e0b; }
.result-card.low { border-left-color: var(--success); }

.result-rank {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 2.5rem;
}

.result-main {
  flex: 1;
}

.result-authors {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.result-authors svg {
  color: var(--text-secondary);
}

.author {
  color: var(--text);
}

.result-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.result-similarity {
  text-align: right;
  min-width: 100px;
}

.result-details-wrap {
  width: 100%;
  margin-top: 0.25rem;
}

.details-toggle {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.result-details {
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.26rem 0;
  font-size: 0.86rem;
}

.metric-row.total {
  margin-top: 0.3rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  font-weight: 600;
}

.metric-note {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.code-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.code-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.code-panel-title {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
}

.code-panel pre {
  margin: 0;
  padding: 0.75rem;
  max-height: 420px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre;
}

.code-loading,
.code-error {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.sim-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.result-card.high .sim-value { color: var(--danger); }
.result-card.medium .sim-value { color: #f59e0b; }
.result-card.low .sim-value { color: var(--success); }

.sim-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.sim-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.result-card.high .sim-fill { background: var(--danger); }
.result-card.medium .sim-fill { background: #f59e0b; }
.result-card.low .sim-fill { background: var(--success); }

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reveal {
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .view-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .code-compare {
    grid-template-columns: 1fr;
  }
}
