:root {
  --bg: #0f1117;
  --bg-elevated: #171a24;
  --bg-card: #1d2230;
  --border: #2c3347;
  --text: #f3f5f9;
  --text-muted: #a3adc2;
  --primary: #ff6b8b;
  --primary-hover: #ff859f;
  --primary-contrast: #14080c;
  --accent: #5eead4;
  --warning: #fbbf24;
  --danger: #f87171;
  --success: #34d399;
  --focus-ring: #60a5fa;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  z-index: 1000;
}

.skip-link:focus {
  top: 0.75rem;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Environment / Demo Mode Banner */
.env-banner {
  background: rgba(251, 191, 36, 0.14);
  border-bottom: 1px solid rgba(251, 191, 36, 0.4);
  padding: 0.55rem 0;
  font-size: 0.875rem;
}

.env-banner__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.env-banner p {
  margin: 0;
  color: var(--text);
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.25rem;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  color: var(--primary);
  font-size: 1.35rem;
}

.brand__tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn:hover,
.nav-btn.is-active {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border);
}

.nav-btn--admin {
  color: var(--warning);
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

/* Main Layout */
.main-content {
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.view-section {
  margin-bottom: 2.5rem;
}

/* Hero */
.hero-card {
  background: radial-gradient(circle at top right, rgba(255, 107, 139, 0.18), transparent 55%),
              linear-gradient(145deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.hero-card h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.6rem);
  margin: 0 0 0.85rem;
  line-height: 1.2;
}

.lead {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 68ch;
  margin-bottom: 1.5rem;
}

.hero-actions {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.privacy-pillars {
  list-style: none;
  padding: 1.25rem 0 0;
  margin: 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.privacy-pillars strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.15rem;
}

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

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

.btn--primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

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

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--text-muted);
}

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

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-card);
}

.btn--danger {
  background: rgba(248, 113, 113, 0.16);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.45);
}

.btn--danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.28);
}

.btn--sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn--full {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge--online {
  background: rgba(52, 211, 153, 0.16);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.badge--offline {
  background: rgba(163, 173, 194, 0.12);
  color: var(--text-muted);
}

.badge--match {
  background: rgba(255, 107, 139, 0.2);
  color: var(--primary);
  border: 1px solid rgba(255, 107, 139, 0.45);
}

.badge--warning,
.badge--admin {
  background: rgba(251, 191, 36, 0.18);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

/* Cards & Forms */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

.form-error {
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

/* Discovery Wall */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin: 0 0 0.25rem;
}

.text-muted {
  color: var(--text-muted);
  margin: 0;
}

.wall-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.search-box input {
  min-width: 230px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  margin: 0;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color 0.15s ease;
}

.profile-card:hover {
  border-color: #434d6b;
}

.profile-card__top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.35rem;
  color: #fff;
  overflow: hidden;
  border: 2px solid var(--border);
}

.avatar--lg {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--aurora {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
}
.avatar--ember {
  background: linear-gradient(135deg, #f97316, #ef4444);
}
.avatar--meadow {
  background: linear-gradient(135deg, #10b981, #059669);
}
.avatar--ocean {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
}
.avatar--twilight {
  background: linear-gradient(135deg, #6366f1, #a855f7);
}

.profile-card__meta h3 {
  margin: 0;
  font-size: 1.1rem;
}

.profile-card__handle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.profile-card__bio {
  font-size: 0.92rem;
  color: var(--text);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-card__badges,
.profile-card__match-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.profile-card__badges {
  margin-top: 0.35rem;
  gap: 0.35rem;
}

.profile-card__bio {
  margin-top: 0.85rem;
}

.profile-card__tags {
  margin-top: 0.75rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.profile-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Profile Detail View */
.profile-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.profile-editor-card {
  margin-top: 1.5rem;
}

.checkbox-pill--inline {
  display: inline-flex;
}

.profile-back-link {
  margin-bottom: 1rem;
}

.profile-heading {
  margin: 0;
}

.profile-handle-meta {
  margin: 0.2rem 0 0.6rem;
}

.profile-status-badges {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.profile-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.profile-bio {
  white-space: pre-wrap;
}

.admin-users-heading {
  margin-top: 2rem;
}

.profile-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.action-cluster {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* State Boxes & Callouts */
.state-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.state-box--error {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: 1rem;
}

.callout--info {
  border-color: rgba(94, 234, 212, 0.4);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-card--wide {
  max-width: 760px;
}

.modal-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-card__header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-card__body {
  padding: 1.5rem;
}

.conversation-thread {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 34vh;
  min-height: 5rem;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.conversation-message {
  align-self: flex-start;
  max-width: min(85%, 36rem);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow-wrap: anywhere;
}

.conversation-message--mine {
  align-self: flex-end;
  background: rgba(255, 107, 139, 0.16);
}

.conversation-message p,
.call-request p {
  margin: 0;
  white-space: pre-wrap;
}

.conversation-message time {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.conversation-form {
  margin-top: 0.85rem;
}

.conversation-call-section {
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
  padding-top: 0.75rem;
}

.conversation-call-section h3 {
  margin-top: 0;
}

.call-request {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.6rem;
}

.call-request .text-muted {
  margin-top: 0.3rem;
}

.conversation-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.call-consent-note {
  padding: 0.75rem;
  border-left: 3px solid var(--primary);
  background: var(--bg-elevated);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.video-preview-stage {
  background: #08090d;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  margin: 1rem 0;
}

.local-video {
  width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  background: #000;
}

/* Admin Tables */
.admin-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
}

/* Toast Notifications */
.toast-region {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: 0.88rem;
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .hero-card {
    padding: 1.5rem;
  }
  .search-box input {
    min-width: 100%;
  }
  .modal-backdrop {
    align-items: flex-start;
    padding: 0.5rem;
  }
  .modal-card {
    max-height: 96vh;
  }
  .modal-card__body {
    padding: 1rem;
  }
  .conversation-thread {
    max-height: 30vh;
  }
}