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

:root {
  --gold: #C8A960;
  --gold-light: #E8D5A0;
  --gold-dim: rgba(200, 169, 96, 0.15);
  --deep: #0A0A12;
  --surface: #111120;
  --surface-light: #1A1A2E;
  --surface-hover: #1F1F35;
  --text: #E8E4DC;
  --text-muted: #9B97A0;
  --text-dim: #5A5770;
  --violet: #6B4FA0;
  --violet-glow: rgba(107, 79, 160, 0.2);
  --warm: #C07850;
  --border: rgba(200, 169, 96, 0.12);
  --border-hover: rgba(200, 169, 96, 0.3);
  --danger: #C05870;
  --success: #50A880;
  --radius: 6px;
  --radius-lg: 12px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--deep);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient background layers */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.ambient::before {
  content: '';
  position: absolute;
  top: -30%; left: -20%;
  width: 80vw; height: 80vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(107, 79, 160, 0.07) 0%, transparent 70%);
  animation: drift 25s ease-in-out infinite;
}
.ambient::after {
  content: '';
  position: absolute;
  bottom: -20%; right: -15%;
  width: 60vw; height: 60vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 169, 96, 0.05) 0%, transparent 70%);
  animation: drift 30s ease-in-out infinite reverse;
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(5vw, -3vh); }
  66% { transform: translate(-3vw, 5vh); }
}

.content { position: relative; z-index: 1; }

/* Navigation */
nav {
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.nav-logo .logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold), var(--violet));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--deep);
  font-family: 'Instrument Serif', serif;
  flex-shrink: 0;
}

.nav-logo .logo-name {
  font-family: 'Instrument Serif', serif;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--gold-light);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  transition: color 0.2s, background 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: var(--deep);
  border-color: var(--gold);
}
.btn-primary:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(200, 169, 96, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-light);
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(107, 79, 160, 0.08);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 169, 96, 0.1);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

/* Tags / pills */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  background: var(--surface-light);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag-gold {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: rgba(200, 169, 96, 0.2);
}

.tag-violet {
  background: var(--violet-glow);
  color: #A87FD0;
  border-color: rgba(107, 79, 160, 0.3);
}

/* Category labels */
.cat-frameworks { color: var(--gold); }
.cat-research { color: #80C8A0; }
.cat-organizations { color: #80A8C8; }
.cat-tools { color: var(--warm); }
.cat-general { color: var(--text-muted); }

/* Alert/Flash messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid;
  display: none;
}
.alert.show { display: block; }
.alert-error {
  background: rgba(192, 88, 112, 0.1);
  color: #E87090;
  border-color: rgba(192, 88, 112, 0.3);
}
.alert-success {
  background: rgba(80, 168, 128, 0.1);
  color: #70C8A0;
  border-color: rgba(80, 168, 128, 0.3);
}

/* Layout helpers */
.max-w { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.max-w-sm { max-width: 480px; margin: 0 auto; }

.page-header {
  padding: 3rem 0 2rem;
}

.page-title {
  font-family: 'Instrument Serif', serif;
  font-size: 2rem;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Section divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-dim);
}

/* Avatar */
.avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--violet), var(--gold));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Instrument Serif', serif;
  font-size: 1rem;
  color: var(--deep);
  font-weight: 600;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.2rem;
  color: var(--gold-light);
}
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.2rem; line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

/* Portal nav tabs */
.portal-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.35rem;
  margin-bottom: 2rem;
}

.tab-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--surface-light);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--border);
}
.tab-btn:hover:not(.active) { color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  nav { padding: 1rem; }
  .max-w { padding: 0 1rem; }
  .page-title { font-size: 1.5rem; }
  .portal-tabs { flex-wrap: wrap; }
  .tab-btn { flex: none; }
}
