:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-soft: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --card: #111827;
  --border: rgba(148, 163, 184, 0.2);
  --shadow: rgba(3, 9, 22, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% 10%, #1b2233, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px clamp(20px, 4vw, 56px) 24px;
  gap: 28px;
}

.site-header {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 24px;
}

.brand img {
  width: 140px;
  height: auto;
  filter: drop-shadow(0 8px 20px var(--shadow));
}

.nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.nav-actions {
  justify-self: end;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: rgba(56, 189, 248, 0.12);
}

.nav-actions {
  position: relative;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.menu {
  position: absolute;
  right: 0;
  top: 48px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 160px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.menu.open {
  display: flex;
}

.menu-item {
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}

.menu-item:hover {
  background: rgba(56, 189, 248, 0.12);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}

.hero-logo {
  width: min(320px, 80vw);
  height: auto;
}

.hero-text h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  margin: 0 0 12px;
}

.hero-text p {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
  line-height: 1.7;
}

.hero-text {
  width: min(760px, 100%);
  margin: 0 auto;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.primary-btn,
.ghost-btn,
button.primary-btn,
button.ghost-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #0b1120;
}

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

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
}

.feature-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  width: 100%;
  max-width: 960px;
  margin-top: 16px;
}

.feature-card {
  background: var(--card);
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: left;
}

.feature-card h3 {
  margin: 0 0 8px;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
}

.content-grid {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--card);
  padding: 22px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.panel.wide {
  max-width: 900px;
  margin: 0 auto;
}

.matches-panel {
  width: min(1480px, 100%);
  max-width: none;
}

.panel.narrow {
  max-width: 520px;
  margin: 0 auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-header-copy h2 {
  margin: 0 0 6px;
}

.panel-header-copy p {
  margin: 0;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.how-it-works-link {
  background: rgba(255, 255, 255, 0.04);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.form {
  display: grid;
  gap: 12px;
}

.form.two-col {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}

.form input,
.form textarea,
.form select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  font-size: 0.95rem;
}

.form select {
  appearance: none;
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

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

.preferences-section {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.preferences-title {
  margin: 0 0 10px;
  font-size: 1rem;
}

.preferences-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.hospital-preferences-picker {
  display: grid;
  gap: 10px;
}

.hospital-preferences-input-row {
  display: flex;
  gap: 8px;
}

.hospital-preferences-input-row input {
  flex: 1;
}

.hospital-preferences-add {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
}

.hospital-preferences-add:hover {
  border-color: rgba(56, 189, 248, 0.45);
}

.hospital-preferences-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hospital-preferences-error {
  min-height: 1em;
  color: #fca5a5;
  font-size: 0.85rem;
}

.hospital-preferences-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0b1324;
  color: var(--text);
  font-size: 0.9rem;
}

.hospital-preferences-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.hospital-preferences-remove:hover {
  color: var(--text);
}

.form .full {
  grid-column: 1 / -1;
}

.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.matches {
  display: grid;
  gap: 14px;
}

.match-group {
  display: grid;
  gap: 12px;
}

.match-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.match-group-title {
  margin: 0;
  font-size: 1rem;
}

.match-group-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}

.match-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #0f172a;
}

.match-card h4 {
  margin: 0 0 6px;
}

.match-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.swap-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.98));
}

.swap-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent);
}

.swap-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.swap-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cycle-swap {
  display: grid;
  gap: 14px;
}

.cycle-explainer {
  position: relative;
  overflow: hidden;
}

.cycle-explainer::before {
  content: "";
  position: absolute;
  inset: -20% auto auto -10%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.18), transparent 68%);
  pointer-events: none;
}

.fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 180ms ease;
}

.fullscreen-modal[hidden] {
  display: none;
}

.fullscreen-modal.open {
  opacity: 1;
}

.fullscreen-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 11, 19, 0.78);
  backdrop-filter: blur(14px);
}

.fullscreen-modal-sheet {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background:
    radial-gradient(700px 300px at 10% 0%, rgba(56, 189, 248, 0.1), transparent 60%),
    linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 19, 36, 0.98));
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45);
}

.fullscreen-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.fullscreen-modal-header h2 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.fullscreen-modal-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fullscreen-modal-close {
  flex-shrink: 0;
}

.fullscreen-modal-body {
  display: grid;
  gap: 16px;
}

.cycle-demo {
  display: grid;
  gap: 14px;
  margin-top: 6px;
}

.cycle-demo-board {
  position: relative;
}

