@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
}

/* Screens */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.screen-hidden { display: none !important; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
}
.toast-error { background: var(--color-error); color: white; }
.toast-success { background: var(--color-success); color: white; }
.toast-info { background: var(--color-primary); color: white; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.logo {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--color-primary);
}
.auth-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.auth-form input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.auth-form input::placeholder { color: #94a3b8; }
.auth-error {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.auth-actions { margin-top: 1.25rem; }
.auth-toggle {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}
.auth-divider {
  text-align: center;
  margin: 1.25rem 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  border: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0,0,0,0.05); color: var(--color-text); }
.btn-block { width: 100%; }
.btn-large { padding: 0.75rem 1.5rem; }
.btn-icon {
  background: none;
  border: none;
  font-size: 1.25rem;
  padding: 0.25rem;
  color: var(--color-text-muted);
}
.btn-icon:hover { color: var(--color-text); }
.btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-primary .btn-spinner { border-color: rgba(255,255,255,0.3); border-top-color: white; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Form container (Profile, Upload) */
.form-container {
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.form-header h2 { flex: 1; font-size: 1.25rem; }
.step-indicator {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Form groups */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.required { color: var(--color-error); }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.field-error {
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}
.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error .tag-input-wrapper { border-color: var(--color-error); }

/* Chips / Tags */
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-height: 44px;
}
.tag-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: #e0e7ff;
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
}
.chip-remove {
  background: none;
  border: none;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.chip-remove:hover { opacity: 1; }
.tag-input-wrapper input {
  flex: 1;
  min-width: 120px;
  border: none !important;
  padding: 0.25rem 0 !important;
  box-shadow: none !important;
}

/* Links list */
.link-input-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.link-input-row input { flex: 1; }
.links-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}
.link-chip-remove {
  background: none;
  border: none;
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover,
.dropzone:focus {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.04);
  outline: none;
}
.dropzone.drag-over {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.08);
}
.dropzone.dropzone-error { border-color: var(--color-error); background: rgba(220, 38, 38, 0.05); }
.dropzone-text { display: block; font-size: 0.95rem; margin-bottom: 0.25rem; }
.dropzone-hint { font-size: 0.8rem; color: var(--color-text-muted); }
.dropzone-secondary { padding: 1rem; }

/* File preview */
.file-preview,
.file-previews { margin-top: 0.75rem; }
.file-preview-hidden { display: none !important; }
.file-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.file-preview-row .file-info { display: flex; align-items: center; gap: 0.5rem; }
.file-preview-row .file-status { color: var(--color-success); font-size: 0.85rem; }
.file-preview-row .file-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}
.file-preview-row .file-remove:hover { color: var(--color-error); }

/* Matches screen */
.matches-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo-small { font-size: 1.25rem; font-weight: 700; color: var(--color-primary); }
.matches-header h2 { flex: 1; font-size: 1.1rem; }
#screen-matches.screen {
  display: block !important;
  min-height: 100vh;
  padding: 0;
}
.matches-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: calc(100vh - 56px);
}
@media (max-width: 900px) {
  .matches-layout { grid-template-columns: 1fr; }
  .matches-panel { border-top: 1px solid var(--color-border); }
}

.matches-feed {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
}
@media (max-width: 900px) { .matches-feed { border-right: none; } }
.matches-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.matches-toolbar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 0.9rem;
}
.matches-list { display: flex; flex-direction: column; gap: 0.75rem; }
.match-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.match-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}
.match-card.match-card-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.match-card h4 { font-size: 1rem; margin-bottom: 0.2rem; }
.match-card .match-lab { font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.match-card .match-score {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}
.match-card .match-focus { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.5rem; line-height: 1.4; }

.matches-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--color-text-muted);
}
.matches-loading-hidden { display: none !important; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.empty-state-hidden { display: none !important; }
.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state h3 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--color-text-muted); margin-bottom: 1rem; }

/* Right panel */
.matches-panel {
  background: #fafbfc;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.why-match h3,
.chat-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}
.why-match-empty {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}
.why-match-content-hidden { display: none !important; }
.why-match-score {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}
.why-match-reasons {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}
.why-match-reasons li {
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.why-match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.why-match-tags .chip { font-size: 0.8rem; padding: 0.2rem 0.5rem; }
.why-match-focus { font-size: 0.85rem; color: var(--color-text-muted); line-height: 1.5; }

/* Chat */
.chat-section { flex: 1; display: flex; flex-direction: column; min-height: 200px; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
  min-height: 120px;
  max-height: 220px;
}
.chat-placeholder {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}
.chat-bubble {
  margin-bottom: 0.75rem;
  max-width: 90%;
}
.chat-bubble-user { margin-left: auto; text-align: right; }
.chat-bubble-assistant { margin-right: auto; }
.chat-bubble .bubble-content {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
}
.chat-bubble-user .bubble-content {
  background: var(--color-primary);
  color: white;
}
.chat-bubble-assistant .bubble-content {
  background: #f1f5f9;
  color: var(--color-text);
}
.chat-typing {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 0.5rem 0;
  font-style: italic;
}
.chat-typing-hidden { display: none !important; }
.chat-input-wrapper {
  display: flex;
  gap: 0.5rem;
}
.chat-input-wrapper input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.chat-input-wrapper input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.chat-input-wrapper input:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
}

/* Focus styles for accessibility */
input:focus-visible,
button:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