.cycle-demo-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.cycle-demo-cards {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.cycle-demo-person {
  display: grid;
  gap: 10px;
  min-height: 196px;
  padding: 18px 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(11, 19, 36, 0.9));
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.cycle-demo-name {
  font-weight: 700;
  font-size: 1rem;
}

.cycle-demo-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cycle-demo-status {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(248, 113, 113, 0.24);
  background: rgba(127, 29, 29, 0.18);
  color: #fca5a5;
  font-size: 1rem;
  font-weight: 700;
  transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease;
}

.cycle-demo-status.satisfied {
  border-color: rgba(74, 222, 128, 0.26);
  background: rgba(20, 83, 45, 0.24);
  color: #bbf7d0;
}

.cycle-demo-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.cycle-demo-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cycle-demo-slot,
.cycle-demo-value {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(8, 15, 28, 0.68);
}

.cycle-demo-slot {
  border-style: solid;
  border-color: rgba(148, 163, 184, 0.16);
  position: relative;
  overflow: hidden;
}

.cycle-demo-slot.active {
  border-color: rgba(56, 189, 248, 0.28);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.08);
}

.cycle-demo-value.want {
  color: #fca5a5;
  border-style: solid;
  border-color: rgba(248, 113, 113, 0.24);
  background: rgba(127, 29, 29, 0.14);
}

.cycle-demo-slot,
.cycle-demo-value.want {
  transition: border-color 220ms ease, background-color 220ms ease, color 220ms ease, box-shadow 220ms ease;
}

.cycle-demo-slot.resolved,
.cycle-demo-value.want.resolved {
  border-color: rgba(74, 222, 128, 0.28);
  background: rgba(20, 83, 45, 0.22);
  color: #bbf7d0;
}

.cycle-demo-steps {
  display: grid;
  gap: 8px;
}

.cycle-demo-step {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(11, 19, 36, 0.82);
  color: var(--text);
  opacity: 0.45;
  transition: opacity 220ms ease, border-color 220ms ease, background-color 220ms ease;
}

.cycle-demo-step.active {
  opacity: 1;
  border-color: rgba(56, 189, 248, 0.34);
}

.cycle-demo-step.active:last-child {
  border-color: rgba(134, 239, 172, 0.32);
  background: rgba(34, 197, 94, 0.08);
}

.cycle-demo-person.active {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.24);
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.08);
}

.cycle-demo-person.resolved {
  border-color: rgba(134, 239, 172, 0.28);
  box-shadow: 0 0 0 1px rgba(134, 239, 172, 0.12), 0 16px 32px rgba(34, 197, 94, 0.08);
}

.cycle-demo-slot.resolved {
  border-color: rgba(134, 239, 172, 0.28);
}

.cycle-demo-token rect {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1;
  filter: drop-shadow(0 10px 24px rgba(2, 8, 23, 0.35));
}

.cycle-demo-token text {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
}

.cycle-demo-token.settled rect {
  stroke: rgba(255, 255, 255, 0.28);
}

.swap-person.current-user {
  border-color: rgba(56, 189, 248, 0.48);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18), 0 12px 28px rgba(14, 165, 233, 0.12);
}

.cycle-participants {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: stretch;
}

.swap-person {
  background: #0b1324;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}

.swap-person h4 {
  margin: 0 0 8px;
}

.swap-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.swap-meta span {
  color: var(--text);
  font-weight: 600;
}

.swap-arrow {
  font-size: 1.6rem;
  color: var(--accent);
}

.direct-swap .swap-arrow {
  font-size: 1.2rem;
}

.swap-loop {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-dot {
  opacity: 0.5;
}

@media (max-width: 720px) {
  .page {
    padding: 18px 12px 16px;
    gap: 20px;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    gap: 8px;
  }

  .match-group-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 14px;
  }

  .panel-actions {
    width: 100%;
  }

  .panel-actions .ghost-btn,
  .panel-actions .primary-btn {
    width: 100%;
    justify-content: center;
  }

  .cycle-demo-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .match-group-grid {
    grid-template-columns: 1fr;
  }

  .match-card {
    padding: 14px;
  }

  .swap-person {
    padding: 10px;
  }

  .cycle-demo-board {
    min-height: 0;
  }

  .cycle-demo-person {
    min-height: auto;
  }

  .cycle-demo-name {
    font-size: 0.92rem;
  }

  .fullscreen-modal {
    padding: 12px;
  }

  .fullscreen-modal-sheet {
    max-height: calc(100vh - 24px);
    padding: 18px;
    border-radius: 20px;
  }

  .fullscreen-modal-header {
    flex-direction: column;
  }

  .fullscreen-modal-close {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .swap-stage::before,
  .cycle-demo-person {
    animation: none;
  }
}
